test/testhaptic.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 17 Sep 2014 14:49:36 -0400
changeset 9147 6bf589c8d549
parent 9072 0c1a46c018aa
child 9356 e87d6e1e812a
permissions -rw-r--r--
Haptic: Deal with negative periodic magnitudes (thanks, Elias!).

A negative periodic magnitude doesn't exist in Windows' and MacOS' FF APIs

The periodic magnitude parameter of the SDL Haptic API is based on the Linux
FF API, so it means they are not directly compatible:
'dwMagnitude' is a 'DWORD', which is unsigned.

Fixes Bugzilla #2701.
slouken@2713
     1
/*
slouken@2713
     2
Copyright (c) 2008, Edgar Simo Serra
slouken@2713
     3
All rights reserved.
slouken@2713
     4
slouken@2713
     5
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
slouken@2713
     6
slouken@2713
     7
    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
slouken@2713
     8
    * 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.
slouken@2713
     9
    * 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.
slouken@2713
    10
slouken@2713
    11
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.
slouken@2713
    12
*/
slouken@2713
    13
slouken@2713
    14
/*
slouken@2713
    15
 * includes
slouken@2713
    16
 */
slouken@3338
    17
#include <stdlib.h>
slouken@2713
    18
#include <string.h>             /* strstr */
bobbens@2748
    19
#include <ctype.h>              /* isdigit */
slouken@2713
    20
aschiffler@6771
    21
#include "SDL.h"
aschiffler@6771
    22
aschiffler@6771
    23
#ifndef SDL_HAPTIC_DISABLED
aschiffler@6771
    24
aschiffler@6771
    25
#include "SDL_haptic.h"
slouken@2713
    26
slouken@2713
    27
static SDL_Haptic *haptic;
slouken@2713
    28
slouken@2713
    29
slouken@2713
    30
/*
slouken@2713
    31
 * prototypes
slouken@2713
    32
 */
slouken@2713
    33
static void abort_execution(void);
slouken@2713
    34
static void HapticPrintSupported(SDL_Haptic * haptic);
slouken@2713
    35
slouken@2713
    36
slouken@2713
    37
/**
slouken@2713
    38
 * @brief The entry point of this force feedback demo.
slouken@2713
    39
 * @param[in] argc Number of arguments.
slouken@2713
    40
 * @param[in] argv Array of argc arguments.
slouken@2713
    41
 */
slouken@2713
    42
int
slouken@2713
    43
main(int argc, char **argv)
slouken@2713
    44
{
slouken@2713
    45
    int i;
slouken@2713
    46
    char *name;
bobbens@2748
    47
    int index;
icculus@9072
    48
    SDL_HapticEffect efx[9];
icculus@9072
    49
    int id[9];
slouken@2713
    50
    int nefx;
slouken@2713
    51
    unsigned int supported;
slouken@2713
    52
aschiffler@7639
    53
    /* Enable standard application logging */
aschiffler@7639
    54
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
aschiffler@7639
    55
slouken@2713
    56
    name = NULL;
bobbens@2748
    57
    index = -1;
slouken@2713
    58
    if (argc > 1) {
slouken@2713
    59
        name = argv[1];
slouken@2713
    60
        if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
aschiffler@7639
    61
            SDL_Log("USAGE: %s [device]\n"
bobbens@2748
    62
                   "If device is a two-digit number it'll use it as an index, otherwise\n"
bobbens@2748
    63
                   "it'll use it as if it were part of the device's name.\n",
bobbens@2748
    64
                   argv[0]);
slouken@2713
    65
            return 0;
slouken@2713
    66
        }
bobbens@2748
    67
bobbens@2748
    68
        i = strlen(name);
bobbens@2748
    69
        if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) {
bobbens@2748
    70
            index = atoi(name);
bobbens@2748
    71
            name = NULL;
bobbens@2748
    72
        }
slouken@2713
    73
    }
slouken@2713
    74
slouken@2713
    75
    /* Initialize the force feedbackness */
slouken@2713
    76
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
slouken@2713
    77
             SDL_INIT_HAPTIC);
aschiffler@7639
    78
    SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
slouken@2713
    79
    if (SDL_NumHaptics() > 0) {
bobbens@2748
    80
        /* We'll just use index or the first force feedback device found */
slouken@2713
    81
        if (name == NULL) {
bobbens@2748
    82
            i = (index != -1) ? index : 0;
slouken@2713
    83
        }
slouken@2713
    84
        /* Try to find matching device */
slouken@2713
    85
        else {
slouken@2713
    86
            for (i = 0; i < SDL_NumHaptics(); i++) {
slouken@2713
    87
                if (strstr(SDL_HapticName(i), name) != NULL)
slouken@2713
    88
                    break;
slouken@2713
    89
            }
slouken@2713
    90
slouken@2713
    91
            if (i >= SDL_NumHaptics()) {
aschiffler@7639
    92
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
slouken@2713
    93
                       name);
slouken@2713
    94
                return 1;
slouken@2713
    95
            }
slouken@2713
    96
        }
slouken@2713
    97
slouken@2713
    98
        haptic = SDL_HapticOpen(i);
slouken@2713
    99
        if (haptic == NULL) {
aschiffler@7639
   100
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
bobbens@2748
   101
                   SDL_GetError());
slouken@2713
   102
            return 1;
slouken@2713
   103
        }
aschiffler@7639
   104
        SDL_Log("Device: %s\n", SDL_HapticName(i));
slouken@2713
   105
        HapticPrintSupported(haptic);
slouken@2713
   106
    } else {
aschiffler@7639
   107
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
slouken@2713
   108
        return 1;
slouken@2713
   109
    }
slouken@2713
   110
slouken@2713
   111
    /* We only want force feedback errors. */
slouken@2713
   112
    SDL_ClearError();
slouken@2713
   113
slouken@2713
   114
    /* Create effects. */
slouken@2713
   115
    memset(&efx, 0, sizeof(efx));
slouken@2713
   116
    nefx = 0;
slouken@2713
   117
    supported = SDL_HapticQuery(haptic);
slouken@2713
   118
aschiffler@7639
   119
    SDL_Log("\nUploading effects\n");
slouken@2713
   120
    /* First we'll try a SINE effect. */
slouken@2713
   121
    if (supported & SDL_HAPTIC_SINE) {
aschiffler@7639
   122
        SDL_Log("   effect %d: Sine Wave\n", nefx);
slouken@2713
   123
        efx[nefx].type = SDL_HAPTIC_SINE;
slouken@2713
   124
        efx[nefx].periodic.period = 1000;
icculus@9147
   125
        efx[nefx].periodic.magnitude = -0x2000;    /* Negative magnitude and ...                      */
icculus@9147
   126
        efx[nefx].periodic.phase = 18000;          /* ... 180 degrees phase shift => cancel eachother */
slouken@2713
   127
        efx[nefx].periodic.length = 5000;
slouken@2713
   128
        efx[nefx].periodic.attack_length = 1000;
slouken@2713
   129
        efx[nefx].periodic.fade_length = 1000;
slouken@2713
   130
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
slouken@2713
   131
        if (id[nefx] < 0) {
aschiffler@7639
   132
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
slouken@2713
   133
            abort_execution();
slouken@2713
   134
        }
slouken@2713
   135
        nefx++;
slouken@2713
   136
    }
slouken@2713
   137
    /* Now we'll try a SAWTOOTHUP */
slouken@2713
   138
    if (supported & SDL_HAPTIC_SAWTOOTHUP) {
aschiffler@7639
   139
        SDL_Log("   effect %d: Sawtooth Up\n", nefx);
philipp@7263
   140
        efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP;
slouken@2713
   141
        efx[nefx].periodic.period = 500;
slouken@2713
   142
        efx[nefx].periodic.magnitude = 0x5000;
slouken@2713
   143
        efx[nefx].periodic.length = 5000;
slouken@2713
   144
        efx[nefx].periodic.attack_length = 1000;
slouken@2713
   145
        efx[nefx].periodic.fade_length = 1000;
slouken@2713
   146
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
slouken@2713
   147
        if (id[nefx] < 0) {
aschiffler@7639
   148
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
slouken@2713
   149
            abort_execution();
slouken@2713
   150
        }
slouken@2713
   151
        nefx++;
slouken@2713
   152
    }
icculus@9072
   153
    
slouken@2713
   154
    /* Now the classical constant effect. */
slouken@2713
   155
    if (supported & SDL_HAPTIC_CONSTANT) {
aschiffler@7639
   156
        SDL_Log("   effect %d: Constant Force\n", nefx);
slouken@2713
   157
        efx[nefx].type = SDL_HAPTIC_CONSTANT;
slouken@2713
   158
        efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR;
slouken@2713
   159
        efx[nefx].constant.direction.dir[0] = 20000;    /* Force comes from the south-west. */
slouken@2713
   160
        efx[nefx].constant.length = 5000;
slouken@2713
   161
        efx[nefx].constant.level = 0x6000;
slouken@2713
   162
        efx[nefx].constant.attack_length = 1000;
slouken@2713
   163
        efx[nefx].constant.fade_length = 1000;
slouken@2713
   164
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
slouken@2713
   165
        if (id[nefx] < 0) {
aschiffler@7639
   166
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
slouken@2713
   167
            abort_execution();
slouken@2713
   168
        }
slouken@2713
   169
        nefx++;
slouken@2713
   170
    }
icculus@9072
   171
    
slouken@2713
   172
    /* The cute spring effect. */
slouken@2713
   173
    if (supported & SDL_HAPTIC_SPRING) {
aschiffler@7639
   174
        SDL_Log("   effect %d: Condition Spring\n", nefx);
slouken@2713
   175
        efx[nefx].type = SDL_HAPTIC_SPRING;
slouken@2713
   176
        efx[nefx].condition.length = 5000;
slouken@2713
   177
        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
icculus@9070
   178
            efx[nefx].condition.right_sat[i] = 0xFFFF;
icculus@9070
   179
            efx[nefx].condition.left_sat[i] = 0xFFFF;
slouken@2713
   180
            efx[nefx].condition.right_coeff[i] = 0x2000;
slouken@2713
   181
            efx[nefx].condition.left_coeff[i] = 0x2000;
slouken@2713
   182
            efx[nefx].condition.center[i] = 0x1000;     /* Displace the center for it to move. */
slouken@2713
   183
        }
slouken@2713
   184
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
slouken@2713
   185
        if (id[nefx] < 0) {
aschiffler@7639
   186
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
slouken@2713
   187
            abort_execution();
slouken@2713
   188
        }
slouken@2713
   189
        nefx++;
slouken@2713
   190
    }
icculus@9072
   191
    /* The interesting damper effect. */
icculus@9072
   192
    if (supported & SDL_HAPTIC_DAMPER) {
icculus@9072
   193
        SDL_Log("   effect %d: Condition Damper\n", nefx);
icculus@9072
   194
        efx[nefx].type = SDL_HAPTIC_DAMPER;
icculus@9072
   195
        efx[nefx].condition.length = 5000;
icculus@9072
   196
        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
icculus@9072
   197
            efx[nefx].condition.right_sat[i] = 0xFFFF;
icculus@9072
   198
            efx[nefx].condition.left_sat[i] = 0xFFFF;
icculus@9072
   199
            efx[nefx].condition.right_coeff[i] = 0x2000;
icculus@9072
   200
            efx[nefx].condition.left_coeff[i] = 0x2000;
icculus@9072
   201
        }
icculus@9072
   202
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
icculus@9072
   203
        if (id[nefx] < 0) {
icculus@9072
   204
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
icculus@9072
   205
            abort_execution();
icculus@9072
   206
        }
icculus@9072
   207
        nefx++;
icculus@9072
   208
    }
slouken@2713
   209
    /* The pretty awesome inertia effect. */
slouken@2713
   210
    if (supported & SDL_HAPTIC_INERTIA) {
aschiffler@7639
   211
        SDL_Log("   effect %d: Condition Inertia\n", nefx);
slouken@8741
   212
        efx[nefx].type = SDL_HAPTIC_INERTIA;
slouken@2713
   213
        efx[nefx].condition.length = 5000;
slouken@2713
   214
        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
icculus@9070
   215
            efx[nefx].condition.right_sat[i] = 0xFFFF;
icculus@9070
   216
            efx[nefx].condition.left_sat[i] = 0xFFFF;
slouken@2713
   217
            efx[nefx].condition.right_coeff[i] = 0x2000;
slouken@2713
   218
            efx[nefx].condition.left_coeff[i] = 0x2000;
icculus@9070
   219
            efx[nefx].condition.deadband[i] = 0x1000;    /* 1/16th of axis-range around the center is 'dead'. */
slouken@2713
   220
        }
slouken@2713
   221
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
slouken@2713
   222
        if (id[nefx] < 0) {
aschiffler@7639
   223
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
slouken@2713
   224
            abort_execution();
slouken@2713
   225
        }
slouken@2713
   226
        nefx++;
slouken@2713
   227
    }
icculus@9072
   228
    /* The hot friction effect. */
icculus@9072
   229
    if (supported & SDL_HAPTIC_FRICTION) {
icculus@9072
   230
        SDL_Log("   effect %d: Condition Friction\n", nefx);
icculus@9072
   231
        efx[nefx].type = SDL_HAPTIC_FRICTION;
icculus@9072
   232
        efx[nefx].condition.length = 5000;
icculus@9072
   233
        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
icculus@9072
   234
            efx[nefx].condition.right_sat[i] = 0xFFFF;
icculus@9072
   235
            efx[nefx].condition.left_sat[i] = 0xFFFF;
icculus@9072
   236
            efx[nefx].condition.right_coeff[i] = 0x2000;
icculus@9072
   237
            efx[nefx].condition.left_coeff[i] = 0x2000;
icculus@9072
   238
        }
icculus@9072
   239
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
icculus@9072
   240
        if (id[nefx] < 0) {
icculus@9072
   241
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
icculus@9072
   242
            abort_execution();
icculus@9072
   243
        }
icculus@9072
   244
        nefx++;
icculus@9072
   245
    }
icculus@9072
   246
    
icculus@9072
   247
    /* Now we'll try a ramp effect */
icculus@9072
   248
    if (supported & SDL_HAPTIC_RAMP) {
icculus@9072
   249
        SDL_Log("   effect %d: Ramp\n", nefx);
icculus@9072
   250
        efx[nefx].type = SDL_HAPTIC_RAMP;
icculus@9072
   251
        efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN;
icculus@9072
   252
        efx[nefx].ramp.direction.dir[0] = 1;     /* Force comes from                 */
icculus@9072
   253
        efx[nefx].ramp.direction.dir[1] = -1;    /*                  the north-east. */
icculus@9072
   254
        efx[nefx].ramp.length = 5000;
icculus@9072
   255
        efx[nefx].ramp.start = 0x4000;
icculus@9072
   256
        efx[nefx].ramp.end = -0x4000;
icculus@9072
   257
        efx[nefx].ramp.attack_length = 1000;
icculus@9072
   258
        efx[nefx].ramp.fade_length = 1000;
icculus@9072
   259
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
icculus@9072
   260
        if (id[nefx] < 0) {
icculus@9072
   261
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
icculus@9072
   262
            abort_execution();
icculus@9072
   263
        }
icculus@9072
   264
        nefx++;
icculus@9072
   265
    }
slouken@2713
   266
philipp@7629
   267
    /* Finally we'll try a left/right effect. */
icculus@7621
   268
    if (supported & SDL_HAPTIC_LEFTRIGHT) {
aschiffler@7639
   269
        SDL_Log("   effect %d: Left/Right\n", nefx);
icculus@7621
   270
        efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
icculus@7621
   271
        efx[nefx].leftright.length = 5000;
icculus@7621
   272
        efx[nefx].leftright.large_magnitude = 0x3000;
icculus@7621
   273
        efx[nefx].leftright.small_magnitude = 0xFFFF;
icculus@7621
   274
        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
icculus@7621
   275
        if (id[nefx] < 0) {
aschiffler@7639
   276
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
icculus@7621
   277
            abort_execution();
icculus@7621
   278
        }
icculus@7621
   279
        nefx++;
icculus@7621
   280
    }
icculus@7621
   281
icculus@7621
   282
aschiffler@7639
   283
    SDL_Log
slouken@2713
   284
        ("\nNow playing effects for 5 seconds each with 1 second delay between\n");
slouken@2713
   285
    for (i = 0; i < nefx; i++) {
aschiffler@7639
   286
        SDL_Log("   Playing effect %d\n", i);
slouken@2713
   287
        SDL_HapticRunEffect(haptic, id[i], 1);
slouken@2713
   288
        SDL_Delay(6000);        /* Effects only have length 5000 */
slouken@2713
   289
    }
slouken@2713
   290
slouken@2713
   291
    /* Quit */
slouken@2713
   292
    if (haptic != NULL)
slouken@2713
   293
        SDL_HapticClose(haptic);
slouken@2713
   294
    SDL_Quit();
slouken@2713
   295
slouken@2713
   296
    return 0;
slouken@2713
   297
}
slouken@2713
   298
slouken@2713
   299
slouken@2713
   300
/*
slouken@2713
   301
 * Cleans up a bit.
slouken@2713
   302
 */
slouken@2713
   303
static void
slouken@2713
   304
abort_execution(void)
slouken@2713
   305
{
aschiffler@7639
   306
    SDL_Log("\nAborting program execution.\n");
slouken@2713
   307
slouken@2713
   308
    SDL_HapticClose(haptic);
slouken@2713
   309
    SDL_Quit();
slouken@2713
   310
slouken@2713
   311
    exit(1);
slouken@2713
   312
}
slouken@2713
   313
slouken@2713
   314
slouken@2713
   315
/*
slouken@2713
   316
 * Displays information about the haptic device.
slouken@2713
   317
 */
slouken@2713
   318
static void
slouken@2713
   319
HapticPrintSupported(SDL_Haptic * haptic)
slouken@2713
   320
{
slouken@2713
   321
    unsigned int supported;
slouken@2713
   322
slouken@2713
   323
    supported = SDL_HapticQuery(haptic);
aschiffler@7639
   324
    SDL_Log("   Supported effects [%d effects, %d playing]:\n",
slouken@2713
   325
           SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic));
slouken@2713
   326
    if (supported & SDL_HAPTIC_CONSTANT)
aschiffler@7639
   327
        SDL_Log("      constant\n");
slouken@2713
   328
    if (supported & SDL_HAPTIC_SINE)
aschiffler@7639
   329
        SDL_Log("      sine\n");
icculus@7621
   330
    /* !!! FIXME: put this back when we have more bits in 2.1 */
gabomdq@7678
   331
    /* if (supported & SDL_HAPTIC_SQUARE)
gabomdq@7677
   332
        SDL_Log("      square\n"); */
slouken@2713
   333
    if (supported & SDL_HAPTIC_TRIANGLE)
aschiffler@7639
   334
        SDL_Log("      triangle\n");
slouken@2713
   335
    if (supported & SDL_HAPTIC_SAWTOOTHUP)
aschiffler@7639
   336
        SDL_Log("      sawtoothup\n");
slouken@2713
   337
    if (supported & SDL_HAPTIC_SAWTOOTHDOWN)
aschiffler@7639
   338
        SDL_Log("      sawtoothdown\n");
slouken@2713
   339
    if (supported & SDL_HAPTIC_RAMP)
aschiffler@7639
   340
        SDL_Log("      ramp\n");
slouken@2713
   341
    if (supported & SDL_HAPTIC_FRICTION)
aschiffler@7639
   342
        SDL_Log("      friction\n");
slouken@2713
   343
    if (supported & SDL_HAPTIC_SPRING)
aschiffler@7639
   344
        SDL_Log("      spring\n");
slouken@2713
   345
    if (supported & SDL_HAPTIC_DAMPER)
aschiffler@7639
   346
        SDL_Log("      damper\n");
slouken@2713
   347
    if (supported & SDL_HAPTIC_INERTIA)
aschiffler@7639
   348
        SDL_Log("      inertia\n");
slouken@2713
   349
    if (supported & SDL_HAPTIC_CUSTOM)
aschiffler@7639
   350
        SDL_Log("      custom\n");
icculus@7621
   351
    if (supported & SDL_HAPTIC_LEFTRIGHT)
aschiffler@7639
   352
        SDL_Log("      left/right\n");
aschiffler@7639
   353
    SDL_Log("   Supported capabilities:\n");
slouken@2713
   354
    if (supported & SDL_HAPTIC_GAIN)
aschiffler@7639
   355
        SDL_Log("      gain\n");
slouken@2713
   356
    if (supported & SDL_HAPTIC_AUTOCENTER)
aschiffler@7639
   357
        SDL_Log("      autocenter\n");
slouken@2713
   358
    if (supported & SDL_HAPTIC_STATUS)
aschiffler@7639
   359
        SDL_Log("      status\n");
slouken@2713
   360
}
aschiffler@6771
   361
aschiffler@6771
   362
#else
aschiffler@6771
   363
aschiffler@6771
   364
int
aschiffler@6771
   365
main(int argc, char *argv[])
aschiffler@6771
   366
{
aschiffler@7639
   367
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
aschiffler@6771
   368
    exit(1);
aschiffler@6771
   369
}
aschiffler@6771
   370
aschiffler@6771
   371
#endif