Mercurial > sdl-ios-xcode
diff src/SDL.c @ 2472:3f73c88c9abb gsoc2008_force_feedback
First commit of the SDL_haptic subsystem.
Code compiles and works, very limited functionality (linux only).
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 01 Jun 2008 11:44:25 +0000 |
parents | 8f1ab2f7c722 |
children | 64fa227c01ce |
line wrap: on
line diff
--- a/src/SDL.c Wed Apr 23 06:26:07 2008 +0000 +++ b/src/SDL.c Sun Jun 01 11:44:25 2008 +0000 @@ -38,6 +38,10 @@ extern int SDL_JoystickInit(void); extern void SDL_JoystickQuit(void); #endif +#if !SDL_HAPTIC_DISABLED +extern int SDL_HapticInit(void); +extern int SDL_HapticQuit(void); +#endif #if !SDL_CDROM_DISABLED extern int SDL_CDROMInit(void); extern void SDL_CDROMQuit(void); @@ -123,6 +127,22 @@ } #endif +#if !SDL_HAPTIC_DISABLED + /* Initialize the haptic subsystem */ + if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) { + if (SDL_HapticInit() < 0) { + return (-1); + } + SDL_initialized |= SDL_INIT_HAPTIC; + } +#else + if (flags & SDL_INIT_HAPTIC) { + SDL_SetError("SDL not built with haptic (force feedback) support"); + return (-1); + } +#endif + + #if !SDL_CDROM_DISABLED /* Initialize the CD-ROM subsystem */ if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) { @@ -180,6 +200,12 @@ SDL_initialized &= ~SDL_INIT_JOYSTICK; } #endif +#if !SDL_HAPTIC_DISABLED + if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) { + SDL_HapticQuit(); + SDL_initialized &= ~SDL_INIT_HAPTIC; + } +#endif #if !SDL_TIMERS_DISABLED if ((flags & SDL_initialized & SDL_INIT_TIMER)) { SDL_TimerQuit();