diff options
| author | SND\edgbla_cp <SND\edgbla_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-05-09 05:38:48 +0000 |
|---|---|---|
| committer | SND\edgbla_cp <SND\edgbla_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-05-09 05:38:48 +0000 |
| commit | 2f0f4c038428171244fd4e188a04df3aa07b241a (patch) | |
| tree | 04157330145c9fc1cbd28e2c61d50778b28a7b6d /plugins | |
| parent | 8f4da5b653f91eaca82f02565a9932ae0ef371f8 (diff) | |
| download | pcsxr-2f0f4c038428171244fd4e188a04df3aa07b241a.tar.gz | |
dfinput, mouse (experimental).
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@66705 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/dfinput/cfg-gtk2.c | 50 | ||||
| -rw-r--r-- | plugins/dfinput/cfg.c | 6 | ||||
| -rw-r--r-- | plugins/dfinput/dfinput.ui | 31 | ||||
| -rw-r--r-- | plugins/dfinput/pad.c | 35 | ||||
| -rw-r--r-- | plugins/dfinput/pad.h | 2 | ||||
| -rw-r--r-- | plugins/dfinput/xkb.c | 72 |
6 files changed, 167 insertions, 29 deletions
diff --git a/plugins/dfinput/cfg-gtk2.c b/plugins/dfinput/cfg-gtk2.c index a3626873..7921f726 100644 --- a/plugins/dfinput/cfg-gtk2.c +++ b/plugins/dfinput/cfg-gtk2.c @@ -188,11 +188,18 @@ static void UpdateKeyList() { for (i = 0; i < 2; i++) {
int total;
- if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
- total = DKEY_TOTAL;
- } else {
- total = DKEY_TOTAL - 3;
- }
+ switch(g.cfg.PadDef[i].Type)
+ {
+ case PSE_PAD_TYPE_MOUSE:
+ total = 0;
+ break;
+ case PSE_PAD_TYPE_STANDARD:
+ total = DKEY_TOTAL - 3;
+ break;
+ case PSE_PAD_TYPE_ANALOGPAD:
+ total = DKEY_TOTAL;
+ break;
+ }
widget = gtk_builder_get_object(xml, widgetname[i]);
@@ -299,7 +306,14 @@ static void OnDeviceChanged(GtkWidget *widget, gpointer user_data) { static void OnTypeChanged(GtkWidget *widget, gpointer user_data) {
int n = (int)user_data, current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- g.cfg.PadDef[n].Type = (current == 0 ? PSE_PAD_TYPE_STANDARD : PSE_PAD_TYPE_ANALOGPAD);
+
+ int padTypeList[] = {
+ PSE_PAD_TYPE_STANDARD,
+ PSE_PAD_TYPE_ANALOGPAD,
+ PSE_PAD_TYPE_MOUSE
+ };
+
+ g.cfg.PadDef[n].Type = padTypeList[current];
UpdateKeyList();
}
@@ -308,6 +322,10 @@ static void OnThreadedToggled(GtkWidget *widget, gpointer user_data) { g.cfg.Threaded = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
+static void OnHideCursorToggled(GtkWidget *widget, gpointer user_data) {
+ g.cfg.HideCursor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+}
+
static void ReadDKeyEvent(int padnum, int key) {
SDL_Joystick *js;
time_t t;
@@ -641,6 +659,11 @@ long PADconfigure() { g_signal_connect_data(GTK_OBJECT(widget), "toggled",
G_CALLBACK(OnThreadedToggled), NULL, NULL, G_CONNECT_AFTER);
+ widget = gtk_builder_get_object(xml, "checkcg");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.HideCursor);
+ g_signal_connect_data(GTK_OBJECT(widget), "toggled",
+ G_CALLBACK(OnHideCursorToggled), NULL, NULL, G_CONNECT_AFTER);
+
widget = gtk_builder_get_object(xml, "combodev1");
g_signal_connect_data(GTK_OBJECT(widget), "changed",
G_CALLBACK(OnDeviceChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
@@ -649,15 +672,26 @@ long PADconfigure() { g_signal_connect_data(GTK_OBJECT(widget), "changed",
G_CALLBACK(OnDeviceChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
+ int padTypeList[] = {
+ 0,
+ 2, // PSE_PAD_TYPE_MOUSE
+ 0, // PSE_PAD_TYPE_NEGCON
+ 0, // PSE_PAD_TYPE_GUN
+ 0, // PSE_PAD_TYPE_STANDARD
+ 1, // PSE_PAD_TYPE_ANALOGJOY
+ 0, // PSE_PAD_TYPE_GUNCON
+ 1, //PSE_PAD_TYPE_ANALOGPAD
+ };
+
widget = gtk_builder_get_object(xml, "combotype1");
gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- g.cfg.PadDef[0].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
+ padTypeList[g.cfg.PadDef[0].Type]);
g_signal_connect_data(GTK_OBJECT(widget), "changed",
G_CALLBACK(OnTypeChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
widget = gtk_builder_get_object(xml, "combotype2");
gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- g.cfg.PadDef[1].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
+ padTypeList[g.cfg.PadDef[1].Type]);
g_signal_connect_data(GTK_OBJECT(widget), "changed",
G_CALLBACK(OnTypeChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c index 64c60a2d..3ac9dfa8 100644 --- a/plugins/dfinput/cfg.c +++ b/plugins/dfinput/cfg.c @@ -26,6 +26,7 @@ static void SetDefaultConfig() { memset(&g.cfg, 0, sizeof(g.cfg)); g.cfg.Threaded = 1; + g.cfg.HideCursor = 0; g.cfg.PadDef[0].DevNum = 0; g.cfg.PadDef[1].DevNum = 1; @@ -128,7 +129,9 @@ void LoadPADConfig() { while (fgets(buf, 256, fp) != NULL) { if (strncmp(buf, "Threaded=", 9) == 0) { g.cfg.Threaded = atoi(&buf[9]); - } else if (strncmp(buf, "[PAD", 4) == 0) { + } else if (strncmp(buf, "HideCursor=", 11) == 0) { + g.cfg.HideCursor = atoi(&buf[11]); + } else if (strncmp(buf, "[PAD", 4) == 0) { current = atoi(&buf[4]) - 1; if (current < 0) { current = 0; @@ -281,6 +284,7 @@ void SavePADConfig() { fprintf(fp, "[CONFIG]\n"); fprintf(fp, "Threaded=%d\n", g.cfg.Threaded); + fprintf(fp, "HideCursor=%d\n", g.cfg.HideCursor); fprintf(fp, "\n"); for (i = 0; i < 2; i++) { diff --git a/plugins/dfinput/dfinput.ui b/plugins/dfinput/dfinput.ui index 144a14c8..5d3ef1ef 100644 --- a/plugins/dfinput/dfinput.ui +++ b/plugins/dfinput/dfinput.ui @@ -4,7 +4,7 @@ <!-- interface-naming-policy project-wide --> <object class="GtkListStore" id="liststore1"> <columns> - <!-- column-name item text --> + <!-- column-name item --> <column type="gchararray"/> </columns> <data> @@ -14,11 +14,14 @@ <row> <col id="0" translatable="yes">Analog Pad</col> </row> + <row> + <col id="0" translatable="yes">Mouse</col> + </row> </data> </object> <object class="GtkListStore" id="liststore2"> <columns> - <!-- column-name item text --> + <!-- column-name item --> <column type="gchararray"/> </columns> <data> @@ -28,6 +31,9 @@ <row> <col id="0" translatable="yes">Analog Pad</col> </row> + <row> + <col id="0" translatable="yes">Mouse</col> + </row> </data> </object> <object class="GtkDialog" id="CfgWnd"> @@ -35,7 +41,6 @@ <property name="resizable">False</property> <property name="window_position">center</property> <property name="type_hint">normal</property> - <property name="has_separator">False</property> <child internal-child="vbox"> <object class="GtkVBox" id="dialog-vbox1"> <property name="visible">True</property> @@ -456,8 +461,9 @@ <child> <object class="GtkVBox" id="vbox3"> <property name="visible">True</property> + <property name="border_width">5</property> <property name="orientation">vertical</property> - <property name="spacing">20</property> + <property name="spacing">5</property> <child> <object class="GtkCheckButton" id="checkmt"> <property name="label" translatable="yes">Multi-Threaded (Recommended)</property> @@ -468,11 +474,24 @@ </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> - <property name="padding">16</property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="checkcg"> + <property name="label" translatable="yes">Hide cursor</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="position">2</property> diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index a4cd908a..fcb86b5e 100644 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -26,7 +26,7 @@ static void (*gpuVisualVibration)(uint32_t, uint32_t) = NULL;
char *PSEgetLibName(void) {
- return _("Gamepad/Keyboard Input");
+ return _("Gamepad/Keyboard/Mouse Input");
}
uint32_t PSEgetLibType(void) {
@@ -34,13 +34,21 @@ uint32_t PSEgetLibType(void) { }
uint32_t PSEgetLibVersion(void) {
- return (1 << 16) | (1 << 8);
+ return (1 << 16) | (2 << 8);
}
+static int padDataLenght[] = {0, 2, 3, 1, 1, 3, 3, 3};
void PADsetMode(const int pad, const int mode) {
g.PadState[pad].PadMode = mode;
- g.PadState[pad].PadID = mode ? 0x73 : 0x41;
-
+
+ if (g.cfg.PadDef[pad].Type == PSE_PAD_TYPE_ANALOGPAD) {
+ g.PadState[pad].PadID = mode ? 0x73 : 0x41;
+ }
+ else {
+ g.PadState[pad].PadID = (g.cfg.PadDef[pad].Type << 4) |
+ padDataLenght[g.cfg.PadDef[pad].Type];
+ }
+
g.PadState[pad].Vib0 = 0;
g.PadState[pad].Vib1 = 0;
g.PadState[pad].VibF[0] = 0;
@@ -414,8 +422,6 @@ unsigned char PADpoll(unsigned char value) { case CMD_READ_DATA_AND_VIBRATE:
default:
- UpdateInput();
-
n = g.PadState[CurPad].KeyStatus;
n &= g.PadState[CurPad].JoyKeyStatus;
@@ -429,7 +435,15 @@ unsigned char PADpoll(unsigned char value) { stdpar[CurPad][5] = g.PadState[CurPad].AnalogStatus[ANALOG_RIGHT][1];
stdpar[CurPad][6] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][0];
stdpar[CurPad][7] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][1];
- } else {
+ }
+ else if(g.PadState[CurPad].PadID == 0x12)
+ {
+ CmdLen = 6;
+
+ stdpar[CurPad][4] = g.PadState[0].MouseAxis[0][0];
+ stdpar[CurPad][5] = g.PadState[0].MouseAxis[0][1];
+ }
+ else {
CmdLen = 4;
}
@@ -595,8 +609,11 @@ long PADreadPort2(PadDataS *pad) { long PADkeypressed(void) {
long s;
-
- CheckKeyboard();
+
+ static int frame = 0;
+ if( !frame )
+ UpdateInput();
+ frame ^= 1;
s = g.KeyLeftOver;
g.KeyLeftOver = 0;
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h index 1ad35a43..06913c4c 100644 --- a/plugins/dfinput/pad.h +++ b/plugins/dfinput/pad.h @@ -121,6 +121,7 @@ typedef struct tagPadDef { typedef struct tagConfig {
uint8_t Threaded;
+ uint8_t HideCursor;
PADDEF PadDef[2];
} CONFIG;
@@ -134,6 +135,7 @@ 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];
+ volatile int8_t MouseAxis[2][2];
uint8_t Vib0, Vib1;
volatile uint8_t VibF[2];
#if SDL_VERSION_ATLEAST(1,3,0)
diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c index 687b150a..6a7a21bd 100644 --- a/plugins/dfinput/xkb.c +++ b/plugins/dfinput/xkb.c @@ -19,6 +19,9 @@ #include "pad.h" static Atom wmprotocols, wmdelwindow; +static int g_currentMouse_X; +static int g_currentMouse_Y; +static Window window; void InitKeyboard() { wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0); @@ -26,12 +29,27 @@ void InitKeyboard() { XkbSetDetectableAutoRepeat(g.Disp, 1, NULL); + if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || + g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { + int revert_to; + XGetInputFocus(g.Disp, &window, &revert_to); + XGrabPointer(g.Disp, window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); + } + + g_currentMouse_X = 0; + g_currentMouse_Y = 0; + g.PadState[0].KeyStatus = 0xFFFF; g.PadState[1].KeyStatus = 0xFFFF; } void DestroyKeyboard() { XkbSetDetectableAutoRepeat(g.Disp, 0, NULL); + + if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || + g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { + XUngrabPointer(g.Disp, CurrentTime); + } } static void bdown(int pad, int bit) @@ -53,10 +71,46 @@ void CheckKeyboard() { XEvent evt; XClientMessageEvent *xce; uint16_t Key; - + while (XPending(g.Disp)) { XNextEvent(g.Disp, &evt); switch (evt.type) { + case ButtonPress: + for(i = 0; i < 2; ++i) { + if(g.cfg.PadDef[i].Type == PSE_PAD_TYPE_MOUSE) { + switch(evt.xbutton.button) { + case 1: + bdown(i, 11); + break; + case 3: + bdown(i, 10); + break; + } + } + } + break; + case ButtonRelease: + for(i = 0; i < 2; ++i) { + if(g.cfg.PadDef[i].Type == PSE_PAD_TYPE_MOUSE) { + switch(evt.xbutton.button) { + case 1: + bup(i, 11); + break; + case 3: + bup(i, 10); + break; + } + } + } + break; + case MotionNotify: + g_currentMouse_X = evt.xmotion.x - 160; + g_currentMouse_Y = evt.xmotion.y - 120; + if( g_currentMouse_X < -128) g_currentMouse_X = -128; + if( g_currentMouse_X > 127) g_currentMouse_X = 127; + if( g_currentMouse_Y < -128) g_currentMouse_Y = -128; + if( g_currentMouse_Y > 127) g_currentMouse_Y = 127; + break; case KeyPress: Key = XLookupKeysym((XKeyEvent *)&evt, 0); found = 0; @@ -71,8 +125,7 @@ void CheckKeyboard() { if (!found && !AnalogKeyPressed(Key)) { g.KeyLeftOver = Key; } - return; - + break; case KeyRelease: Key = XLookupKeysym((XKeyEvent *)&evt, 0); found = 0; @@ -88,7 +141,6 @@ void CheckKeyboard() { g.KeyLeftOver = ((long)Key | 0x40000000); } break; - case ClientMessage: xce = (XClientMessageEvent *)&evt; if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow) { @@ -98,5 +150,15 @@ void CheckKeyboard() { } break; } - } + } + + g.PadState[0].MouseAxis[0][0] = g_currentMouse_X; + g.PadState[0].MouseAxis[0][1] = g_currentMouse_Y; + g_currentMouse_X *= 0.7; + g_currentMouse_Y *= 0.7; + + if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || + g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { + XWarpPointer(g.Disp, None, window, 0, 0, 0, 0, 160, 120); + } } |
