test/testhotplug.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 06 Feb 2014 07:38:41 -0500
changeset 8181 3632013330ad
parent 8180 16afd5b764b3
child 8188 47b9ab82bebf
permissions -rw-r--r--
Fixed return values on testhotplug mainline.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     1
/*
8180
16afd5b764b3 Fixed copyright date.
Ryan C. Gordon <icculus@icculus.org>
parents: 8169
diff changeset
     2
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     3
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     4
  This software is provided 'as-is', without any express or implied
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     6
  arising from the use of this software.
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     7
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    10
  freely.
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    11
*/
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    12
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    13
/* Simple program to test the SDL joystick hotplugging */
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    14
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    15
#include <stdio.h>
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    16
#include <stdlib.h>
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    17
#include <string.h>
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    18
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    19
#include "SDL.h"
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    20
#include "SDL_haptic.h"
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    21
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    22
#ifndef SDL_JOYSTICK_DISABLED
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    23
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    24
int
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    25
main(int argc, char *argv[])
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    26
{
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    27
    SDL_Joystick *joystick = NULL;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    28
    SDL_Haptic *haptic = NULL;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    29
    SDL_JoystickID instance = -1;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    30
    SDL_bool keepGoing = SDL_TRUE;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    31
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    32
    /* Enable standard application logging */
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    33
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);	
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    34
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    35
    SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    36
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    37
    /* Initialize SDL (Note: video is required to start event loop) */
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    38
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0) {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    39
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    40
        exit(1);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    41
    }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    42
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    43
    //SDL_CreateWindow("Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, 0);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    44
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    45
    SDL_Log("There are %d joysticks at startup\n", SDL_NumJoysticks());
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    46
    SDL_Log("There are %d haptic devices at startup\n", SDL_NumHaptics());
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    47
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    48
    while(keepGoing)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    49
    {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    50
        SDL_Event event;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    51
        while(SDL_PollEvent(&event))
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    52
        {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    53
            switch(event.type)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    54
            {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    55
                case SDL_QUIT:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    56
                    keepGoing = SDL_FALSE;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    57
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    58
                case SDL_JOYDEVICEADDED:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    59
                    if (joystick != NULL)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    60
                    {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    61
                        SDL_Log("Only one joystick supported by this test\n");
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    62
                    }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    63
                    else
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    64
                    {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    65
                        joystick = SDL_JoystickOpen(event.jdevice.which);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    66
                        instance = SDL_JoystickInstanceID(joystick);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    67
                        SDL_Log("Joy Added  : %d : %s\n", event.jdevice.which, SDL_JoystickName(joystick));
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    68
                        if (SDL_JoystickIsHaptic(joystick))
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    69
                        {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    70
                            haptic = SDL_HapticOpenFromJoystick(joystick);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    71
                            if (haptic)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    72
                            {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    73
                                SDL_Log("Joy Haptic Opened\n");
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    74
                                if (SDL_HapticRumbleInit( haptic ) != 0)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    75
                                {
8166
d1be9ce49463 testhotplug: Actually log the SDL_Error that occured on failures
Edward Rudd <urkle@outoforder.cc>
parents: 8165
diff changeset
    76
                                    SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    77
                                    SDL_HapticClose(haptic);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    78
                                    haptic = NULL;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    79
                                }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    80
                            } else {
8166
d1be9ce49463 testhotplug: Actually log the SDL_Error that occured on failures
Edward Rudd <urkle@outoforder.cc>
parents: 8165
diff changeset
    81
                                SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError());
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    82
                            }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    83
                        }
8165
2b8ba3d53a67 add logging for the case when haptic is not detected on the joystick as well.
Edward Rudd <urkle@outoforder.cc>
parents: 8164
diff changeset
    84
                        else
2b8ba3d53a67 add logging for the case when haptic is not detected on the joystick as well.
Edward Rudd <urkle@outoforder.cc>
parents: 8164
diff changeset
    85
                        {
2b8ba3d53a67 add logging for the case when haptic is not detected on the joystick as well.
Edward Rudd <urkle@outoforder.cc>
parents: 8164
diff changeset
    86
                            SDL_Log("No haptic found\n");
2b8ba3d53a67 add logging for the case when haptic is not detected on the joystick as well.
Edward Rudd <urkle@outoforder.cc>
parents: 8164
diff changeset
    87
                        }
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    88
                    }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    89
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    90
                case SDL_JOYDEVICEREMOVED:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    91
                    if (instance == event.jdevice.which)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    92
                    {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    93
                        SDL_Log("Joy Removed: %d\n", event.jdevice.which);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    94
                        instance = -1;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    95
                        if(haptic)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    96
                        {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    97
                            SDL_HapticClose(haptic);
8165
2b8ba3d53a67 add logging for the case when haptic is not detected on the joystick as well.
Edward Rudd <urkle@outoforder.cc>
parents: 8164
diff changeset
    98
                            haptic = NULL;
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
    99
                        }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   100
                        SDL_JoystickClose(joystick);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   101
                        joystick = NULL;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   102
                    } else {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   103
                        SDL_Log("Unknown joystick diconnected\n");
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   104
                    }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   105
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   106
                case SDL_JOYAXISMOTION:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   107
//                    SDL_Log("Axis Move: %d\n", event.jaxis.axis);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   108
                    SDL_HapticRumblePlay(haptic, 0.2, 250);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   109
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   110
                case SDL_JOYBUTTONDOWN:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   111
                    SDL_Log("Button Press: %d\n", event.jbutton.button);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   112
                    if(haptic)
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   113
                    {
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   114
                        SDL_HapticRumblePlay(haptic, 0.2, 250);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   115
                    }
8169
663ba61243ff allow safely quitting the hotplug test by pressing button 0 on the joystick
Edward Rudd <urkle@outoforder.cc>
parents: 8166
diff changeset
   116
					if (event.jbutton.button == 0) {
663ba61243ff allow safely quitting the hotplug test by pressing button 0 on the joystick
Edward Rudd <urkle@outoforder.cc>
parents: 8166
diff changeset
   117
						SDL_Log("Exiting due to button press of button 0\n");
663ba61243ff allow safely quitting the hotplug test by pressing button 0 on the joystick
Edward Rudd <urkle@outoforder.cc>
parents: 8166
diff changeset
   118
						keepGoing = SDL_FALSE;
663ba61243ff allow safely quitting the hotplug test by pressing button 0 on the joystick
Edward Rudd <urkle@outoforder.cc>
parents: 8166
diff changeset
   119
					}
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   120
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   121
                case SDL_JOYBUTTONUP:
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   122
                    SDL_Log("Button Release: %d\n", event.jbutton.button);
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   123
                    break;
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   124
            }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   125
        }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   126
    }
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   127
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   128
    SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
8181
3632013330ad Fixed return values on testhotplug mainline.
Ryan C. Gordon <icculus@icculus.org>
parents: 8180
diff changeset
   129
3632013330ad Fixed return values on testhotplug mainline.
Ryan C. Gordon <icculus@icculus.org>
parents: 8180
diff changeset
   130
    return 0;
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   131
}
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   132
#else
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   133
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   134
int
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   135
main(int argc, char *argv[])
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   136
{
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   137
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
8181
3632013330ad Fixed return values on testhotplug mainline.
Ryan C. Gordon <icculus@icculus.org>
parents: 8180
diff changeset
   138
    return 1;
8164
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   139
}
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   140
478fbe1f032f add simple test showing off hotplugging of joysticks w/ haptic.
Edward Rudd <urkle@outoforder.cc>
parents:
diff changeset
   141
#endif