aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfinput
diff options
context:
space:
mode:
authorksv19862014-11-29 17:15:37 +0300
committernotaz2014-12-20 20:44:08 +0200
commit4e47706596441172d1cc3f203b8baa398cea3023 (patch)
tree179547ab9f3d75ea856ce19a05e7a0063b396331 /plugins/dfinput
parentce0e7ac9c11993f9165615dec870c50e1c3b39bf (diff)
downloadpcsx_rearmed-4e47706596441172d1cc3f203b8baa398cea3023.tar.gz
pcsx_rearmed-4e47706596441172d1cc3f203b8baa398cea3023.tar.bz2
pcsx_rearmed-4e47706596441172d1cc3f203b8baa398cea3023.zip
libretro: Add rumble support
Conflicts: frontend/libretro.c
Diffstat (limited to 'plugins/dfinput')
-rw-r--r--plugins/dfinput/externals.h2
-rw-r--r--plugins/dfinput/pad.c60
2 files changed, 39 insertions, 23 deletions
diff --git a/plugins/dfinput/externals.h b/plugins/dfinput/externals.h
index 5419977..042d9dc 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 is_strong);
+extern void plat_trigger_vibrate(int pad, uint32_t low, uint32_t high);
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++];
}