[mednaffe] 03/06: [Windows] Detect XINPUT_DEVTYPE_GAMEPAD SDL2 has been patched.
Stephen Kitt
skitt at moszumanska.debian.org
Tue Aug 2 21:00:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
skitt pushed a commit to branch upstream
in repository mednaffe.
commit 06868fe1de083d2701442199e1d31230895ffd01
Author: AmatCoder <amatcoder at gmail.com>
Date: Sun Jul 26 14:16:01 2015 +0200
[Windows] Detect XINPUT_DEVTYPE_GAMEPAD
SDL2 has been patched.
---
src/input.c | 25 ++++++++++++++++++++-----
src/joystick_win.c | 41 +++++++++++++++++++++++++++--------------
src/joystick_win.h | 15 ++++++++-------
3 files changed, 55 insertions(+), 26 deletions(-)
diff --git a/src/input.c b/src/input.c
index f6821ac..91a5d63 100644
--- a/src/input.c
+++ b/src/input.c
@@ -715,7 +715,7 @@ void on_input_clicked (GtkButton *button, guidata *gui)
{
if (GetJoy(a,gui)>0)
{
- gchar *id =g_strdup_printf(" - Unique ID: %016llx\n", gui->joy[a].id);
+ gchar *id =g_strdup_printf(" - Unique ID: %016llx\n", gui->joy[a].id);
print_log("Joystick detected: ", FE, gui);
print_log(gui->joy[a].name, FE, gui);
print_log(id, FE, gui);
@@ -770,14 +770,29 @@ void on_input_clicked (GtkButton *button, guidata *gui)
(guid.data[5]=='t'))*/
if (g_strcmp0(pszGUID, "00000000000000000000000000000000")==0)
{
- gui->joy[i].id = (0x00000000 << 24) | (0x00000001 << 16);
- gui->joy[i].xinput = TRUE;
+ int type, subtype;
+
+ type = SDL_JoystickDevType(gui->joy[i].sdljoy); // Those functions does not exits in SDL
+ subtype = SDL_JoystickDevSubType(gui->joy[i].sdljoy); // I patched it to expose XINPUT_CAPABILITIES
+
+ if ((type > -1) &&
+ (type < 2) &&
+ (subtype > -1 ) &&
+ (subtype < 20))
+ {
+ gui->joy[i].id = ((type << 24) | (subtype << 16));
+ }
+ else
+ gui->joy[i].id = (0x00000000 << 24) | (0x00000001 << 16);
+
+ gui->joy[i].xinput = TRUE;
+ CheckDuplicatesXInput(i, gui);
}
else
{
- GetJoy(i, gui);
+ GetJoy(i, gui);
+ CheckDuplicates(i, gui);
}
- CheckDuplicates(i, gui);
}
}
diff --git a/src/joystick_win.c b/src/joystick_win.c
index 35503ba..a4b016e 100644
--- a/src/joystick_win.c
+++ b/src/joystick_win.c
@@ -1,23 +1,23 @@
/*
* joystick_win.c
- *
+ *
* Copyright 2013-2015 AmatCoder
- *
+ *
* This file is part of Mednaffe.
- *
+ *
* Mednaffe is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* Mednaffe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with Mednaffe; if not, see <http://www.gnu.org/licenses/>.
- *
+ *
*/
#include "common.h"
@@ -25,14 +25,14 @@
#include "stdint.h"
#include "string.h"
-uint64_t CalcOldStyleID(unsigned arg_num_axes, unsigned arg_num_balls,
+uint64_t CalcOldStyleID(unsigned arg_num_axes, unsigned arg_num_balls,
unsigned arg_num_hats, unsigned arg_num_buttons)
{
uint8 digest[16];
int tohash[4];
md5_context hashie;
uint64_t ret = 0;
-
+
tohash[0] = arg_num_axes;
tohash[1] = arg_num_balls;
tohash[2] = arg_num_hats;
@@ -60,21 +60,34 @@ void CheckDuplicates(guint js, guidata *gui)
gui->joy[a].id++;
CheckDuplicates(a, gui);
}
- }
+ }
+}
+
+void CheckDuplicatesXInput(guint js, guidata *gui)
+{
+ int a;
+ for (a=0;a<9;a++)
+ {
+ if (a==js) break;
+ if (gui->joy[js].id == gui->joy[a].id) {
+ gui->joy[js].id++;
+ CheckDuplicates(js, gui);
+ }
+ }
}
gint GetJoy(guint js, guidata *gui)
-{
+{
//printf("Number of Axes: %d\n", SDL_JoystickNumAxes(gui->joy[js].sdljoy));
//printf("Number of Hats: %d\n", SDL_JoystickNumHats(gui->joy[js].sdljoy));
//printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(gui->joy[js].sdljoy));
//printf("Number of Balls: %d\n", SDL_JoystickNumBalls(gui->joy[js].sdljoy));
-
+
gui->joy[js].id = CalcOldStyleID(SDL_JoystickNumAxes(gui->joy[js].sdljoy),
- 0,
+ 0,
SDL_JoystickNumHats(gui->joy[js].sdljoy),
SDL_JoystickNumButtons(gui->joy[js].sdljoy));
-
+
return 1;
-
+
}
diff --git a/src/joystick_win.h b/src/joystick_win.h
index 1422fc6..668a10f 100644
--- a/src/joystick_win.h
+++ b/src/joystick_win.h
@@ -1,29 +1,30 @@
/*
* joystick_win.h
- *
+ *
* Copyright 2013-2015 AmatCoder
- *
+ *
* This file is part of Mednaffe.
- *
+ *
* Mednaffe is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* Mednaffe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with Mednaffe; if not, see <http://www.gnu.org/licenses/>.
- *
+ *
*/
-
+
#ifndef JOYSTICK_WIN_H
#define JOYSTICK_WIN_H
void CheckDuplicates(guint js, guidata *gui);
+ void CheckDuplicatesXInput(guint js, guidata *gui);
gint GetJoy(guint js, guidata *gui);
#endif /* JOYSTICK_WIN_H */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mednaffe.git
More information about the Pkg-games-commits
mailing list