test/testrumble.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sat, 22 Dec 2012 20:43:51 -0800
changeset 6771 55337ff4256f
parent 5535 96594ac5fd1a
child 7437 964e8876ad3b
permissions -rw-r--r--
Fix compiler warning; minor harness driver cleanup; fix test build for SDL versions compiled with --disable-joystick or --disable-haptic
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: 5360
diff changeset
     1
/*
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5360
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: 5360
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5360
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: 5360
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: 5360
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: 5360
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5360
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: 5360
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: 5360
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5360
diff changeset
    11
*/
5360
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
/*
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
Copyright (c) 2011, Edgar Simo Serra
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
All rights reserved.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    * Neither the name of the Simple Directmedia Layer (SDL) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
*/
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
/*
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
 * includes
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
 */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include <stdlib.h>
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include <stdio.h>              /* printf */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include <string.h>             /* strstr */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#include <ctype.h>              /* isdigit */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
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: 5535
diff changeset
    33
#include "SDL.h"
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: 5535
diff changeset
    34
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: 5535
diff changeset
    35
#ifndef SDL_HAPTIC_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: 5535
diff changeset
    36
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: 5535
diff changeset
    37
#include "SDL_haptic.h"
5360
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
static SDL_Haptic *haptic;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
/**
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
 * @brief The entry point of this force feedback demo.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
 * @param[in] argc Number of arguments.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
 * @param[in] argv Array of argc arguments.
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
 */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
int
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
main(int argc, char **argv)
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
{
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
    int i;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
    char *name;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
    int index;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
    SDL_HapticEffect efx[5];
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
    int id[5];
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    int nefx;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
    unsigned int supported;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    name = NULL;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    index = -1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    if (argc > 1) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
        name = argv[1];
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
        if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
            printf("USAGE: %s [device]\n"
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
                   "If device is a two-digit number it'll use it as an index, otherwise\n"
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
                   "it'll use it as if it were part of the device's name.\n",
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
                   argv[0]);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
            return 0;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
        }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
        i = strlen(name);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
        if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
            index = atoi(name);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
            name = NULL;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
        }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    /* Initialize the force feedbackness */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
             SDL_INIT_HAPTIC);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    printf("%d Haptic devices detected.\n", SDL_NumHaptics());
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    if (SDL_NumHaptics() > 0) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        /* We'll just use index or the first force feedback device found */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        if (name == NULL) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
            i = (index != -1) ? index : 0;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
        }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
        /* Try to find matching device */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
        else {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
            for (i = 0; i < SDL_NumHaptics(); i++) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
                if (strstr(SDL_HapticName(i), name) != NULL)
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
                    break;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
            }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
            if (i >= SDL_NumHaptics()) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
                printf("Unable to find device matching '%s', aborting.\n",
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
                       name);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
                return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
            }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
        }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
        haptic = SDL_HapticOpen(i);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
        if (haptic == NULL) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
            printf("Unable to create the haptic device: %s\n",
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
                   SDL_GetError());
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
            return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
        }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
        printf("Device: %s\n", SDL_HapticName(i));
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    } else {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
        printf("No Haptic devices found!\n");
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
        return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
    /* We only want force feedback errors. */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
    SDL_ClearError();
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
        printf("\nRumble not supported!\n");
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
        return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
    if (SDL_HapticRumbleInit(haptic) != 0) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
        printf("\nFailed to initialize rumble: %s\n", SDL_GetError());
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
        return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    printf("Playing 2 second rumble at 0.5 magnitude.\n");
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
       return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
    SDL_Delay(2000);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    printf("Stopping rumble.\n");
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
    SDL_HapticRumbleStop(haptic);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
    SDL_Delay(2000);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
    printf("Playing 2 second rumble at 0.3 magnitude.\n");
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
    if (SDL_HapticRumblePlay(haptic, 0.3, 5000) != 0) {
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
       return 1;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    }
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    SDL_Delay(2000);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    /* Quit */
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
    if (haptic != NULL)
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
        SDL_HapticClose(haptic);
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
    SDL_Quit();
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
    return 0;
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
}
220d3af9121f Simple rumble API for haptic
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
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: 5535
diff changeset
   147
#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: 5535
diff changeset
   148
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: 5535
diff changeset
   149
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: 5535
diff changeset
   150
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: 5535
diff changeset
   151
{
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: 5535
diff changeset
   152
    fprintf(stderr, "SDL compiled without Haptic support.\n");
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: 5535
diff changeset
   153
    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: 5535
diff changeset
   154
}
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: 5535
diff changeset
   155
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: 5535
diff changeset
   156
#endif