Mercurial > sdl-ios-xcode
annotate src/haptic/darwin/SDL_syshaptic.c @ 2541:f2649eaa552e gsoc2008_force_feedback
More verbose errors.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 20 Jul 2008 21:50:01 +0000 |
parents | 1f9c20580ab4 |
children | 4e055fa7acb9 |
rev | line source |
---|---|
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2008 Edgar Simo |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
21 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
23 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
24 #ifdef SDL_HAPTIC_IOKIT |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
25 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
26 #include "SDL_haptic.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
27 #include "../SDL_syshaptic.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
28 #include "SDL_joystick.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
29 #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
30 /*#include "../../joystick/dawrin/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
31 |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
32 #include <IOKit/IOKitLib.h> |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
33 #include <IOKit/hid/IOHIDKeys.h> |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 #include <ForceFeedback/ForceFeedback.h> |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
35 #include <ForceFeedback/ForceFeedbackConstants.h> |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
37 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
38 #define MAX_HAPTICS 32 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
39 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
40 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
41 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
42 * List of available haptic devices. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
43 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
44 static struct |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
45 { |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
46 char name[256]; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 io_service_t dev; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 SDL_Haptic *haptic; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 } SDL_hapticlist[MAX_HAPTICS]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
50 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
51 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
52 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 * Haptic system hardware data. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
55 struct haptic_hwdata |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
56 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
57 FFDeviceObjectReference device; /* Hardware device. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
58 }; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
60 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
61 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
62 * Haptic system effect data. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
63 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
64 struct haptic_hweffect |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
65 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
66 FFEffectObjectReference ref; /* Reference. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
67 struct FFEFFECT effect; /* Hardware effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
68 }; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
69 |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
70 /* |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
71 * Prototypes. |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
72 */ |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
73 static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
74 static int HIDGetDeviceProduct(io_service_t dev, char * name); |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
75 |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
76 |
2541 | 77 /* |
78 * Like strerror but for force feedback errors. | |
79 */ | |
80 static const char * | |
81 FFStrError(HRESULT err) | |
82 { | |
83 switch (err) { | |
84 case FFERR_DEVICEFULL: | |
85 return "device full"; | |
86 case FFERR_DEVICENOTREG: | |
87 return "device not registered"; | |
88 case FFERR_DEVICEPAUSED: | |
89 return "device paused"; | |
90 case FFERR_DEVICERELEASED: | |
91 return "device released"; | |
92 case FFERR_EFFECTPLAYING: | |
93 return "effect playing"; | |
94 case FFERR_EFFECTTYPEMISMATCH: | |
95 return "effect type mismatch"; | |
96 case FFERR_EFFECTTYPENOTSUPPORTED: | |
97 return "effect type not supported"; | |
98 case FFERR_GENERIC: | |
99 return "undetermined error"; | |
100 case FFERR_HASEFFECTS: | |
101 return "device has effects"; | |
102 case FFERR_INCOMPLETEEFFECT: | |
103 return "incomplete effect"; | |
104 case FFERR_INTERNAL: | |
105 return "internal fault"; | |
106 case FFERR_INVALIDDOWNLOADID: | |
107 return "invalid download id"; | |
108 case FFERR_INVALIDPARAM: | |
109 return "invalid parameter"; | |
110 case FFERR_MOREDATA: | |
111 return "more data"; | |
112 case FFERR_NOINTERFACE: | |
113 return "interface not supported"; | |
114 case FFERR_NOTDOWNLOADED: | |
115 return "effect is not downloaded"; | |
116 case FFERR_NOTINITIALIZED: | |
117 return "object has not been initialized"; | |
118 case FFERR_OUTOFMEMORY: | |
119 return "out of memory"; | |
120 case FFERR_UNPLUGGED: | |
121 return "device is unplugged"; | |
122 case FFERR_UNSUPPORTED: | |
123 return "function call unsupported"; | |
124 case FFERR_UNSUPPORTEDAXIS: | |
125 return "axis unsupported"; | |
126 | |
127 default: | |
128 return "unknown error"; | |
129 } | |
130 } | |
131 | |
132 | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
133 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
134 * Initializes the haptic subsystem. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
135 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
136 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
137 SDL_SYS_HapticInit(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
138 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
139 int numhaptics; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
140 IOReturn result; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
141 io_iterator_t iter; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 CFDictionaryRef match; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
143 io_service_t device; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
145 /* Clear all the memory. */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
146 SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist)); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
147 |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
148 /* Get HID devices. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
149 match = IOServiceMatching(kIOHIDDeviceKey); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
150 if (match == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 SDL_SetError("Haptic: Failed to get IOServiceMatching."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
152 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
153 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
154 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
155 /* Now search I/O Registry for matching devices. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
156 result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
157 if (result != kIOReturnSuccess) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
158 SDL_SetError("Haptic: Couldn't create a HID object iterator."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
159 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
160 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
161 /* IOServiceGetMatchingServices consumes dictionary. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
162 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
163 numhaptics = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
164 while ((device = IOIteratorNext(iter)) != IO_OBJECT_NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
165 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 /* Check for force feedback. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 if (FFIsForceFeedback(device) == FF_OK) { |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
168 HIDGetDeviceProduct(device, SDL_hapticlist[numhaptics].name); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
169 SDL_hapticlist[numhaptics].dev = device; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 SDL_hapticlist[numhaptics].haptic = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 numhaptics++; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
172 } |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
173 else { /* Free the unused device. */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
174 IOObjectRelease(device); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
175 } |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
176 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
177 /* Reached haptic limit. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
178 if (numhaptics >= MAX_HAPTICS) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
179 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
180 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
181 IOObjectRelease(iter); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
182 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 return numhaptics; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
185 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
187 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
188 * Return the name of a haptic device, does not need to be opened. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 const char * |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
191 SDL_SYS_HapticName(int index) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
192 { |
2537
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
193 return SDL_hapticlist[index].name; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
194 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
195 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
196 /* |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
197 * Gets the device's product name. |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
198 */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
199 static int |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
200 HIDGetDeviceProduct(io_service_t dev, char *name) |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
201 { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
202 CFMutableDictionaryRef hidProperties, usbProperties; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
203 io_registry_entry_t parent1, parent2; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
204 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
205 hidProperties = usbProperties = 0; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
206 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
207 /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
208 * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
209 */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
210 if ((KERN_SUCCESS == |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
211 IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
212 && (KERN_SUCCESS == |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
213 IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
214 && (KERN_SUCCESS == |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
215 IORegistryEntryCreateCFProperties(parent2, &usbProperties, |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
216 kCFAllocatorDefault, |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
217 kNilOptions))) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
218 if (usbProperties) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
219 CFTypeRef refCF = 0; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
220 /* get device info |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
221 * try hid dictionary first, if fail then go to usb dictionary |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
222 */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
223 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
224 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
225 /* Get product name */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
226 refCF = |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
227 CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
228 if (!refCF) |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
229 refCF = |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
230 CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
231 if (refCF) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
232 if (!CFStringGetCString(refCF, name, 256, |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
233 CFStringGetSystemEncoding())) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
234 SDL_SetError("CFStringGetCString error retrieving pDevice->product."); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
235 return -1; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
236 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
237 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
238 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
239 CFRelease(usbProperties); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
240 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
241 else { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
242 SDL_SetError("IORegistryEntryCreateCFProperties failed to create usbProperties."); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
243 return -1; |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
244 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
245 |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
246 /* Release stuff. */ |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
247 if (kIOReturnSuccess != IOObjectRelease(parent2)) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
248 SDL_SetError("IOObjectRelease error with parent2."); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
249 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
250 if (kIOReturnSuccess != IOObjectRelease(parent1)) { |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
251 SDL_SetError("IOObjectRelease error with parent1."); |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
252 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
253 } |
8d92ec01f92f
Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2535
diff
changeset
|
254 return 0; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
255 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
256 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
257 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
258 #define FF_TEST(ff, s) \ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
259 if (features.supportedEffects & ff) supported |= s |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
260 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
261 * Gets supported features. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
262 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
263 static unsigned int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
264 GetSupportedFeatures(FFDeviceObjectReference device, |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
265 int *neffects, int *nplaying, int *naxes) |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
266 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
267 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
268 FFCAPABILITIES features; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
269 unsigned int supported; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
270 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
271 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
272 ret = FFDeviceGetForceFeedbackCapabilities(device, &features); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
273 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
274 SDL_SetError("Haptic: Unable to get device's supported features."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
275 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
276 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
277 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
278 supported = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
279 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
280 /* Get maximum effects. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
281 *neffects = features.storageCapacity; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
282 *nplaying = features.playbackCapacity; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
283 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
284 /* Test for effects. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
285 FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
286 FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
287 FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
288 FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
289 FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
290 FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
291 FF_TEST(FFCAP_ET_SAWTOOTHDOWN, SDL_HAPTIC_SAWTOOTHDOWN); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
292 FF_TEST(FFCAP_ET_SPRING, SDL_HAPTIC_SPRING); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
293 FF_TEST(FFCAP_ET_DAMPER, SDL_HAPTIC_DAMPER); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
294 FF_TEST(FFCAP_ET_INERTIA, SDL_HAPTIC_INERTIA); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
295 FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
296 FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
297 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
298 /* Check if supports gain. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
299 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN, |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
300 &val, sizeof(val)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
301 if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
302 else if (ret != FFERR_UNSUPPORTED) { |
2541 | 303 SDL_SetError("Haptic: Unable to get if device supports gain: %s.", |
304 FFStrError(ret);); | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
305 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
306 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
307 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
308 /* Checks if supports autocenter. */ |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
309 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER, |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
310 &val, sizeof(val)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
311 if (ret == FF_OK) supported |= SDL_HAPTIC_AUTOCENTER; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
312 else if (ret != FFERR_UNSUPPORTED) { |
2541 | 313 SDL_SetError("Haptic: Unable to get if device supports autocenter: %s.", |
314 FFStrError(ret)); | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
315 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
316 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
317 |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
318 /* Check for axes, we have an artificial limit on axes */ |
2528 | 319 *naxes = ((features.numFfAxes) > 3) ? |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
320 3 : features.numFfAxes; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
321 |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
322 /* Always supported features. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
323 supported |= SDL_HAPTIC_STATUS; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
324 return supported; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
325 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
326 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
327 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
328 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
329 * Opens the haptic device from the file descriptor. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
330 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
331 static int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
332 SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
333 { |
2541 | 334 HRESULT ret; |
335 | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
336 /* Allocate the hwdata */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
337 haptic->hwdata = (struct haptic_hwdata *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
338 SDL_malloc(sizeof(*haptic->hwdata)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
339 if (haptic->hwdata == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
340 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
341 goto creat_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
342 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
343 SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
344 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
345 /* Open the device */ |
2541 | 346 ret = FFCreateDevice( service, &haptic->hwdata->device); |
347 if (ret != FF_OK) { | |
348 SDL_SetError("Haptic: Unable to create device from service: %s.", | |
349 FFStrError(ret)); | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
350 goto creat_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
351 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
352 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
353 /* Get supported features. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
354 haptic->supported = GetSupportedFeatures(haptic->hwdata->device, |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
355 &haptic->neffects, &haptic->nplaying, |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
356 &haptic->naxes); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
357 if (haptic->supported == 0) { /* Error since device supports nothing. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
358 goto open_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
359 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
360 haptic->effects = (struct haptic_effect *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
361 SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
362 if (haptic->effects == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
363 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
364 goto open_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
365 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
366 /* Clear the memory */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
367 SDL_memset(haptic->effects, 0, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
368 sizeof(struct haptic_effect) * haptic->neffects); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
369 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
370 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
371 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
372 /* Error handling */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
373 open_err: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
374 FFReleaseDevice(haptic->hwdata->device); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
375 creat_err: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
376 if (haptic->hwdata != NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
377 free(haptic->hwdata); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
378 haptic->hwdata = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
379 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
380 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
381 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
382 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
383 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
384 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
385 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
386 * Opens a haptic device for usage. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
387 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
388 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
389 SDL_SYS_HapticOpen(SDL_Haptic * haptic) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
390 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
391 return SDL_SYS_HapticOpenFromService(haptic, |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
392 SDL_hapticlist[haptic->index].dev); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
393 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
394 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
395 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
396 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
397 * Opens a haptic device from first mouse it finds for usage. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
398 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
399 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
400 SDL_SYS_HapticMouse(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
401 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
402 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
403 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
404 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
405 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
406 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
407 * Checks to see if a joystick has haptic features. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
408 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
409 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
410 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
411 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
412 return SDL_FALSE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
413 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
414 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
415 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
416 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
417 * Checks to see if the haptic device and joystick and in reality the same. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
418 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
419 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
420 SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
421 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
422 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
423 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
424 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
425 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
426 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
427 * Opens a SDL_Haptic from a SDL_Joystick. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
428 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
429 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
430 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
431 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
432 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
433 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
434 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
435 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
436 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
437 * Closes the haptic device. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
438 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
439 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
440 SDL_SYS_HapticClose(SDL_Haptic * haptic) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
441 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
442 int i; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
443 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
444 if (haptic->hwdata) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
445 |
2530 | 446 /* Free the effects. */ |
447 for (i=0; i<haptic->neffects; i++) { | |
448 if (haptic->effects[i].hweffect != NULL) { | |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
449 SDL_SYS_HapticFreeFFEFFECT(&haptic->effects[i].hweffect->effect, |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
450 haptic->effects[i].effect.type); |
2530 | 451 SDL_free(haptic->effects[i].hweffect); |
452 } | |
453 } | |
454 SDL_free(haptic->effects); | |
455 haptic->neffects = 0; | |
456 | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
457 /* Clean up */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
458 FFReleaseDevice(haptic->hwdata->device); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
459 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
460 /* Free */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
461 SDL_free(haptic->hwdata); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
462 haptic->hwdata = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
463 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
464 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
465 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
466 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
467 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
468 * Clean up after system specific haptic stuff |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
469 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
470 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
471 SDL_SYS_HapticQuit(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
472 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
473 int i; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
474 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
475 for (i=0; i < SDL_numhaptics; i++) { |
2530 | 476 /* Opened and not closed haptics are leaked, this is on purpose. |
477 * Close your haptic devices after usage. */ | |
478 | |
479 /* Free the io_service_t */ | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
480 IOObjectRelease(SDL_hapticlist[i].dev); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
481 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
482 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
483 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
484 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
485 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
486 * Sets the direction. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
487 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
488 static int |
2529
e1d5d16e88a8
Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents:
2528
diff
changeset
|
489 SDL_SYS_SetDirection( FFEFFECT * effect, SDL_HapticDirection *dir, int naxes ) |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
490 { |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
491 LONG *rglDir; |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
492 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
493 /* Handle no axes a part. */ |
2528 | 494 if (naxes == 0) { |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
495 effect->rglDirection = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
496 return 0; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
497 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
498 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
499 /* Has axes. */ |
2529
e1d5d16e88a8
Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents:
2528
diff
changeset
|
500 rglDir = SDL_malloc( sizeof(LONG) * naxes ); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
501 if (rglDir == NULL) { |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
502 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
503 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
504 } |
2529
e1d5d16e88a8
Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents:
2528
diff
changeset
|
505 SDL_memset( rglDir, 0, sizeof(LONG) * naxes ); |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
506 effect->rglDirection = rglDir; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
507 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
508 switch (dir->type) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
509 case SDL_HAPTIC_POLAR: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
510 effect->dwFlags |= FFEFF_POLAR; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
511 rglDir[0] = dir->dir[0]; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
512 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
513 case SDL_HAPTIC_CARTESIAN: |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
514 effect->dwFlags |= FFEFF_CARTESIAN; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
515 rglDir[0] = dir->dir[0]; |
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
516 rglDir[1] = dir->dir[1]; |
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
517 rglDir[2] = dir->dir[2]; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
518 return 0; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
519 case SDL_HAPTIC_SPHERICAL: |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
520 effect->dwFlags |= FFEFF_SPHERICAL; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
521 rglDir[0] = dir->dir[0]; |
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
522 rglDir[1] = dir->dir[1]; |
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
523 rglDir[2] = dir->dir[2]; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
524 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
525 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
526 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
527 SDL_SetError("Haptic: Unknown direction type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
528 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
529 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
530 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
531 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
532 #define CONVERT(x) (((x)*10000) / 0xFFFF ) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
533 /* |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
534 * Creates the FFEFFECT from a SDL_HapticEffect. |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
535 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
536 static int |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
537 SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src ) |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
538 { |
2530 | 539 int i; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
540 FFCONSTANTFORCE *constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
541 FFPERIODIC *periodic; |
2530 | 542 FFCONDITION *condition; /* Actually an array of conditions - one per axis. */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
543 FFRAMPFORCE *ramp; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
544 FFCUSTOMFORCE *custom; |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
545 FFENVELOPE *envelope; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
546 SDL_HapticConstant *hap_constant; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
547 SDL_HapticPeriodic *hap_periodic; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
548 SDL_HapticCondition *hap_condition; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
549 SDL_HapticRamp *hap_ramp; |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
550 SDL_HapticCustom *hap_custom; |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
551 DWORD *axes; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
552 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
553 /* Set global stuff. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
554 SDL_memset(dest, 0, sizeof(FFEFFECT)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
555 dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
556 dest->dwSamplePeriod = 0; /* Not used by us. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
557 dest->dwGain = 10000; /* Gain is set globally, not locally. */ |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
558 |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
559 /* Envelope. */ |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
560 envelope = SDL_malloc( sizeof(FFENVELOPE) ); |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
561 if (envelope == NULL) { |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
562 SDL_OutOfMemory(); |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
563 return -1; |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
564 } |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
565 SDL_memset(envelope, 0, sizeof(FFENVELOPE)); |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
566 dest->lpEnvelope = envelope; |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
567 envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
568 |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
569 /* Axes. */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
570 dest->cAxes = haptic->naxes; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
571 if (dest->cAxes > 0) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
572 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
573 if (axes == NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
574 SDL_OutOfMemory(); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
575 return -1; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
576 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
577 axes[0] = FFJOFS_X; /* Always at least one axis. */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
578 if (dest->cAxes > 1) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
579 axes[1] = FFJOFS_Y; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
580 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
581 if (dest->cAxes > 2) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
582 axes[2] = FFJOFS_Z; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
583 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
584 dest->rgdwAxes = axes; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
585 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
586 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
587 |
2530 | 588 /* The big type handling switch, even bigger then linux's version. */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
589 switch (src->type) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
590 case SDL_HAPTIC_CONSTANT: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
591 hap_constant = &src->constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
592 constant = SDL_malloc( sizeof(FFCONSTANTFORCE) ); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
593 if (constant == NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
594 SDL_OutOfMemory(); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
595 return -1; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
596 } |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
597 SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
598 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
599 /* Specifics */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
600 constant->lMagnitude = CONVERT(hap_constant->level); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
601 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
602 dest->lpvTypeSpecificParams = constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
603 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
604 /* Generics */ |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
605 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
606 dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
607 dest->dwTriggerRepeatInterval = hap_constant->interval; |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
608 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
609 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
610 /* Direction. */ |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
611 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
612 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
613 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
614 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
615 /* Envelope */ |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
616 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level); |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
617 envelope->dwAttackTime = hap_constant->attack_length * 1000; |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
618 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level); |
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
619 envelope->dwFadeTime = hap_constant->fade_length * 1000; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
620 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
621 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
622 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
623 case SDL_HAPTIC_SINE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
624 case SDL_HAPTIC_SQUARE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
625 case SDL_HAPTIC_TRIANGLE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
626 case SDL_HAPTIC_SAWTOOTHUP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
627 case SDL_HAPTIC_SAWTOOTHDOWN: |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
628 hap_periodic = &src->periodic; |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
629 periodic = SDL_malloc(sizeof(FFPERIODIC)); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
630 if (periodic == NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
631 SDL_OutOfMemory(); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
632 return -1; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
633 } |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
634 SDL_memset(periodic, 0, sizeof(FFPERIODIC)); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
635 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
636 /* Specifics */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
637 periodic->dwMagnitude = CONVERT(hap_periodic->magnitude); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
638 periodic->lOffset = CONVERT(hap_periodic->offset); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
639 periodic->dwPhase = hap_periodic->phase; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
640 periodic->dwPeriod = hap_periodic->period * 1000; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
641 dest->cbTypeSpecificParams = sizeof(FFPERIODIC); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
642 dest->lpvTypeSpecificParams = periodic; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
643 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
644 /* Generics */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
645 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
646 dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
647 dest->dwTriggerRepeatInterval = hap_periodic->interval; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
648 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
649 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
650 /* Direction. */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
651 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
652 return -1; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
653 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
654 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
655 /* Envelope */ |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
656 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
657 envelope->dwAttackTime = hap_periodic->attack_length * 1000; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
658 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
659 envelope->dwFadeTime = hap_periodic->fade_length * 1000; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
660 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
661 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
662 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
663 case SDL_HAPTIC_SPRING: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
664 case SDL_HAPTIC_DAMPER: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
665 case SDL_HAPTIC_INERTIA: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
666 case SDL_HAPTIC_FRICTION: |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
667 hap_condition = &src->condition; |
2530 | 668 condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes); |
669 if (condition == NULL) { | |
670 SDL_OutOfMemory(); | |
671 return -1; | |
672 } | |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
673 SDL_memset(condition, 0, sizeof(FFCONDITION)); |
2530 | 674 |
675 /* Specifics */ | |
676 for (i=0; i<dest->cAxes; i++) { | |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
677 condition[i].lOffset = CONVERT(hap_condition->center[i]); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
678 condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
679 condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
680 condition[i].dwPositiveSaturation = CONVERT(hap_condition->right_sat[i]); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
681 condition[i].dwNegativeSaturation = CONVERT(hap_condition->left_sat[i]); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
682 condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]); |
2530 | 683 } |
684 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes; | |
685 dest->lpvTypeSpecificParams = condition; | |
686 | |
687 /* Generics */ | |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
688 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
689 dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
690 dest->dwTriggerRepeatInterval = hap_condition->interval; |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
691 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ |
2530 | 692 |
693 /* Direction. */ | |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
694 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { |
2530 | 695 return -1; |
696 } | |
697 | |
2532 | 698 /* Envelope */ |
699 /* TODO Check is envelope actually used. | |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
700 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
701 envelope->dwAttackTime = hap_condition->attack_length * 1000; |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
702 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level); |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
703 envelope->dwFadeTime = hap_condition->fade_length * 1000; |
2532 | 704 */ |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
705 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
706 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
707 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
708 case SDL_HAPTIC_RAMP: |
2522
0877146be013
Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents:
2521
diff
changeset
|
709 hap_ramp = &src->ramp; |
2533
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
710 ramp = SDL_malloc(sizeof(FFRAMPFORCE)); |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
711 if (ramp == NULL) { |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
712 SDL_OutOfMemory(); |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
713 return -1; |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
714 } |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
715 SDL_memset(ramp, 0, sizeof(FFRAMPFORCE)); |
2533
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
716 |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
717 /* Specifics */ |
2534
e597de8dccd5
Was a typo in the mac os x documentation.
Edgar Simo <bobbens@gmail.com>
parents:
2533
diff
changeset
|
718 ramp->lStart = CONVERT(hap_ramp->start); |
2533
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
719 ramp->lEnd = CONVERT(hap_ramp->end); |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
720 dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
721 dest->lpvTypeSpecificParams = ramp; |
2533
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
722 |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
723 /* Generics */ |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
724 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
725 dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button); |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
726 dest->dwTriggerRepeatInterval = hap_ramp->interval; |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
727 dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
728 |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
729 /* Direction. */ |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
730 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
731 return -1; |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
732 } |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
733 |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
734 /* Envelope */ |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
735 envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level); |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
736 envelope->dwAttackTime = hap_ramp->attack_length * 1000; |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
737 envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level); |
0c8cea99c4b8
Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2532
diff
changeset
|
738 envelope->dwFadeTime = hap_ramp->fade_length * 1000; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
739 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
740 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
741 |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
742 case SDL_HAPTIC_CUSTOM: |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
743 hap_custom = &src->custom; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
744 custom = SDL_malloc(sizeof(FFCUSTOMFORCE)); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
745 if (custom == NULL) { |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
746 SDL_OutOfMemory(); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
747 return -1; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
748 } |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
749 SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE)); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
750 |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
751 /* Specifics */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
752 custom->cChannels = hap_custom->channels; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
753 custom->dwSamplePeriod = hap_custom->period * 1000; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
754 custom->cSamples = hap_custom->samples; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
755 custom->rglForceData = SDL_malloc(sizeof(LONG)*custom->cSamples*custom->cChannels); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
756 for (i=0; i<hap_custom->samples*hap_custom->channels; i++) { /* Copy data. */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
757 custom->rglForceData[i] = CONVERT(hap_custom->data[i]); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
758 } |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
759 dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
760 dest->lpvTypeSpecificParams = custom; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
761 |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
762 /* Generics */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
763 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
764 dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
765 dest->dwTriggerRepeatInterval = hap_custom->interval; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
766 dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
767 |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
768 /* Direction. */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
769 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
770 return -1; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
771 } |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
772 |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
773 /* Envelope */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
774 envelope->dwAttackLevel = CONVERT(hap_custom->attack_level); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
775 envelope->dwAttackTime = hap_custom->attack_length * 1000; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
776 envelope->dwFadeLevel = CONVERT(hap_custom->fade_level); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
777 envelope->dwFadeTime = hap_custom->fade_length * 1000; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
778 |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
779 break; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
780 |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
781 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
782 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
783 SDL_SetError("Haptic: Unknown effect type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
784 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
785 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
786 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
787 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
788 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
789 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
790 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
791 /* |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
792 * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT. |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
793 */ |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
794 static void |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
795 SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect, int type ) |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
796 { |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
797 FFCUSTOMFORCE *custom; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
798 |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
799 if (effect->lpEnvelope != NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
800 SDL_free(effect->lpEnvelope); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
801 effect->lpEnvelope = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
802 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
803 if (effect->rgdwAxes != NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
804 SDL_free(effect->rgdwAxes); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
805 effect->rgdwAxes = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
806 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
807 if (effect->lpvTypeSpecificParams != NULL) { |
2535
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
808 if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
809 custom = (FFCUSTOMFORCE*) effect->lpvTypeSpecificParams; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
810 SDL_free(custom->rglForceData); |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
811 custom->rglForceData = NULL; |
f0ed8471497d
Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents:
2534
diff
changeset
|
812 } |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
813 SDL_free(effect->lpvTypeSpecificParams); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
814 effect->lpvTypeSpecificParams = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
815 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
816 if (effect->rglDirection != NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
817 SDL_free(effect->rglDirection); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
818 effect->rglDirection = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
819 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
820 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
821 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
822 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
823 /* |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
824 * Gets the effect type from the generic SDL haptic effect wrapper. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
825 */ |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
826 CFUUIDRef |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
827 SDL_SYS_HapticEffectType(struct haptic_effect * effect) |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
828 { |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
829 switch (effect->effect.type) { |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
830 case SDL_HAPTIC_CONSTANT: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
831 return kFFEffectType_ConstantForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
832 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
833 case SDL_HAPTIC_RAMP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
834 return kFFEffectType_RampForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
835 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
836 case SDL_HAPTIC_SQUARE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
837 return kFFEffectType_Square_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
838 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
839 case SDL_HAPTIC_SINE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
840 return kFFEffectType_Sine_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
841 |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
842 case SDL_HAPTIC_TRIANGLE: |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
843 return kFFEffectType_Triangle_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
844 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
845 case SDL_HAPTIC_SAWTOOTHUP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
846 return kFFEffectType_SawtoothUp_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
847 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
848 case SDL_HAPTIC_SAWTOOTHDOWN: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
849 return kFFEffectType_SawtoothDown_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
850 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
851 case SDL_HAPTIC_SPRING: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
852 return kFFEffectType_Spring_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
853 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
854 case SDL_HAPTIC_DAMPER: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
855 return kFFEffectType_Damper_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
856 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
857 case SDL_HAPTIC_INERTIA: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
858 return kFFEffectType_Inertia_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
859 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
860 case SDL_HAPTIC_FRICTION: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
861 return kFFEffectType_Friction_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
862 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
863 case SDL_HAPTIC_CUSTOM: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
864 return kFFEffectType_CustomForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
865 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
866 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
867 SDL_SetError("Haptic: Unknown effect type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
868 return NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
869 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
870 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
871 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
872 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
873 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
874 * Creates a new haptic effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
875 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
876 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
877 SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect * effect, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
878 SDL_HapticEffect * base) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
879 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
880 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
881 CFUUIDRef type; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
882 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
883 /* Alloc the effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
884 effect->hweffect = (struct haptic_hweffect *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
885 SDL_malloc(sizeof(struct haptic_hweffect)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
886 if (effect->hweffect == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
887 SDL_OutOfMemory(); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
888 goto err_hweffect; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
889 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
890 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
891 /* Get the type. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
892 type = SDL_SYS_HapticEffectType(effect); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
893 if (type == NULL) { |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
894 goto err_hweffect; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
895 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
896 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
897 /* Get the effect. */ |
2538
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
898 if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) { |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
899 goto err_effectdone; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
900 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
901 |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
902 /* Create the actual effect. */ |
2538
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
903 ret = FFDeviceCreateEffect(haptic->hwdata->device, type, |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
904 &effect->hweffect->effect, &effect->hweffect->ref); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
905 if (ret != FF_OK) { |
2541 | 906 SDL_SetError("Haptic: Unable to create effect: %s.", FFStrError(ret)); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
907 goto err_effectdone; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
908 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
909 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
910 return 0; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
911 |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
912 err_effectdone: |
2538
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
913 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type); |
2527
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
914 err_hweffect: |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
915 if (effect->hweffect != NULL) { |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
916 SDL_free(effect->hweffect); |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
917 effect->hweffect = NULL; |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
918 } |
924a32719b6f
Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents:
2522
diff
changeset
|
919 return -1; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
920 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
921 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
922 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
923 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
924 * Updates an effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
925 */ |
2531
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
926 int |
7f2a4c387292
Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents:
2530
diff
changeset
|
927 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
928 struct haptic_effect * effect, SDL_HapticEffect * data) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
929 { |
2538
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
930 HRESULT ret; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
931 FFEffectParameterFlag flags; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
932 FFEFFECT temp; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
933 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
934 /* Get the effect. */ |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
935 SDL_memset(&temp, 0, sizeof(FFEFFECT)); |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
936 if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) { |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
937 goto err_update; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
938 } |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
939 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
940 /* Set the flags. Might be worthwhile to diff temp with loaded effect and |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
941 * only change those parameters. */ |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
942 flags = FFEP_ALLPARAMS; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
943 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
944 /* Create the actual effect. */ |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
945 ret = FFEffectSetParameters(haptic->hwdata->device, effect->hweffect->ref, |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
946 &temp, flags); |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
947 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
948 if (ret != FF_OK) { |
2541 | 949 SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret)); |
2538
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
950 goto err_update; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
951 } |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
952 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
953 /* Copy it over. */ |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
954 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type); |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
955 SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT)); |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
956 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
957 return 0; |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
958 |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
959 err_update: |
1f9c20580ab4
Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents:
2537
diff
changeset
|
960 SDL_SYS_HapticFreeFFEFFECT(&temp, data->type); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
961 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
962 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
963 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
964 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
965 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
966 * Runs an effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
967 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
968 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
969 SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect * effect, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
970 Uint32 iterations) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
971 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
972 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
973 Uint32 iter; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
974 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
975 /* Check if it's infinite. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
976 if (iterations == SDL_HAPTIC_INFINITY) { |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
977 iter = FF_INFINITE; |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
978 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
979 else |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
980 iter = iterations; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
981 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
982 /* Run the effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
983 ret = FFEffectStart(effect->hweffect->ref, iter, 0); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
984 if (ret != FF_OK) { |
2541 | 985 SDL_SetError("Haptic: Unable to run the effect: %s.", FFStrError(ret)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
986 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
987 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
988 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
989 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
990 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
991 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
992 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
993 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
994 * Stops an effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
995 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
996 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
997 SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect * effect) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
998 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
999 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1000 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1001 ret = FFEffectStop(effect->hweffect->ref); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1002 if (ret != FF_OK) { |
2541 | 1003 SDL_SetError("Haptic: Unable to stop the effect: %s.", FFStrError(ret)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1004 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1005 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1006 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1007 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1008 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1009 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1010 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1011 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1012 * Frees the effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1013 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1014 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1015 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1016 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1017 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1018 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1019 ret = FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1020 if (ret != FF_OK) { |
2541 | 1021 SDL_SetError("Haptic: Error removing the effect from the device: %s.", |
1022 FFStrError(ret)); | |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1023 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1024 SDL_free(effect->hweffect->effect.lpvTypeSpecificParams); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1025 effect->hweffect->effect.lpvTypeSpecificParams = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1026 SDL_free(effect->hweffect); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1027 effect->hweffect = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1028 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1029 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1030 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1031 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1032 * Gets the status of a haptic effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1033 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1034 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1035 SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect * effect) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1036 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1037 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1038 FFEffectStatusFlag status; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1039 |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
1040 ret = FFEffectGetEffectStatus(effect->hweffect->ref, &status); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1041 if (ret != FF_OK) { |
2541 | 1042 SDL_SetError("Haptic: Unable to get effect status: %s.", FFStrError(ret)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1043 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1044 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1045 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1046 if (status == 0) return SDL_FALSE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1047 return SDL_TRUE; /* Assume it's playing or emulated. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1048 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1049 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1050 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1051 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1052 * Sets the gain. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1053 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1054 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1055 SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1056 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1057 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1058 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1059 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1060 val = gain * 100; /* Mac OS X uses 0 to 10,000 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1061 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, FFPROP_FFGAIN, &val); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1062 if (ret != FF_OK) { |
2541 | 1063 SDL_SetError("Haptic: Error setting gain: %s.", FFStrError(ret)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1064 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1065 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1066 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1067 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1068 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1069 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1070 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1071 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1072 * Sets the autocentering. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1073 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1074 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1075 SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1076 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1077 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1078 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1079 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1080 /* Mac OS X only has 0 (off) and 1 (on) */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1081 if (autocenter == 0) val = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1082 else val = 1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1083 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1084 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, |
2521
7aa91c21ce5f
Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents:
2520
diff
changeset
|
1085 FFPROP_AUTOCENTER, &val); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1086 if (ret != FF_OK) { |
2541 | 1087 SDL_SetError("Haptic: Error setting autocenter: %s.", FFStrError(ret)); |
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1088 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1089 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1090 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1091 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1092 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1093 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1094 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1095 |
2541 | 1096 #endif /* SDL_HAPTIC_IOKIT */ |