Last active
November 1, 2015 23:20
-
-
Save flibitijibibo/ac56da32679e889b8560 to your computer and use it in GitHub Desktop.
These changes allow for a working experience out of the box with SDL_GameController.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/uinput-feeder.cpp b/src/uinput-feeder.cpp | |
index 6288a06..b832fac 100644 | |
--- a/src/uinput-feeder.cpp | |
+++ b/src/uinput-feeder.cpp | |
@@ -67,11 +67,27 @@ int InitUinput() { | |
dev.id.bustype = BUS_VIRTUAL; | |
// Enable joysticks: 4 axis (2 for each stick). | |
+#ifdef DRC_RAW_AXIS_VALUES | |
for (int i = 0; i < 4; ++i) { | |
dev.absmin[i] = -kStickRadius; | |
dev.absmax[i] = kStickRadius; | |
ioctl(uinput_fd, UI_SET_ABSBIT, i); | |
} | |
+#else | |
+ // These values are largely fudged based on my hardware's raw values. -flibit | |
+ dev.absmin[0] = -108; | |
+ dev.absmax[0] = 108; | |
+ ioctl(uinput_fd, UI_SET_ABSBIT, 0); | |
+ dev.absmin[1] = -108; | |
+ dev.absmax[1] = 108; | |
+ ioctl(uinput_fd, UI_SET_ABSBIT, 1); | |
+ dev.absmin[2] = -98; | |
+ dev.absmax[2] = 98; | |
+ ioctl(uinput_fd, UI_SET_ABSBIT, 2); | |
+ dev.absmin[3] = -98; | |
+ dev.absmax[3] = 98; | |
+ ioctl(uinput_fd, UI_SET_ABSBIT, 3); | |
+#endif | |
// Enable 32 buttons (we only use 19 of these, but it makes things easier). | |
for (int i = 0; i < 32; ++i) { | |
@@ -133,6 +149,8 @@ void FeedDrcInputToUinput(const InputData& inp) { | |
evt[i].type = EV_ABS; | |
evt[i].code = i - 32; | |
evt[i].value = static_cast<int>(sticks[i - 32] * kStickRadius); | |
+ if (((i - 32) % 2) == 1) | |
+ evt[i].value *= -1; // Invert the Y axes. | |
memcpy(&evt[i].time, &tv, sizeof (tv)); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export SDL_GAMECONTROLLERCONFIG="0600000057696920552047616d655000,Wii U GamePad (libdrc),platform:Linux,x:b12,a:b14,b:b15,y:b13,back:b2,guide:b1,start:b3,dpleft:b11,dpdown:b8,dpright:b10,dpup:b9,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,leftstick:b23,rightstick:b22,leftx:a0,lefty:a1,rightx:a2,righty:a3," |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment