From 6862c70328e7aac7057ca3aa265ca63122fb257e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 5 Oct 2014 18:29:22 +0200 Subject: [PATCH] (PS3) Build fix + implement rumble function callback in ps3 joypad driver --- input/ps3_input.c | 23 +++++------------------ input/ps3_input_joypad.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/input/ps3_input.c b/input/ps3_input.c index c6c3cc8724..6d9b4d9b03 100644 --- a/input/ps3_input.c +++ b/input/ps3_input.c @@ -220,25 +220,12 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port, static bool ps3_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { - CellPadActParam params; + ps3_input_t *ps3 = (ps3_input_t*)data; - switch (effect) - { - case RETRO_RUMBLE_WEAK: - if (strength > 1) - strength = 1; - params.motor[0] = strength; - break; - case RETRO_RUMBLE_STRONG: - if (strength > 255) - strength = 255; - params.motor[1] = strength; - break; - } - - cellPadSetActDirect(port, ¶ms); - - return true; + if (ps3 && ps3->joypad) + return input_joypad_set_rumble(ps3->joypad, + port, effect, strength); + return false; } static const rarch_joypad_driver_t *ps3_input_get_joypad_driver(void *data) diff --git a/input/ps3_input_joypad.c b/input/ps3_input_joypad.c index 426d7fd3f1..c45f5726a6 100644 --- a/input/ps3_input_joypad.c +++ b/input/ps3_input_joypad.c @@ -64,7 +64,7 @@ static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) { - int val = 0. axis = -1; + int val = 0, axis = -1; bool is_neg = false, is_pos = false; if (joyaxis == AXIS_NONE || port_num >= MAX_PADS) @@ -210,12 +210,36 @@ static bool ps3_joypad_query_pad(unsigned pad) return pad < MAX_PLAYERS && pad_state[pad]; } +static bool ps3_joypad_rumble(unsigned pad, + enum retro_rumble_effect effect, uint16_t strength) +{ + CellPadActParam params; + + switch (effect) + { + case RETRO_RUMBLE_WEAK: + if (strength > 1) + strength = 1; + params.motor[0] = strength; + break; + case RETRO_RUMBLE_STRONG: + if (strength > 255) + strength = 255; + params.motor[1] = strength; + break; + } + + cellPadSetActDirect(pad, ¶ms); + + return true; +} static void ps3_joypad_destroy(void) { cellPadEnd(); } + rarch_joypad_driver_t ps3_joypad = { ps3_joypad_init, ps3_joypad_query_pad, @@ -223,7 +247,7 @@ rarch_joypad_driver_t ps3_joypad = { ps3_joypad_button, ps3_joypad_axis, ps3_joypad_poll, - NULL, + ps3_joypad_rumble, ps3_joypad_name, "ps3", };