(VITA) Add vibration for PSTV

This commit is contained in:
Francisco José García García 2016-08-30 14:29:19 +02:00
parent 7f0624ff32
commit e3b5fdd815
2 changed files with 32 additions and 5 deletions

View File

@ -140,11 +140,11 @@ static void psp_input_grab_mouse(void *data, bool state)
static bool psp_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
psp_input_t *psp = (psp_input_t*)data;
if (psp && psp->joypad)
return input_joypad_set_rumble(psp->joypad,
port, effect, strength);
return false;
}

View File

@ -197,6 +197,33 @@ static bool psp_joypad_query_pad(unsigned pad)
return pad < PSP_MAX_PADS && pad_state[pad];
}
static bool psp_joypad_rumble(unsigned pad,
enum retro_rumble_effect effect, uint16_t strength)
{
struct SceCtrlActuator params = {
0,
0
};
switch (effect)
{
case RETRO_RUMBLE_WEAK:
if (strength > 1)
strength = 1;
params.unk = strength;
break;
case RETRO_RUMBLE_STRONG:
if (strength > 255)
strength = 255;
params.enable = strength;
break;
}
unsigned p = (pad == 1) ? 2 : pad;
sceCtrlSetActuator(p, &params);
return true;
}
static void psp_joypad_destroy(void)
{
@ -210,7 +237,7 @@ input_device_driver_t psp_joypad = {
psp_joypad_get_buttons,
psp_joypad_axis,
psp_joypad_poll,
NULL,
psp_joypad_rumble,
psp_joypad_name,
#ifdef VITA
"vita",