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 50 #define BINDING_COUNT (SDL_CONTROLLER_BUTTON_MAX + SDL_CONTROLLER_BINDING_AXIS_MAX) 219 for (iIndex = 0; iIndex <
s_nNumAxes; ++iIndex) {
247 return (minA <= minB && maxA >= maxB);
251 return SDL_memcmp(pBindingA, pBindingB,
sizeof(*pBindingA)) == 0;
263 for (iIndex = 0; iIndex <
SDL_arraysize(s_arrBindings); ++iIndex) {
264 pCurrent = &s_arrBindings[iIndex];
283 #ifdef DEBUG_CONTROLLERMAP 301 pCurrent = &s_arrBindings[iCurrentElement];
311 if (bNativeDPad && bCurrentDPad) {
318 if (bNativeAxis == bCurrentAxis &&
326 *pCurrent = *pBinding;
372 if (window ==
NULL) {
378 if (screen ==
NULL) {
395 name ? name :
"Unknown Joystick");
396 SDL_Log(
"Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
401 ====================================================================================\n\ 402 Press the buttons on your controller when indicated\n\ 403 (Your controller may look different than the picture)\n\ 404 If you want to correct a mistake, press backspace or the back button on your device\n\ 405 To skip a button, press SPACE or click/touch the screen\n\ 406 To exit, press ESC\n\ 407 ====================================================================================\n");
413 for (iIndex = 0; iIndex <
s_nNumAxes; ++iIndex) {
414 AxisState *pAxisState = &s_arrAxisState[iIndex];
460 switch (event.
type) {
468 AxisState *pAxisState = &s_arrAxisState[
event.jaxis.axis];
469 int nValue =
event.jaxis.value;
470 int nCurrentDistance, nFarthestDistance;
478 if (nCurrentDistance > nFarthestDistance) {
483 #ifdef DEBUG_CONTROLLERMAP 484 SDL_Log(
"AXIS %d nValue %d nCurrentDistance %d nFarthestDistance %d\n", event.
jaxis.
axis, nValue, nCurrentDistance, nFarthestDistance);
486 if (nFarthestDistance >= 16000) {
492 binding.
value.
axis.axis =
event.jaxis.axis;
505 #ifdef DEBUG_CONTROLLERMAP 510 binding.
value.
hat.hat =
event.jhat.hat;
511 binding.
value.
hat.hat_mask =
event.jhat.value;
523 #ifdef DEBUG_CONTROLLERMAP 572 char trimmed_name[128];
582 trimmed_name[
SDL_strlen(trimmed_name) - 1] =
'\0';
597 for (iIndex = 0; iIndex <
SDL_arraysize(s_arrBindings); ++iIndex) {
607 const char *pszAxisName;
660 pszElement[0] =
'\0';
691 SDL_Log(
"Mapping:\n\n%s\n\n", mapping);
693 printf(
"%s\n", mapping);
697 s_arrAxisState =
NULL;
708 SDL_Joystick *joystick;
723 SDL_Log(
"Joystick %d: %s\n", i, name ? name :
"Unknown Joystick");
725 if (joystick ==
NULL) {
731 guid,
sizeof (guid));
752 device = atoi(argv[1]);
755 if (joystick ==
NULL) {
763 SDL_Log(
"\n\nUsage: ./controllermap number\nFor example: ./controllermap 0\nOr: ./controllermap 0 >> gamecontrollerdb.txt");
773 main(
int argc,
char *argv[])
static void ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding)
static int StandardizeAxisValue(int nValue)
static SDL_bool s_bBindingComplete
SDL_GameControllerBindType
#define SDL_WINDOWPOS_CENTERED
static void SetCurrentBinding(int iBinding)
#define SDL_JoystickClose
static AxisState * s_arrAxisState
#define SDL_JoystickGetVendor
#define SDL_JoystickGetGUID
#define SDL_LoadBMP(file)
#define SDL_INIT_JOYSTICK
SDL_JoyButtonEvent jbutton
union SDL_GameControllerExtendedBind::@48 value
#define SDL_GameControllerGetStringForButton
SDL_Texture * LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
#define SDL_QuitSubSystem
#define SDL_JoystickNameForIndex
A collection of pixels used in software blitting.
static int s_arrBindingOrder[BINDING_COUNT]
#define SDL_JoystickNumButtons
static SDL_bool BBindingContainsBinding(const SDL_GameControllerExtendedBind *pBindingA, const SDL_GameControllerExtendedBind *pBindingB)
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
#define SDL_JoystickGetProduct
static struct @47 s_arrBindingDisplay[BINDING_COUNT]
GLfloat GLfloat GLfloat alpha
GLuint const GLchar * name
#define SDL_JoystickNumAxes
static SDL_AudioDeviceID device
#define SDL_JOYSTICK_AXIS_MIN
GLenum GLenum GLuint texture
#define SDL_JOYSTICK_AXIS_MAX
static Uint32 s_unPendingAdvanceTime
static SDL_bool BMergeAxisBindings(int iIndex)
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerGetStringForAxis
#define SDL_JoystickGetAxisInitialState
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
static SDL_Renderer * renderer
#define SDL_RenderSetLogicalSize
static int s_iCurrentBinding
SDL_GameControllerBindType bindType
GLsizei const GLfloat * value
static void WatchJoystick(SDL_Joystick *joystick)
#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_assert(condition)
#define SDL_LogSetPriority
#define SDL_JoystickNumHats
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
#define SDL_JoystickNumBalls
#define SDL_arraysize(array)
GLenum GLenum GLenum GLenum mapping
static SDL_GameControllerExtendedBind s_arrBindings[BINDING_COUNT]
#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