22 #ifndef SDL_JOYSTICK_DISABLED 25 #define SCREEN_WIDTH 320 26 #define SCREEN_HEIGHT 480 28 #define SCREEN_WIDTH 512 29 #define SCREEN_HEIGHT 320 32 #define MARKER_BUTTON 1 110 char mapping[4096], temp[4096];
113 {342, 132, 0.0,
MARKER_BUTTON,
"x", -1, -1, -1, -1,
""},
114 {387, 167, 0.0,
MARKER_BUTTON,
"a", -1, -1, -1, -1,
""},
115 {431, 132, 0.0,
MARKER_BUTTON,
"b", -1, -1, -1, -1,
""},
116 {389, 101, 0.0,
MARKER_BUTTON,
"y", -1, -1, -1, -1,
""},
117 {174, 132, 0.0,
MARKER_BUTTON,
"back", -1, -1, -1, -1,
""},
118 {233, 132, 0.0,
MARKER_BUTTON,
"guide", -1, -1, -1, -1,
""},
119 {289, 132, 0.0,
MARKER_BUTTON,
"start", -1, -1, -1, -1,
""},
120 {116, 217, 0.0,
MARKER_BUTTON,
"dpleft", -1, -1, -1, -1,
""},
121 {154, 249, 0.0,
MARKER_BUTTON,
"dpdown", -1, -1, -1, -1,
""},
122 {186, 217, 0.0,
MARKER_BUTTON,
"dpright", -1, -1, -1, -1,
""},
123 {154, 188, 0.0,
MARKER_BUTTON,
"dpup", -1, -1, -1, -1,
""},
124 {77, 40, 0.0,
MARKER_BUTTON,
"leftshoulder", -1, -1, -1, -1,
""},
125 {91, 0, 0.0,
MARKER_BUTTON,
"lefttrigger", -1, -1, -1, -1,
""},
126 {396, 36, 0.0,
MARKER_BUTTON,
"rightshoulder", -1, -1, -1, -1,
""},
127 {375, 0, 0.0,
MARKER_BUTTON,
"righttrigger", -1, -1, -1, -1,
""},
128 {75, 154, 0.0,
MARKER_BUTTON,
"leftstick", -1, -1, -1, -1,
""},
129 {305, 230, 0.0,
MARKER_BUTTON,
"rightstick", -1, -1, -1, -1,
""},
130 {75, 154, 0.0,
MARKER_AXIS,
"leftx", -1, -1, -1, -1,
""},
131 {75, 154, 90.0,
MARKER_AXIS,
"lefty", -1, -1, -1, -1,
""},
132 {305, 230, 0.0,
MARKER_AXIS,
"rightx", -1, -1, -1, -1,
""},
133 {305, 230, 90.0,
MARKER_AXIS,
"righty", -1, -1, -1, -1,
""},
140 if (window ==
NULL) {
146 if (screen ==
NULL) {
163 name ? name :
"Unknown Joystick");
164 SDL_Log(
"Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
169 ====================================================================================\n\ 170 Press the buttons on your controller when indicated\n\ 171 (Your controller may look different than the picture)\n\ 172 If you want to correct a mistake, press backspace or the back button on your device\n\ 173 To skip a button, press SPACE or click/touch the screen\n\ 174 To exit, press ESC\n\ 175 ====================================================================================\n");
210 while (!done && !next) {
230 switch (event.
type) {
233 for (_s = 0; _s <
s; _s++) {
234 if (steps[_s].axis == event.
jaxis.
axis) {
239 step->
axis =
event.jaxis.axis;
253 for (_s = 0; _s <
s; _s++) {
259 step->
hat =
event.jhat.hat;
271 for (_s = 0; _s <
s; _s++) {
277 step->
button =
event.jbutton.button;
295 prev_step = &steps[--
s];
324 SDL_Log(
"Mapping:\n\n%s\n\n", mapping);
326 printf(
"%s\n", mapping);
341 SDL_Joystick *joystick;
356 SDL_Log(
"Joystick %d: %s\n", i, name ? name :
"Unknown Joystick");
358 if (joystick ==
NULL) {
364 guid,
sizeof (guid));
387 device = atoi(argv[1]);
391 while ( keepGoing ) {
392 if (joystick ==
NULL) {
393 if ( !reportederror ) {
406 SDL_Log(
"Waiting for attach\n");
421 SDL_Log(
"\n\nUsage: ./controllermap number\nFor example: ./controllermap 0\nOr: ./controllermap 0 >> gamecontrollerdb.txt");
431 main(
int argc,
char *argv[])
#define SDL_WINDOWPOS_CENTERED
#define SDL_JoystickClose
#define SDL_JoystickGetGUID
#define SDL_LoadBMP(file)
#define SDL_INIT_JOYSTICK
SDL_JoyButtonEvent jbutton
SDL_Texture * LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
static SDL_Window * window
GLenum GLenum GLuint texture
#define SDL_QuitSubSystem
#define SDL_JoystickNameForIndex
A collection of pixels used in software blitting.
#define SDL_JoystickNumButtons
GLuint const GLchar * name
uint32_t Uint32
An unsigned 32-bit integer type.
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
GLfloat GLfloat GLfloat alpha
#define SDL_JoystickNumAxes
#define SDL_CreateTextureFromSurface
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
static SDL_Renderer * renderer
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_RenderSetLogicalSize
#define SDL_SetTextureColorMod
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_LogSetPriority
#define SDL_JoystickNumHats
The type used to identify a window.
#define SDL_JoystickNumBalls
uint16_t Uint16
An unsigned 16-bit integer type.
#define SDL_arraysize(array)
GLenum GLenum GLenum GLenum mapping
#define SDL_SetRenderDrawColor
#define SDL_DestroyRenderer
int main(int argc, char *argv[])
#define SDL_DestroyWindow
#define SDL_CreateRenderer
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent
#define SDL_SetTextureAlphaMod
static SDL_bool WatchJoystick(SDL_Joystick *joystick)