4 Commits

Author SHA1 Message Date
6faaa18b3b 1.3.2 2024-01-30 19:49:52 +01:00
6ab6959129 fix: disallow null inputs when editing
feat: allow special inputs while creating a chord input
fixes #93
2024-01-30 19:49:10 +01:00
44d89d3f35 1.3.1 2024-01-24 18:55:46 +01:00
eaf0adaf01 fix: sort legacy chord inputs 2024-01-24 18:55:31 +01:00
11 changed files with 26 additions and 23 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "charachorder-device-manager",
"version": "1.3.0",
"version": "1.3.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "charachorder-device-manager",
"version": "1.3.0",
"version": "1.3.2",
"hasInstallScript": true,
"license": "AGPL-3.0-or-later",
"devDependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "charachorder-device-manager",
"version": "1.3.0",
"version": "1.3.2",
"license": "AGPL-3.0-or-later",
"private": true,
"repository": {

View File

@@ -1,6 +1,6 @@
[package]
name = "app"
version = "1.3.0"
version = "1.3.2"
description = "A Tauri App"
authors = ["Thea Schöbl <dev@theaninova.de>"]
license = "AGPL-3"

View File

@@ -6,7 +6,7 @@
"devPath": "http://localhost:5173",
"distDir": "../build"
},
"package": { "productName": "amacc1ng", "version": "1.3.0" },
"package": { "productName": "amacc1ng", "version": "1.3.2" },
"tauri": {
"allowlist": { "all": false },
"bundle": {

View File

@@ -6,41 +6,49 @@ actions:
id: "LEFT_CTRL"
display: CTRL
title: Control Keyboard Modifier
keyCode: ControlLeft
variant: left
513: &left_shift
id: "LEFT_SHIFT"
title: Shift Keyboard Modifier
keyCode: ShiftLeft
variant: left
icon: shift
514: &left_alt
id: "LEFT_ALT"
display: ALT
title: Alt Keyboard Modifier
keyCode: AltLeft
variant: left
515: &left_gui
id: "LEFT_GUI"
title: GUI Keyboard Modifier
keyCode: MetaLeft
icon: apps
variant: left
516:
variationOf: 512
<<: *left_ctrl
id: "RIGHT_CTRL"
keyCode: ControlRight
variant: right
517:
variationOf: 513
<<: *left_shift
id: "RIGHT_SHIFT"
keyCode: ShiftRight
variant: right
518:
variationOf: 514
<<: *left_alt
id: "RIGHT_ALT"
keyCode: AltRight
variant: right
519:
variationOf: 515
<<: *left_gui
id: "RIGHT_GUI"
keyCode: MetaRight
variant: right
520:
id: "RELEASE_MOD"

View File

@@ -920,35 +920,27 @@ actions:
description: Not required to be supported by any OS
480:
id: "KSC_E0"
keyCode: "ControlLeft"
title: Keyboard Left Control
481:
id: "KSC_E1"
keyCode: "ShiftLeft"
title: Keyboard Left Shift
482:
id: "KSC_E2"
keyCode: "AltLeft"
title: Keyboard Left Alt
483:
id: "KSC_E3"
keyCode: "MetaLeft"
title: Keyboard Left GUI
484:
id: "KSC_E4"
keyCode: "ControlRight"
title: Keyboard Right Control
485:
id: "KSC_E5"
keyCode: "ShiftRight"
title: Keyboard Right Shift
486:
id: "KSC_E6"
keyCode: "AltRight"
title: Keyboard Right Alt
487:
id: "KSC_E7"
keyCode: "MetaRight"
title: Keyboard Right GUI
488:
id: "KSC_E8"

View File

@@ -13,7 +13,10 @@ export function csvChordsToJson(csv: string): CharaChordFile {
.map(line => {
const [input, output] = line.split(/,(?=[^,]*$)/, 2)
return [
input.split("+").map(it => KEYMAP_IDS.get(it.trim())?.code ?? 0),
input
.split("+")
.map(it => KEYMAP_IDS.get(it.trim())?.code ?? 0)
.sort((a, b) => a - b),
output
.trim()
.split("")

View File

@@ -33,7 +33,3 @@ export const KEYMAP_IDS: Map<string, KeyInfo> = new Map(
),
).filter(([id]) => id !== undefined),
)
export const specialKeycodes = new Map([
[" ", 32], // Space
])

View File

@@ -28,7 +28,12 @@
function keydown(event: KeyboardEvent) {
if (!editing) return
event.preventDefault()
pressedKeys.add(inputToAction(event, get(serialPort)?.device === "X")!)
const input = inputToAction(event, get(serialPort)?.device === "X")
if (input == undefined) {
alert("Invalid key")
return
}
pressedKeys.add(input)
pressedKeys = pressedKeys
}

View File

@@ -1,7 +1,5 @@
<script lang="ts">
import {KEYMAP_IDS, specialKeycodes} from "$lib/serial/keymap-codes"
import {tick} from "svelte"
import ActionSelector from "$lib/components/layout/ActionSelector.svelte"
import {changes, ChangeType} from "$lib/undo-redo"
import type {ChordInfo} from "$lib/undo-redo"
import {scale} from "svelte/transition"
@@ -26,6 +24,7 @@
} else if (event.key === "Delete") {
deleteAction(cursorPosition)
} else {
if (event.key === "Shift") return
const action = inputToAction(event, get(serialPort)?.device === "X")
if (action !== undefined) {
insertAction(cursorPosition, action)

View File

@@ -1,9 +1,9 @@
import {KEYMAP_IDS, KEYMAP_KEYCODES, specialKeycodes} from "$lib/serial/keymap-codes"
import {KEYMAP_IDS, KEYMAP_KEYCODES} from "$lib/serial/keymap-codes"
export function inputToAction(event: KeyboardEvent, useKeycodes?: boolean): number | undefined {
if (useKeycodes) {
return KEYMAP_KEYCODES.get(event.code)
} else {
return KEYMAP_IDS.get(event.key)?.code ?? specialKeycodes.get(event.key)
return KEYMAP_IDS.get(event.key)?.code ?? KEYMAP_KEYCODES.get(event.code)
}
}