(PS3) Build fix + implement rumble function callback in ps3 joypad driver

This commit is contained in:
twinaphex 2014-10-05 18:29:22 +02:00
parent 06f84b6f25
commit 6862c70328
2 changed files with 31 additions and 20 deletions

View File

@ -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, &params);
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)

View File

@ -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, &params);
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",
};