From: notaz Date: Sat, 20 Dec 2014 18:26:22 +0000 (+0200) Subject: fix up other platforms after rumble change X-Git-Tag: r20~20 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d71c709541218f67ab32229b03307b045a8ed6cb;p=pcsx_rearmed.git fix up other platforms after rumble change --- diff --git a/frontend/libretro.c b/frontend/libretro.c index 47f07a63..74b5dbff 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -197,7 +197,7 @@ void pl_timing_prepare(int is_pal) is_pal_mode = is_pal; } -void plat_trigger_vibrate(int pad, uint32_t low, uint32_t high) +void plat_trigger_vibrate(int pad, int low, int high) { rumble.set_rumble_state(pad, RETRO_RUMBLE_STRONG, high << 8); rumble.set_rumble_state(pad, RETRO_RUMBLE_WEAK, low ? 0xffff : 0x0); diff --git a/frontend/plat_dummy.c b/frontend/plat_dummy.c index baed0d5c..b490cff6 100644 --- a/frontend/plat_dummy.c +++ b/frontend/plat_dummy.c @@ -54,7 +54,7 @@ void *plat_prepare_screenshot(int *w, int *h, int *bpp) return 0; } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { } diff --git a/frontend/plat_pandora.c b/frontend/plat_pandora.c index 3202c1d6..41dc2feb 100644 --- a/frontend/plat_pandora.c +++ b/frontend/plat_pandora.c @@ -106,6 +106,6 @@ void plat_gvideo_open(int is_pal) plat_omap_gvideo_open(); } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { } diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c index cb7afef7..33e94178 100644 --- a/frontend/plat_pollux.c +++ b/frontend/plat_pollux.c @@ -704,10 +704,15 @@ static int haptic_init(void) return 0; } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { + int is_strong; int ret; + if (low == 0 && high == 0) + return; + is_strong = (high >= 0xf0); + if (hapticdev == -2) return; // it's broken if (hapticdev < 0) { diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 4e77dc35..5e11cf84 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -336,7 +336,7 @@ void *plat_prepare_screenshot(int *w, int *h, int *bpp) return 0; } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { } diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 0805f4ae..99866540 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -205,11 +205,10 @@ typedef struct // values are in range -128 - 127 unsigned char moveX, moveY; - uint8_t Vib[2]; + unsigned char Vib[2]; + unsigned char VibF[2]; - volatile uint8_t VibF[2]; - - unsigned char reserved[87]; + unsigned char reserved[87]; } PadDataS; diff --git a/maemo/hildon.c b/maemo/hildon.c index bd895c96..7e9cd9fe 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -805,7 +805,7 @@ void plat_step_volume(int is_up) { } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { const int vDuration = 10; @@ -817,7 +817,8 @@ void plat_trigger_vibrate(int is_strong) "req_start_manual_vibration"); if (msg) { dbus_message_iter_init_append(msg, &args); - int speed = is_strong ? 200 : 150; + // FIXME: somebody with hardware should tune this + int speed = high; // is_strong ? 200 : 150; int duration = vDuration; if (dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &speed)) { if (dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &duration)) { diff --git a/plugins/dfinput/externals.h b/plugins/dfinput/externals.h index 042d9dcf..a446956e 100644 --- a/plugins/dfinput/externals.h +++ b/plugins/dfinput/externals.h @@ -11,4 +11,4 @@ extern void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in); /* vibration trigger to frontend */ extern int in_enable_vibration; -extern void plat_trigger_vibrate(int pad, uint32_t low, uint32_t high); +extern void plat_trigger_vibrate(int pad, int low, int high); diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index 348bb8f3..7e00a113 100644 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -206,21 +206,24 @@ static void do_cmd2(unsigned char value) } } -static void do_cmd3(unsigned char value) +static void do_vibration(unsigned char value) { + int changed = 0; int i; + switch (CurCmd) { case CMD_READ_DATA_AND_VIBRATE: - if (!in_enable_vibration) - break; - if (padstate[CurPad].pad.controllerType != PSE_PAD_TYPE_ANALOGPAD) - break; - for (i = 0; i < 2; i++) { - if (padstate[CurPad].pad.Vib[i] == CurByte) + if (padstate[CurPad].pad.Vib[i] == CurByte + && padstate[CurPad].pad.VibF[i] != value) { padstate[CurPad].pad.VibF[i] = value; + changed = 1; + } } + if (!in_enable_vibration || !changed) + break; + plat_trigger_vibrate(CurPad, padstate[CurPad].pad.VibF[0], padstate[CurPad].pad.VibF[1]); @@ -252,7 +255,7 @@ unsigned char PADpoll(unsigned char value) { #endif unsigned char PADpoll_pad(unsigned char value) { - if (CurByte == 0) { + if (CurByte == 0) { CurCmd = value; CurByte++; @@ -261,15 +264,16 @@ unsigned char PADpoll_pad(unsigned char value) { CurCmd = CMD_READ_DATA_AND_VIBRATE; return do_cmd(); - } + } - if (CurByte >= CmdLen) - return 0xff; // verified + if (CurByte >= CmdLen) + return 0xff; // verified - if (CurByte == 2) + if (CurByte == 2) do_cmd2(value); - do_cmd3(value); + if (padstate[CurPad].pad.controllerType == PSE_PAD_TYPE_ANALOGPAD) + do_vibration(value); return buf[CurByte++]; }