Mercurial > sdl-ios-xcode
annotate src/haptic/win32/SDL_syshaptic.c @ 2652:380d926cc5a7 gsoc2008_force_feedback
Fix for mingw compilation of haptic subsystem by Alam.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Mon, 25 Aug 2008 17:30:39 +0000 |
parents | ff33a65123ce |
children |
rev | line source |
---|---|
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2008 Edgar Simo |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
21 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
23 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
24 #ifdef SDL_HAPTIC_DINPUT |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
25 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
26 #include "SDL_haptic.h" |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
27 #include "../SDL_syshaptic.h" |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
28 #include "SDL_joystick.h" |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
29 #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
30 #include "../../joystick/win32/SDL_dxjoystick_c.h" /* For joystick hwdata */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
31 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
32 #define WIN32_LEAN_AND_MEAN |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
33 #include <windows.h> |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 |
2570
53bb7d21928d
Another patch for windows haptic.
Edgar Simo <bobbens@gmail.com>
parents:
2569
diff
changeset
|
35 #define DIRECTINPUT_VERSION 0x0700 /* Need at least DirectX 7 for dwStartDelay */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 #include <dinput.h> |
2652
380d926cc5a7
Fix for mingw compilation of haptic subsystem by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2651
diff
changeset
|
37 #include <dxerr8.h> |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
38 #ifdef _MSC_VER |
2580
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2578
diff
changeset
|
39 # pragma comment (lib, "dinput8.lib") |
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2578
diff
changeset
|
40 # pragma comment (lib, "dxguid.lib") |
2652
380d926cc5a7
Fix for mingw compilation of haptic subsystem by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2651
diff
changeset
|
41 # pragma comment (lib, "dxerr8.lib") |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
42 #endif /* _MSC_VER */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
43 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
44 /* an ISO hack for VisualC++ */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
45 #ifdef _MSC_VER |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
46 #define snprintf _snprintf |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 #endif /* _MSC_VER */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
50 #define MAX_HAPTICS 32 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
51 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
52 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 * List of available haptic devices. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
55 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
56 static struct |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
57 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
58 DIDEVICEINSTANCE instance; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 SDL_Haptic *haptic; |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
60 DIDEVCAPS capabilities; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
61 } SDL_hapticlist[MAX_HAPTICS]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
62 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
63 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
64 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
65 * Haptic system hardware data. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
66 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
67 struct haptic_hwdata |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
68 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
69 LPDIRECTINPUTDEVICE2 device; |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
70 DWORD axes[3]; /* Axes to use. */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
71 int is_joystick; /* Device is loaded as joystick. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
72 }; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
73 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
74 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
75 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
76 * Haptic system effect data. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
77 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 struct haptic_hweffect |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
79 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
80 DIEFFECT effect; |
2573
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
81 LPDIRECTINPUTEFFECT ref; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
82 }; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
83 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
84 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
85 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
86 * Internal stuff. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
88 static LPDIRECTINPUT dinput = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
90 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
91 /* |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
92 * External stuff. |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
93 */ |
2580
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2578
diff
changeset
|
94 extern HWND SDL_HelperWindow; |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
95 |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
96 |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
97 /* |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
98 * Prototypes. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
99 */ |
2619
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
100 static void DI_SetError(const char *str, HRESULT err); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
101 static int DI_GUIDIsSame(const GUID * a, const GUID * b); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
102 static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
103 static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE2 device2); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
104 static DWORD DIGetTriggerButton( Uint16 button ); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
105 static int SDL_SYS_SetDirection( DIEFFECT * effect, SDL_HapticDirection *dir, int naxes ); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
106 static int SDL_SYS_ToDIEFFECT( SDL_Haptic * haptic, DIEFFECT * dest, SDL_HapticEffect * src ); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
107 static void SDL_SYS_HapticFreeDIEFFECT( DIEFFECT * effect, int type ); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
108 static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect); |
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
109 /* Callbacks. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
110 static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext); |
2619
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
111 static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
112 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
113 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
114 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
115 * Like SDL_SetError but for DX error codes. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
116 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
117 static void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
118 DI_SetError(const char *str, HRESULT err) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
119 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
120 SDL_SetError( "Haptic: %s - %s: %s", str, |
2652
380d926cc5a7
Fix for mingw compilation of haptic subsystem by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2651
diff
changeset
|
121 DXGetErrorString8A(err), |
380d926cc5a7
Fix for mingw compilation of haptic subsystem by Alam.
Edgar Simo <bobbens@gmail.com>
parents:
2651
diff
changeset
|
122 DXGetErrorDescription8A(err)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
123 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
124 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
125 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
126 /* |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
127 * Checks to see if two GUID are the same. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
128 */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
129 static int |
2619
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
130 DI_GUIDIsSame(const GUID * a, const GUID * b) |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
131 { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
132 if (((a)->Data1 == (b)->Data1) && |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
133 ((a)->Data2 == (b)->Data2) && |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
134 ((a)->Data3 == (b)->Data3) && |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
135 (SDL_strcmp((a)->Data4, (b)->Data4)==0)) |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
136 return 1; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
137 return 0; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
138 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
139 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
140 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
141 /* |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 * Initializes the haptic subsystem. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
145 SDL_SYS_HapticInit(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
146 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
147 HRESULT ret; |
2623
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
148 HINSTANCE instance; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
149 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
150 if (dinput != NULL) { /* Already open. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 SDL_SetError("Haptic: SubSystem already open."); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
152 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
153 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
155 /* Clear all the memory. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
156 SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
157 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
158 SDL_numhaptics = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
159 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
160 ret = CoInitialize(NULL); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
161 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
162 DI_SetError("Coinitialize",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
164 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
165 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 &IID_IDirectInput, &dinput); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
168 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
169 DI_SetError("CoCreateInstance",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
172 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
173 /* Because we used CoCreateInstance, we need to Initialize it, first. */ |
2623
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
174 instance = GetModuleHandle(NULL); |
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
175 if (instance == NULL) { |
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
176 SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError()); |
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
177 return -1; |
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
178 } |
6deba05725ac
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.
Edgar Simo <bobbens@gmail.com>
parents:
2621
diff
changeset
|
179 ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
180 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
181 DI_SetError("Initializing DirectInput device",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
182 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
185 /* Look for haptic devices. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 ret = IDirectInput_EnumDevices( dinput, |
2650
77b5f12bfe11
Yep, 0 is the correct value here
Sam Lantinga <slouken@libsdl.org>
parents:
2646
diff
changeset
|
187 0, |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
188 EnumHapticsCallback, |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 NULL, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
191 DI_SetError("Enumerating DirectInput devices",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
192 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
193 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
194 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
195 return SDL_numhaptics; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
196 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
197 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
198 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
199 * Callback to find the haptic devices. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
200 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
201 static BOOL CALLBACK |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
202 EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
203 { |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
204 HRESULT ret; |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
205 LPDIRECTINPUTDEVICE device; |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
206 |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
207 /* Copy the instance over, useful for creating devices. */ |
2575
57ea8810b5f0
Fixed some stray memcpy and free.
Edgar Simo <bobbens@gmail.com>
parents:
2574
diff
changeset
|
208 SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance, |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
209 sizeof(DIDEVICEINSTANCE)); |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
210 |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
211 /* Open the device */ |
2614 | 212 ret = IDirectInput_CreateDevice( dinput, &pdidInstance->guidInstance, |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
213 &device, NULL ); |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
214 if (FAILED(ret)) { |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
215 /* DI_SetError("Creating DirectInput device",ret); */ |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
216 return DIENUM_CONTINUE; |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
217 } |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
218 |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
219 /* Get capabilities. */ |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
220 SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS); |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
221 ret = IDirectInputDevice_GetCapabilities( device, |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
222 &SDL_hapticlist[SDL_numhaptics].capabilities ); |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
223 if (FAILED(ret)) { |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
224 /* DI_SetError("Getting device capabilities",ret); */ |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
225 IDirectInputDevice_Release(device); |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
226 return DIENUM_CONTINUE; |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
227 } |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
228 |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
229 /* Close up device and count it. */ |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
230 IDirectInputDevice_Release(device); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
231 SDL_numhaptics++; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
232 |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
233 /* Watch out for hard limit. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
234 if (SDL_numhaptics >= MAX_HAPTICS) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
235 return DIENUM_STOP; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
236 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
237 return DIENUM_CONTINUE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
238 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
239 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
240 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
241 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
242 * Return the name of a haptic device, does not need to be opened. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
243 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
244 const char * |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
245 SDL_SYS_HapticName(int index) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
246 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
247 return SDL_hapticlist[index].instance.tszProductName; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
248 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
249 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
250 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
251 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
252 * Callback to get all supported effects. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
253 */ |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
254 #define EFFECT_TEST(e,s) \ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
255 if (DI_GUIDIsSame(&pei->guid, &(e))) \ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
256 haptic->supported |= (s) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
257 static BOOL CALLBACK |
2571 | 258 DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
259 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
260 /* Prepare the haptic device. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
261 SDL_Haptic *haptic = (SDL_Haptic*) pv; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
262 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
263 /* Get supported. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
264 EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
265 EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
266 EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
267 EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
268 EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
269 EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
270 EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
271 EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
272 EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
273 EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
274 EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
275 EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
276 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
277 /* Check for more. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
278 return DIENUM_CONTINUE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
279 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
280 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
281 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
282 /* |
2601 | 283 * Callback to get supported axes. |
284 */ | |
285 static BOOL CALLBACK | |
286 DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) | |
287 { | |
2602 | 288 SDL_Haptic *haptic = (SDL_Haptic *) pvRef; |
2601 | 289 |
2605
0ea3be6e81a7
Make sure axes have force feedback actuators.
Edgar Simo <bobbens@gmail.com>
parents:
2604
diff
changeset
|
290 if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) { |
2601 | 291 |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
292 haptic->hwdata->axes[haptic->naxes] = dev->dwOfs; |
2601 | 293 haptic->naxes++; |
294 | |
295 /* Currently using the artificial limit of 3 axes. */ | |
296 if (haptic->naxes >= 3) { | |
297 return DIENUM_STOP; | |
298 } | |
299 } | |
300 | |
301 return DIENUM_CONTINUE; | |
302 } | |
303 | |
304 | |
305 /* | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
306 * Opens the haptic device from the file descriptor. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
307 * |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
308 * Steps: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
309 * - Open temporary DirectInputDevice interface. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
310 * - Create DirectInputDevice2 interface. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
311 * - Release DirectInputDevice interface. |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
312 * - Call SDL_SYS_HapticOpenFromDevice2 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
313 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
314 static int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
315 SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
316 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
317 HRESULT ret; |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
318 int ret2; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
319 LPDIRECTINPUTDEVICE device; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
320 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
321 /* Allocate the hwdata */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
322 haptic->hwdata = (struct haptic_hwdata *) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
323 SDL_malloc(sizeof(*haptic->hwdata)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
324 if (haptic->hwdata == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
325 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
326 goto creat_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
327 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
328 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
329 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
330 /* Open the device */ |
2569
806919b319d4
Another set of fixes to try to get haptic subsystem compiling on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2568
diff
changeset
|
331 ret = IDirectInput_CreateDevice( dinput, &instance.guidInstance, |
806919b319d4
Another set of fixes to try to get haptic subsystem compiling on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2568
diff
changeset
|
332 &device, NULL ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
333 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
334 DI_SetError("Creating DirectInput device",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
335 goto creat_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
336 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
337 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
338 /* Now get the IDirectInputDevice2 interface, instead. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
339 ret = IDirectInputDevice_QueryInterface( device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
340 &IID_IDirectInputDevice2, |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
341 (LPVOID *) &haptic->hwdata->device ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
342 /* Done with the temporary one now. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
343 IDirectInputDevice_Release(device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
344 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
345 DI_SetError("Querying DirectInput interface",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
346 goto creat_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
347 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
348 |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
349 ret2 = SDL_SYS_HapticOpenFromDevice2( haptic, haptic->hwdata->device ); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
350 if (ret2 < 0) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
351 goto query_err; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
352 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
353 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
354 return 0; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
355 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
356 query_err: |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
357 IDirectInputDevice2_Release(haptic->hwdata->device); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
358 creat_err: |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
359 if (haptic->hwdata != NULL) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
360 SDL_free(haptic->hwdata); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
361 haptic->hwdata = NULL; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
362 } |
2620 | 363 return -1; |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
364 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
365 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
366 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
367 /* |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
368 * Opens the haptic device from the file descriptor. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
369 * |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
370 * Steps: |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
371 * - Set cooperative level. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
372 * - Set data format. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
373 * - Acquire exclusiveness. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
374 * - Reset actuators. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
375 * - Get supported featuers. |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
376 */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
377 static int |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
378 SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE2 device2) |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
379 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
380 { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
381 HRESULT ret; |
2619
fb71df34124f
Made prototypes for all static functions.
Edgar Simo <bobbens@gmail.com>
parents:
2617
diff
changeset
|
382 DIPROPDWORD dipdw; |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
383 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
384 /* We'll use the device2 from now on. */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
385 haptic->hwdata->device = device2; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
386 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
387 /* Grab it exclusively to use force feedback stuff. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
388 ret =IDirectInputDevice2_SetCooperativeLevel( haptic->hwdata->device, |
2580
64fa227c01ce
Added the concept of the HelperWindow to help with DirectInput.
Edgar Simo <bobbens@gmail.com>
parents:
2578
diff
changeset
|
389 SDL_HelperWindow, |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
390 DISCL_EXCLUSIVE | DISCL_BACKGROUND ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
391 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
392 DI_SetError("Setting cooperative level to exclusive",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
393 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
394 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
395 |
2588
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
396 /* Set data format. */ |
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
397 ret = IDirectInputDevice2_SetDataFormat( haptic->hwdata->device, |
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
398 &c_dfDIJoystick2 ); |
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
399 if (FAILED(ret)) { |
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
400 DI_SetError("Setting data format",ret); |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
401 goto acquire_err; |
2588
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
402 } |
57bd3e462138
Seems like you have to set the data format too.
Edgar Simo <bobbens@gmail.com>
parents:
2587
diff
changeset
|
403 |
2601 | 404 /* Get number of axes. */ |
405 ret = IDirectInputDevice2_EnumObjects( haptic->hwdata->device, | |
406 DI_DeviceObjectCallback, | |
407 haptic, DIDFT_AXIS ); | |
408 if (FAILED(ret)) { | |
409 DI_SetError("Getting device axes",ret); | |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
410 goto acquire_err; |
2601 | 411 } |
412 | |
2587
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
413 /* Acquire the device. */ |
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
414 ret = IDirectInputDevice2_Acquire(haptic->hwdata->device); |
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
415 if (FAILED(ret)) { |
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
416 DI_SetError("Acquiring DirectInput device",ret); |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
417 goto acquire_err; |
2587
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
418 } |
b4b3beaea5b5
Need to get cooperative level before acquiring.
Edgar Simo <bobbens@gmail.com>
parents:
2580
diff
changeset
|
419 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
420 /* Reset all actuators - just in case. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
421 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
422 DISFFC_RESET ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
423 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
424 DI_SetError("Resetting device",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
425 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
426 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
427 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
428 /* Enabling actuators. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
429 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
430 DISFFC_SETACTUATORSON ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
431 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
432 DI_SetError("Enabling actuators",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
433 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
434 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
435 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
436 /* Get supported effects. */ |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
437 ret = IDirectInputDevice2_EnumEffects( haptic->hwdata->device, |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
438 DI_EffectCallback, haptic, DIEFT_ALL ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
439 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
440 DI_SetError("Enumerating supported effects",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
441 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
442 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
443 if (haptic->supported == 0) { /* Error since device supports nothing. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
444 SDL_SetError("Haptic: Internal error on finding supported effects."); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
445 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
446 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
447 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
448 /* Check autogain and autocenter. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
449 dipdw.diph.dwSize = sizeof(DIPROPDWORD); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
450 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
451 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
452 dipdw.diph.dwHow = DIPH_DEVICE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
453 dipdw.dwData = 10000; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
454 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
455 DIPROP_FFGAIN, &dipdw.diph ); |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
456 if (!FAILED(ret)) { /* Gain is supported. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
457 haptic->supported |= SDL_HAPTIC_GAIN; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
458 } |
2601 | 459 dipdw.diph.dwObj = 0; |
460 dipdw.diph.dwHow = DIPH_DEVICE; | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
461 dipdw.dwData = DIPROPAUTOCENTER_OFF; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
462 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
463 DIPROP_AUTOCENTER, &dipdw.diph ); |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
464 if (!FAILED(ret)) { /* Autocenter is supported. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
465 haptic->supported |= SDL_HAPTIC_AUTOCENTER; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
466 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
467 |
2626
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
468 /* Status is always supported. */ |
2645
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
469 haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; |
2626
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
470 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
471 /* Check maximum effects. */ |
2631 | 472 haptic->neffects = 128; /* This is not actually supported as thus under windows, |
473 there is no way to tell the number of EFFECTS that a | |
474 device can hold, so we'll just use a "random" number | |
475 instead and put warnings in SDL_haptic.h */ | |
476 haptic->nplaying = 128; /* Even more impossible to get this then neffects. */ | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
477 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
478 /* Prepare effects memory. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
479 haptic->effects = (struct haptic_effect *) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
480 SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
481 if (haptic->effects == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
482 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
483 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
484 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
485 /* Clear the memory */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
486 SDL_memset(haptic->effects, 0, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
487 sizeof(struct haptic_effect) * haptic->neffects); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
488 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
489 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
490 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
491 /* Error handling */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
492 acquire_err: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
493 IDirectInputDevice2_Unacquire(haptic->hwdata->device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
494 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
495 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
496 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
497 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
498 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
499 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
500 * Opens a haptic device for usage. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
501 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
502 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
503 SDL_SYS_HapticOpen(SDL_Haptic * haptic) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
504 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
505 return SDL_SYS_HapticOpenFromInstance( haptic, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
506 SDL_hapticlist[haptic->index].instance ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
507 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
508 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
509 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
510 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
511 * Opens a haptic device from first mouse it finds for usage. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
512 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
513 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
514 SDL_SYS_HapticMouse(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
515 { |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
516 int i; |
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
517 |
2615
088907e9a2bb
Implemented SDL_SYS_HapticMouse on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2614
diff
changeset
|
518 /* Grab the first mouse haptic device we find. */ |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
519 for (i=0; i<SDL_numhaptics; i++) { |
2615
088907e9a2bb
Implemented SDL_SYS_HapticMouse on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2614
diff
changeset
|
520 if (SDL_hapticlist[i].capabilities.dwDevType == DIDEVTYPE_MOUSE ) { |
088907e9a2bb
Implemented SDL_SYS_HapticMouse on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2614
diff
changeset
|
521 return i; |
088907e9a2bb
Implemented SDL_SYS_HapticMouse on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2614
diff
changeset
|
522 } |
2612
63ea27a96a96
Check for capabilities at init.
Edgar Simo <bobbens@gmail.com>
parents:
2611
diff
changeset
|
523 } |
2615
088907e9a2bb
Implemented SDL_SYS_HapticMouse on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2614
diff
changeset
|
524 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
525 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
526 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
527 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
528 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
529 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
530 * Checks to see if a joystick has haptic features. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
531 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
532 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
533 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
534 { |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
535 if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
536 return SDL_TRUE; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
537 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
538 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
539 return SDL_FALSE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
540 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
541 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
542 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
543 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
544 * Checks to see if the haptic device and joystick and in reality the same. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
545 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
546 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
547 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
548 { |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
549 HRESULT ret; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
550 DIDEVICEINSTANCE hap_instance, joy_instance; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
551 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
552 /* Get the device instances. */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
553 ret = IDirectInputDevice2_GetDeviceInfo( haptic->hwdata->device, |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
554 &hap_instance ); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
555 if (FAILED(ret)) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
556 return 0; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
557 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
558 ret = IDirectInputDevice2_GetDeviceInfo( joystick->hwdata->InputDevice, |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
559 &joy_instance ); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
560 if (FAILED(ret)) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
561 return 0; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
562 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
563 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
564 if (DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance)) |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
565 return 1; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
566 |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
567 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
568 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
569 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
570 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
571 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
572 * Opens a SDL_Haptic from a SDL_Joystick. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
573 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
574 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
575 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
576 { |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
577 int ret; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
578 |
2621
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
579 /* Allocate the hwdata */ |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
580 haptic->hwdata = (struct haptic_hwdata *) |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
581 SDL_malloc(sizeof(*haptic->hwdata)); |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
582 if (haptic->hwdata == NULL) { |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
583 SDL_OutOfMemory(); |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
584 return -1; |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
585 } |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
586 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
587 |
83659de20bf2
Forgot to alloc the hwdata when opening from joystick.
Edgar Simo <bobbens@gmail.com>
parents:
2620
diff
changeset
|
588 /* Now open the device. */ |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
589 ret = SDL_SYS_HapticOpenFromDevice2( haptic, joystick->hwdata->InputDevice ); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
590 if (ret < 0) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
591 return -1; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
592 } |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
593 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
594 /* It's using the joystick device. */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
595 haptic->hwdata->is_joystick = 1; |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
596 |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
597 return 0; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
598 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
599 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
600 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
601 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
602 * Closes the haptic device. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
603 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
604 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
605 SDL_SYS_HapticClose(SDL_Haptic * haptic) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
606 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
607 if (haptic->hwdata) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
608 |
2561
3696b9ce8a37
Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c.
Edgar Simo <bobbens@gmail.com>
parents:
2551
diff
changeset
|
609 /* Free effects. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
610 SDL_free(haptic->effects); |
2561
3696b9ce8a37
Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c.
Edgar Simo <bobbens@gmail.com>
parents:
2551
diff
changeset
|
611 haptic->effects = NULL; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
612 haptic->neffects = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
613 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
614 /* Clean up */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
615 IDirectInputDevice2_Unacquire(haptic->hwdata->device); |
2617
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
616 /* Only release if isn't grabbed by a joystick. */ |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
617 if (haptic->hwdata->is_joystick == 0) { |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
618 IDirectInputDevice2_Release(haptic->hwdata->device); |
a168397d6549
Finished implementing the haptic<->joystick functions.
Edgar Simo <bobbens@gmail.com>
parents:
2615
diff
changeset
|
619 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
620 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
621 /* Free */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
622 SDL_free(haptic->hwdata); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
623 haptic->hwdata = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
624 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
625 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
626 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
627 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
628 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
629 * Clean up after system specific haptic stuff |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
630 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
631 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
632 SDL_SYS_HapticQuit(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
633 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
634 IDirectInput_Release(dinput); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
635 dinput = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
636 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
637 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
638 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
639 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
640 * Converts an SDL trigger button to an DIEFFECT trigger button. |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
641 */ |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
642 static DWORD |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
643 DIGetTriggerButton( Uint16 button ) |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
644 { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
645 DWORD dwTriggerButton; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
646 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
647 dwTriggerButton = DIEB_NOTRIGGER; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
648 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
649 if (button != 0) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
650 dwTriggerButton = DIJOFS_BUTTON(button - 1); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
651 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
652 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
653 return dwTriggerButton; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
654 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
655 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
656 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
657 /* |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
658 * Sets the direction. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
659 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
660 static int |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
661 SDL_SYS_SetDirection( DIEFFECT * effect, SDL_HapticDirection *dir, int naxes ) |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
662 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
663 LONG *rglDir; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
664 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
665 /* Handle no axes a part. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
666 if (naxes == 0) { |
2599
e9641d2250e5
With no axes use spherical direction by default.
Edgar Simo <bobbens@gmail.com>
parents:
2598
diff
changeset
|
667 effect->dwFlags |= DIEFF_SPHERICAL; /* Set as default. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
668 effect->rglDirection = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
669 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
670 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
671 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
672 /* Has axes. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
673 rglDir = SDL_malloc( sizeof(LONG) * naxes ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
674 if (rglDir == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
675 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
676 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
677 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
678 SDL_memset( rglDir, 0, sizeof(LONG) * naxes ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
679 effect->rglDirection = rglDir; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
680 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
681 switch (dir->type) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
682 case SDL_HAPTIC_POLAR: |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
683 effect->dwFlags |= DIEFF_POLAR; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
684 rglDir[0] = dir->dir[0]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
685 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
686 case SDL_HAPTIC_CARTESIAN: |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
687 effect->dwFlags |= DIEFF_CARTESIAN; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
688 rglDir[0] = dir->dir[0]; |
2604
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
689 if (naxes > 1) |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
690 rglDir[1] = dir->dir[1]; |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
691 if (naxes > 2) |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
692 rglDir[2] = dir->dir[2]; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
693 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
694 case SDL_HAPTIC_SPHERICAL: |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
695 effect->dwFlags |= DIEFF_SPHERICAL; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
696 rglDir[0] = dir->dir[0]; |
2604
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
697 if (naxes > 1) |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
698 rglDir[1] = dir->dir[1]; |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
699 if (naxes > 2) |
4eee4d565368
Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents:
2603
diff
changeset
|
700 rglDir[2] = dir->dir[2]; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
701 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
702 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
703 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
704 SDL_SetError("Haptic: Unknown direction type."); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
705 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
706 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
707 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
708 |
2609
eec0c81ede06
CONVERT now checks for overflows.
Edgar Simo <bobbens@gmail.com>
parents:
2607
diff
changeset
|
709 #define CONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
710 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
711 * Creates the DIEFFECT from a SDL_HapticEffect. |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
712 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
713 static int |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
714 SDL_SYS_ToDIEFFECT( SDL_Haptic * haptic, DIEFFECT * dest, SDL_HapticEffect * src ) |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
715 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
716 int i; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
717 DICONSTANTFORCE *constant; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
718 DIPERIODIC *periodic; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
719 DICONDITION *condition; /* Actually an array of conditions - one per axis. */ |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
720 DIRAMPFORCE *ramp; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
721 DICUSTOMFORCE *custom; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
722 DIENVELOPE *envelope; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
723 SDL_HapticConstant *hap_constant; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
724 SDL_HapticPeriodic *hap_periodic; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
725 SDL_HapticCondition *hap_condition; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
726 SDL_HapticRamp *hap_ramp; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
727 SDL_HapticCustom *hap_custom; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
728 DWORD *axes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
729 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
730 /* Set global stuff. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
731 SDL_memset(dest, 0, sizeof(DIEFFECT)); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
732 dest->dwSize = sizeof(DIEFFECT); /* Set the structure size. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
733 dest->dwSamplePeriod = 0; /* Not used by us. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
734 dest->dwGain = 10000; /* Gain is set globally, not locally. */ |
2600
d1140f0ebedf
Using DIEFF_OBJECTOFFSETS now that seems obligatory.
Edgar Simo <bobbens@gmail.com>
parents:
2599
diff
changeset
|
735 dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
736 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
737 /* Envelope. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
738 envelope = SDL_malloc( sizeof(DIENVELOPE) ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
739 if (envelope == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
740 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
741 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
742 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
743 SDL_memset(envelope, 0, sizeof(DIENVELOPE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
744 dest->lpEnvelope = envelope; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
745 envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
746 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
747 /* Axes. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
748 dest->cAxes = haptic->naxes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
749 if (dest->cAxes > 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
750 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
751 if (axes == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
752 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
753 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
754 } |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
755 axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
756 if (dest->cAxes > 1) { |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
757 axes[1] = haptic->hwdata->axes[1]; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
758 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
759 if (dest->cAxes > 2) { |
2606
bb175d957174
Some correctness, especially on axes.
Edgar Simo <bobbens@gmail.com>
parents:
2605
diff
changeset
|
760 axes[2] = haptic->hwdata->axes[2]; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
761 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
762 dest->rgdwAxes = axes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
763 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
764 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
765 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
766 /* The big type handling switch, even bigger then linux's version. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
767 switch (src->type) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
768 case SDL_HAPTIC_CONSTANT: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
769 hap_constant = &src->constant; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
770 constant = SDL_malloc( sizeof(DICONSTANTFORCE) ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
771 if (constant == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
772 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
773 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
774 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
775 SDL_memset(constant, 0, sizeof(DICONSTANTFORCE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
776 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
777 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
778 constant->lMagnitude = CONVERT(hap_constant->level); |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
779 dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
780 dest->lpvTypeSpecificParams = constant; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
781 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
782 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
783 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
784 dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
785 dest->dwTriggerRepeatInterval = hap_constant->interval; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
786 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
787 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
788 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
789 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
790 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
791 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
792 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
793 /* Envelope */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
794 if ((hap_constant->attack_length==0) && (hap_constant->fade_length==0)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
795 SDL_free(dest->lpEnvelope); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
796 dest->lpEnvelope = NULL; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
797 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
798 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
799 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
800 envelope->dwAttackTime = hap_constant->attack_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
801 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
802 envelope->dwFadeTime = hap_constant->fade_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
803 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
804 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
805 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
806 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
807 case SDL_HAPTIC_SINE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
808 case SDL_HAPTIC_SQUARE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
809 case SDL_HAPTIC_TRIANGLE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
810 case SDL_HAPTIC_SAWTOOTHUP: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
811 case SDL_HAPTIC_SAWTOOTHDOWN: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
812 hap_periodic = &src->periodic; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
813 periodic = SDL_malloc(sizeof(DIPERIODIC)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
814 if (periodic == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
815 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
816 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
817 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
818 SDL_memset(periodic, 0, sizeof(DIPERIODIC)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
819 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
820 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
821 periodic->dwMagnitude = CONVERT(hap_periodic->magnitude); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
822 periodic->lOffset = CONVERT(hap_periodic->offset); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
823 periodic->dwPhase = hap_periodic->phase; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
824 periodic->dwPeriod = hap_periodic->period * 1000; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
825 dest->cbTypeSpecificParams = sizeof(DIPERIODIC); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
826 dest->lpvTypeSpecificParams = periodic; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
827 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
828 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
829 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
830 dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
831 dest->dwTriggerRepeatInterval = hap_periodic->interval; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
832 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
833 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
834 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
835 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
836 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
837 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
838 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
839 /* Envelope */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
840 if ((hap_periodic->attack_length==0) && (hap_periodic->fade_length==0)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
841 SDL_free(dest->lpEnvelope); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
842 dest->lpEnvelope = NULL; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
843 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
844 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
845 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
846 envelope->dwAttackTime = hap_periodic->attack_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
847 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
848 envelope->dwFadeTime = hap_periodic->fade_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
849 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
850 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
851 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
852 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
853 case SDL_HAPTIC_SPRING: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
854 case SDL_HAPTIC_DAMPER: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
855 case SDL_HAPTIC_INERTIA: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
856 case SDL_HAPTIC_FRICTION: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
857 hap_condition = &src->condition; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
858 condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
859 if (condition == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
860 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
861 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
862 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
863 SDL_memset(condition, 0, sizeof(DICONDITION)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
864 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
865 /* Specifics */ |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
866 for (i=0; i<(int)dest->cAxes; i++) { |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
867 condition[i].lOffset = CONVERT(hap_condition->center[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
868 condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
869 condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
870 condition[i].dwPositiveSaturation = CONVERT(hap_condition->right_sat[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
871 condition[i].dwNegativeSaturation = CONVERT(hap_condition->left_sat[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
872 condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
873 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
874 dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
875 dest->lpvTypeSpecificParams = condition; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
876 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
877 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
878 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
879 dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
880 dest->dwTriggerRepeatInterval = hap_condition->interval; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
881 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
882 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
883 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
884 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
885 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
886 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
887 |
2629 | 888 /* Envelope - Not actually supported by most CONDITION implementations. */ |
889 SDL_free(dest->lpEnvelope); | |
890 dest->lpEnvelope = NULL; | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
891 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
892 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
893 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
894 case SDL_HAPTIC_RAMP: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
895 hap_ramp = &src->ramp; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
896 ramp = SDL_malloc(sizeof(DIRAMPFORCE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
897 if (ramp == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
898 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
899 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
900 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
901 SDL_memset(ramp, 0, sizeof(DIRAMPFORCE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
902 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
903 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
904 ramp->lStart = CONVERT(hap_ramp->start); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
905 ramp->lEnd = CONVERT(hap_ramp->end); |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
906 dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
907 dest->lpvTypeSpecificParams = ramp; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
908 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
909 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
910 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
911 dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
912 dest->dwTriggerRepeatInterval = hap_ramp->interval; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
913 dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
914 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
915 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
916 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
917 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
918 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
919 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
920 /* Envelope */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
921 if ((hap_ramp->attack_length==0) && (hap_ramp->fade_length==0)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
922 SDL_free(dest->lpEnvelope); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
923 dest->lpEnvelope = NULL; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
924 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
925 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
926 envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
927 envelope->dwAttackTime = hap_ramp->attack_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
928 envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
929 envelope->dwFadeTime = hap_ramp->fade_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
930 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
931 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
932 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
933 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
934 case SDL_HAPTIC_CUSTOM: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
935 hap_custom = &src->custom; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
936 custom = SDL_malloc(sizeof(DICUSTOMFORCE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
937 if (custom == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
938 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
939 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
940 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
941 SDL_memset(custom, 0, sizeof(DICUSTOMFORCE)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
942 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
943 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
944 custom->cChannels = hap_custom->channels; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
945 custom->dwSamplePeriod = hap_custom->period * 1000; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
946 custom->cSamples = hap_custom->samples; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
947 custom->rglForceData = SDL_malloc(sizeof(LONG)*custom->cSamples*custom->cChannels); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
948 for (i=0; i<hap_custom->samples*hap_custom->channels; i++) { /* Copy data. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
949 custom->rglForceData[i] = CONVERT(hap_custom->data[i]); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
950 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
951 dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
952 dest->lpvTypeSpecificParams = custom; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
953 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
954 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
955 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
956 dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
957 dest->dwTriggerRepeatInterval = hap_custom->interval; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
958 dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
959 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
960 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
961 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
962 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
963 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
964 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
965 /* Envelope */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
966 if ((hap_custom->attack_length==0) && (hap_custom->fade_length==0)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
967 SDL_free(dest->lpEnvelope); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
968 dest->lpEnvelope = NULL; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
969 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
970 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
971 envelope->dwAttackLevel = CONVERT(hap_custom->attack_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
972 envelope->dwAttackTime = hap_custom->attack_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
973 envelope->dwFadeLevel = CONVERT(hap_custom->fade_level); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
974 envelope->dwFadeTime = hap_custom->fade_length * 1000; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
975 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
976 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
977 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
978 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
979 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
980 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
981 SDL_SetError("Haptic: Unknown effect type."); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
982 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
983 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
984 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
985 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
986 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
987 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
988 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
989 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
990 * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT. |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
991 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
992 static void |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
993 SDL_SYS_HapticFreeDIEFFECT( DIEFFECT * effect, int type ) |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
994 { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
995 DICUSTOMFORCE *custom; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
996 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
997 if (effect->lpEnvelope != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
998 SDL_free(effect->lpEnvelope); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
999 effect->lpEnvelope = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1000 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1001 if (effect->rgdwAxes != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1002 SDL_free(effect->rgdwAxes); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1003 effect->rgdwAxes = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1004 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1005 if (effect->lpvTypeSpecificParams != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1006 if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1007 custom = (DICUSTOMFORCE*) effect->lpvTypeSpecificParams; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1008 SDL_free(custom->rglForceData); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1009 custom->rglForceData = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1010 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1011 SDL_free(effect->lpvTypeSpecificParams); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1012 effect->lpvTypeSpecificParams = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1013 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1014 if (effect->rglDirection != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1015 SDL_free(effect->rglDirection); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1016 effect->rglDirection = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1017 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1018 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1019 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1020 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1021 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1022 * Gets the effect type from the generic SDL haptic effect wrapper. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1023 */ |
2598 | 1024 static REFGUID |
1025 SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1026 { |
2598 | 1027 switch (effect->type) { |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1028 case SDL_HAPTIC_CONSTANT: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1029 return &GUID_ConstantForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1030 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1031 case SDL_HAPTIC_RAMP: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1032 return &GUID_RampForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1033 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1034 case SDL_HAPTIC_SQUARE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1035 return &GUID_Square; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1036 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1037 case SDL_HAPTIC_SINE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1038 return &GUID_Sine; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1039 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1040 case SDL_HAPTIC_TRIANGLE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1041 return &GUID_Triangle; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1042 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1043 case SDL_HAPTIC_SAWTOOTHUP: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1044 return &GUID_SawtoothUp; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1045 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1046 case SDL_HAPTIC_SAWTOOTHDOWN: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1047 return &GUID_SawtoothDown; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1048 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1049 case SDL_HAPTIC_SPRING: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1050 return &GUID_Spring; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1051 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1052 case SDL_HAPTIC_DAMPER: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1053 return &GUID_Damper; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1054 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1055 case SDL_HAPTIC_INERTIA: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1056 return &GUID_Inertia; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1057 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1058 case SDL_HAPTIC_FRICTION: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1059 return &GUID_Friction; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1060 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1061 case SDL_HAPTIC_CUSTOM: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
1062 return &GUID_CustomForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1063 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1064 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1065 SDL_SetError("Haptic: Unknown effect type."); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1066 return NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1067 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1068 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1069 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1070 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1071 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1072 * Creates a new haptic effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1073 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1074 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1075 SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect * effect, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1076 SDL_HapticEffect * base) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1077 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1078 HRESULT ret; |
2574
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1079 |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1080 /* Get the type. */ |
2598 | 1081 REFGUID type = SDL_SYS_HapticEffectType(base); |
2574
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1082 if (type == NULL) { |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1083 goto err_hweffect; |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1084 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1085 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1086 /* Alloc the effect. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1087 effect->hweffect = (struct haptic_hweffect *) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1088 SDL_malloc(sizeof(struct haptic_hweffect)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1089 if (effect->hweffect == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1090 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1091 goto err_hweffect; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1092 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1093 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1094 /* Get the effect. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1095 if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) { |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1096 goto err_effectdone; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1097 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1098 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1099 /* Create the actual effect. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1100 ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type, |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1101 &effect->hweffect->effect, &effect->hweffect->ref, NULL); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1102 if (FAILED(ret)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1103 DI_SetError("Unable to create effect",ret); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1104 goto err_effectdone; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1105 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1106 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1107 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1108 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1109 err_effectdone: |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1110 SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1111 err_hweffect: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1112 if (effect->hweffect != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1113 SDL_free(effect->hweffect); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1114 effect->hweffect = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1115 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1116 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1117 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1118 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1119 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1120 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1121 * Updates an effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1122 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1123 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1124 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1125 struct haptic_effect * effect, SDL_HapticEffect * data) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1126 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1127 HRESULT ret; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1128 DWORD flags; |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1129 DIEFFECT temp; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1130 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1131 /* Get the effect. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1132 SDL_memset(&temp, 0, sizeof(DIEFFECT)); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1133 if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) { |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1134 goto err_update; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1135 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1136 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1137 /* Set the flags. Might be worthwhile to diff temp with loaded effect and |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1138 * only change those parameters. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1139 flags = DIEP_DIRECTION | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1140 DIEP_DURATION | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1141 DIEP_ENVELOPE | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1142 DIEP_STARTDELAY | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1143 DIEP_TRIGGERBUTTON | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1144 DIEP_TRIGGERREPEATINTERVAL | |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1145 DIEP_TYPESPECIFICPARAMS; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1146 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1147 /* Create the actual effect. */ |
2574
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
1148 ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); |
2573
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
1149 if (FAILED(ret)) { |
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
1150 DI_SetError("Unable to update effect",ret); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1151 goto err_update; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1152 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1153 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1154 /* Copy it over. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1155 SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1156 SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT)); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1157 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1158 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1159 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1160 err_update: |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1161 SDL_SYS_HapticFreeDIEFFECT(&temp, data->type); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1162 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1163 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1164 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1165 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1166 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1167 * Runs an effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1168 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1169 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1170 SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect * effect, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1171 Uint32 iterations) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1172 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1173 HRESULT ret; |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1174 DWORD iter; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1175 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1176 /* Check if it's infinite. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1177 if (iterations == SDL_HAPTIC_INFINITY) { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1178 iter = INFINITE; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1179 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1180 else |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1181 iter = iterations; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1182 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1183 /* Run the effect. */ |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1184 ret = IDirectInputEffect_Start( effect->hweffect->ref, iter, 0 ); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1185 if (FAILED(ret)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1186 DI_SetError("Running the effect",ret); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1187 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1188 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1189 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1190 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1191 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1192 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1193 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1194 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1195 * Stops an effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1196 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1197 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1198 SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect * effect) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1199 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1200 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1201 |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1202 ret = IDirectInputEffect_Stop(effect->hweffect->ref); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1203 if (FAILED(ret)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1204 DI_SetError("Unable to stop effect",ret); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1205 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1206 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1207 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1208 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1209 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1210 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1211 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1212 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1213 * Frees the effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1214 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1215 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1216 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1217 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1218 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1219 |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1220 ret = IDirectInputEffect_Unload(effect->hweffect->ref); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1221 if (FAILED(ret)) { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1222 DI_SetError("Removing effect from the device",ret); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1223 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1224 SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, effect->effect.type); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1225 SDL_free(effect->hweffect); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1226 effect->hweffect = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1227 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1228 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1229 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1230 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1231 * Gets the status of a haptic effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1232 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1233 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1234 SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect * effect) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1235 { |
2626
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1236 HRESULT ret; |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1237 DWORD status; |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1238 |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1239 ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status); |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1240 if (FAILED(ret)) { |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1241 DI_SetError("Getting effect status",ret); |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1242 return -1; |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1243 } |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1244 |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1245 if (status == 0) return SDL_FALSE; |
53dd30491c71
Added SDL_HAPTIC_STATUS support to windows haptic port.
Edgar Simo <bobbens@gmail.com>
parents:
2623
diff
changeset
|
1246 return SDL_TRUE; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1247 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1248 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1249 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1250 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1251 * Sets the gain. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1252 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1253 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1254 SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1255 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1256 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1257 DIPROPDWORD dipdw; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1258 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1259 /* Create the weird structure thingy. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1260 dipdw.diph.dwSize = sizeof(DIPROPDWORD); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1261 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1262 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1263 dipdw.diph.dwHow = DIPH_DEVICE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1264 dipdw.dwData = gain * 100; /* 0 to 10,000 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1265 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1266 /* Try to set the autocenter. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1267 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1268 DIPROP_FFGAIN, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1269 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1270 DI_SetError("Setting gain",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1271 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1272 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1273 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1274 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1275 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1276 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1277 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1278 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1279 * Sets the autocentering. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1280 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1281 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1282 SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1283 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1284 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1285 DIPROPDWORD dipdw; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1286 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1287 /* Create the weird structure thingy. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1288 dipdw.diph.dwSize = sizeof(DIPROPDWORD); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1289 dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1290 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1291 dipdw.diph.dwHow = DIPH_DEVICE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1292 dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF : |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1293 DIPROPAUTOCENTER_ON; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1294 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1295 /* Try to set the autocenter. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1296 ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1297 DIPROP_AUTOCENTER, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1298 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1299 DI_SetError("Setting autocenter",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1300 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1301 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1302 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1303 return 0; |
2645
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1304 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1305 |
2645
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1306 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1307 /* |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1308 * Pauses the device. |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1309 */ |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1310 int |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1311 SDL_SYS_HapticPause(SDL_Haptic * haptic) |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1312 { |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1313 HRESULT ret; |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1314 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1315 /* Pause the device. */ |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1316 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1317 DISFFC_PAUSE ); |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1318 if (FAILED(ret)) { |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1319 DI_SetError("Pausing the device",ret); |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1320 return -1; |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1321 } |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1322 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1323 return 0; |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1324 } |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1325 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1326 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1327 /* |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1328 * Pauses the device. |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1329 */ |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1330 int |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1331 SDL_SYS_HapticUnpause(SDL_Haptic * haptic) |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1332 { |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1333 HRESULT ret; |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1334 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1335 /* Unpause the device. */ |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1336 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1337 DISFFC_CONTINUE ); |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1338 if (FAILED(ret)) { |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1339 DI_SetError("Pausing the device",ret); |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1340 return -1; |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1341 } |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1342 |
269ba4f28d0e
Added support for pausing/unpausing haptic devices.
Edgar Simo <bobbens@gmail.com>
parents:
2631
diff
changeset
|
1343 return 0; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1344 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1345 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1346 |
2646 | 1347 /* |
1348 * Stops all the playing effects on the device. | |
1349 */ | |
1350 int | |
2651
ff33a65123ce
Fixed silly mistake because of coding too fast.
Edgar Simo <bobbens@gmail.com>
parents:
2650
diff
changeset
|
1351 SDL_SYS_HapticStopAll(SDL_Haptic * haptic) |
2646 | 1352 { |
1353 HRESULT ret; | |
1354 | |
1355 /* Try to stop the effects. */ | |
1356 ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, | |
1357 DISFFC_STOPALL ); | |
1358 if (FAILED(ret)) { | |
1359 DI_SetError("Stopping the device",ret); | |
1360 return -1; | |
1361 } | |
1362 | |
1363 return 0; | |
1364 } | |
1365 | |
1366 | |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1367 #endif /* SDL_HAPTIC_DINPUT */ |