summaryrefslogtreecommitdiff
path: root/plugins/dfinput
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-01-10 02:01:40 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-01-10 02:01:40 +0000
commite6f7bdccab5c872fb80ca039a702761e45e74f40 (patch)
tree0203e5496917e83f8eb8dde7c57d6473720d7ca9 /plugins/dfinput
parentd53f6a1bc93fc8c91552717b762142ac564ed40d (diff)
downloadpcsxr-e6f7bdccab5c872fb80ca039a702761e45e74f40.tar.gz
- dfinput: visual vibration.
- padssspsx: imported. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@61950 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput')
-rw-r--r--plugins/dfinput/pad.c70
-rw-r--r--plugins/dfinput/pad.h2
2 files changed, 66 insertions, 6 deletions
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
index a0207aab..423e2db0 100644
--- a/plugins/dfinput/pad.c
+++ b/plugins/dfinput/pad.c
@@ -18,6 +18,8 @@
#include "pad.h"
+static void (*gpuVisualVibration)(uint32_t, uint32_t) = NULL;
+
char *PSEgetLibName(void) {
return _("Gamepad/Keyboard Input");
}
@@ -30,13 +32,23 @@ uint32_t PSEgetLibVersion(void) {
return (1 << 16) | (1 << 8);
}
+void PADsetMode(const int pad, const int mode) {
+ g.PadState[pad].PadMode = mode;
+ g.PadState[pad].PadID = mode ? 0x73 : 0x41;
+
+ g.PadState[pad].Vib0 = 0;
+ g.PadState[pad].Vib1 = 0;
+ g.PadState[pad].VibF[0] = 0;
+ g.PadState[pad].VibF[1] = 0;
+}
+
long PADinit(long flags) {
LoadPADConfig();
- g.PadState[0].PadMode = 0;
- g.PadState[0].PadID = 0x41;
- g.PadState[1].PadMode = 0;
- g.PadState[1].PadID = 0x41;
+ PADsetMode(0, 0);
+ PADsetMode(1, 0);
+
+ gpuVisualVibration = NULL;
return PSE_PAD_ERR_SUCCESS;
}
@@ -263,6 +275,26 @@ unsigned char PADpoll(unsigned char value) {
}
switch (CurCmd) {
+ case CMD_READ_DATA_AND_VIBRATE:
+ if (g.cfg.PadDef[CurPad].Type == PSE_PAD_TYPE_ANALOGPAD) {
+ if (CurByte == g.PadState[CurPad].Vib0) {
+ g.PadState[CurPad].VibF[0] = value;
+
+ if (gpuVisualVibration != NULL && (g.PadState[CurPad].VibF[0] != 0 || g.PadState[CurPad].VibF[1] != 0)) {
+ gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]);
+ }
+ }
+
+ if (CurByte == g.PadState[CurPad].Vib1) {
+ g.PadState[CurPad].VibF[1] = value;
+
+ if (gpuVisualVibration != NULL && (g.PadState[CurPad].VibF[0] != 0 || g.PadState[CurPad].VibF[1] != 0)) {
+ gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]);
+ }
+ }
+ }
+ break;
+
case CMD_CONFIG_MODE:
if (CurByte == 2) {
switch (value) {
@@ -281,8 +313,7 @@ unsigned char PADpoll(unsigned char value) {
case CMD_SET_MODE_AND_LOCK:
if (CurByte == 2) {
- g.PadState[CurPad].PadMode = value;
- g.PadState[CurPad].PadID = value ? 0x73 : 0x41;
+ PADsetMode(CurPad, value);
}
break;
@@ -317,6 +348,29 @@ unsigned char PADpoll(unsigned char value) {
}
}
break;
+
+ case CMD_VIBRATION_TOGGLE:
+ if (CurByte >= 2 && CurByte < CmdLen) {
+ if (CurByte == g.PadState[CurPad].Vib0) {
+ buf[CurByte] = 0;
+ }
+ if (CurByte == g.PadState[CurPad].Vib1) {
+ buf[CurByte] = 1;
+ }
+
+ if (value == 0) {
+ g.PadState[CurPad].Vib0 = CurByte;
+ if ((g.PadState[CurPad].PadID & 0x0f) < (CurByte - 1) / 2) {
+ g.PadState[CurPad].PadID = (g.PadState[CurPad].PadID & 0xf0) + (CurByte - 1) / 2;
+ }
+ } else if (value == 1) {
+ g.PadState[CurPad].Vib1 = CurByte;
+ if ((g.PadState[CurPad].PadID & 0x0f) < (CurByte - 1) / 2) {
+ g.PadState[CurPad].PadID = (g.PadState[CurPad].PadID & 0xf0) + (CurByte - 1) / 2;
+ }
+ }
+ }
+ break;
}
if (CurByte >= CmdLen) return 0;
@@ -368,6 +422,10 @@ long PADkeypressed(void) {
return s;
}
+void PADregisterVibration(void (*callback)(uint32_t, uint32_t)) {
+ gpuVisualVibration = callback;
+}
+
#ifndef _MACOSX
long PADconfigure(void) {
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
index 8347caf8..0362fdcb 100644
--- a/plugins/dfinput/pad.h
+++ b/plugins/dfinput/pad.h
@@ -123,6 +123,8 @@ typedef struct tagPadState {
volatile uint16_t JoyKeyStatus;
volatile uint8_t AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position
volatile uint8_t AnalogKeyStatus[ANALOG_TOTAL][4];
+ uint8_t Vib0, Vib1;
+ volatile uint8_t VibF[2];
} PADSTATE;
typedef struct tagGlobalData {