test/testjoystick.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 9998 f67cf37e9cd4
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
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
/*
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9922
diff changeset
     2
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
5535
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"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    21
#ifdef __EMSCRIPTEN__
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    22
#include <emscripten/emscripten.h>
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    23
#endif
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    24
6771
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
    25
#ifndef SDL_JOYSTICK_DISABLED
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
    26
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    27
#ifdef __IPHONEOS__
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7017
diff changeset
    28
#define SCREEN_WIDTH    320
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7017
diff changeset
    29
#define SCREEN_HEIGHT   480
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    30
#else
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7017
diff changeset
    31
#define SCREEN_WIDTH    640
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7017
diff changeset
    32
#define SCREEN_HEIGHT   480
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    33
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    34
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    35
SDL_Renderer *screen = NULL;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    36
SDL_bool retval = SDL_FALSE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    37
SDL_bool done = SDL_FALSE;
6771
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
    38
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    39
static void
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    40
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
    41
{
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    42
    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
    43
    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
    44
}
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    45
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    46
void
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    47
loop(void *arg)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    48
{
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    49
    SDL_Event event;
6398
c294faf5fce5 Cleaned up testjoystick.c, improved usage of renderer API, added colors!
Ryan C. Gordon <icculus@icculus.org>
parents: 6397
diff changeset
    50
    int i;
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    51
    SDL_Joystick *joystick = (SDL_Joystick *)arg;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    52
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    53
        /* blank screen, set up for drawing this frame. */
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
    54
    SDL_SetRenderDrawColor(screen, 0x0, 0x0, 0x0, SDL_ALPHA_OPAQUE);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    55
        SDL_RenderClear(screen);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
    56
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) {
9433
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    59
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    60
            case SDL_JOYDEVICEREMOVED:
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    61
                SDL_Log("Joystick device %d removed.\n", (int) event.jdevice.which);
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    62
                SDL_Log("Our instance ID is %d\n", (int) SDL_JoystickInstanceID(joystick));
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    63
                break;
bd062398b648 Cleanups in the joystick code.
Ryan C. Gordon <icculus@icculus.org>
parents: 9340
diff changeset
    64
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
    65
            case SDL_JOYAXISMOTION:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    66
                SDL_Log("Joystick %d axis %d value: %d\n",
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
    67
                       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
    68
                       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
    69
                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
    70
            case SDL_JOYHATMOTION:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    71
                SDL_Log("Joystick %d hat %d value:",
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
    72
                       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
    73
                if (event.jhat.value == SDL_HAT_CENTERED)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    74
                    SDL_Log(" centered");
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
    75
                if (event.jhat.value & SDL_HAT_UP)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    76
                    SDL_Log(" up");
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
    77
                if (event.jhat.value & SDL_HAT_RIGHT)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    78
                    SDL_Log(" right");
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
    79
                if (event.jhat.value & SDL_HAT_DOWN)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    80
                    SDL_Log(" down");
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
    81
                if (event.jhat.value & SDL_HAT_LEFT)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    82
                    SDL_Log(" left");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    83
                SDL_Log("\n");
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
    84
                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
    85
            case SDL_JOYBALLMOTION:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    86
                SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
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
    87
                       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
    88
                       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
    89
                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
    90
            case SDL_JOYBUTTONDOWN:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    91
                SDL_Log("Joystick %d button %d down\n",
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
    92
                       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
    93
                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
    94
            case SDL_JOYBUTTONUP:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    95
                SDL_Log("Joystick %d button %d up\n",
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
    96
                       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
    97
                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
    98
            case SDL_KEYDOWN:
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
    99
                if ((event.key.keysym.sym != SDLK_ESCAPE) &&
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   100
                    (event.key.keysym.sym != SDLK_AC_BACK)) {
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
   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
                /* Fall through to signal quit */
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   104
            case SDL_FINGERDOWN:
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   105
            case SDL_MOUSEBUTTONDOWN:
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
   106
            case SDL_QUIT:
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   107
                done = SDL_TRUE;
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
   108
                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
   109
            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
   110
                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
   111
            }
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
   112
        }
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
   113
        /* Update visual joystick state */
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   114
        SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   115
        for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   116
            if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   117
                DrawRect(screen, (i%20) * 34, SCREEN_HEIGHT - 68 + (i/20) * 34, 32, 32);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   118
            }
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   119
        }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   120
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   121
        SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   122
        for (i = 0; i < SDL_JoystickNumAxes(joystick); ++i) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   123
            /* Draw the X/Y axis */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   124
            int x, y;
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   125
            x = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   126
            x *= SCREEN_WIDTH;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   127
            x /= 65535;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   128
            if (x < 0) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   129
                x = 0;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   130
            } else if (x > (SCREEN_WIDTH - 16)) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   131
                x = SCREEN_WIDTH - 16;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   132
            }
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   133
            ++i;
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   134
            if (i < SDL_JoystickNumAxes(joystick)) {
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   135
                y = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   136
            } else {
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   137
                y = 32768;
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   138
            }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   139
            y *= SCREEN_HEIGHT;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   140
            y /= 65535;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   141
            if (y < 0) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   142
                y = 0;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   143
            } else if (y > (SCREEN_HEIGHT - 16)) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   144
                y = SCREEN_HEIGHT - 16;
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
   145
            }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2201
diff changeset
   146
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   147
            DrawRect(screen, x, y, 16, 16);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   148
        }
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   149
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   150
        SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   151
        for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   152
            /* Derive the new position */
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   153
            int x = SCREEN_WIDTH/2;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   154
            int y = SCREEN_HEIGHT/2;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   155
            const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i);
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   156
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   157
            if (hat_pos & SDL_HAT_UP) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   158
                y = 0;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   159
            } else if (hat_pos & SDL_HAT_DOWN) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   160
                y = SCREEN_HEIGHT-8;
6397
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   161
            }
efdf44f20799 Updated testjoystick.c for SDL2 API and draw more information.
Ryan C. Gordon <icculus@icculus.org>
parents: 6256
diff changeset
   162
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   163
            if (hat_pos & SDL_HAT_LEFT) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   164
                x = 0;
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   165
            } else if (hat_pos & SDL_HAT_RIGHT) {
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   166
                x = SCREEN_WIDTH-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
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   169
            DrawRect(screen, x, y, 8, 8);
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
        }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   171
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   172
        SDL_RenderPresent(screen);
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   173
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   174
        if (SDL_JoystickGetAttached( joystick ) == 0) {
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   175
            done = SDL_TRUE;
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   176
            retval = SDL_TRUE;  /* keep going, wait for reattach. */
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   177
        }
9607
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   178
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   179
#ifdef __EMSCRIPTEN__
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   180
    if (done) {
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   181
        emscripten_cancel_main_loop();
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   182
    }
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9433
diff changeset
   183
#endif
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   184
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   185
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   186
static SDL_bool
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   187
WatchJoystick(SDL_Joystick * joystick)
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   188
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   189
    SDL_Window *window = NULL;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   190
    const char *name = NULL;
9340
af5be9462bb4 Fixed test programs for joystick not exiting on events after first disconnect.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9338
diff changeset
   191
af5be9462bb4 Fixed test programs for joystick not exiting on events after first disconnect.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9338
diff changeset
   192
    retval = SDL_FALSE;
9338
86bc1c9a090f Fixed bug 2873 - Joystick test won't reload after reattach
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   193
    done = SDL_FALSE;
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   194
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   195
    /* Create a window to display joystick axis position */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   196
    window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   197
                              SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   198
                              SCREEN_HEIGHT, 0);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   199
    if (window == NULL) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   200
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   201
        return SDL_FALSE;
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
   202
    }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   203
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   204
    screen = SDL_CreateRenderer(window, -1, 0);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   205
    if (screen == NULL) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   206
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   207
        SDL_DestroyWindow(window);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   208
        return SDL_FALSE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   209
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   210
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   211
    SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   212
    SDL_RenderClear(screen);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   213
    SDL_RenderPresent(screen);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   214
    SDL_RaiseWindow(window);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   215
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   216
    /* Print info about the joystick we are watching */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   217
    name = SDL_JoystickName(joystick);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   218
    SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   219
           name ? name : "Unknown Joystick");
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   220
    SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   221
           SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   222
           SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   223
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   224
    /* Loop, getting joystick events! */
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   225
#ifdef __EMSCRIPTEN__
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   226
    emscripten_set_main_loop_arg(loop, joystick, 0, 1);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   227
#else
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   228
    while (!done) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   229
        loop(joystick);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   230
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   231
#endif
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 8762
diff changeset
   232
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   233
    SDL_DestroyRenderer(screen);
9340
af5be9462bb4 Fixed test programs for joystick not exiting on events after first disconnect.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9338
diff changeset
   234
    screen = NULL;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   235
    SDL_DestroyWindow(window);
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   236
    return retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   237
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   238
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
   239
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
   240
main(int argc, char *argv[])
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   241
{
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
   242
    const char *name;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   243
    int i;
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
   244
    SDL_Joystick *joystick;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   245
9876
1496e502e51d Added initial support for MFi game controllers on iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 9619
diff changeset
   246
    SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
1496e502e51d Added initial support for MFi game controllers on iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 9619
diff changeset
   247
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   248
    /* Enable standard application logging */
9922
b066d5fd5fa7 Replaced tabs with spaces in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9916
diff changeset
   249
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   250
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
   251
    /* Initialize SDL (Note: video is required to start event loop) */
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   252
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   253
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
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
   254
        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
   255
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   256
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
   257
    /* Print information about the joysticks */
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   258
    SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks());
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
   259
    for (i = 0; i < SDL_NumJoysticks(); ++i) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   260
        name = SDL_JoystickNameForIndex(i);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   261
        SDL_Log("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
   262
        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
   263
        if (joystick == NULL) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   264
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
2201
Sam Lantinga <slouken@libsdl.org>
parents: 2200
diff changeset
   265
                    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
   266
        } else {
6747
b617821795bf Patched testjoystick.c to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 6736
diff changeset
   267
            char guid[64];
9916
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   268
            SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
6747
b617821795bf Patched testjoystick.c to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 6736
diff changeset
   269
            SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
b617821795bf Patched testjoystick.c to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 6736
diff changeset
   270
                                      guid, sizeof (guid));
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   271
            SDL_Log("       axes: %d\n", SDL_JoystickNumAxes(joystick));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   272
            SDL_Log("      balls: %d\n", SDL_JoystickNumBalls(joystick));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   273
            SDL_Log("       hats: %d\n", SDL_JoystickNumHats(joystick));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   274
            SDL_Log("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   275
            SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   276
            SDL_Log("       guid: %s\n", guid);
2200
893c862eed86 Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
   277
            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
   278
        }
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
   279
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   280
9876
1496e502e51d Added initial support for MFi game controllers on iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 9619
diff changeset
   281
#if defined(__ANDROID__) || defined(__IPHONEOS__)
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   282
    if (SDL_NumJoysticks() > 0) {
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   283
#else
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   284
    if (argv[1]) {
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   285
#endif
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   286
        SDL_bool reportederror = SDL_FALSE;
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   287
        SDL_bool keepGoing = SDL_TRUE;
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   288
        SDL_Event event;
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   289
        int device;
9876
1496e502e51d Added initial support for MFi game controllers on iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 9619
diff changeset
   290
#if defined(__ANDROID__) || defined(__IPHONEOS__)
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   291
        device = 0;
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   292
#else
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   293
        device = atoi(argv[1]);
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   294
#endif
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   295
        joystick = SDL_JoystickOpen(device);
9916
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   296
        if (joystick != NULL) {
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   297
            SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   298
        }
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   299
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   300
        while ( keepGoing ) {
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   301
            if (joystick == NULL) {
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   302
                if ( !reportederror ) {
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   303
                    SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
6732
b4201930fb9f Don't hang testjoystick if we failed to open the device in the first place.
Ryan C. Gordon <icculus@icculus.org>
parents: 6731
diff changeset
   304
                    keepGoing = SDL_FALSE;
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   305
                    reportederror = SDL_TRUE;
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   306
                }
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   307
            } else {
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   308
                reportederror = SDL_FALSE;
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   309
                keepGoing = WatchJoystick(joystick);
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   310
                SDL_JoystickClose(joystick);
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   311
            }
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   312
6736
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   313
            joystick = NULL;
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   314
            if (keepGoing) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   315
                SDL_Log("Waiting for attach\n");
6736
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   316
            }
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   317
            while (keepGoing) {
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   318
                SDL_WaitEvent(&event);
7017
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   319
                if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN)
7c2eb015a6d7 Fixed bug 1759 - Updates to testjoystick.c
Sam Lantinga <slouken@libsdl.org>
parents: 6771
diff changeset
   320
                    || (event.type == SDL_MOUSEBUTTONDOWN)) {
6736
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   321
                    keepGoing = SDL_FALSE;
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   322
                } else if (event.type == SDL_JOYDEVICEADDED) {
8078
ef59ad725ac5 Fixed access of command line arguments on Android in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8073
diff changeset
   323
                    joystick = SDL_JoystickOpen(device);
9916
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   324
                    if (joystick != NULL) {
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   325
                        SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
9429bc102632 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Ryan C. Gordon <icculus@icculus.org>
parents: 9876
diff changeset
   326
                    }
6736
03dd4a1d06e9 You can get window events after shutting down the window, so don't abort the program if that happens.
Sam Lantinga <slouken@libsdl.org>
parents: 6733
diff changeset
   327
                    break;
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   328
                }
6730
36158e4061f4 Allow testjoystick to quit, instead of looping on hotplug events forever.
Ryan C. Gordon <icculus@icculus.org>
parents: 6690
diff changeset
   329
            }
6731
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   330
        }
572559876818 Cleaned out tabstops, other minor style nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 6730
diff changeset
   331
    }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6586
diff changeset
   332
    SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   333
8073
ccbeeb164979 Fixed missing return warning in test program source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8048
diff changeset
   334
    return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   335
}
6771
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   336
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   337
#else
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   338
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   339
int
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   340
main(int argc, char *argv[])
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   341
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   342
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
6771
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   343
    exit(1);
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   344
}
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   345
55337ff4256f Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6747
diff changeset
   346
#endif