Fix navigation on deadzone option, convert backing value to int to match other sliders

This commit is contained in:
Mr-Wiseguy 2024-05-24 17:55:16 -04:00
parent 773cc3bbb0
commit a4f61016bb
4 changed files with 23 additions and 19 deletions

View File

@ -92,6 +92,7 @@
/> />
</div> </div>
</div> </div>
<!-- joystick deadzone --> <!-- joystick deadzone -->
<div class="config-option" data-event-mouseover="set_cur_config_index(4)"> <div class="config-option" data-event-mouseover="set_cur_config_index(4)">
<label class="config-option__title">Joystick Deadzone</label> <label class="config-option__title">Joystick Deadzone</label>
@ -101,7 +102,7 @@
class="nav-vert" class="nav-vert"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(4)" data-event-focus="set_cur_config_index(4)"
id="joystick_deadzone" id="joystick_deadzone_input"
type="range" type="range"
min="0" min="0"
max="100" max="100"
@ -112,60 +113,60 @@
</div> </div>
<!-- background input --> <!-- background input -->
<div class="config-option" data-event-mouseover="set_cur_config_index(4)" id="conf-general__Background-Input"> <div class="config-option" data-event-mouseover="set_cur_config_index(5)" id="conf-general__Background-Input">
<label class="config-option__title">Background Input</label> <label class="config-option__title">Background Input</label>
<div class="config-option__list"> <div class="config-option__list">
<input <input
type="radio" type="radio"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(4)" data-event-focus="set_cur_config_index(5)"
name="background_input_mode" name="background_input_mode"
data-checked="background_input_mode" data-checked="background_input_mode"
value="On" value="On"
id="bg_input_enabled" id="bg_input_enabled"
style="nav-up: #mouse_sensitivity_input; nav-down: #autosave_enabled" style="nav-up: #joystick_deadzone_input; nav-down: #autosave_enabled"
/> />
<label class="config-option__tab-label" for="bg_input_enabled">On</label> <label class="config-option__tab-label" for="bg_input_enabled">On</label>
<input <input
type="radio" type="radio"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(4)" data-event-focus="set_cur_config_index(5)"
name="background_input_mode" name="background_input_mode"
data-checked="background_input_mode" data-checked="background_input_mode"
value="Off" value="Off"
id="bg_input_disabled" id="bg_input_disabled"
style="nav-up: #mouse_sensitivity_input; nav-down: #autosave_disabled" style="nav-up: #joystick_deadzone_input; nav-down: #autosave_disabled"
/> />
<label class="config-option__tab-label" for="bg_input_disabled">Off</label> <label class="config-option__tab-label" for="bg_input_disabled">Off</label>
</div> </div>
</div> </div>
<!-- autosave --> <!-- autosave -->
<div class="config-option" data-event-mouseover="set_cur_config_index(5)"> <div class="config-option" data-event-mouseover="set_cur_config_index(6)">
<label class="config-option__title">Autosaving</label> <label class="config-option__title">Autosaving</label>
<div class="config-option__list"> <div class="config-option__list">
<input <input
type="radio" type="radio"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(5)" data-event-focus="set_cur_config_index(6)"
name="autosave_mode" name="autosave_mode"
data-checked="autosave_mode" data-checked="autosave_mode"
value="On" value="On"
id="autosave_enabled" id="autosave_enabled"
style="nav-up: #bg_input_enabled" style="nav-up: #bg_input_enabled; nav-down: #analog_cam_enabled"
/> />
<label class="config-option__tab-label" for="autosave_enabled">On</label> <label class="config-option__tab-label" for="autosave_enabled">On</label>
<input <input
type="radio" type="radio"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(5)" data-event-focus="set_cur_config_index(6)"
name="autosave_mode" name="autosave_mode"
data-checked="autosave_mode" data-checked="autosave_mode"
value="Off" value="Off"
id="autosave_disabled" id="autosave_disabled"
style="nav-up: #bg_input_disabled" style="nav-up: #bg_input_disabled; nav-down: #analog_cam_disabled"
/> />
<label class="config-option__tab-label" for="autosave_disabled">Off</label> <label class="config-option__tab-label" for="autosave_disabled">Off</label>
</div> </div>
@ -197,6 +198,9 @@
<b>This setting does not affect keyboard input.</b> <b>This setting does not affect keyboard input.</b>
</p> </p>
<p data-if="cur_config_index == 5"> <p data-if="cur_config_index == 5">
Applies a deadzone to joystick inputs.
</p>
<p data-if="cur_config_index == 6">
Turns on autosaving and prevents owl saves from being deleted on load. Autosaves act as owl saves and take up the same slot as they do. Turns on autosaving and prevents owl saves from being deleted on load. Autosaves act as owl saves and take up the same slot as they do.
<br/> <br/>
<br/> <br/>

View File

@ -129,10 +129,10 @@ namespace recomp {
// Gyro and mouse sensitivities range from 0 to 100. // Gyro and mouse sensitivities range from 0 to 100.
int get_gyro_sensitivity(); int get_gyro_sensitivity();
int get_mouse_sensitivity(); int get_mouse_sensitivity();
float get_joystick_deadzone(); int get_joystick_deadzone();
void set_gyro_sensitivity(int strength); void set_gyro_sensitivity(int strength);
void set_mouse_sensitivity(int strength); void set_mouse_sensitivity(int strength);
void set_joystick_deadzone(float value); void set_joystick_deadzone(int strength);
enum class TargetingMode { enum class TargetingMode {
Switch, Switch,

View File

@ -175,7 +175,7 @@ void set_general_settings_from_json(const nlohmann::json& config_json) {
recomp::set_rumble_strength(from_or_default(config_json, "rumble_strength", 25)); recomp::set_rumble_strength(from_or_default(config_json, "rumble_strength", 25));
recomp::set_gyro_sensitivity(from_or_default(config_json, "gyro_sensitivity", 50)); recomp::set_gyro_sensitivity(from_or_default(config_json, "gyro_sensitivity", 50));
recomp::set_mouse_sensitivity(from_or_default(config_json, "mouse_sensitivity", is_steam_deck ? 50 : 0)); recomp::set_mouse_sensitivity(from_or_default(config_json, "mouse_sensitivity", is_steam_deck ? 50 : 0));
recomp::set_joystick_deadzone(from_or_default(config_json, "joystick_deadzone", 0.0f)); recomp::set_joystick_deadzone(from_or_default(config_json, "joystick_deadzone", 5));
recomp::set_autosave_mode(from_or_default(config_json, "autosave_mode", recomp::AutosaveMode::On)); recomp::set_autosave_mode(from_or_default(config_json, "autosave_mode", recomp::AutosaveMode::On));
recomp::set_debug_mode_enabled(from_or_default(config_json, "debug_mode", false)); recomp::set_debug_mode_enabled(from_or_default(config_json, "debug_mode", false));
} }

View File

@ -274,7 +274,7 @@ struct ControlOptionsContext {
int rumble_strength; // 0 to 100 int rumble_strength; // 0 to 100
int gyro_sensitivity; // 0 to 100 int gyro_sensitivity; // 0 to 100
int mouse_sensitivity; // 0 to 100 int mouse_sensitivity; // 0 to 100
float joystick_deadzone; int joystick_deadzone; // 0 to 100
recomp::TargetingMode targeting_mode; recomp::TargetingMode targeting_mode;
recomp::BackgroundInputMode background_input_mode; recomp::BackgroundInputMode background_input_mode;
recomp::AutosaveMode autosave_mode; recomp::AutosaveMode autosave_mode;
@ -301,7 +301,7 @@ int recomp::get_mouse_sensitivity() {
return control_options_context.mouse_sensitivity; return control_options_context.mouse_sensitivity;
} }
float recomp::get_joystick_deadzone() { int recomp::get_joystick_deadzone() {
return control_options_context.joystick_deadzone; return control_options_context.joystick_deadzone;
} }
@ -319,8 +319,8 @@ void recomp::set_mouse_sensitivity(int sensitivity) {
} }
} }
void recomp::set_joystick_deadzone(float value) { void recomp::set_joystick_deadzone(int deadzone) {
control_options_context.joystick_deadzone = value; control_options_context.joystick_deadzone = deadzone;
if (general_model_handle) { if (general_model_handle) {
general_model_handle.DirtyVariable("joystick_deadzone"); general_model_handle.DirtyVariable("joystick_deadzone");
} }