Mercurial > sdl-ios-xcode
annotate src/haptic/win32/SDL_syshaptic.c @ 2574:c1f07fdd1e2d gsoc2008_force_feedback
Windows build should compile after this.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Thu, 31 Jul 2008 16:38:13 +0000 |
parents | 40b89e3d7ab5 |
children | 57ea8810b5f0 |
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 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
30 /*#include "../../joystick/win32/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */ |
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> |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
37 #include <dxerr9.h> /* From DirectX SDK 9c */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
38 #ifdef _MSC_VER |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
39 # pragma comment (lib, "dxerr9.lib") |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
40 #endif /* _MSC_VER */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
41 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
42 /* 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
|
43 #ifdef _MSC_VER |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
44 #define snprintf _snprintf |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
45 #endif /* _MSC_VER */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
46 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 #define MAX_HAPTICS 32 |
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 |
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 * 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
|
53 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 static struct |
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 DIDEVICEINSTANCE instance; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
57 SDL_Haptic *haptic; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
58 } SDL_hapticlist[MAX_HAPTICS]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
60 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
61 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
62 * Haptic system hardware data. |
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 struct haptic_hwdata |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
65 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
66 LPDIRECTINPUTDEVICE2 device; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
67 DIDEVCAPS capabilities; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
70 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
71 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
72 * Haptic system effect data. |
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 struct haptic_hweffect |
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 DIEFFECT effect; |
2573
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
77 LPDIRECTINPUTEFFECT ref; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 }; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
81 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
82 * Internal stuff. |
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 static LPDIRECTINPUT dinput = NULL; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 /* |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
88 * External stuff. |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
89 */ |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
90 extern HINSTANCE SDL_Instance; |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
91 extern HWND SDL_Window; |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
92 |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
93 |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
94 /* |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
95 * Prototypes. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
96 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
97 static BOOL CALLBACK 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
|
98 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
99 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
100 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
101 * 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
|
102 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
103 static void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
104 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
|
105 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
106 SDL_SetError( "Haptic: %s - %s: %s", str, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
107 DXGetErrorString9(err), |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
108 DXGetErrorDescription9(err)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
109 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
110 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
111 |
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 * Initializes the haptic subsystem. |
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 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
116 SDL_SYS_HapticInit(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
117 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
118 HRESULT ret; |
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 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
|
121 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
|
122 return -1; |
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 /* Clear all the memory. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
126 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
|
127 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
128 SDL_numhaptics = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
129 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
130 ret = CoInitialize(NULL); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
131 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
132 DI_SetError("Coinitialize",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
133 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
134 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
135 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
136 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
|
137 &IID_IDirectInput, &dinput); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
138 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
139 DI_SetError("CoCreateInstance",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
140 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
141 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 /* Because we used CoCreateInstance, we need to Initialize it, first. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 ret = IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
145 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
146 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
|
147 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
148 } |
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 /* Look for haptic devices. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 ret = IDirectInput_EnumDevices( dinput, |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
152 DIDEVTYPE_DEVICE, |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
153 EnumHapticsCallback, |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 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
|
155 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
156 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
|
157 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
158 } |
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 return SDL_numhaptics; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
161 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
162 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
164 * 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
|
165 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 static BOOL CALLBACK |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 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
|
168 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
169 memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 sizeof(DIDEVICEINSTANCE)); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 SDL_numhaptics++; |
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 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
|
174 return DIENUM_STOP; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
175 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
176 return DIENUM_CONTINUE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
177 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
178 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
179 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
180 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
181 * 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
|
182 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 const char * |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 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
|
185 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 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
|
187 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
188 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
191 * 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
|
192 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
193 #define EFFECT_TEST(e,s) \ |
2573
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
194 if (&pei->guid == &(e)) \ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
195 haptic->supported |= (s) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
196 static BOOL CALLBACK |
2571 | 197 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
|
198 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
199 /* Prepare the haptic device. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
200 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
|
201 haptic->supported = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
202 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
203 /* Get supported. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
217 /* Check for more. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
218 return DIENUM_CONTINUE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
219 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
220 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
221 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
222 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
223 * 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
|
224 * |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
225 * Steps: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
226 * - Open temporary DirectInputDevice interface. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
227 * - Create DirectInputDevice2 interface. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
228 * - Release DirectInputDevice interface. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
229 * - Acquire exclusiveness. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
230 * - Reset actuators. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
231 * - Get supported featuers. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
232 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
233 static int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
234 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
|
235 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
236 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
237 LPDIRECTINPUTDEVICE device; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
238 DIPROPDWORD dipdw; |
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 /* Allocate the hwdata */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
241 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
|
242 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
|
243 if (haptic->hwdata == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
244 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
245 goto creat_err; |
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 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
|
248 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
249 /* 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
|
250 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
|
251 &device, NULL ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
252 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
253 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
|
254 goto creat_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
255 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
256 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
257 /* 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
|
258 ret = IDirectInputDevice_QueryInterface( device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
259 &IID_IDirectInputDevice2, |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
260 (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
|
261 /* 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
|
262 IDirectInputDevice_Release(device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
263 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
264 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
|
265 goto creat_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
266 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
267 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
268 /* Acquire the device. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
269 ret = IDirectInputDevice2_Acquire(haptic->hwdata->device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
270 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
271 DI_SetError("Acquiring DirectInput device",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
272 goto query_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
273 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
274 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
275 /* 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
|
276 ret =IDirectInputDevice2_SetCooperativeLevel( haptic->hwdata->device, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
277 SDL_Window, |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
278 DISCL_EXCLUSIVE | DISCL_BACKGROUND ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
279 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
280 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
|
281 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
282 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
283 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
284 /* 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
|
285 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
|
286 DISFFC_RESET ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
287 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
288 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
|
289 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
290 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
291 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
292 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
293 /* Enabling actuators. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
294 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
|
295 DISFFC_SETACTUATORSON ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
296 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
297 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
|
298 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
299 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
300 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
301 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
302 /* Get capabilities. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
303 ret = IDirectInputDevice2_GetCapabilities( haptic->hwdata->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
|
304 &haptic->hwdata->capabilities ); |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
305 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
306 DI_SetError("Getting device capabilities",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
307 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
308 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
309 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
310 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
311 /* Get supported effects. */ |
2568
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
312 ret = IDirectInputDevice2_EnumEffects( haptic->hwdata->device, |
5ad98a77bacb
First attempt to fix compilation on windows.
Edgar Simo <bobbens@gmail.com>
parents:
2566
diff
changeset
|
313 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
|
314 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
315 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
|
316 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
317 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
318 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
|
319 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
|
320 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
321 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
322 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
323 /* Check autogain and autocenter. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
324 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
|
325 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
|
326 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
327 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
|
328 dipdw.dwData = 10000; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
329 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
|
330 DIPROP_FFGAIN, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
331 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
332 if (ret != DIERR_UNSUPPORTED) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
333 DI_SetError("Checking gain",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
334 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
335 } |
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 else { /* Gain is supported. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
338 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
|
339 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
340 dipdw.dwData = DIPROPAUTOCENTER_OFF; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
341 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
|
342 DIPROP_AUTOCENTER, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
343 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
344 if (ret != DIERR_UNSUPPORTED) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
345 DI_SetError("Checking autocenter",ret); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
346 goto acquire_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 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
349 else { /* Autocenter is supported. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
350 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
|
351 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
352 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
353 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
354 /* Check maximum effects. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
355 haptic->neffects = 128; /* TODO actually figure this out. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
356 haptic->nplaying = 128; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
357 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
358 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
359 /* Prepare effects memory. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
360 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
|
361 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
|
362 if (haptic->effects == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
363 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
364 goto acquire_err; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
365 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
366 /* Clear the memory */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
367 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
|
368 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
|
369 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
370 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
371 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
372 /* Error handling */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
373 acquire_err: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
374 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
|
375 query_err: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
376 IDirectInputDevice2_Release(haptic->hwdata->device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
377 creat_err: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
378 if (haptic->hwdata != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
379 free(haptic->hwdata); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
380 haptic->hwdata = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
381 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
382 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
383 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
384 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
385 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
386 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
387 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
388 * 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
|
389 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
390 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
391 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
|
392 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
393 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
|
394 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
|
395 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
396 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
397 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
398 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
399 * 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
|
400 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
401 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
402 SDL_SYS_HapticMouse(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
403 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
404 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
405 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
406 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
407 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
408 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
409 * 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
|
410 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
411 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
412 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
|
413 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
414 return SDL_FALSE; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
415 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
416 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
417 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
418 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
419 * 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
|
420 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
421 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
422 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
|
423 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
424 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
425 } |
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 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
429 * 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
|
430 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
431 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
432 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
|
433 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
434 return -1; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
437 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
438 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
439 * Closes the haptic device. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
440 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
441 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
442 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
|
443 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
444 if (haptic->hwdata) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
445 |
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
|
446 /* Free effects. */ |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
447 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
|
448 haptic->effects = NULL; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
449 haptic->neffects = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
450 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
451 /* Clean up */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
452 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
|
453 IDirectInputDevice2_Release(haptic->hwdata->device); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
454 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
455 /* Free */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
456 SDL_free(haptic->hwdata); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
457 haptic->hwdata = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
458 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
459 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
460 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
461 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
462 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
463 * 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
|
464 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
465 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
466 SDL_SYS_HapticQuit(void) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
467 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
468 IDirectInput_Release(dinput); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
469 dinput = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
470 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
471 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
472 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
473 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
474 * 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
|
475 */ |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
476 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
|
477 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
|
478 { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
479 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
|
480 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
481 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
|
482 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
483 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
|
484 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
|
485 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
486 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
487 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
|
488 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
489 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
490 |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
491 /* |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
492 * Sets the direction. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
493 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
494 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
|
495 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
|
496 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
497 LONG *rglDir; |
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 /* 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
|
500 if (naxes == 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
501 effect->rglDirection = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
502 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
503 } |
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 /* Has axes. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
506 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
|
507 if (rglDir == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
508 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
509 return -1; |
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 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
|
512 effect->rglDirection = rglDir; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
513 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
514 switch (dir->type) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
515 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
|
516 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
|
517 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
|
518 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
519 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
|
520 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
|
521 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
|
522 rglDir[1] = dir->dir[1]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
523 rglDir[2] = dir->dir[2]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
524 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
525 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
|
526 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
|
527 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
|
528 rglDir[1] = dir->dir[1]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
529 rglDir[2] = dir->dir[2]; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
530 return 0; |
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 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
533 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
|
534 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
535 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
536 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
537 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
538 #define CONVERT(x) (((x)*10000) / 0xFFFF ) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
539 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
540 * 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
|
541 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
542 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
|
543 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
|
544 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 DIENVELOPE *envelope; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
552 SDL_HapticConstant *hap_constant; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
553 SDL_HapticPeriodic *hap_periodic; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
554 SDL_HapticCondition *hap_condition; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
555 SDL_HapticRamp *hap_ramp; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
556 SDL_HapticCustom *hap_custom; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
557 DWORD *axes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
558 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
559 /* 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
|
560 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
|
561 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
|
562 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
|
563 dest->dwGain = 10000; /* Gain is set globally, not locally. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
564 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
565 /* 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
|
566 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
|
567 if (envelope == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
568 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
569 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
570 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
571 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
|
572 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
|
573 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
|
574 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
575 /* Axes. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
576 dest->cAxes = haptic->naxes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
577 if (dest->cAxes > 0) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
578 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
|
579 if (axes == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
580 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
581 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
582 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
583 axes[0] = DIJOFS_X; /* 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
|
584 if (dest->cAxes > 1) { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
585 axes[1] = DIJOFS_Y; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
586 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
587 if (dest->cAxes > 2) { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
588 axes[2] = DIJOFS_Z; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
589 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
590 dest->rgdwAxes = axes; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
591 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
592 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
593 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
594 /* 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
|
595 switch (src->type) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
596 case SDL_HAPTIC_CONSTANT: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
597 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
|
598 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
|
599 if (constant == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
600 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
601 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
602 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
603 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
|
604 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
605 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
606 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
|
607 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
|
608 dest->lpvTypeSpecificParams = constant; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
609 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
610 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 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
|
615 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
616 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
617 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
|
618 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
619 } |
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 /* 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
|
622 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
|
623 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
|
624 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
|
625 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
626 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 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
|
631 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
632 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
633 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
634 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
635 case SDL_HAPTIC_SINE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
636 case SDL_HAPTIC_SQUARE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
637 case SDL_HAPTIC_TRIANGLE: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
638 case SDL_HAPTIC_SAWTOOTHUP: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
639 case SDL_HAPTIC_SAWTOOTHDOWN: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
640 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
|
641 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
|
642 if (periodic == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
643 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
644 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
645 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
646 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
|
647 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
648 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 dest->lpvTypeSpecificParams = periodic; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
655 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
656 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
657 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
|
658 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
|
659 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
|
660 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
|
661 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
662 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
663 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
|
664 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
665 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
666 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
667 /* 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
|
668 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
|
669 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
|
670 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
|
671 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
672 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
673 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
|
674 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
|
675 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
|
676 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
|
677 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
678 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
679 break; |
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 case SDL_HAPTIC_SPRING: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
682 case SDL_HAPTIC_DAMPER: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
683 case SDL_HAPTIC_INERTIA: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
684 case SDL_HAPTIC_FRICTION: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
685 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
|
686 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
|
687 if (condition == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
688 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
689 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
690 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
691 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
|
692 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
693 /* Specifics */ |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
694 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
|
695 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
|
696 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
|
697 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
|
698 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
|
699 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
|
700 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
|
701 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
702 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
|
703 dest->lpvTypeSpecificParams = condition; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
704 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
705 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
706 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
|
707 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
|
708 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
|
709 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
|
710 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
711 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
712 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
|
713 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
714 } |
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 /* Envelope */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
717 /* TODO Check is envelope actually used. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
718 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
719 envelope->dwAttackTime = hap_condition->attack_length * 1000; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
720 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
721 envelope->dwFadeTime = hap_condition->fade_length * 1000; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
722 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
723 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
724 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
725 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
726 case SDL_HAPTIC_RAMP: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
727 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
|
728 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
|
729 if (ramp == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
730 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
731 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
732 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
733 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
|
734 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
735 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 dest->lpvTypeSpecificParams = ramp; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
740 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
741 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 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
|
746 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
747 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
748 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
|
749 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
750 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
751 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
752 /* 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
|
753 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
|
754 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
|
755 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
|
756 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
757 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
758 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
|
759 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
|
760 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
|
761 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
|
762 } |
2551
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 break; |
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 case SDL_HAPTIC_CUSTOM: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
767 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
|
768 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
|
769 if (custom == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
770 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
771 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
772 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
773 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
|
774 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
775 /* Specifics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
783 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
|
784 dest->lpvTypeSpecificParams = custom; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
785 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
786 /* Generics */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
787 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
|
788 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
|
789 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
|
790 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
|
791 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
792 /* Direction. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
793 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
|
794 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
795 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
796 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
797 /* 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
|
798 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
|
799 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
|
800 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
|
801 } |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
802 else { |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
803 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
|
804 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
|
805 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
|
806 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
|
807 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
808 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
809 break; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
810 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
811 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
812 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
813 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
|
814 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
815 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
816 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
817 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
818 } |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
821 /* |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
822 * 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
|
823 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
824 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
|
825 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
|
826 { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
827 DICUSTOMFORCE *custom; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
828 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
829 if (effect->lpEnvelope != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
830 SDL_free(effect->lpEnvelope); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
831 effect->lpEnvelope = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
832 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
833 if (effect->rgdwAxes != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
834 SDL_free(effect->rgdwAxes); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
835 effect->rgdwAxes = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
836 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
837 if (effect->lpvTypeSpecificParams != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
838 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
|
839 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
|
840 SDL_free(custom->rglForceData); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
841 custom->rglForceData = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
842 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
843 SDL_free(effect->lpvTypeSpecificParams); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
844 effect->lpvTypeSpecificParams = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
845 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
846 if (effect->rglDirection != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
847 SDL_free(effect->rglDirection); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
848 effect->rglDirection = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
849 } |
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 |
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 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
854 * 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
|
855 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
856 REFGUID |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
857 SDL_SYS_HapticEffectType(struct haptic_effect * effect) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
858 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
859 switch (effect->effect.type) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
860 case SDL_HAPTIC_CONSTANT: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
861 return &GUID_ConstantForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
862 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
863 case SDL_HAPTIC_RAMP: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
864 return &GUID_RampForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
865 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
866 case SDL_HAPTIC_SQUARE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
867 return &GUID_Square; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
868 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
869 case SDL_HAPTIC_SINE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
870 return &GUID_Sine; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
871 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
872 case SDL_HAPTIC_TRIANGLE: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
873 return &GUID_Triangle; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
874 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
875 case SDL_HAPTIC_SAWTOOTHUP: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
876 return &GUID_SawtoothUp; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
877 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
878 case SDL_HAPTIC_SAWTOOTHDOWN: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
879 return &GUID_SawtoothDown; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
880 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
881 case SDL_HAPTIC_SPRING: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
882 return &GUID_Spring; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
883 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
884 case SDL_HAPTIC_DAMPER: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
885 return &GUID_Damper; |
2551
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 case SDL_HAPTIC_INERTIA: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
888 return &GUID_Inertia; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
889 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
890 case SDL_HAPTIC_FRICTION: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
891 return &GUID_Friction; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
892 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
893 case SDL_HAPTIC_CUSTOM: |
2572
bb1481265341
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2571
diff
changeset
|
894 return &GUID_CustomForce; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
895 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
896 default: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
897 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
|
898 return NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
899 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
900 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
901 |
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 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
904 * 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
|
905 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
906 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
907 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
|
908 SDL_HapticEffect * base) |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
909 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
910 HRESULT ret; |
2574
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
911 |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
912 /* Get the type. */ |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
913 REFGUID type = SDL_SYS_HapticEffectType(effect); |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
914 if (type == NULL) { |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
915 goto err_hweffect; |
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
916 } |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
917 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
918 /* Alloc the effect. */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
919 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
|
920 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
|
921 if (effect->hweffect == NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
922 SDL_OutOfMemory(); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
923 goto err_hweffect; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
924 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
925 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
926 /* 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
|
927 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
|
928 goto err_effectdone; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
929 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
930 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
931 /* 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
|
932 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
|
933 &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
|
934 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
|
935 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
|
936 goto err_effectdone; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
937 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
938 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
939 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
940 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
941 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
|
942 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
|
943 err_hweffect: |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
944 if (effect->hweffect != NULL) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
945 SDL_free(effect->hweffect); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
946 effect->hweffect = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
947 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
948 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
949 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
950 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
951 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
952 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
953 * Updates an effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
954 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
955 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
956 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
|
957 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
|
958 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
959 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
|
960 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
|
961 DIEFFECT temp; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
962 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
963 /* 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
|
964 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
|
965 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
|
966 goto err_update; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
967 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
968 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
969 /* 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
|
970 * 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
|
971 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
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 DIEP_TYPESPECIFICPARAMS; |
2551
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 /* Create the actual effect. */ |
2574
c1f07fdd1e2d
Windows build should compile after this.
Edgar Simo <bobbens@gmail.com>
parents:
2573
diff
changeset
|
980 ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); |
2573
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
981 if (FAILED(ret)) { |
40b89e3d7ab5
More windows haptic patches.
Edgar Simo <bobbens@gmail.com>
parents:
2572
diff
changeset
|
982 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
|
983 goto err_update; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
986 /* 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
|
987 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
|
988 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
|
989 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
990 return 0; |
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 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
|
993 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
|
994 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
995 } |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
998 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
999 * Runs an effect. |
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 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1002 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
|
1003 Uint32 iterations) |
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 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
|
1006 DWORD iter; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1007 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1008 /* 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
|
1009 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
|
1010 iter = INFINITE; |
2551
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1011 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1012 else |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1013 iter = iterations; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1014 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1015 /* 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
|
1016 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
|
1017 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
|
1018 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
|
1019 return -1; |
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 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1023 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1024 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1025 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1026 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1027 * Stops an effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1028 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1029 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1030 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
|
1031 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1032 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1033 |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1034 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
|
1035 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
|
1036 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
|
1037 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1038 } |
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 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1041 } |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1044 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1045 * Frees the effect. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1046 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1047 void |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1048 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
|
1049 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1050 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1051 |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1052 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
|
1053 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
|
1054 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
|
1055 } |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1056 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
|
1057 SDL_free(effect->hweffect); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1058 effect->hweffect = NULL; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1059 } |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1062 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1063 * 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
|
1064 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1065 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1066 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
|
1067 { |
2566
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1068 SDL_SetError("Haptic: Status not supported."); |
94ff09afa478
Basic haptic support for windows should work. Needs testing (probably won't compile).
Edgar Simo <bobbens@gmail.com>
parents:
2561
diff
changeset
|
1069 return -1; |
2551
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 |
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 * Sets the gain. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1075 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1076 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1077 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
|
1078 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1079 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1080 DIPROPDWORD dipdw; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1081 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1082 /* 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
|
1083 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
|
1084 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
|
1085 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1086 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
|
1087 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
|
1088 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1089 /* 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
|
1090 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
|
1091 DIPROP_FFGAIN, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1092 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1093 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
|
1094 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1095 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1096 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1097 return 0; |
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 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1100 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1101 /* |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1102 * Sets the autocentering. |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1103 */ |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1104 int |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1105 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
|
1106 { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1107 HRESULT ret; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1108 DIPROPDWORD dipdw; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1109 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1110 /* 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
|
1111 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
|
1112 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
|
1113 dipdw.diph.dwObj = 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1114 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
|
1115 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
|
1116 DIPROPAUTOCENTER_ON; |
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 /* 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
|
1119 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
|
1120 DIPROP_AUTOCENTER, &dipdw.diph ); |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1121 if (FAILED(ret)) { |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1122 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
|
1123 return -1; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1124 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1125 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1126 return 0; |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1127 |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1128 } |
f010e1d4e431
First version of the windows haptic port, won't compile yet.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1129 |
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 #endif /* SDL_HAPTIC_DINPUT */ |