Files
chat_grid/client/src/input/mainCommandRouter.ts

75 lines
2.8 KiB
TypeScript
Raw Normal View History

/**
* Declarative command ids for the primary gameplay input mode.
*/
export type MainModeCommand =
| 'editNickname'
| 'toggleMute'
| 'toggleOutputMode'
| 'toggleLoopback'
| 'toggleVoiceLayer'
| 'toggleItemLayer'
| 'toggleMediaLayer'
| 'toggleWorldLayer'
| 'masterVolumeUp'
| 'masterVolumeDown'
| 'openEffectSelect'
| 'effectValueUp'
| 'effectValueDown'
| 'speakCoordinates'
| 'openMicGainEdit'
| 'calibrateMicrophone'
| 'useItem'
| 'secondaryUseItem'
| 'speakUsers'
| 'addItem'
2026-03-08 19:27:23 -04:00
| 'locateNearestItem'
| 'listItems'
| 'pickupDropItem'
| 'openItemManagement'
2026-03-08 19:27:23 -04:00
| 'editItem'
| 'inspectItem'
| 'pingServer'
2026-03-08 19:27:23 -04:00
| 'locateNearestUser'
| 'listUsers'
| 'openHelp'
| 'openChat'
| 'openAdminMenu'
| 'chatPrev'
| 'chatNext'
| 'chatFirst'
| 'chatLast'
| 'escape';
/**
* Maps raw key events to a semantic command for main mode handling.
*/
export function resolveMainModeCommand(code: string, shiftKey: boolean): MainModeCommand | null {
if (code === 'KeyN') return shiftKey ? null : 'editNickname';
if (code === 'KeyM') return shiftKey ? 'toggleOutputMode' : 'toggleMute';
if (code === 'Digit1') return shiftKey ? 'toggleLoopback' : 'toggleVoiceLayer';
2026-03-08 19:27:23 -04:00
if (code === 'Digit2') return shiftKey ? null : 'toggleItemLayer';
if (code === 'Digit3') return shiftKey ? null : 'toggleMediaLayer';
if (code === 'Digit4') return shiftKey ? null : 'toggleWorldLayer';
if (code === 'KeyE') return shiftKey ? null : 'openEffectSelect';
if (code === 'Equal') return shiftKey ? 'effectValueUp' : 'masterVolumeUp';
if (code === 'Minus') return shiftKey ? 'effectValueDown' : 'masterVolumeDown';
if (code === 'NumpadAdd') return 'masterVolumeUp';
if (code === 'NumpadSubtract') return 'masterVolumeDown';
if (code === 'KeyC') return shiftKey ? null : 'speakCoordinates';
if (code === 'KeyV') return shiftKey ? 'calibrateMicrophone' : 'openMicGainEdit';
if (code === 'Enter') return shiftKey ? 'secondaryUseItem' : 'useItem';
if (code === 'KeyU') return shiftKey ? null : 'speakUsers';
if (code === 'KeyA') return shiftKey ? null : 'addItem';
2026-03-08 19:27:23 -04:00
if (code === 'KeyI') return shiftKey ? 'listItems' : 'locateNearestItem';
if (code === 'KeyD') return shiftKey ? null : 'pickupDropItem';
2026-03-08 19:27:23 -04:00
if (code === 'KeyO') return shiftKey ? 'inspectItem' : 'editItem';
if (code === 'KeyP') return shiftKey ? null : 'pingServer';
2026-03-08 19:27:23 -04:00
if (code === 'KeyL') return shiftKey ? 'listUsers' : 'locateNearestUser';
if (code === 'Slash') return shiftKey ? 'openHelp' : 'openChat';
if (code === 'KeyZ') return shiftKey ? 'openAdminMenu' : 'openItemManagement';
if (code === 'Comma') return shiftKey ? 'chatFirst' : 'chatPrev';
if (code === 'Period') return shiftKey ? 'chatLast' : 'chatNext';
2026-03-08 19:27:23 -04:00
if (code === 'Escape') return shiftKey ? null : 'escape';
return null;
}