feat(developer): scancode and forms 🙀

- fixes to the special case test

Fixes: #9403
This commit is contained in:
Steven R. Loomis 2023-10-02 18:00:48 -05:00
parent 8200f84418
commit 2b2661bb1b
2 changed files with 15 additions and 5 deletions

View file

@ -202,6 +202,7 @@ export const CLDRScanToUSVirtualKeyCodes = {
0x56: k.K_oE2, // << Same as 0x7D; found on iso, abnt2
0x73: k.K_oC1,
0x7D: k.K_oE2, // << Same as 0x56; found on jis
};
export type KeyMap = number[][];

View file

@ -3,7 +3,7 @@ import 'mocha';
import {assert} from 'chai';
import { CommonTypesMessages } from '../../src/util/common-events.js';
import { testReaderCases } from '../helpers/reader-callback-test.js';
import { CLDRScanToVkey, CLDRScanToKeyMap } from '../../src/consts/virtual-key-constants.js';
import { CLDRScanToVkey, CLDRScanToKeyMap, USVirtualKeyCodes } from '../../src/consts/virtual-key-constants.js';
function pluckKeysFromKeybag(keys: LKKey[], ids: string[]) {
return keys.filter(({id}) => ids.indexOf(id) !== -1);
@ -163,11 +163,20 @@ describe('check scan code routines', () => {
// check all scancodes
for (let scan = 0; scan <= 0xFF; scan++) {
const vkey = CLDRScanToVkey(scan);
if (vkey !== undefined && vkey !== 226) {
assert.isFalse(vkeyToScan.has(vkey),
`vkey ${vkey} (other than 226) mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`);
vkeyToScan.set(vkey, scan);
if (vkey === undefined) {
// not mapped, which is OK
continue;
}
if (scan === 0x56 || scan === 0x7D) {
// These both can map to this scancode
assert.equal(vkey, USVirtualKeyCodes.K_oE2);
} else {
// don't check those exceptions
assert.isFalse(vkeyToScan.has(vkey),
`vkey ${vkey} mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`);
}
// do make sure nothing else maps to that vkey
vkeyToScan.set(vkey, scan);
}
});
});