gyro sensitivity option + update range inputs styling

This commit is contained in:
thecozies 2024-04-21 12:14:41 -05:00
parent a5c359d28c
commit 26117389aa
8 changed files with 53 additions and 9 deletions

View File

@ -40,7 +40,7 @@
<div class="config-option" data-event-mouseover="set_cur_config_index(1)"> <div class="config-option" data-event-mouseover="set_cur_config_index(1)">
<label class="config-option__title">Rumble Strength</label> <label class="config-option__title">Rumble Strength</label>
<div class="config-option__range-wrapper config-option__list"> <div class="config-option__range-wrapper config-option__list">
<label class="config-option__range-label">{{rumble_strength}}</label> <label class="config-option__range-label">{{rumble_strength}}%</label>
<input <input
class="nav-vert" class="nav-vert"
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
@ -54,6 +54,25 @@
/> />
</div> </div>
</div> </div>
<!-- gyro sensitivity -->
<div class="config-option" data-event-mouseover="set_cur_config_index(2)">
<label class="config-option__title">Gyro Sensitivity</label>
<div class="config-option__range-wrapper config-option__list">
<label class="config-option__range-label">{{gyro_sensitivity}}%</label>
<input
class="nav-vert"
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(2)"
id="gyro_sensitivity_input"
type="range"
min="0"
max="100"
style="flex: 1; margin: 0dp;"
data-value="gyro_sensitivity"
/>
</div>
</div>
</div> </div>
<!-- Descriptions --> <!-- Descriptions -->
<div class="config__wrapper"> <div class="config__wrapper">
@ -63,6 +82,9 @@
<p data-if="cur_config_index == 1"> <p data-if="cur_config_index == 1">
Controls the strength of rumble when using a controller that supports it. Setting this to zero will disable rumble. Controls the strength of rumble when using a controller that supports it. Setting this to zero will disable rumble.
</p> </p>
<p data-if="cur_config_index == 2">
Controls the sensitivity of gyro when using a controller that supports it. Setting this to zero will disable gyro.
</p>
</div> </div>
</div> </div>
</form> </form>

View File

@ -9,7 +9,7 @@
<div class="config-option" data-event-mouseover="set_cur_config_index(0)"> <div class="config-option" data-event-mouseover="set_cur_config_index(0)">
<label class="config-option__title">Background Music Volume</label> <label class="config-option__title">Background Music Volume</label>
<div class="config-option__range-wrapper config-option__list"> <div class="config-option__range-wrapper config-option__list">
<label class="config-option__range-label">{{bgm_volume}}</label> <label class="config-option__range-label">{{bgm_volume}}%</label>
<input <input
data-event-blur="set_cur_config_index(-1)" data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(0)" data-event-focus="set_cur_config_index(0)"

File diff suppressed because one or more lines are too long

View File

@ -178,7 +178,7 @@
input.range slidertrack { input.range slidertrack {
@include trans-colors; @include trans-colors;
height: 2dp; height: 2dp;
margin-top: 7dp; margin-top: space(8);
background-color: $color-border; background-color: $color-border;
} }
@ -186,8 +186,9 @@
@include trans-colors; @include trans-colors;
width: space(16); width: space(16);
height: space(16); height: space(16);
margin-right: -6dp; margin-top: space(1);
margin-left: -8dp; margin-right: space(-8);
margin-left: space(-8);
transition: background-color $transition-quick; transition: background-color $transition-quick;
border-radius: 8dp; border-radius: 8dp;
background-color: $color-text-dim; background-color: $color-text-dim;
@ -230,7 +231,8 @@
@extend %label-sm; @extend %label-sm;
display: block; display: block;
flex: 0 0 space(16); // flex: 0 0 space(32);
width: space(56);
margin: 0 12dp; margin: 0 12dp;
margin-right: space(16); margin-right: space(16);
padding: 0; padding: 0;

View File

@ -124,6 +124,10 @@ namespace recomp {
// Rumble strength ranges from 0 to 100. // Rumble strength ranges from 0 to 100.
int get_rumble_strength(); int get_rumble_strength();
void set_rumble_strength(int strength); void set_rumble_strength(int strength);
// Gyro sensitivity ranges from 0 to 100 (gets doubled).
int get_gyro_sensitivity();
void set_gyro_sensitivity(int strength);
enum class TargetingMode { enum class TargetingMode {
Switch, Switch,

View File

@ -128,6 +128,7 @@ void save_general_config(const std::filesystem::path& path) {
recomp::to_json(config_json["targeting_mode"], recomp::get_targeting_mode()); recomp::to_json(config_json["targeting_mode"], recomp::get_targeting_mode());
config_json["rumble_strength"] = recomp::get_rumble_strength(); config_json["rumble_strength"] = recomp::get_rumble_strength();
config_json["gyro_sensitivity"] = recomp::get_gyro_sensitivity();
config_json["debug_mode"] = recomp::get_debug_mode_enabled(); config_json["debug_mode"] = recomp::get_debug_mode_enabled();
config_file << std::setw(4) << config_json; config_file << std::setw(4) << config_json;
} }
@ -140,6 +141,7 @@ void load_general_config(const std::filesystem::path& path) {
recomp::set_targeting_mode(from_or_default(config_json, "targeting_mode", recomp::TargetingMode::Switch)); recomp::set_targeting_mode(from_or_default(config_json, "targeting_mode", recomp::TargetingMode::Switch));
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_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

@ -505,8 +505,9 @@ bool recomp::get_input_digital(const std::span<const recomp::InputField> fields)
void recomp::get_gyro_deltas(float* x, float* y) { void recomp::get_gyro_deltas(float* x, float* y) {
std::array<float, 2> cur_rotation_delta = InputState.rotation_delta; std::array<float, 2> cur_rotation_delta = InputState.rotation_delta;
*x = cur_rotation_delta[0]; float sensitivity = (float)recomp::get_gyro_sensitivity() / 50.0f;
*y = cur_rotation_delta[1]; *x = cur_rotation_delta[0] * sensitivity;
*y = cur_rotation_delta[1] * sensitivity;
} }
bool recomp::game_input_disabled() { bool recomp::game_input_disabled() {

View File

@ -211,6 +211,7 @@ void close_config_menu() {
struct ControlOptionsContext { struct ControlOptionsContext {
int rumble_strength = 50; // 0 to 100 int rumble_strength = 50; // 0 to 100
int gyro_sensitivity = 50; // 0 to 200
recomp::TargetingMode targeting_mode = recomp::TargetingMode::Switch; recomp::TargetingMode targeting_mode = recomp::TargetingMode::Switch;
}; };
@ -227,6 +228,17 @@ void recomp::set_rumble_strength(int strength) {
} }
} }
int recomp::get_gyro_sensitivity() {
return control_options_context.gyro_sensitivity;
}
void recomp::set_gyro_sensitivity(int sensitivity) {
control_options_context.gyro_sensitivity = sensitivity;
if (general_model_handle) {
general_model_handle.DirtyVariable("gyro_sensitivity");
}
}
recomp::TargetingMode recomp::get_targeting_mode() { recomp::TargetingMode recomp::get_targeting_mode() {
return control_options_context.targeting_mode; return control_options_context.targeting_mode;
} }
@ -672,6 +684,7 @@ public:
bind_config_list_events(constructor); bind_config_list_events(constructor);
constructor.Bind("rumble_strength", &control_options_context.rumble_strength); constructor.Bind("rumble_strength", &control_options_context.rumble_strength);
constructor.Bind("gyro_sensitivity", &control_options_context.gyro_sensitivity);
bind_option(constructor, "targeting_mode", &control_options_context.targeting_mode); bind_option(constructor, "targeting_mode", &control_options_context.targeting_mode);
general_model_handle = constructor.GetModelHandle(); general_model_handle = constructor.GetModelHandle();