Skip to content

Commit

Permalink
Add option to disable gamepad capture when window is unfocussed #1231
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownskl committed May 28, 2024
1 parent 162433b commit 64407fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
1 change: 1 addition & 0 deletions renderer/context/userContext.defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const gamepad_config = {
'RightThumbYAxis': '3',
},
gamepad_deadzone: 0.2,
gamepad_force_capture: false,
}

export const defaultSettings = {
Expand Down
40 changes: 10 additions & 30 deletions renderer/pages/settings/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,28 @@ function SettingsInput() {
<h1>Gamepad</h1>

<p>
<label>Enable vibration (broken)</label>
<label>Enable vibration</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ setControllerVibration } checked={settings.controller_vibration} />&nbsp; ({ settings.controller_vibration ? 'Enabled' : 'Disabled'})
</label>
</p>
<p>
<label>Force gamepad capture</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ () => setGamepadConfig({ gamepad_force_capture: !settings.gamepad_config.gamepad_force_capture }) } checked={settings.gamepad_config.gamepad_force_capture} />&nbsp; ({ settings.gamepad_config.gamepad_force_capture ? 'Enabled' : 'Disabled'})
</label> <br />
<small>Enabling this will capture gamepad input even when the window is not focussed.</small>
</p>
<p>
<label>Enable keyboard mapping</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ () => setGamepadConfig({ enable_keyboard: !settings.gamepad_config.enable_keyboard }) } checked={settings.gamepad_config.enable_keyboard} />&nbsp; ({ settings.gamepad_config.enable_keyboard ? 'Enabled' : 'Disabled'})
</label>
</p>
<p hidden={ !settings.gamepad_config.enable_keyboard }>
<p>
<label></label>
<label style={{ minWidth: 0 }}>
<Link href="/settings/input/keyboardmap"><Button className="btn-small" label="Configure Keyboard mappings"></Button></Link>
<Link href="/settings/input/keyboardmap"><Button className="btn-small" label="Configure Keyboard mappings" disabled={ !settings.gamepad_config.enable_keyboard }></Button></Link>
</label>
</p>
<p>
Expand All @@ -94,33 +101,6 @@ function SettingsInput() {
<p><i>No options yet</i></p>
</Card>

<Card>
<h1>Input</h1>

{/* <p>
<label>Enable Touch input</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ setTouchInput } checked={settings.input_touch} />&nbsp; ({ settings.input_touch ? 'Enabled' : 'Disabled'})
</label>
</p>
<p>
<label>Enable Mouse & Keyboard</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ setMKBInput } checked={settings.input_mousekeyboard} />&nbsp; ({ settings.input_mousekeyboard ? 'Enabled' : 'Disabled'})
</label> <br />
{ (!settings.input_newgamepad && settings.input_mousekeyboard) ? <small style={{ color: 'orange' }}>Using the Mouse & Keyboard driver together with the Gamepad keyboard mappings will cause conflicts</small> : '' }
</p>
<p>
<label>Enable Keyboard to Gamepad</label>
<label style={{ minWidth: 0 }}>
<input type='checkbox' onChange={ setLegacyInput } checked={!settings.input_newgamepad} />&nbsp; ({ !settings.input_newgamepad ? 'Enabled' : 'Disabled'})
</label><br />
<small>(Disabling this feature will disable the keyboard to gamepad mapping and only allows controls from the gamepad.)</small>
</p> */}
</Card>

<Card>
<h1>Controllers detected</h1>

Expand Down
2 changes: 2 additions & 0 deletions renderer/pages/stream/[serverid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function Stream() {
gamepad_mapping: settings.gamepad_config.gamepad_mapping,
gamepad_axes_mapping: settings.gamepad_config.gamepad_axes_mapping,
gamepad_deadzone: settings.gamepad_config.gamepad_deadzone,
enable_vibration: settings.controller_vibration,
// gamepad_force_capture: false, // @TODO: Implement config switch

// vibration: settings.controller_vibration,
})
Expand Down

0 comments on commit 64407fa

Please sign in to comment.