Skip to content

Commit

Permalink
Fall back to KC_BSLS if no mappings exist for KC_NUHS
Browse files Browse the repository at this point in the history
and update the keymap lut
  • Loading branch information
precondition committed Aug 12, 2022
1 parent 0ca3c40 commit 70bc318
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/i18n/keymap_extras/convert_keymap_extras_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,38 @@ function generateMissingKcBsls(kcInfo) {
return bslsInfoLines;
}

function generateMissingKcNuhs(kcInfo) {
// If no explicit mapping for KC_NUHS exist, as is the case for many ANSI layouts, fall
// back to the KC_BSLS mapping.
if (kcInfo.has('KC_NUHS')) {
return '';
}
if (!kcInfo.has('KC_BSLS')) {
throw new Error(
'The input file is missing a mapping to both KC_BSLS and KC_NUHS. At least one of them must be mapped to an locale alias!'
);
}
const kcBslsInfo = kcInfo.get('KC_BSLS');
const kcPipeInfo = kcInfo.get('S(KC_BSLS)');
// Copy the KC_BSLS kc info object but replace the associated intl alias with KC_NUHS.
// Since it is pointless to repeat the US kc alias in the title, we only keep the clarification.
const kcNuhsInfo = {
...kcBslsInfo,
intlAlias: 'KC_NUHS',
title: kcBslsInfo.clarification
};
const shiftedNuhsInfo = {
...kcPipeInfo,
intlAlias: 'S(KC_NUHS)',
title: kcPipeInfo.clarification
};
kcInfo.set('KC_NUHS', kcNuhsInfo);
kcInfo.set('S(KC_NUHS)', shiftedNuhsInfo);
let nuhsInfoLines = stringify('KC_NUHS', kcNuhsInfo) + '\n';
nuhsInfoLines += stringify('S(KC_NUHS)', shiftedNuhsInfo);
return nuhsInfoLines;
}

function generateMissingShiftedAliasKcInfo(kcInfo) {
let ret = '';
for (const [shiftedKc, shiftedAlias] of shiftedKc2shiftedAlias.entries()) {
Expand Down Expand Up @@ -374,6 +406,7 @@ fs.readFile(process.argv.at(-1), 'utf8', function (err, data) {
console.log(convertedLines.join('\n'));
console.log('/* Other keys */');
console.log(generateMissingKcBsls(kcInfo));
console.log(generateMissingKcNuhs(kcInfo));
console.log(generateMissingShiftedAliasKcInfo(kcInfo));
spaceCadetKeycodes = [
'KC_LSPO',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/keymap_extras/keymap_german.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default {
KC_BSLS: { name: "'\n#", title: '' },
'S(KC_BSLS)': { name: "'", title: '' },
KC_PIPE: { name: "'", title: '' },

KC_LCBR: { name: 'Ü', title: 'S(DE_UDIA) (capital Ü)' },
KC_COLN: { name: 'Ö', title: 'S(DE_ODIA) (capital Ö)' },
KC_DQUO: { name: 'Ä', title: 'S(DE_ADIA) (capital Ä)' },
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/keymap_extras/keymap_russian.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export default {

/* Other keys */

KC_NUHS: { name: '/\n\\', title: '' },
'S(KC_NUHS)': { name: '/', title: '' },
KC_TILD: { name: 'Ё', title: 'S(RU_YO) (capital Ё)' },
KC_LCBR: { name: 'Х', title: 'S(RU_HA) (capital Х)' },
KC_RCBR: { name: 'Ъ', title: 'S(RU_HARD) (capital Ъ)' },
Expand Down

0 comments on commit 70bc318

Please sign in to comment.