diff options
author | Sam Lantinga <slouken@libsdl.org> | 2017-01-04 10:28:07 -0800 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2017-01-04 10:28:07 -0800 |
commit | 2d511b312bc3d0a72e4e55431e73d1d45503e55a (patch) | |
tree | 37ba0a4506f9b8da7d26e73dac87c558f6ec4622 /test/controllermap.c | |
parent | c626e1023c45d449989a53854e473ab0238b00b8 (diff) | |
download | sdl-2d511b312bc3d0a72e4e55431e73d1d45503e55a.tar.gz |
Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value.
This is useful for controller mapping programs to determine an axis' zero state
Diffstat (limited to 'test/controllermap.c')
-rw-r--r-- | test/controllermap.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/controllermap.c b/test/controllermap.c index f0a01f061..d5f1f2205 100644 --- a/test/controllermap.c +++ b/test/controllermap.c @@ -337,6 +337,7 @@ WatchJoystick(SDL_Joystick * joystick) Uint8 alpha=200, alpha_step = -1; Uint32 alpha_ticks = 0; SDL_JoystickID nJoystickID; + int iIndex; /* Create a window to display joystick axis position */ window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, @@ -383,6 +384,13 @@ WatchJoystick(SDL_Joystick * joystick) s_nNumAxes = SDL_JoystickNumAxes(joystick); s_arrAxisState = SDL_calloc(s_nNumAxes, sizeof(*s_arrAxisState)); + for (iIndex = 0; iIndex < s_nNumAxes; ++iIndex) { + AxisState *pAxisState = &s_arrAxisState[iIndex]; + Sint16 nInitialValue; + pAxisState->m_bMoving = SDL_JoystickGetAxisInitialState(joystick, iIndex, &nInitialValue); + pAxisState->m_nStartingValue = nInitialValue; + pAxisState->m_nFarthestValue = nInitialValue; + } /* Loop, getting joystick events! */ while (!done && !s_bBindingComplete) { |