test/testjoystick.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 14 Oct 2012 00:24:07 -0700
changeset 6586 ab57cc69dcc0
parent 6398 c294faf5fce5
child 6690 9548c8a58103
permissions -rw-r--r--
Updated testjoystick for SDL 2.0 API - patch from simon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     1
/*
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
    11
*/
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    13
/* Simple program to test the SDL joystick routines */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    15
#include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    16
#include <stdlib.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    17
#include <string.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    19
#include "SDL.h"
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    20
#include "common.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    21
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    22
static CommonState *state;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    23
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
    25
#define MAX_NUM_AXES 6
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
    26
#define MAX_NUM_HATS 2
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
    27
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    28
static void
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    29
DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    30
{
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    31
    const SDL_Rect area = { x, y, w, h };
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    32
    SDL_RenderFillRect(r, &area);
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    33
}
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    34
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    35
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    36
WatchJoystick(SDL_Joystick * joystick)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    37
{
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    38
    SDL_Window *window = NULL;
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    39
    SDL_Renderer *screen = NULL;
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    40
    SDL_Rect viewport;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    41
    SDL_Event event;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
    42
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    43
    const char *name = NULL;
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    44
    int done = 0;
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    45
    int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    46
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    47
    /* Print info about the joystick we are watching */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    48
    name = SDL_JoystickName(SDL_JoystickIndex(joystick));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    49
    printf("Watching joystick %d: (%s)\n", SDL_JoystickIndex(joystick),
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    50
           name ? name : "Unknown Joystick");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    51
    printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    52
           SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    53
           SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    54
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    55
    /* Loop, getting joystick events! */
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    56
    while (!done) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    57
        while (SDL_PollEvent(&event)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    58
            switch (event.type) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    59
            case SDL_JOYAXISMOTION:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    60
                printf("Joystick %d axis %d value: %d\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    61
                       event.jaxis.which,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    62
                       event.jaxis.axis, event.jaxis.value);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    63
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    64
            case SDL_JOYHATMOTION:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    65
                printf("Joystick %d hat %d value:",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    66
                       event.jhat.which, event.jhat.hat);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    67
                if (event.jhat.value == SDL_HAT_CENTERED)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    68
                    printf(" centered");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    69
                if (event.jhat.value & SDL_HAT_UP)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    70
                    printf(" up");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    71
                if (event.jhat.value & SDL_HAT_RIGHT)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    72
                    printf(" right");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    73
                if (event.jhat.value & SDL_HAT_DOWN)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    74
                    printf(" down");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    75
                if (event.jhat.value & SDL_HAT_LEFT)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    76
                    printf(" left");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    77
                printf("\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    78
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    79
            case SDL_JOYBALLMOTION:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    80
                printf("Joystick %d ball %d delta: (%d,%d)\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    81
                       event.jball.which,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    82
                       event.jball.ball, event.jball.xrel, event.jball.yrel);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    83
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    84
            case SDL_JOYBUTTONDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    85
                printf("Joystick %d button %d down\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    86
                       event.jbutton.which, event.jbutton.button);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    87
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    88
            case SDL_JOYBUTTONUP:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    89
                printf("Joystick %d button %d up\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    90
                       event.jbutton.which, event.jbutton.button);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    91
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    92
            case SDL_KEYDOWN:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    93
                if (event.key.keysym.sym != SDLK_ESCAPE) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    94
                    break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    95
                }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    96
                /* Fall through to signal quit */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    97
            case SDL_QUIT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    98
                done = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
    99
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   100
            default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   101
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   102
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   103
        }
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   104
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   105
        /* Update visual joystick state */
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   106
        for (i = 0; i < state->num_windows; ++i) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   107
            screen = state->renderers[i];
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   108
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   109
            /* Erase previous axes */
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   110
            SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   111
            SDL_RenderClear(screen);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   112
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   113
            /* Query the sizes */
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   114
            SDL_RenderGetViewport(screen, &viewport);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   115
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   116
            SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   117
            for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   118
                if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   119
                    DrawRect(screen, i * 34, viewport.h - 34, 32, 32);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   120
                }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   121
            }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2201
diff changeset
   122
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   123
            SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   124
            for (i = 0; i < SDL_JoystickNumAxes(joystick) / 2; ++i) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   125
                /* Draw the X/Y axis */
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   126
                int x, y;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   127
                x = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 0)) + 32768);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   128
                x *= viewport.w ;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   129
                x /= 65535;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   130
                if (x < 0) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   131
                    x = 0;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   132
                } else if (x > (viewport.w - 16)) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   133
                    x = viewport.w - 16;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   134
                }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   135
                y = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 1)) + 32768);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   136
                y *= viewport.h;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   137
                y /= 65535;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   138
                if (y < 0) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   139
                    y = 0;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   140
                } else if (y > (viewport.h - 16)) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   141
                    y = viewport.h - 16;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   142
                }
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   143
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   144
                DrawRect(screen, x, y, 16, 16);
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   145
            }
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   146
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   147
            SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   148
            for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   149
                /* Derive the new position */
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   150
                int x = viewport.w/2;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   151
                int y = viewport.h/2;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   152
                const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   153
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   154
                if (hat_pos & SDL_HAT_UP) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   155
                    y = 0;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   156
                } else if (hat_pos & SDL_HAT_DOWN) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   157
                    y = viewport.h-8;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   158
                }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   159
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   160
                if (hat_pos & SDL_HAT_LEFT) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   161
                    x = 0;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   162
                } else if (hat_pos & SDL_HAT_RIGHT) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   163
                    x = viewport.w-8;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   164
                }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   165
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   166
                DrawRect(screen, x, y, 8, 8);
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   167
            }
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   168
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   169
            SDL_RenderPresent(screen);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   170
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   171
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   172
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   173
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   174
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   175
main(int argc, char *argv[])
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   176
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   177
    const char *name;
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   178
    int i, joy=-1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   179
    SDL_Joystick *joystick;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   180
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   181
    /* Initialize SDL (Note: video is required to start event loop) */
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   182
    if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   183
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   184
        exit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   185
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   186
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   187
    /* Initialize test framework */
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   188
    state = CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   189
    if (!state) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   190
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   191
        return 1;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   192
    }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   193
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   194
    /* Print information about the joysticks */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   195
    printf("There are %d joysticks attached\n", SDL_NumJoysticks());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   196
    for (i = 0; i < SDL_NumJoysticks(); ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   197
        name = SDL_JoystickName(i);
2201
Sam Lantinga <slouken@libsdl.org>
parents: 2200
diff changeset
   198
        printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
2200
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   199
        joystick = SDL_JoystickOpen(i);
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   200
        if (joystick == NULL) {
2201
Sam Lantinga <slouken@libsdl.org>
parents: 2200
diff changeset
   201
            fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
Sam Lantinga <slouken@libsdl.org>
parents: 2200
diff changeset
   202
                    SDL_GetError());
2200
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   203
        } else {
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   204
            printf("       axes: %d\n", SDL_JoystickNumAxes(joystick));
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   205
            printf("      balls: %d\n", SDL_JoystickNumBalls(joystick));
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   206
            printf("       hats: %d\n", SDL_JoystickNumHats(joystick));
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   207
            printf("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   208
            SDL_JoystickClose(joystick);
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   209
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   210
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   211
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   212
    for (i = 1; i < argc;) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   213
        int consumed;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   214
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   215
        consumed = CommonArg(state, i);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   216
        if (consumed == 0) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   217
            consumed = -1;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   218
            if (SDL_isdigit(*argv[i])) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   219
                joy = SDL_atoi(argv[i]);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   220
                consumed = 1;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   221
            }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   222
        }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   223
        if (consumed < 0) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   224
            return 1;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   225
        }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   226
        i += consumed;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   227
    }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   228
    if (!CommonInit(state)) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   229
        return 2;
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   230
    }
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   231
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   232
    if (joy > -1) {
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   233
        joystick = SDL_JoystickOpen(joy);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   234
        if (joystick == NULL) {
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   235
            printf("Couldn't open joystick %d: %s\n", joy,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   236
                   SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   237
        } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   238
            WatchJoystick(joystick);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   239
            SDL_JoystickClose(joystick);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   240
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   241
    }
6586
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   242
    SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
ab57cc69dcc0 Updated testjoystick for SDL 2.0 API - patch from simon
Sam Lantinga <slouken@libsdl.org>
parents: 6398
diff changeset
   243
    CommonQuit(state);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   244
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1855
diff changeset
   245
    return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   246
}