From 1a5718de70533c2ff42dc59dd73a2138ba8e8427 Mon Sep 17 00:00:00 2001 From: Yoichiro Date: Wed, 13 Dec 2023 20:41:19 +0900 Subject: [PATCH 1/2] Fix the issue that a keyboard layout rendering with encoders failed. --- src/assets/keymaps/KillerWhaleDuo.ts | 818 ++++++++++++++++++ .../catalog/keyboard/keymap/Catalogkeymap.tsx | 7 +- .../configure/keymap/Keymap.stories.tsx | 5 + 3 files changed, 827 insertions(+), 3 deletions(-) create mode 100644 src/assets/keymaps/KillerWhaleDuo.ts diff --git a/src/assets/keymaps/KillerWhaleDuo.ts b/src/assets/keymaps/KillerWhaleDuo.ts new file mode 100644 index 00000000..0e05c6ca --- /dev/null +++ b/src/assets/keymaps/KillerWhaleDuo.ts @@ -0,0 +1,818 @@ +export const KillerWhaleDuoKeymap = [ + [ + { + x: 1.25, + c: '#aaaaaa', + }, + '\n\n\n0,0\n\n\n\n\n\ne1', + { + x: 14, + }, + '\n\n\n0,0\n\n\n\n\n\ne5', + ], + [ + { + y: -0.75, + }, + '\n\n\n0,0\n\n\n\n\n\ne0', + { + x: 2.5, + c: '#cccccc', + }, + '0,3\n\n\n0,0', + { + x: 9.5, + }, + '7,3\n\n\n0,0', + { + x: 2.5, + c: '#aaaaaa', + }, + '\n\n\n0,0\n\n\n\n\n\ne4', + ], + [ + { + y: -0.75, + x: 2.5, + c: '#cccccc', + }, + '0,4\n\n\n0,0', + { + x: 1, + }, + '0,2\n\n\n0,0', + { + x: 7.5, + }, + '7,2\n\n\n0,0', + { + x: 1, + }, + '7,4\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 5.5, + }, + '0,1\n\n\n0,0', + { + x: 5.5, + }, + '7,1\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 1.5, + }, + '0,5\n\n\n0,0', + { + x: 1, + }, + '1,4\n\n\n0,0', + { + x: 9.5, + }, + '8,4\n\n\n0,0', + { + x: 1, + }, + '7,5\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 0.5, + }, + '1,0\n\n\n0,0', + { + x: 1, + }, + '1,5\n\n\n0,0', + { + x: 1, + }, + '1,3\n\n\n0,0', + { + x: 7.5, + }, + '8,3\n\n\n0,0', + { + x: 1, + }, + '8,5\n\n\n0,0', + { + x: 1, + }, + '8,0\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 5.5, + }, + '1,2\n\n\n0,0', + { + x: 5.5, + }, + '8,2\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 1.5, + }, + '2,0\n\n\n0,0', + { + x: 1, + }, + '2,5\n\n\n0,0', + { + x: 9.5, + }, + '9,5\n\n\n0,0', + { + x: 1, + }, + '9,0\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 0.5, + }, + '2,1\n\n\n0,0', + { + x: 1, + }, + '3,0\n\n\n0,0', + { + x: 1, + }, + '2,4\n\n\n0,0', + { + x: 7.5, + }, + '9,4\n\n\n0,0', + { + x: 1, + }, + '10,0\n\n\n0,0', + { + x: 1, + }, + '9,1\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 5.5, + }, + '2,3\n\n\n0,0', + { + x: 5.5, + }, + '9,3\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 7.25, + c: '#777777', + w: 1.5, + }, + '4,3\n\n\n0,0', + { + x: 1, + w: 1.5, + }, + '11,3\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 1.5, + c: '#cccccc', + }, + '3,1\n\n\n0,0', + { + x: 1, + }, + '4,0\n\n\n0,0', + { + x: 9.5, + }, + '11,0\n\n\n0,0', + { + x: 1, + }, + '10,1\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 0.5, + }, + '3,2\n\n\n0,0', + { + x: 1, + }, + '4,1\n\n\n0,0', + { + x: 1, + }, + '3,5\n\n\n0,0', + { + x: 7.5, + }, + '10,5\n\n\n0,0', + { + x: 1, + }, + '11,1\n\n\n0,0', + { + x: 1, + }, + '10,2\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 5.5, + }, + '3,4\n\n\n0,0', + { + x: 5.5, + }, + '10,4\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 1.5, + }, + '4,2\n\n\n0,0', + { + x: 5, + c: '#aaaaaa', + }, + '\n\n\n0,0\n\n\n\n\n\ne3', + { + x: 1.5, + }, + '\n\n\n0,0\n\n\n\n\n\ne7', + { + x: 5, + c: '#cccccc', + }, + '11,2\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 2.5, + }, + '4,5\n\n\n0,0', + { + x: 11.5, + }, + '11,5\n\n\n0,0', + ], + [ + { + x: 7, + }, + '5,4\n\n\n0,0', + '5,3\n\n\n0,0', + { + x: 0.5, + }, + '12,3\n\n\n0,0', + '12,4\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 1, + }, + '3,6\n\n\n0,0', + { + x: 14.5, + }, + '11,6\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 4.5, + }, + '6,5\n\n\n0,0', + { + x: 7.5, + }, + '12,6\n\n\n0,0', + ], + [ + { + y: -0.75, + x: 3.25, + c: '#aaaaaa', + }, + '\n\n\n0,0\n\n\n\n\n\ne2', + ], + [ + { + y: -0.75, + c: '#cccccc', + }, + '2,6\n\n\n0,0', + { + c: '#777777', + }, + '0,6\n\n\n0,0', + { + c: '#cccccc', + }, + '4,6\n\n\n0,0', + { + x: 11.25, + c: '#aaaaaa', + }, + '\n\n\n0,0\n\n\n\n\n\ne6', + { + x: 0.25, + c: '#cccccc', + }, + '10,6\n\n\n0,0', + { + c: '#777777', + }, + '7,6\n\n\n0,0', + { + c: '#cccccc', + }, + '8,6\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 4.5, + }, + '5,6\n\n\n0,0', + { + x: 7.5, + }, + '13,5\n\n\n0,0', + ], + [ + { + y: -0.5, + x: 1, + }, + '1,6\n\n\n0,0', + { + x: 14.5, + }, + '9,6\n\n\n0,0', + ], + [ + { + y: 0.25, + x: 1, + c: '#aaaaaa', + }, + '\n\n\n0,1\n\n\n\n\n\ne1', + { + x: 11.75, + }, + '\n\n\n0,1\n\n\n\n\n\ne5', + ], + [ + { + y: -0.75, + }, + '\n\n\n0,1\n\n\n\n\n\ne0', + { + x: 13.75, + }, + '\n\n\n0,1\n\n\n\n\n\ne4', + ], + [ + { + y: -0.75, + x: 3, + c: '#cccccc', + h: 0.75, + }, + '0,3\n\n\n0,1', + { + x: 7.75, + h: 0.75, + }, + '7,3\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 2, + h: 0.75, + }, + '0,4\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '0,2\n\n\n0,1', + { + x: 5.75, + h: 0.75, + }, + '7,2\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '7,4\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 5, + h: 0.75, + }, + '0,1\n\n\n0,1', + { + x: 3.75, + h: 0.75, + }, + '7,1\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 1, + h: 0.75, + }, + '0,5\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '1,4\n\n\n0,1', + { + x: 7.75, + h: 0.75, + }, + '8,4\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '7,5\n\n\n0,1', + ], + [ + { + y: -0.75, + h: 0.75, + }, + '1,0\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '1,5\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '1,3\n\n\n0,1', + { + x: 5.75, + h: 0.75, + }, + '8,3\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '8,5\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '8,0\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 5, + h: 0.75, + }, + '1,2\n\n\n0,1', + { + x: 3.75, + h: 0.75, + }, + '8,2\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 1, + h: 0.75, + }, + '2,0\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '2,5\n\n\n0,1', + { + x: 7.75, + h: 0.75, + }, + '9,5\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '9,0\n\n\n0,1', + ], + [ + { + y: -0.75, + h: 0.75, + }, + '2,1\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '3,0\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '2,4\n\n\n0,1', + { + x: 1.25, + c: '#777777', + h: 0.75, + }, + '4,3\n\n\n0,1', + { + x: 1.25, + h: 0.75, + }, + '11,3\n\n\n0,1', + { + x: 1.25, + c: '#cccccc', + h: 0.75, + }, + '9,4\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '10,0\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '9,1\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 5, + h: 0.75, + }, + '2,3\n\n\n0,1', + { + x: 3.75, + h: 0.75, + }, + '9,3\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 1, + h: 0.75, + }, + '3,1\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '4,0\n\n\n0,1', + { + x: 7.75, + h: 0.75, + }, + '11,0\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '10,1\n\n\n0,1', + ], + [ + { + y: -0.75, + h: 0.75, + }, + '3,2\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '4,1\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '3,5\n\n\n0,1', + { + x: 5.75, + h: 0.75, + }, + '10,5\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '11,1\n\n\n0,1', + { + x: 1, + h: 0.75, + }, + '10,2\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 5, + h: 0.75, + }, + '3,4\n\n\n0,1', + { + x: 0.25, + c: '#aaaaaa', + }, + '\n\n\n0,1\n\n\n\n\n\ne3', + { + x: 1.25, + }, + '\n\n\n0,1\n\n\n\n\n\ne7', + { + x: 0.25, + c: '#cccccc', + h: 0.75, + }, + '10,4\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 1, + h: 0.75, + }, + '4,2\n\n\n0,1', + { + x: 11.75, + h: 0.75, + }, + '11,2\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 2, + h: 0.75, + }, + '4,5\n\n\n0,1', + { + x: 9.75, + h: 0.75, + }, + '11,5\n\n\n0,1', + ], + [ + { + y: -0.25, + x: 1, + h: 0.75, + }, + '3,6\n\n\n0,1', + { + x: 3.75, + h: 0.75, + }, + '5,4\n\n\n0,1', + { + h: 0.75, + }, + '5,3\n\n\n0,1', + { + x: 0.25, + h: 0.75, + }, + '12,3\n\n\n0,1', + { + h: 0.75, + }, + '12,4\n\n\n0,1', + { + x: 3.75, + h: 0.75, + }, + '11,6\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 4.5, + h: 0.75, + }, + '6,5\n\n\n0,1', + { + x: 4.75, + h: 0.75, + }, + '12,6\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 3.25, + c: '#aaaaaa', + }, + '\n\n\n0,1\n\n\n\n\n\ne2', + { + x: 7.25, + }, + '\n\n\n0,1\n\n\n\n\n\ne6', + ], + [ + { + y: -0.75, + c: '#cccccc', + h: 0.75, + }, + '2,6\n\n\n0,1', + { + c: '#777777', + h: 0.75, + }, + '0,6\n\n\n0,1', + { + c: '#cccccc', + h: 0.75, + }, + '4,6\n\n\n0,1', + { + x: 9.75, + h: 0.75, + }, + '10,6\n\n\n0,1', + { + c: '#777777', + h: 0.75, + }, + '7,6\n\n\n0,1', + { + c: '#cccccc', + h: 0.75, + }, + '8,6\n\n\n0,1', + ], + [ + { + y: -0.75, + x: 4.5, + h: 0.75, + }, + '5,6\n\n\n0,1', + { + x: 4.75, + h: 0.75, + }, + '13,5\n\n\n0,1', + ], + [ + { + y: -0.5, + x: 1, + h: 0.75, + }, + '1,6\n\n\n0,1', + { + x: 11.75, + h: 0.75, + }, + '9,6\n\n\n0,1', + ], +]; diff --git a/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx b/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx index 4fde3b73..eb983597 100644 --- a/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx +++ b/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx @@ -133,7 +133,7 @@ export default function CatalogKeymap(props: CatalogKeymapProps) { ccwKeymap = null; } } else { - keymap = { + const dummyKeymap: IKeymap = { isAny: false, code: 0, kinds: [], @@ -146,8 +146,9 @@ export default function CatalogKeymap(props: CatalogKeymapProps) { keywords: [], }, }; - cwKeymap = null; - ccwKeymap = null; + keymap = structuredClone(dummyKeymap); + cwKeymap = structuredClone(dummyKeymap); + ccwKeymap = structuredClone(dummyKeymap); } const remap = null; const cwRemap = null; diff --git a/src/components/configure/keymap/Keymap.stories.tsx b/src/components/configure/keymap/Keymap.stories.tsx index e8b2b941..a394b67d 100644 --- a/src/components/configure/keymap/Keymap.stories.tsx +++ b/src/components/configure/keymap/Keymap.stories.tsx @@ -31,6 +31,7 @@ import { CtMacropadWithoutDefaultOptionKeymap } from '../../../assets/keymaps/Ct import { GiabalanaiKeymap } from '../../../assets/keymaps/GiabalanaiKeymap'; import { MOD_LEFT } from '../../../services/hid/Constraints'; import { FrogNpKeymap } from '../../../assets/keymaps/FrogNpKeymap'; +import { KillerWhaleDuoKeymap } from '../../../assets/keymaps/KillerWhaleDuo'; export default { title: 'Keyboards', @@ -240,6 +241,10 @@ export const FrogNp = () => { option: 4, optionChoice: 2 }, { option: 5, optionChoice: 0 }, ]); +export const KillerWhaleDuo = () => + genKeyboardView('KillerWhaleDuo', KillerWhaleDuoKeymap, [ + { option: 0, optionChoice: 0 }, + ]); export const Jisplit89 = () => genKeyboardView('Jisplit89', Jisplit89Keymap); export const Naked64SF = () => genKeyboardView('Naked64SF', Naked64SFKeymap); export const SilverBullet44Kai = () => From 9b5974c27c08c4e766e24146d31c7e18a8623e37 Mon Sep 17 00:00:00 2001 From: Yoichiro Date: Wed, 13 Dec 2023 20:55:15 +0900 Subject: [PATCH 2/2] Fix the PDF output issue. --- src/services/pdf/KeymapPdfGenerator.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/services/pdf/KeymapPdfGenerator.ts b/src/services/pdf/KeymapPdfGenerator.ts index 03b78e47..d4dd1918 100644 --- a/src/services/pdf/KeymapPdfGenerator.ts +++ b/src/services/pdf/KeymapPdfGenerator.ts @@ -310,18 +310,24 @@ export class KeymapPdfGenerator { const labelW = roofWidth + r * 2; const labelH = (roofHeight + r * 2) / 3; - const label = key.label; - const holdLabel = buildHoldKeyLabel(key.keymap, key.keymap.isAny); - let modifierLabel = key.meta; - if (holdLabel === '' && modifierLabel === '') { - modifierLabel = buildModLabel( - key.keymap.modifiers || null, - key.keymap.direction! - ); + // FIXME: Add logics for Encoder. + let label: string = ''; + let modifierLabel: string = ''; + let holdLabel: string = ''; + let metaRight: string = ''; + if (key !== undefined) { + label = key.label; + holdLabel = buildHoldKeyLabel(key.keymap, key.keymap.isAny); + modifierLabel = key.meta; + if (holdLabel === '' && modifierLabel === '') { + modifierLabel = buildModLabel( + key.keymap.modifiers || null, + key.keymap.direction! + ); + } + metaRight = key.metaRight ? key.metaRight : ''; } - const metaRight = key.metaRight ? key.metaRight : ''; - this.drawLabels( page, ['', modifierLabel, ''],