X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfinput%2Fpad.c;h=3e333660c8b72ad987e343f4cb4051e5cf1ce25b;hb=1351a8fbef932e26a56e841b6c43de6d907fde5c;hp=348bb8f346a39f9f2b3ba94a27fab86662da92cd;hpb=4e47706596441172d1cc3f203b8baa398cea3023;p=pcsx_rearmed.git diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index 348bb8f3..3e333660 100644 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -42,6 +42,7 @@ enum { CMD_VIBRATION_TOGGLE = 0x4D, }; +#ifndef HAVE_LIBRETRO static struct { uint8_t PadMode; uint8_t PadID; @@ -206,21 +207,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]); @@ -239,6 +243,7 @@ static void do_cmd3(unsigned char value) break; } } +#endif #if 0 #include @@ -251,8 +256,9 @@ unsigned char PADpoll(unsigned char value) { #define PADpoll PADpoll_ #endif +#ifndef HAVE_LIBRETRO unsigned char PADpoll_pad(unsigned char value) { - if (CurByte == 0) { + if (CurByte == 0) { CurCmd = value; CurByte++; @@ -261,15 +267,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++]; } @@ -298,3 +305,4 @@ void pad_init(void) padstate[i].PadMode = padstate[i].pad.controllerType == PSE_PAD_TYPE_ANALOGPAD; } } +#endif