aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfinput
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dfinput')
-rw-r--r--plugins/dfinput/externals.h2
-rw-r--r--plugins/dfinput/pad.c30
2 files changed, 18 insertions, 14 deletions
diff --git a/plugins/dfinput/externals.h b/plugins/dfinput/externals.h
index 042d9dc..a446956 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 348bb8f..7e00a11 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++];
}