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