diff --git a/src/lib/assets/key-symbols.json b/src/lib/assets/key-symbols.json index 47e00f4d..68f92448 100644 --- a/src/lib/assets/key-symbols.json +++ b/src/lib/assets/key-symbols.json @@ -1,3 +1,94 @@ { - "SPA": "␣" + "SPA": "␣", + "DEL": "␡", + "RH_Thumb_3_Left": "", + "RH_Thumb_3_Down": "", + "RH_Thumb_3_Right": "", + "RH_Thumb_3_Up": "", + "RH_Thumb_3_Center": "", + "RH_Thumb_2_Left": "", + "RH_Thumb_2_Down": "", + "RH_Thumb_2_Right": "", + "RH_Thumb_2_Up": "", + "RH_Thumb_2_Center": "", + "RH_Thumb_1_Left": "", + "RH_Thumb_1_Down": "", + "RH_Thumb_1_Right": "", + "RH_Thumb_1_Up": "", + "RH_Thumb_1_Center": "", + "RH_Pinky_Left": "", + "RH_Pinky_Down": "", + "RH_Pinky_Right": "", + "RH_Pinky_Up": "", + "RH_Pinky_Center": "", + "RH_Ring_Secondary_Left": "", + "RH_Ring_Secondary_Down": "", + "RH_Ring_Secondary_Right": "", + "RH_Ring_Secondary_Up": "", + "RH_Ring_Secondary_Center": "", + "RH_Ring_Primary_Left": "", + "RH_Ring_Primary_Down": "", + "RH_Ring_Primary_Right": "", + "RH_Ring_Primary_Up": "", + "RH_Ring_Primary_Center": "", + "RH_Middle_Secondary_Left": "", + "RH_Middle_Secondary_Down": "", + "RH_Middle_Secondary_Right": "", + "RH_Middle_Secondary_Up": "", + "RH_Middle_Secondary_Center": "", + "RH_Middle_Primary_Left": "", + "RH_Middle_Primary_Down": "", + "RH_Middle_Primary_Right": "", + "RH_Middle_Primary_Up": "", + "RH_Middle_Primary_Center": "", + "RH_Index_Left": "", + "RH_Index_Down": "", + "RH_Index_Right": "", + "RH_Index_Up": "", + "RH_Index_Center": "", + "LH_Thumb_3_Left": "", + "LH_Thumb_3_Down": "", + "LH_Thumb_3_Right": "", + "LH_Thumb_3_Up": "", + "LH_Thumb_3_Center": "", + "LH_Thumb_2_Left": "", + "LH_Thumb_2_Down": "", + "LH_Thumb_2_Right": "", + "LH_Thumb_2_Up": "", + "LH_Thumb_2_Center": "", + "LH_Thumb_1_Left": "", + "LH_Thumb_1_Down": "", + "LH_Thumb_1_Right": "", + "LH_Thumb_1_Up": "", + "LH_Thumb_1_Center": "", + "LH_Pinky_Left": "", + "LH_Pinky_Down": "", + "LH_Pinky_Right": "", + "LH_Pinky_Up": "", + "LH_Pinky_Center": "", + "LH_Ring_Secondary_Left": "", + "LH_Ring_Secondary_Down": "", + "LH_Ring_Secondary_Right": "", + "LH_Ring_Secondary_Up": "", + "LH_Ring_Secondary_Center": "", + "LH_Ring_Primary_Left": "", + "LH_Ring_Primary_Down": "", + "LH_Ring_Primary_Right": "", + "LH_Ring_Primary_Up": "", + "LH_Ring_Primary_Center": "", + "LH_Middle_Secondary_Left": "", + "LH_Middle_Secondary_Down": "", + "LH_Middle_Secondary_Right": "", + "LH_Middle_Secondary_Up": "", + "LH_Middle_Secondary_Center": "", + "LH_Middle_Primary_Left": "", + "LH_Middle_Primary_Down": "", + "LH_Middle_Primary_Right": "", + "LH_Middle_Primary_Up": "", + "LH_Middle_Primary_Center": "", + "LH_Index_Left": "", + "LH_Index_Down": "", + "LH_Index_Right": "", + "LH_Index_Up": "", + "LH_Index_Center": "" } diff --git a/src/lib/components/LayoutCC1.svelte b/src/lib/components/LayoutCC1.svelte index 27cd4757..dfecdae3 100644 --- a/src/lib/components/LayoutCC1.svelte +++ b/src/lib/components/LayoutCC1.svelte @@ -15,42 +15,42 @@
- +
- - + +
- - + +
- +
- +
- - + +
- - + +
- +
- - + +
- - + +
- - + +
diff --git a/src/lib/components/RingInput.svelte b/src/lib/components/RingInput.svelte index 47142bf6..ce29a54d 100644 --- a/src/lib/components/RingInput.svelte +++ b/src/lib/components/RingInput.svelte @@ -1,12 +1,12 @@
- {#each layout as keys, quadrant} - {/each} @@ -64,6 +81,7 @@ $cr: math.div($size, 2) - 2 * $offset; will-change: scale, offset-distance; + user-select: none; scale: 0.9; offset-path: path( @@ -82,7 +100,7 @@ font-size: 16px; - opacity: 0.3; + opacity: 0.2; transition: scale 250ms ease, opacity 250ms ease, offset-distance 250ms ease; @@ -137,4 +155,12 @@ clip-path: polygon(50% 50%, 0 0, 0 100%); } } + + .secondary > button { + filter: brightness(80%) contrast(120%); + } + + .tertiary > button { + filter: brightness(80%) contrast(110%); + } diff --git a/src/lib/serial/connection.js b/src/lib/serial/connection.js index 8bdfbd10..09720113 100644 --- a/src/lib/serial/connection.js +++ b/src/lib/serial/connection.js @@ -10,6 +10,9 @@ export const serialLog = writable([]) /** @type {import('svelte/store').Writable>} */ export const chords = writable([]) +/** @type {import('svelte/store').Writable<[number[], number[], number[]]>} */ +export const layout = writable([[], [], []]) + /** @type {import('svelte/store').Writable} */ export const syncing = writable(false) @@ -21,6 +24,14 @@ export async function initSerial() { device ??= new CharaDevice() serialPort.set(device) + const parsedLayout = [[], [], []] + for (let layer = 1; layer <= 3; layer++) { + for (let i = 0; i < 90; i++) { + parsedLayout[layer - 1][i] = await device.getLayoutKey(layer, i) + } + } + layout.set(parsedLayout) + const chordCount = await device.getChordCount() const chordInfo = [] for (let i = 0; i < chordCount; i++) { diff --git a/src/lib/serial/device.js b/src/lib/serial/device.js index 8e1431a3..58870e28 100644 --- a/src/lib/serial/device.js +++ b/src/lib/serial/device.js @@ -179,4 +179,15 @@ export class CharaDevice { unk: Number(b), } } + + /** + * @param layer {number} + * @param id {number} + * @returns {Promise} + */ + async getLayoutKey(layer, id) { + const layout = await this.send(`VAR B3 A${layer} ${id}`) + const [position] = layout.split(" ").map(Number) + return position + } }