Home | History | Annotate | Download | only in test

Lines Matching refs:joystick

13 /* Simple program to test the SDL joystick routines */
40 WatchJoystick(SDL_Joystick * joystick)
50 /* Create a window to display joystick axis position */
51 window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED,
71 /* Print info about the joystick we are watching */
72 name = SDL_JoystickName(joystick);
73 SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
74 name ? name : "Unknown Joystick");
75 SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
76 SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
77 SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
79 /* Loop, getting joystick events! */
88 SDL_Log("Joystick %d axis %d value: %d\n",
93 SDL_Log("Joystick %d hat %d value:",
108 SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
113 SDL_Log("Joystick %d button %d down\n",
117 SDL_Log("Joystick %d button %d up\n",
135 /* Update visual joystick state */
137 for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
138 if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
144 for (i = 0; i < SDL_JoystickNumAxes(joystick); ++i) {
147 x = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
156 if (i < SDL_JoystickNumAxes(joystick)) {
157 y = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
173 for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) {
177 const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i);
196 if (SDL_JoystickGetAttached( joystick ) == 0) {
212 SDL_Joystick *joystick;
227 SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
228 joystick = SDL_JoystickOpen(i);
229 if (joystick == NULL) {
234 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
236 SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick));
237 SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick));
238 SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick));
239 SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
240 SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
242 SDL_JoystickClose(joystick);
260 joystick = SDL_JoystickOpen(device);
263 if (joystick == NULL) {
265 SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
271 keepGoing = WatchJoystick(joystick);
272 SDL_JoystickClose(joystick);
275 joystick = NULL;
285 joystick = SDL_JoystickOpen(device);
301 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");