+static void do_vibration(unsigned char value)
+{
+ int changed = 0;
+ int i;
+
+ switch (CurCmd) {
+ case CMD_READ_DATA_AND_VIBRATE:
+ for (i = 0; i < 2; i++) {
+ 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]);
+ 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
+#include <stdio.h>
+unsigned char PADpoll_(unsigned char value);
+unsigned char PADpoll(unsigned char value) {
+ unsigned char b = CurByte, r = PADpoll_(value);
+ printf("poll[%d] %02x %02x\n", b, value, r);
+ return r;
+}
+#define PADpoll PADpoll_
+#endif