feat(nds): use key codes instead of keys to handle multiple layouts
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m31s

This commit is contained in:
2026-02-16 13:57:26 +01:00
parent 4110539824
commit f4ebe93135
3 changed files with 12 additions and 13 deletions

View File

@@ -1,19 +1,18 @@
const KEY_TO_NDS_BUTTON: Record<string, string> = {
const CODE_TO_NDS_BUTTON: Record<string, string> = {
ArrowUp: "UP",
ArrowDown: "DOWN",
ArrowLeft: "LEFT",
ArrowRight: "RIGHT",
D: "A",
S: "B",
Z: "X",
Q: "Y",
" ": "SELECT",
KeyD: "A",
KeyS: "B",
KeyW: "X",
KeyA: "Y",
Space: "SELECT",
Enter: "START",
};
export const mapKeyToNDS = (key: string): string | null => {
key = key.length === 1 ? key.toUpperCase() : key;
return KEY_TO_NDS_BUTTON[key] ?? null;
export const mapCodeToNDS = (code: string): string | null => {
return CODE_TO_NDS_BUTTON[code] ?? null;
};
export const useMouseUp = (callback: () => void) => {