summaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'input.c')
-rw-r--r--input.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/input.c b/input.c
index 44455d2..9aef248 100644
--- a/input.c
+++ b/input.c
@@ -24,6 +24,11 @@ bool libretro_supports_ff_override = false;
bool libretro_ff_enabled = false;
bool libretro_ff_enabled_prev = false;
+unsigned turbo_period = TURBO_PERIOD_MIN;
+unsigned turbo_pulse_width = TURBO_PULSE_WIDTH_MIN;
+unsigned turbo_a_counter = 0;
+unsigned turbo_b_counter = 0;
+
static u32 old_key = 0;
static retro_input_state_t input_state_cb;
@@ -56,6 +61,8 @@ u32 update_input(void)
{
unsigned i;
uint32_t new_key = 0;
+ bool turbo_a = false;
+ bool turbo_b = false;
if (!input_state_cb)
return 0;
@@ -69,6 +76,9 @@ u32 update_input(void)
libretro_ff_enabled = libretro_supports_ff_override &&
(ret & (1 << RETRO_DEVICE_ID_JOYPAD_R2));
+
+ turbo_a = (ret & (1 << RETRO_DEVICE_ID_JOYPAD_X));
+ turbo_b = (ret & (1 << RETRO_DEVICE_ID_JOYPAD_Y));
}
else
{
@@ -77,7 +87,35 @@ u32 update_input(void)
libretro_ff_enabled = libretro_supports_ff_override &&
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2);
+
+ turbo_a = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X);
+ turbo_b = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y);
+ }
+
+ /* Handle turbo buttons */
+ if (turbo_a)
+ {
+ new_key |= (turbo_a_counter < turbo_pulse_width) ?
+ BUTTON_A : 0;
+
+ turbo_a_counter++;
+ if (turbo_a_counter >= turbo_period)
+ turbo_a_counter = 0;
}
+ else
+ turbo_a_counter = 0;
+
+ if (turbo_b)
+ {
+ new_key |= (turbo_b_counter < turbo_pulse_width) ?
+ BUTTON_B : 0;
+
+ turbo_b_counter++;
+ if (turbo_b_counter >= turbo_period)
+ turbo_b_counter = 0;
+ }
+ else
+ turbo_b_counter = 0;
if ((new_key | old_key) != old_key)
trigger_key(new_key);