8 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
5b6a5ea36d 1.3.0 2024-01-20 22:24:39 +01:00
14cbb5553b feat: add auto-space info 2024-01-20 22:24:00 +01:00
duianto
8ed72fe958 fix: typo 2024-01-11 09:36:33 +01:00
06b83f79ef feat: add refresh button
resolves #82
2024-01-05 00:12:42 +01:00
17 changed files with 61 additions and 36 deletions

View File

@@ -92,6 +92,7 @@ const config = {
"stat_2", "stat_2",
"description", "description",
"add_circle", "add_circle",
"refresh",
], ],
codePoints: { codePoints: {
speed: "e9e4", speed: "e9e4",

4
package-lock.json generated
View File

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

View File

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

View File

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

View File

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

View File

@@ -14,6 +14,7 @@ const de = {
sync: { sync: {
TITLE_READ: "Neueste Änderungen werden abgerufen", TITLE_READ: "Neueste Änderungen werden abgerufen",
TITLE_WRITE: "Änderungen werden gespeichert", TITLE_WRITE: "Änderungen werden gespeichert",
RELOAD: "Neu laden",
}, },
backup: { backup: {
TITLE: "Verlauf speichern", TITLE: "Verlauf speichern",

View File

@@ -21,6 +21,7 @@ const en = {
sync: { sync: {
TITLE_READ: "Reading latest changes", TITLE_READ: "Reading latest changes",
TITLE_WRITE: "Saving changes to device", TITLE_WRITE: "Saving changes to device",
RELOAD: "Reload",
}, },
modal: { modal: {
CLOSE: "Close", CLOSE: "Close",

View File

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

View File

@@ -3,7 +3,9 @@ description: OS-Layout sensitive keycodes
actions: actions:
256: 256:
id: "KSC_00" id: "KSC_00"
icon: block
title: No Key Pressed title: No Key Pressed
description: Also commonly used at the end of a chord to remove auto-spaces
257: 257:
id: "KSC_01" id: "KSC_01"
title: Keyboard Error Roll Over title: Keyboard Error Roll Over
@@ -918,35 +920,27 @@ actions:
description: Not required to be supported by any OS description: Not required to be supported by any OS
480: 480:
id: "KSC_E0" id: "KSC_E0"
keyCode: "ControlLeft"
title: Keyboard Left Control title: Keyboard Left Control
481: 481:
id: "KSC_E1" id: "KSC_E1"
keyCode: "ShiftLeft"
title: Keyboard Left Shift title: Keyboard Left Shift
482: 482:
id: "KSC_E2" id: "KSC_E2"
keyCode: "AltLeft"
title: Keyboard Left Alt title: Keyboard Left Alt
483: 483:
id: "KSC_E3" id: "KSC_E3"
keyCode: "MetaLeft"
title: Keyboard Left GUI title: Keyboard Left GUI
484: 484:
id: "KSC_E4" id: "KSC_E4"
keyCode: "ControlRight"
title: Keyboard Right Control title: Keyboard Right Control
485: 485:
id: "KSC_E5" id: "KSC_E5"
keyCode: "ShiftRight"
title: Keyboard Right Shift title: Keyboard Right Shift
486: 486:
id: "KSC_E6" id: "KSC_E6"
keyCode: "AltRight"
title: Keyboard Right Alt title: Keyboard Right Alt
487: 487:
id: "KSC_E7" id: "KSC_E7"
keyCode: "MetaRight"
title: Keyboard Right GUI title: Keyboard Right GUI
488: 488:
id: "KSC_E8" id: "KSC_E8"

View File

@@ -13,7 +13,10 @@ export function csvChordsToJson(csv: string): CharaChordFile {
.map(line => { .map(line => {
const [input, output] = line.split(/,(?=[^,]*$)/, 2) const [input, output] = line.split(/,(?=[^,]*$)/, 2)
return [ 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 output
.trim() .trim()
.split("") .split("")

View File

@@ -55,6 +55,12 @@ export async function initSerial(manual = false) {
const device = get(serialPort) ?? new CharaDevice() const device = get(serialPort) ?? new CharaDevice()
await device.init(manual) await device.init(manual)
serialPort.set(device) serialPort.set(device)
sync()
}
export async function sync() {
const device = get(serialPort)
if (!device) return
const chordCount = await device.getChordCount() const chordCount = await device.getChordCount()
syncStatus.set("downloading") syncStatus.set("downloading")

View File

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

View File

@@ -1,21 +1,32 @@
<script lang="ts"> <script lang="ts">
import {syncProgress, syncStatus} from "$lib/serial/connection" import {serialPort, syncProgress, syncStatus, sync} from "$lib/serial/connection"
import LL from "../i18n/i18n-svelte" import LL from "../i18n/i18n-svelte"
import {fly} from "svelte/transition" import {slide} from "svelte/transition"
</script> </script>
{#if $syncStatus !== "done"} <div class="container">
<div transition:fly={{y: 40}}> {#if $syncStatus !== "done"}
<progress max={$syncProgress?.max ?? 1} value={$syncProgress?.current ?? 1}></progress> <div transition:slide>
{#if $syncStatus === "downloading"} <progress max={$syncProgress?.max ?? 1} value={$syncProgress?.current ?? 1}></progress>
<div>{$LL.sync.TITLE_READ()}</div> {#if $syncStatus === "downloading"}
{:else} <div>{$LL.sync.TITLE_READ()}</div>
<div>{$LL.sync.TITLE_WRITE()}</div> {:else}
{/if} <div>{$LL.sync.TITLE_WRITE()}</div>
</div> {/if}
{/if} </div>
{:else if $serialPort}
<button transition:slide on:click={sync}><span class="icon">refresh</span>{$LL.sync.RELOAD()}</button>
{/if}
</div>
<style lang="scss"> <style lang="scss">
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
div { div {
font-size: 12px; font-size: 12px;
} }

View File

@@ -28,7 +28,12 @@
function keydown(event: KeyboardEvent) { function keydown(event: KeyboardEvent) {
if (!editing) return if (!editing) return
event.preventDefault() 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 pressedKeys = pressedKeys
} }

View File

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

View File

@@ -11,7 +11,7 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
</script> </script>
<h3>Type the following to confim the action</h3> <h3>Type the following to confirm the action</h3>
<p>{challengeString}</p> <p>{challengeString}</p>
<input type="text" bind:value={challengeInput} placeholder={challengeString} /> <input type="text" bind:value={challengeInput} placeholder={challengeString} />