Add missing VS2012 test projects; update VS2010 and VS2012 solutions; update keybord suite for VS compiler warnings
2 Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
13 Copyright (c) 2011, Edgar Simo Serra
16 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
18 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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.
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.
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.
29 #include <stdio.h> /* printf */
30 #include <string.h> /* strstr */
31 #include <ctype.h> /* isdigit */
35 #ifndef SDL_HAPTIC_DISABLED
37 #include "SDL_haptic.h"
39 static SDL_Haptic *haptic;
43 * @brief The entry point of this force feedback demo.
44 * @param[in] argc Number of arguments.
45 * @param[in] argv Array of argc arguments.
48 main(int argc, char **argv)
53 SDL_HapticEffect efx[5];
56 unsigned int supported;
62 if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
63 printf("USAGE: %s [device]\n"
64 "If device is a two-digit number it'll use it as an index, otherwise\n"
65 "it'll use it as if it were part of the device's name.\n",
71 if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) {
77 /* Initialize the force feedbackness */
78 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
80 printf("%d Haptic devices detected.\n", SDL_NumHaptics());
81 if (SDL_NumHaptics() > 0) {
82 /* We'll just use index or the first force feedback device found */
84 i = (index != -1) ? index : 0;
86 /* Try to find matching device */
88 for (i = 0; i < SDL_NumHaptics(); i++) {
89 if (strstr(SDL_HapticName(i), name) != NULL)
93 if (i >= SDL_NumHaptics()) {
94 printf("Unable to find device matching '%s', aborting.\n",
100 haptic = SDL_HapticOpen(i);
101 if (haptic == NULL) {
102 printf("Unable to create the haptic device: %s\n",
106 printf("Device: %s\n", SDL_HapticName(i));
108 printf("No Haptic devices found!\n");
112 /* We only want force feedback errors. */
115 if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
116 printf("\nRumble not supported!\n");
119 if (SDL_HapticRumbleInit(haptic) != 0) {
120 printf("\nFailed to initialize rumble: %s\n", SDL_GetError());
123 printf("Playing 2 second rumble at 0.5 magnitude.\n");
124 if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) {
125 printf("\nFailed to play rumble: %s\n", SDL_GetError() );
129 printf("Stopping rumble.\n");
130 SDL_HapticRumbleStop(haptic);
132 printf("Playing 2 second rumble at 0.3 magnitude.\n");
133 if (SDL_HapticRumblePlay(haptic, 0.3, 5000) != 0) {
134 printf("\nFailed to play rumble: %s\n", SDL_GetError() );
141 SDL_HapticClose(haptic);
150 main(int argc, char *argv[])
152 fprintf(stderr, "SDL compiled without Haptic support.\n");