Rebind mic calibration to Shift+V and add manual volume edit
This commit is contained in:
@@ -131,8 +131,12 @@
|
|||||||
"description": "Lower/raise active effect value"
|
"description": "Lower/raise active effect value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keys": "Shift+C",
|
"keys": "V",
|
||||||
"description": "Calibrate mic input gain over 5 seconds"
|
"description": "Set volume"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keys": "Shift+V",
|
||||||
|
"description": "Microphone calibration"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.22 R150";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R151";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -653,6 +653,7 @@ function textInputMaxLengthForMode(mode: typeof state.mode): number | null {
|
|||||||
if (mode === 'nickname') return NICKNAME_MAX_LENGTH;
|
if (mode === 'nickname') return NICKNAME_MAX_LENGTH;
|
||||||
if (mode === 'chat') return 500;
|
if (mode === 'chat') return 500;
|
||||||
if (mode === 'itemPropertyEdit') return 500;
|
if (mode === 'itemPropertyEdit') return 500;
|
||||||
|
if (mode === 'micGainEdit') return 8;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +671,7 @@ function pasteIntoActiveTextInput(raw: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTextEditingMode(mode: typeof state.mode): boolean {
|
function isTextEditingMode(mode: typeof state.mode): boolean {
|
||||||
return mode === 'nickname' || mode === 'chat' || mode === 'itemPropertyEdit';
|
return mode === 'nickname' || mode === 'chat' || mode === 'itemPropertyEdit' || mode === 'micGainEdit';
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTextInputEdit(code: string, key: string, maxLength: number, ctrlKey = false, allowReplaceOnNextType = false): void {
|
function applyTextInputEdit(code: string, key: string, maxLength: number, ctrlKey = false, allowReplaceOnNextType = false): void {
|
||||||
@@ -1506,11 +1507,21 @@ function handleNormalModeInput(code: string, shiftKey: boolean): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (code === 'KeyC') {
|
if (code === 'KeyC') {
|
||||||
|
updateStatus(`${state.player.x}, ${state.player.y}`);
|
||||||
|
audio.sfxUiBlip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code === 'KeyV') {
|
||||||
if (shiftKey) {
|
if (shiftKey) {
|
||||||
void calibrateMicInputGain();
|
void calibrateMicInputGain();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateStatus(`${state.player.x}, ${state.player.y}`);
|
state.mode = 'micGainEdit';
|
||||||
|
state.nicknameInput = audio.getOutboundInputGain().toFixed(2);
|
||||||
|
state.cursorPos = state.nicknameInput.length;
|
||||||
|
replaceTextOnNextType = true;
|
||||||
|
updateStatus(`Set volume: ${state.nicknameInput}`);
|
||||||
audio.sfxUiBlip();
|
audio.sfxUiBlip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1836,6 +1847,34 @@ function handleChatModeInput(code: string, key: string, ctrlKey: boolean): void
|
|||||||
applyTextInputEdit(code, key, 500, ctrlKey);
|
applyTextInputEdit(code, key, 500, ctrlKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMicGainEditModeInput(code: string, key: string, ctrlKey: boolean): void {
|
||||||
|
if (code === 'Enter') {
|
||||||
|
const value = Number(state.nicknameInput.trim());
|
||||||
|
if (!Number.isFinite(value) || value < MIC_CALIBRATION_MIN_GAIN || value > MIC_CALIBRATION_MAX_GAIN) {
|
||||||
|
updateStatus(`Volume must be between ${MIC_CALIBRATION_MIN_GAIN} and ${MIC_CALIBRATION_MAX_GAIN}.`);
|
||||||
|
audio.sfxUiCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const applied = audio.setOutboundInputGain(value);
|
||||||
|
persistMicInputGain(applied);
|
||||||
|
state.mode = 'normal';
|
||||||
|
replaceTextOnNextType = false;
|
||||||
|
updateStatus(`Volume set to ${applied.toFixed(2)}.`);
|
||||||
|
audio.sfxUiConfirm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code === 'Escape') {
|
||||||
|
state.mode = 'normal';
|
||||||
|
replaceTextOnNextType = false;
|
||||||
|
updateStatus('Cancelled.');
|
||||||
|
audio.sfxUiCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
applyTextInputEdit(code, key, 8, ctrlKey, true);
|
||||||
|
}
|
||||||
|
|
||||||
function handleEffectSelectModeInput(code: string, key: string): void {
|
function handleEffectSelectModeInput(code: string, key: string): void {
|
||||||
if (code === 'ArrowDown' || code === 'ArrowUp') {
|
if (code === 'ArrowDown' || code === 'ArrowUp') {
|
||||||
state.effectSelectIndex =
|
state.effectSelectIndex =
|
||||||
@@ -2537,6 +2576,8 @@ function setupInputHandlers(): void {
|
|||||||
handleNicknameModeInput(code, event.key, event.ctrlKey);
|
handleNicknameModeInput(code, event.key, event.ctrlKey);
|
||||||
} else if (state.mode === 'chat') {
|
} else if (state.mode === 'chat') {
|
||||||
handleChatModeInput(code, event.key, event.ctrlKey);
|
handleChatModeInput(code, event.key, event.ctrlKey);
|
||||||
|
} else if (state.mode === 'micGainEdit') {
|
||||||
|
handleMicGainEditModeInput(code, event.key, event.ctrlKey);
|
||||||
} else if (state.mode === 'effectSelect') {
|
} else if (state.mode === 'effectSelect') {
|
||||||
handleEffectSelectModeInput(code, event.key);
|
handleEffectSelectModeInput(code, event.key);
|
||||||
} else if (state.mode === 'helpView') {
|
} else if (state.mode === 'helpView') {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export type GameMode =
|
|||||||
| 'helpView'
|
| 'helpView'
|
||||||
| 'nickname'
|
| 'nickname'
|
||||||
| 'chat'
|
| 'chat'
|
||||||
|
| 'micGainEdit'
|
||||||
| 'effectSelect'
|
| 'effectSelect'
|
||||||
| 'listUsers'
|
| 'listUsers'
|
||||||
| 'listItems'
|
| 'listItems'
|
||||||
|
|||||||
Reference in New Issue
Block a user