From: notaz Date: Thu, 26 Dec 2024 19:03:15 +0000 (+0200) Subject: libretro: simplify axis_range_modifier X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a79c063e3c75ac6d3c6bdc4e9350a1be6d5ec83;p=pcsx_rearmed.git libretro: simplify axis_range_modifier also default to square as that better matches psx on modern controllers --- diff --git a/frontend/libretro.c b/frontend/libretro.c index 7f953a5f..86c33673 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2140,7 +2140,7 @@ static void update_variables(bool in_flight) { axis_bounds_modifier = true; } - else if (strcmp(var.value, "circle") == 0) + else { axis_bounds_modifier = false; } @@ -2864,26 +2864,19 @@ static uint16_t get_analog_button(int16_t ret, retro_input_state_t input_state_c return button; } -unsigned char axis_range_modifier(int16_t axis_value, bool is_square) +static unsigned char axis_range_modifier(int axis_value, bool is_square) { - float modifier_axis_range = 0; + int modifier_axis_range; if (is_square) - { - modifier_axis_range = round((axis_value >> 8) / 0.785) + 128; - if (modifier_axis_range < 0) - { - modifier_axis_range = 0; - } - else if (modifier_axis_range > 255) - { - modifier_axis_range = 255; - } - } + modifier_axis_range = roundf((axis_value >> 8) / 0.785f) + 128; else - { - modifier_axis_range = MIN(((axis_value >> 8) + 128), 255); - } + modifier_axis_range = (axis_value >> 8) + 128; + + if (modifier_axis_range < 0) + modifier_axis_range = 0; + else if (modifier_axis_range > 255) + modifier_axis_range = 255; return modifier_axis_range; } diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index a07491b6..0d9379db 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -909,7 +909,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { { "square", "Square" }, { NULL, NULL }, }, - "circle", + "square", }, { "pcsx_rearmed_vibration",