Skip to content

Commit

Permalink
Change game_pad_stick_left_stick_deadzone_, game_pad_stick_right_stic…
Browse files Browse the repository at this point in the history
…k_deadzone_, game_pad_stick_xy_scale_ type (double -> std::optional<double>)
  • Loading branch information
tekezo committed Oct 9, 2023
1 parent 6484210 commit 18a3870
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
18 changes: 12 additions & 6 deletions src/share/core_configuration/details/profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,16 @@ class profile final {
double get_device_game_pad_stick_left_stick_deadzone(const device_identifiers& identifiers) const {
for (const auto& d : devices_) {
if (d.get_identifiers() == identifiers) {
return d.get_game_pad_stick_left_stick_deadzone();
if (auto value = d.get_game_pad_stick_left_stick_deadzone()) {
return *value;
}
}
}
return device::game_pad_stick_left_stick_deadzone_default_value;
}

void set_device_game_pad_stick_left_stick_deadzone(const device_identifiers& identifiers,
double value) {
std::optional<double> value) {
add_device(identifiers);

for (auto&& device : devices_) {
Expand All @@ -507,14 +509,16 @@ class profile final {
double get_device_game_pad_stick_right_stick_deadzone(const device_identifiers& identifiers) const {
for (const auto& d : devices_) {
if (d.get_identifiers() == identifiers) {
return d.get_game_pad_stick_right_stick_deadzone();
if (auto value = d.get_game_pad_stick_right_stick_deadzone()) {
return *value;
}
}
}
return device::game_pad_stick_right_stick_deadzone_default_value;
}

void set_device_game_pad_stick_right_stick_deadzone(const device_identifiers& identifiers,
double value) {
std::optional<double> value) {
add_device(identifiers);

for (auto&& device : devices_) {
Expand All @@ -528,14 +532,16 @@ class profile final {
double get_device_game_pad_stick_xy_scale(const device_identifiers& identifiers) const {
for (const auto& d : devices_) {
if (d.get_identifiers() == identifiers) {
return d.get_game_pad_stick_xy_scale();
if (auto value = d.get_game_pad_stick_xy_scale()) {
return *value;
}
}
}
return device::game_pad_stick_xy_scale_default_value;
}

void set_device_game_pad_stick_xy_scale(const device_identifiers& identifiers,
double value) {
std::optional<double> value) {
add_device(identifiers);

for (auto&& device : devices_) {
Expand Down
35 changes: 19 additions & 16 deletions src/share/core_configuration/details/profile/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class device final {
mouse_flip_vertical_wheel_(false),
mouse_flip_horizontal_wheel_(false),
mouse_swap_xy_(false),
mouse_swap_wheel_(false),
game_pad_stick_left_stick_deadzone_(game_pad_stick_left_stick_deadzone_default_value),
game_pad_stick_right_stick_deadzone_(game_pad_stick_right_stick_deadzone_default_value),
game_pad_stick_xy_scale_(game_pad_stick_xy_scale_default_value) {
mouse_swap_wheel_(false) {
auto ignore_configured = false;
auto manipulate_caps_lock_led_configured = false;

Expand Down Expand Up @@ -188,9 +185,15 @@ class device final {
j["mouse_flip_horizontal_wheel"] = mouse_flip_horizontal_wheel_;
j["mouse_swap_xy"] = mouse_swap_xy_;
j["mouse_swap_wheel"] = mouse_swap_wheel_;
j["game_pad_stick_left_stick_deadzone"] = game_pad_stick_left_stick_deadzone_;
j["game_pad_stick_right_stick_deadzone"] = game_pad_stick_right_stick_deadzone_;
j["game_pad_stick_xy_scale"] = game_pad_stick_xy_scale_;
if (game_pad_stick_left_stick_deadzone_ != std::nullopt) {
j["game_pad_stick_left_stick_deadzone"] = *game_pad_stick_left_stick_deadzone_;
}
if (game_pad_stick_right_stick_deadzone_ != std::nullopt) {
j["game_pad_stick_right_stick_deadzone"] = *game_pad_stick_right_stick_deadzone_;
}
if (game_pad_stick_xy_scale_ != std::nullopt) {
j["game_pad_stick_xy_scale"] = *game_pad_stick_xy_scale_;
}
j["simple_modifications"] = simple_modifications_.to_json();
j["fn_function_keys"] = fn_function_keys_.to_json();
return j;
Expand Down Expand Up @@ -290,28 +293,28 @@ class device final {
coordinate_between_properties();
}

double get_game_pad_stick_left_stick_deadzone(void) const {
std::optional<double> get_game_pad_stick_left_stick_deadzone(void) const {
return game_pad_stick_left_stick_deadzone_;
}
void set_game_pad_stick_left_stick_deadzone(double value) {
void set_game_pad_stick_left_stick_deadzone(std::optional<double> value) {
game_pad_stick_left_stick_deadzone_ = value;

coordinate_between_properties();
}

double get_game_pad_stick_right_stick_deadzone(void) const {
std::optional<double> get_game_pad_stick_right_stick_deadzone(void) const {
return game_pad_stick_right_stick_deadzone_;
}
void set_game_pad_stick_right_stick_deadzone(double value) {
void set_game_pad_stick_right_stick_deadzone(std::optional<double> value) {
game_pad_stick_right_stick_deadzone_ = value;

coordinate_between_properties();
}

double get_game_pad_stick_xy_scale(void) const {
std::optional<double> get_game_pad_stick_xy_scale(void) const {
return game_pad_stick_xy_scale_;
}
void set_game_pad_stick_xy_scale(double value) {
void set_game_pad_stick_xy_scale(std::optional<double> value) {
game_pad_stick_xy_scale_ = value;

coordinate_between_properties();
Expand Down Expand Up @@ -353,9 +356,9 @@ class device final {
bool mouse_flip_horizontal_wheel_;
bool mouse_swap_xy_;
bool mouse_swap_wheel_;
double game_pad_stick_left_stick_deadzone_;
double game_pad_stick_right_stick_deadzone_;
double game_pad_stick_xy_scale_;
std::optional<double> game_pad_stick_left_stick_deadzone_;
std::optional<double> game_pad_stick_right_stick_deadzone_;
std::optional<double> game_pad_stick_xy_scale_;
simple_modifications simple_modifications_;
simple_modifications fn_function_keys_;
};
Expand Down

0 comments on commit 18a3870

Please sign in to comment.