summaryrefslogtreecommitdiff
path: root/plugins/dfinput
diff options
context:
space:
mode:
authorSND\dario86_cp <SND\dario86_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-03-10 13:25:33 +0000
committerSND\dario86_cp <SND\dario86_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-03-10 13:25:33 +0000
commit8ee251f1379ffab7d0fd914429e834ae672afc57 (patch)
tree0c1777bce792bc9e38931ab7c5aa2cd787c34f5a /plugins/dfinput
parent1b70fa81feaca1d699357e99a5718df50f400b65 (diff)
downloadpcsxr-8ee251f1379ffab7d0fd914429e834ae672afc57.tar.gz
Fixed issue #8061 (by darktjm).
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@64383 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput')
-rw-r--r--plugins/dfinput/cfg-gtk2.c8
-rw-r--r--plugins/dfinput/cfg.c8
-rw-r--r--plugins/dfinput/pad.c7
-rw-r--r--plugins/dfinput/pad.h3
-rw-r--r--plugins/dfinput/xkb.c18
5 files changed, 39 insertions, 5 deletions
diff --git a/plugins/dfinput/cfg-gtk2.c b/plugins/dfinput/cfg-gtk2.c
index fba94719..ddfa3554 100644
--- a/plugins/dfinput/cfg-gtk2.c
+++ b/plugins/dfinput/cfg-gtk2.c
@@ -41,7 +41,8 @@ const int DPad[DKEY_TOTAL] = {
DKEY_SELECT,
DKEY_START,
DKEY_L3,
- DKEY_R3
+ DKEY_R3,
+ DKEY_ANALOG
};
const char *DPadText[DKEY_TOTAL] = {
@@ -60,7 +61,8 @@ const char *DPadText[DKEY_TOTAL] = {
N_("Select"),
N_("Start"),
N_("L3"),
- N_("R3")
+ N_("R3"),
+ N_("Analog")
};
const char *AnalogText[] = {
@@ -189,7 +191,7 @@ static void UpdateKeyList() {
if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
total = DKEY_TOTAL;
} else {
- total = DKEY_TOTAL - 2;
+ total = DKEY_TOTAL - 3;
}
widget = gtk_builder_get_object(xml, widgetname[i]);
diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c
index ce9a97f2..64c60a2d 100644
--- a/plugins/dfinput/cfg.c
+++ b/plugins/dfinput/cfg.c
@@ -48,6 +48,7 @@ static void SetDefaultConfig() {
g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].Key = XK_x;
g.cfg.PadDef[0].KeyDef[DKEY_CROSS].Key = XK_z;
g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].Key = XK_s;
+ g.cfg.PadDef[0].KeyDef[DKEY_ANALOG].Key = XK_b;
// Pad1 joystick
g.cfg.PadDef[0].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
@@ -153,6 +154,11 @@ void LoadPADConfig() {
g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a;
g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b;
g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c;
+ } else if (strncmp(buf, "Analog=", 7) == 0) {
+ sscanf(buf, "Analog=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].J.d = c;
} else if (strncmp(buf, "Start=", 6) == 0) {
sscanf(buf, "Start=%d,%d,%d", &a, &b, &c);
g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a;
@@ -288,6 +294,8 @@ void SavePADConfig() {
g.cfg.PadDef[i].KeyDef[DKEY_L3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L3].J.d);
fprintf(fp, "R3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R3].Key,
g.cfg.PadDef[i].KeyDef[DKEY_R3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R3].J.d);
+ fprintf(fp, "Analog=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_ANALOG].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_ANALOG].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_ANALOG].J.d);
fprintf(fp, "Start=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_START].Key,
g.cfg.PadDef[i].KeyDef[DKEY_START].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_START].J.d);
fprintf(fp, "Up=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_UP].Key,
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
index 423e2db0..e3029340 100644
--- a/plugins/dfinput/pad.c
+++ b/plugins/dfinput/pad.c
@@ -129,7 +129,14 @@ long PADquery(void) {
}
static void UpdateInput(void) {
+ int pad;
if (!g.cfg.Threaded) CheckJoy();
+ for(pad = 0; pad < 2; pad++) {
+ if(g.PadState[pad].PadModeSwitch) {
+ g.PadState[pad].PadModeSwitch = 0;
+ PADsetMode(pad, 1 - g.PadState[pad].PadMode);
+ }
+ }
CheckKeyboard();
}
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
index 0362fdcb..0fbabbcd 100644
--- a/plugins/dfinput/pad.h
+++ b/plugins/dfinput/pad.h
@@ -77,6 +77,7 @@ enum {
DKEY_CIRCLE,
DKEY_CROSS,
DKEY_SQUARE,
+ DKEY_ANALOG,
DKEY_TOTAL
};
@@ -119,6 +120,8 @@ typedef struct tagPadState {
SDL_Joystick *JoyDev;
uint8_t PadMode;
uint8_t PadID;
+ uint8_t PadModeKey;
+ volatile uint8_t PadModeSwitch;
volatile uint16_t KeyStatus;
volatile uint16_t JoyKeyStatus;
volatile uint8_t AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position
diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c
index bfadef10..687b150a 100644
--- a/plugins/dfinput/xkb.c
+++ b/plugins/dfinput/xkb.c
@@ -34,6 +34,20 @@ void DestroyKeyboard() {
XkbSetDetectableAutoRepeat(g.Disp, 0, NULL);
}
+static void bdown(int pad, int bit)
+{
+ if(bit < 16)
+ g.PadState[pad].KeyStatus &= ~(1 << bit);
+ else if(bit == DKEY_ANALOG)
+ g.PadState[pad].PadModeSwitch = 1;
+}
+
+static void bup(int pad, int bit)
+{
+ if(bit < 16)
+ g.PadState[pad].KeyStatus |= (1 << bit);
+}
+
void CheckKeyboard() {
uint8_t i, j, found;
XEvent evt;
@@ -50,7 +64,7 @@ void CheckKeyboard() {
for (j = 0; j < DKEY_TOTAL; j++) {
if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
found = 1;
- g.PadState[i].KeyStatus &= ~(1 << j);
+ bdown(i, j);
}
}
}
@@ -66,7 +80,7 @@ void CheckKeyboard() {
for (j = 0; j < DKEY_TOTAL; j++) {
if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
found = 1;
- g.PadState[i].KeyStatus |= (1 << j);
+ bup(i, j);
}
}
}