aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfinput/pad.c
diff options
context:
space:
mode:
authorksv19862014-11-29 17:15:37 +0300
committerksv19862014-11-29 17:28:57 +0300
commit8d24cb85c2a67040aff70716f317fd6d37777dd5 (patch)
tree11f25b84f46982367069df1f691e1171ba5f4de9 /plugins/dfinput/pad.c
parentde2a99184b5e478a39a2cb82872d8d5c4af0f3f6 (diff)
downloadpcsx_rearmed-8d24cb85c2a67040aff70716f317fd6d37777dd5.tar.gz
pcsx_rearmed-8d24cb85c2a67040aff70716f317fd6d37777dd5.tar.bz2
pcsx_rearmed-8d24cb85c2a67040aff70716f317fd6d37777dd5.zip
libretro: Add rumble support
Diffstat (limited to 'plugins/dfinput/pad.c')
-rw-r--r--plugins/dfinput/pad.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
index 53a254a..348bb8f 100644
--- a/plugins/dfinput/pad.c
+++ b/plugins/dfinput/pad.c
@@ -203,22 +203,41 @@ static void do_cmd2(unsigned char value)
break;
}
break;
-
- case CMD_READ_DATA_AND_VIBRATE:
- if (value == 1 && CurPad == 0 && in_enable_vibration)
- plat_trigger_vibrate(0);
- break;
}
}
static void do_cmd3(unsigned char value)
{
- if (in_enable_vibration && CurCmd == CMD_READ_DATA_AND_VIBRATE && CurPad == 0) {
- if (value >= 0xf0)
- plat_trigger_vibrate(1);
- else if (value > 0x40)
- plat_trigger_vibrate(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)
+ padstate[CurPad].pad.VibF[i] = value;
+ }
+
+ plat_trigger_vibrate(CurPad,
+ padstate[CurPad].pad.VibF[0],
+ padstate[CurPad].pad.VibF[1]);
+ break;
+ case CMD_VIBRATION_TOGGLE:
+ for (i = 0; i < 2; i++) {
+ if (padstate[CurPad].pad.Vib[i] == CurByte)
+ buf[CurByte] = 0;
+ }
+ if (value < 2) {
+ padstate[CurPad].pad.Vib[value] = CurByte;
+ if((padstate[CurPad].PadID & 0x0f) < (CurByte - 1) / 2) {
+ padstate[CurPad].PadID = (padstate[CurPad].PadID & 0xf0) + (CurByte - 1) / 2;
+ }
+ }
+ break;
+ }
}
#if 0
@@ -233,9 +252,7 @@ unsigned char PADpoll(unsigned char value) {
#endif
unsigned char PADpoll_pad(unsigned char value) {
-
- switch (CurByte) {
- case 0:
+ if (CurByte == 0) {
CurCmd = value;
CurByte++;
@@ -244,16 +261,15 @@ unsigned char PADpoll_pad(unsigned char value) {
CurCmd = CMD_READ_DATA_AND_VIBRATE;
return do_cmd();
- case 2:
+ }
+
+ if (CurByte >= CmdLen)
+ return 0xff; // verified
+
+ if (CurByte == 2)
do_cmd2(value);
- break;
- case 3:
- do_cmd3(value);
- break;
- }
- if (CurByte >= CmdLen)
- return 0xff; // verified
+ do_cmd3(value);
return buf[CurByte++];
}