X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfinput%2Fpad.c;h=7e00a1131fcdb28928883efd63da5c5c221610f2;hp=ab55db0f2ee289f53b1cd34f1dde35776a99dd95;hb=3bd31caf9e9f5ddab2bf4fbdb5a129f4972c45f3;hpb=b944a30eda75c36c94ef71e7768497801887612b diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index ab55db0f..7e00a113 100644 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -21,7 +21,7 @@ #include -#include "../../libpcsxcore/psemu_plugin_defs.h" +#include "psemu_plugin_defs.h" #include "main.h" enum { @@ -203,14 +203,46 @@ 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(); - break; } } +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 unsigned char PADpoll_(unsigned char value); @@ -223,7 +255,6 @@ unsigned char PADpoll(unsigned char value) { #endif unsigned char PADpoll_pad(unsigned char value) { - if (CurByte == 0) { CurCmd = value; CurByte++; @@ -235,11 +266,14 @@ unsigned char PADpoll_pad(unsigned char value) { return do_cmd(); } + if (CurByte >= CmdLen) + return 0xff; // verified + if (CurByte == 2) do_cmd2(value); - if (CurByte >= CmdLen) - return 0xff; // verified + if (padstate[CurPad].pad.controllerType == PSE_PAD_TYPE_ANALOGPAD) + do_vibration(value); return buf[CurByte++]; }