summaryrefslogtreecommitdiff
path: root/plugins
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
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')
-rw-r--r--plugins/dfinput/pad.c70
-rw-r--r--plugins/dfinput/pad.h2
-rw-r--r--plugins/dfxvideo/draw.c217
-rw-r--r--plugins/dfxvideo/gpu.c4
4 files changed, 176 insertions, 117 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 {
diff --git a/plugins/dfxvideo/draw.c b/plugins/dfxvideo/draw.c
index db90cdf7..53451ad7 100644
--- a/plugins/dfxvideo/draw.c
+++ b/plugins/dfxvideo/draw.c
@@ -1613,15 +1613,16 @@ void DoBufferSwap(void)
if (iMaintainAspect)
MaintainAspect(&dstx, &dsty, &_w, &_h);
+/*Whistler: too slow/laggy so commented out for now
if(iRumbleTime)
{
- dstx+=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2);
- _w-=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal);
- dsty+=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2);
- _h-=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2);
+ dstx += (rand() % iRumbleVal) - iRumbleVal / 2;
+ _w -= (rand() % iRumbleVal) - iRumbleVal / 2;
+ dsty += (rand() % iRumbleVal) - iRumbleVal / 2;
+ _h -= (rand() % iRumbleVal) - iRumbleVal / 2;
iRumbleTime--;
}
-
+*/
XvShmPutImage(display, xv_port, window, hGC, xvi,
0,0, //src x,y
finalw,finalh, //src w,h
@@ -1902,54 +1903,54 @@ static void hq2x_32_def(uint32_t * dst0, uint32_t * dst1, const uint32_t * src0,
mask |= cache_vert_mask[i] << 5; // << 1 << 5 == << 6
mask |= interp_32_diff(c[8], c[4]) << 7;
-#define P0 dst0[0]
-#define P1 dst0[1]
-#define P2 dst1[0]
-#define P3 dst1[1]
-#define MUR interp_32_diff(c[1], c[5])
-#define MDR interp_32_diff(c[5], c[7])
-#define MDL interp_32_diff(c[7], c[3])
-#define MUL interp_32_diff(c[3], c[1])
-#define IC(p0) c[p0]
-#define I11(p0,p1) interp_32_11(c[p0], c[p1])
-#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
-#define I31(p0,p1) interp_32_31(c[p0], c[p1])
-#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
-#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
-#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
-#define I53(p0,p1) interp_32_53(c[p0], c[p1])
-#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
-#define I71(p0,p1) interp_32_71(c[p0], c[p1])
-#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
-#define I97(p0,p1) interp_32_97(c[p0], c[p1])
-#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
-#define I151(p0,p1) interp_32_151(c[p0], c[p1])
-
+#define P0 dst0[0]
+#define P1 dst0[1]
+#define P2 dst1[0]
+#define P3 dst1[1]
+#define MUR interp_32_diff(c[1], c[5])
+#define MDR interp_32_diff(c[5], c[7])
+#define MDL interp_32_diff(c[7], c[3])
+#define MUL interp_32_diff(c[3], c[1])
+#define IC(p0) c[p0]
+#define I11(p0,p1) interp_32_11(c[p0], c[p1])
+#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
+#define I31(p0,p1) interp_32_31(c[p0], c[p1])
+#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
+#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
+#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
+#define I53(p0,p1) interp_32_53(c[p0], c[p1])
+#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
+#define I71(p0,p1) interp_32_71(c[p0], c[p1])
+#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
+#define I97(p0,p1) interp_32_97(c[p0], c[p1])
+#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
+#define I151(p0,p1) interp_32_151(c[p0], c[p1])
+
switch (mask) {
#include "hq2x.h"
- }
-
-#undef P0
-#undef P1
-#undef P2
-#undef P3
-#undef MUR
-#undef MDR
-#undef MDL
-#undef MUL
-#undef IC
-#undef I11
-#undef I211
-#undef I31
-#undef I332
-#undef I431
-#undef I521
-#undef I53
-#undef I611
-#undef I71
-#undef I772
-#undef I97
-#undef I1411
+ }
+
+#undef P0
+#undef P1
+#undef P2
+#undef P3
+#undef MUR
+#undef MDR
+#undef MDL
+#undef MUL
+#undef IC
+#undef I11
+#undef I211
+#undef I31
+#undef I332
+#undef I431
+#undef I521
+#undef I53
+#undef I611
+#undef I71
+#undef I772
+#undef I97
+#undef I1411
#undef I151
src0 += 1;
@@ -2042,66 +2043,66 @@ static void hq3x_32_def(uint32_t* dst0, uint32_t* dst1, uint32_t* dst2, const
cache_vert_mask[i] = interp_32_diff(c[7], c[4]) << 1;
mask |= cache_vert_mask[i] << 5; // << 1 << 5 == << 6
mask |= interp_32_diff(c[8], c[4]) << 7;
-
-#define P0 dst0[0]
-#define P1 dst0[1]
-#define P2 dst0[2]
-#define P3 dst1[0]
-#define P4 dst1[1]
-#define P5 dst1[2]
-#define P6 dst2[0]
-#define P7 dst2[1]
-#define P8 dst2[2]
-#define MUR interp_32_diff(c[1], c[5])
-#define MDR interp_32_diff(c[5], c[7])
-#define MDL interp_32_diff(c[7], c[3])
-#define MUL interp_32_diff(c[3], c[1])
-#define IC(p0) c[p0]
-#define I11(p0,p1) interp_32_11(c[p0], c[p1])
-#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
-#define I31(p0,p1) interp_32_31(c[p0], c[p1])
-#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
-#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
-#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
-#define I53(p0,p1) interp_32_53(c[p0], c[p1])
-#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
-#define I71(p0,p1) interp_32_71(c[p0], c[p1])
-#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
-#define I97(p0,p1) interp_32_97(c[p0], c[p1])
-#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
-#define I151(p0,p1) interp_32_151(c[p0], c[p1])
+
+#define P0 dst0[0]
+#define P1 dst0[1]
+#define P2 dst0[2]
+#define P3 dst1[0]
+#define P4 dst1[1]
+#define P5 dst1[2]
+#define P6 dst2[0]
+#define P7 dst2[1]
+#define P8 dst2[2]
+#define MUR interp_32_diff(c[1], c[5])
+#define MDR interp_32_diff(c[5], c[7])
+#define MDL interp_32_diff(c[7], c[3])
+#define MUL interp_32_diff(c[3], c[1])
+#define IC(p0) c[p0]
+#define I11(p0,p1) interp_32_11(c[p0], c[p1])
+#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
+#define I31(p0,p1) interp_32_31(c[p0], c[p1])
+#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
+#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
+#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
+#define I53(p0,p1) interp_32_53(c[p0], c[p1])
+#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
+#define I71(p0,p1) interp_32_71(c[p0], c[p1])
+#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
+#define I97(p0,p1) interp_32_97(c[p0], c[p1])
+#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
+#define I151(p0,p1) interp_32_151(c[p0], c[p1])
switch (mask) {
#include "hq3x.h"
- }
-
-#undef P0
-#undef P1
-#undef P2
-#undef P3
-#undef P4
-#undef P5
-#undef P6
-#undef P7
-#undef P8
-#undef MUR
-#undef MDR
-#undef MDL
-#undef MUL
-#undef IC
-#undef I11
-#undef I211
-#undef I31
-#undef I332
-#undef I431
-#undef I521
-#undef I53
-#undef I611
-#undef I71
-#undef I772
-#undef I97
-#undef I1411
-#undef I151
+ }
+
+#undef P0
+#undef P1
+#undef P2
+#undef P3
+#undef P4
+#undef P5
+#undef P6
+#undef P7
+#undef P8
+#undef MUR
+#undef MDR
+#undef MDL
+#undef MUL
+#undef IC
+#undef I11
+#undef I211
+#undef I31
+#undef I332
+#undef I431
+#undef I521
+#undef I53
+#undef I611
+#undef I71
+#undef I772
+#undef I97
+#undef I1411
+#undef I151
src0 += 1;
src1 += 1;
diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c
index e5b911f9..4aa6f230 100644
--- a/plugins/dfxvideo/gpu.c
+++ b/plugins/dfxvideo/gpu.c
@@ -2280,7 +2280,7 @@ void CALLBACK GPUvBlank( int val )
vBlank = val;
}
-void CALLBACK GPUvisualVibration(unsigned long iSmall, unsigned long iBig)
+void CALLBACK GPUvisualVibration(uint32_t iSmall, uint32_t iBig)
{
int iVibVal;
@@ -2291,7 +2291,5 @@ void CALLBACK GPUvisualVibration(unsigned long iSmall, unsigned long iBig)
if(iBig) iRumbleVal=max(4*iVibVal,min(15*iVibVal,((int)iBig *iVibVal)/10));
else iRumbleVal=max(1*iVibVal,min( 3*iVibVal,((int)iSmall*iVibVal)/10));
- srand(timeGetTime()); // init rand (will be used in BufferSwap)
-
iRumbleTime=15; // let the rumble last 16 buffer swaps
}