Skip to content

Commit

Permalink
feat(developer): scancode and forms 🙀
Browse files Browse the repository at this point in the history
- fixes to the special case test

Fixes: #9403
  • Loading branch information
srl295 committed Oct 2, 2023
1 parent 8200f84 commit 2b2661b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions common/web/types/src/consts/virtual-key-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[][];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
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} (other than 226) mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`);
vkeyToScan.set(vkey, scan);
`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);
}
});
});

0 comments on commit 2b2661b

Please sign in to comment.