summaryrefslogtreecommitdiffstats
path: root/src/skel/glfw/glfw.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2020-12-09 01:41:45 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2020-12-09 04:36:28 +0100
commitcf4aedd97cda528dd77bfce06eb3e46a7382ced1 (patch)
tree6045bfb10cd7a49268e1f0775d244b340665d986 /src/skel/glfw/glfw.cpp
parentMerge pull request #872 from withmorten/sized-enums-miami (diff)
downloadre3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar.gz
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar.bz2
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar.lz
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar.xz
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.tar.zst
re3-cf4aedd97cda528dd77bfce06eb3e46a7382ced1.zip
Diffstat (limited to 'src/skel/glfw/glfw.cpp')
-rw-r--r--src/skel/glfw/glfw.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index c219e711..a73db217 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -70,9 +70,6 @@ static psGlobalType PsGlobal;
#define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var)
-#undef MAKEPOINTS
-#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l)))
-
size_t _dwMemAvailPhys;
RwUInt32 gGameState;
@@ -878,6 +875,36 @@ void _InputInitialiseJoys()
PSGLOBAL(joy1id) = -1;
PSGLOBAL(joy2id) = -1;
+ // Load our gamepad mappings.
+#define SDL_GAMEPAD_DB_PATH "gamecontrollerdb.txt"
+ FILE *f = fopen(SDL_GAMEPAD_DB_PATH, "rb");
+ if (f) {
+ fseek(f, 0, SEEK_END);
+ size_t fsize = ftell(f);
+ fseek(f, 0, SEEK_SET);
+
+ char *db = (char*)malloc(fsize + 1);
+ if (fread(db, 1, fsize, f) == fsize) {
+ db[fsize] = '\0';
+
+ if (glfwUpdateGamepadMappings(db) == GLFW_FALSE)
+ Error("glfwUpdateGamepadMappings didn't succeed, check " SDL_GAMEPAD_DB_PATH ".\n");
+ } else
+ Error("fread on " SDL_GAMEPAD_DB_PATH " wasn't successful.\n");
+
+ free(db);
+ fclose(f);
+ } else
+ printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from re3/gamefiles to GTA3 directory. Some gamepads may not be recognized.\n");
+
+#undef SDL_GAMEPAD_DB_PATH
+
+ // But always overwrite it with the one in SDL_GAMECONTROLLERCONFIG.
+ char const* EnvControlConfig = getenv("SDL_GAMECONTROLLERCONFIG");
+ if (EnvControlConfig != nil) {
+ glfwUpdateGamepadMappings(EnvControlConfig);
+ }
+
for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
if (glfwJoystickPresent(i) && !IsThisJoystickBlacklisted(i)) {
if (PSGLOBAL(joy1id) == -1)