annotate src/haptic/darwin/SDL_syshaptic.c @ 2642:b04679da6627 gsoc2008_force_feedback

Simplified some error messages.
author Edgar Simo <bobbens@gmail.com>
date Mon, 11 Aug 2008 15:29:28 +0000
parents e1e1be935178
children 269ba4f28d0e
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 */
2633
6b0d1f494c10 Fixed typo.
Edgar Simo <bobbens@gmail.com>
parents: 2632
diff changeset
30 #include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */
2520
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 {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
46 char name[256]; /* Name of the device. */
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
47
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
48 io_service_t dev; /* Node we use to create the device. */
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
49 SDL_Haptic *haptic; /* Haptic currently assosciated with it. */
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
50
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
51 /* Usage pages for determining if it's a mouse or not. */
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
52 long usage;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
53 long usagePage;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54 } SDL_hapticlist[MAX_HAPTICS];
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55
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 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58 * Haptic system hardware data.
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 struct haptic_hwdata
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 FFDeviceObjectReference device; /* Hardware device. */
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
63 UInt8 axes[3];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 };
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68 * Haptic system effect data.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
70 struct haptic_hweffect
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
72 FFEffectObjectReference ref; /* Reference. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
73 struct FFEFFECT effect; /* Hardware effect. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
74 };
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
76 /*
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
77 * Prototypes.
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
78 */
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
79 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
80 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
81
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
83 /*
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
84 * Like strerror but for force feedback errors.
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
85 */
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
86 static const char *
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
87 FFStrError(HRESULT err)
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
88 {
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
89 switch (err) {
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
90 case FFERR_DEVICEFULL:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
91 return "device full";
2608
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
92 /* This should be valid, but for some reason isn't defined... */
2543
3544a632064c Commented out a bit until definition is found.
Edgar Simo <bobbens@gmail.com>
parents: 2542
diff changeset
93 /*case FFERR_DEVICENOTREG:
3544a632064c Commented out a bit until definition is found.
Edgar Simo <bobbens@gmail.com>
parents: 2542
diff changeset
94 return "device not registered";*/
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
95 case FFERR_DEVICEPAUSED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
96 return "device paused";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
97 case FFERR_DEVICERELEASED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
98 return "device released";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
99 case FFERR_EFFECTPLAYING:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
100 return "effect playing";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
101 case FFERR_EFFECTTYPEMISMATCH:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
102 return "effect type mismatch";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
103 case FFERR_EFFECTTYPENOTSUPPORTED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
104 return "effect type not supported";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
105 case FFERR_GENERIC:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
106 return "undetermined error";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
107 case FFERR_HASEFFECTS:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
108 return "device has effects";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
109 case FFERR_INCOMPLETEEFFECT:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
110 return "incomplete effect";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
111 case FFERR_INTERNAL:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
112 return "internal fault";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
113 case FFERR_INVALIDDOWNLOADID:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
114 return "invalid download id";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
115 case FFERR_INVALIDPARAM:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
116 return "invalid parameter";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
117 case FFERR_MOREDATA:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
118 return "more data";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
119 case FFERR_NOINTERFACE:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
120 return "interface not supported";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
121 case FFERR_NOTDOWNLOADED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
122 return "effect is not downloaded";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
123 case FFERR_NOTINITIALIZED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
124 return "object has not been initialized";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
125 case FFERR_OUTOFMEMORY:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
126 return "out of memory";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
127 case FFERR_UNPLUGGED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
128 return "device is unplugged";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
129 case FFERR_UNSUPPORTED:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
130 return "function call unsupported";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
131 case FFERR_UNSUPPORTEDAXIS:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
132 return "axis unsupported";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
133
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
134 default:
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
135 return "unknown error";
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
136 }
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
137 }
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
138
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
139
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 * Initializes the haptic subsystem.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 SDL_SYS_HapticInit(void)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
145 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 int numhaptics;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 IOReturn result;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 io_iterator_t iter;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149 CFDictionaryRef match;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
150 io_service_t device;
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
151 CFMutableDictionaryRef hidProperties;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
152 CFTypeRef refCF;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
154 /* Clear all the memory. */
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
155 SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist));
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
156
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
157 /* Get HID devices. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 match = IOServiceMatching(kIOHIDDeviceKey);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
159 if (match == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
160 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
161 return -1;
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164 /* 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
165 result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
166 if (result != kIOReturnSuccess) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167 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
168 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
169 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170 /* IOServiceGetMatchingServices consumes dictionary. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
171
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
172 if (!IOIteratorIsValid(iter)) { /* No iterator. */
2639
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
173 numhaptics = 0;
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
174 return 0;
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
175 }
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
176
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177 numhaptics = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
178 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
179
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180 /* Check for force feedback. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 if (FFIsForceFeedback(device) == FF_OK) {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
182
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
183 /* Set basic device data. */
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
184 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
185 SDL_hapticlist[numhaptics].dev = device;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 SDL_hapticlist[numhaptics].haptic = NULL;
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
187
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
188 /* Set usage pages. */
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
189 hidProperties = 0;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
190 refCF = 0;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
191 result = IORegistryEntryCreateCFProperties(device,
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
192 &hidProperties, kCFAllocatorDefault, kNilOptions);
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
193 if ((result == KERN_SUCCESS) && hidProperties) {
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
194 refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
195 if (refCF) {
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
196 if (!CFNumberGetValue(refCF, kCFNumberLongType,
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
197 &SDL_hapticlist[numhaptics].usagePage))
2642
b04679da6627 Simplified some error messages.
Edgar Simo <bobbens@gmail.com>
parents: 2641
diff changeset
198 SDL_SetError("Haptic: Recieving device's usage page.");
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
199 refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey));
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
200 if (refCF) {
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
201 if (!CFNumberGetValue(refCF, kCFNumberLongType,
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
202 &SDL_hapticlist[numhaptics].usage))
2642
b04679da6627 Simplified some error messages.
Edgar Simo <bobbens@gmail.com>
parents: 2641
diff changeset
203 SDL_SetError("Haptic: Recieving device's usage.");
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
204 }
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
205 }
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
206 CFRelease(hidProperties);
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
207 }
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
208
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
209 /* Device has been added. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
210 numhaptics++;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
211 }
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
212 else { /* Free the unused device. */
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
213 IOObjectRelease(device);
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
214 }
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
215
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
216 /* Reached haptic limit. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
217 if (numhaptics >= MAX_HAPTICS)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
218 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
219 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
220 IOObjectRelease(iter);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
221
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
222 return numhaptics;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
223 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
224
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
225
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
226 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
227 * 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
228 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 const char *
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
230 SDL_SYS_HapticName(int index)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231 {
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
232 return SDL_hapticlist[index].name;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
233 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
234
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
235 /*
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
236 * Gets the device's product name.
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 static int
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
239 HIDGetDeviceProduct(io_service_t dev, char *name)
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 CFMutableDictionaryRef hidProperties, usbProperties;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
242 io_registry_entry_t parent1, parent2;
2546
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
243 kern_return_t ret;
2537
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 hidProperties = usbProperties = 0;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
246
2547
3cfe0ae232c0 Accidently left in hidDevice.
Edgar Simo <bobbens@gmail.com>
parents: 2546
diff changeset
247 ret = IORegistryEntryCreateCFProperties(dev, &hidProperties,
2546
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
248 kCFAllocatorDefault,
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
249 kNilOptions);
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
250 if ((ret != KERN_SUCCESS) || !hidProperties) {
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
251 SDL_SetError("Haptic: Unable to create CFProperties.");
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
252 return -1;
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
253 }
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
254
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
255 /* 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
256 * 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
257 */
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
258 if ((KERN_SUCCESS ==
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
259 IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1))
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
260 && (KERN_SUCCESS ==
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
261 IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2))
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
262 && (KERN_SUCCESS ==
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
263 IORegistryEntryCreateCFProperties(parent2, &usbProperties,
2546
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
264 kCFAllocatorDefault,
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
265 kNilOptions))) {
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
266 if (usbProperties) {
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
267 CFTypeRef refCF = 0;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
268 /* get device info
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
269 * 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
270 */
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
271
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
272
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
273 /* Get product name */
2546
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
274 refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
275 if (!refCF)
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
276 refCF =
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
277 CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name"));
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
278 if (refCF) {
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
279 if (!CFStringGetCString(refCF, name, 256,
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
280 CFStringGetSystemEncoding())) {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
281 SDL_SetError("Haptic: CFStringGetCString error retrieving pDevice->product.");
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
282 return -1;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
283 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
284 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
285
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
286 CFRelease(usbProperties);
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
287 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
288 else {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
289 SDL_SetError("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
290 return -1;
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
291 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
292
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
293 /* Release stuff. */
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
294 if (kIOReturnSuccess != IOObjectRelease(parent2)) {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
295 SDL_SetError("Haptic: IOObjectRelease error with parent2.");
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
296 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
297 if (kIOReturnSuccess != IOObjectRelease(parent1)) {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
298 SDL_SetError("Haptic: IOObjectRelease error with parent1.");
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
299 }
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
300 }
2546
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
301 else {
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
302 SDL_SetError("Haptic: Error getting registry entries.");
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
303 return -1;
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
304 }
daf40497dcd4 Attempt to fix HIDGetDeviceProduct.
Edgar Simo <bobbens@gmail.com>
parents: 2543
diff changeset
305
2537
8d92ec01f92f Support for SDL_HapticName in darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2535
diff changeset
306 return 0;
2520
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
309
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 #define FF_TEST(ff, s) \
2608
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
311 if (features.supportedEffects & (ff)) supported |= (s)
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
312 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
313 * Gets supported features.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
314 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
315 static unsigned int
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
316 GetSupportedFeatures(SDL_Haptic* haptic)
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
317 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
318 HRESULT ret;
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
319 FFDeviceObjectReference device;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
320 FFCAPABILITIES features;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
321 unsigned int supported;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
322 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
323
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
324 device = haptic->hwdata->device;
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
325
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
326 ret = FFDeviceGetForceFeedbackCapabilities(device, &features);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
327 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
328 SDL_SetError("Haptic: Unable to get device's supported features.");
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
329 return -1;
2520
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
332 supported = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
333
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
334 /* Get maximum effects. */
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
335 haptic->neffects = features.storageCapacity;
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
336 haptic->nplaying = features.playbackCapacity;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
337
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
338 /* Test for effects. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 /* Check if supports gain. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
353 ret = FFDeviceGetForceFeedbackProperty( device, FFPROP_FFGAIN,
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
354 &val, sizeof(val));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
355 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
356 else if (ret != FFERR_UNSUPPORTED) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
357 SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
2542
4e055fa7acb9 Fixed some stupid mistakes.
Edgar Simo <bobbens@gmail.com>
parents: 2541
diff changeset
358 FFStrError(ret));
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
359 return -1;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
360 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
361
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
362 /* Checks if supports autocenter. */
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
363 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER,
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
364 &val, sizeof(val));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
365 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
366 else if (ret != FFERR_UNSUPPORTED) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
367 SDL_SetError("Haptic: Unable to get if device supports autocenter: %s.",
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
368 FFStrError(ret));
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
369 return -1;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
370 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
372 /* Check for axes, we have an artificial limit on axes */
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
373 haptic->naxes = ((features.numFfAxes) > 3) ?
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
374 3 : features.numFfAxes;
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
375 /* Actually store the axes we want to use */
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
376 SDL_memcpy( haptic->hwdata->axes, features.ffAxes, haptic->naxes * sizeof(Uint8));
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
377
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
378 /* Always supported features. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379 supported |= SDL_HAPTIC_STATUS;
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
380
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
381 haptic->supported = supported;
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
382 return 0;;
2520
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 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
387 * 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
388 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389 static int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
390 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
391 {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
392 HRESULT ret;
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
393 int ret2;
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
394
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
395 /* Allocate the hwdata */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 haptic->hwdata = (struct haptic_hwdata *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
397 SDL_malloc(sizeof(*haptic->hwdata));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
398 if (haptic->hwdata == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
399 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400 goto creat_err;
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 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
403
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
404 /* Open the device */
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
405 ret = FFCreateDevice( service, &haptic->hwdata->device);
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
406 if (ret != FF_OK) {
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
407 SDL_SetError("Haptic: Unable to create device from service: %s.",
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
408 FFStrError(ret));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
409 goto creat_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
410 }
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 /* Get supported features. */
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
413 ret2 = GetSupportedFeatures( haptic );
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
414 if (haptic->supported < 0) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
415 goto open_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
416 }
2550
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
417
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
418
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
419 /* Reset and then enable actuators. */
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
420 ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
421 FFSFFC_RESET );
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
422 if (ret != FF_OK) {
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
423 SDL_SetError("Haptic: Unable to reset device: %s.", FFStrError(ret));
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
424 goto open_err;
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
425 }
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
426 ret = FFDeviceSendForceFeedbackCommand( haptic->hwdata->device,
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
427 FFSFFC_SETACTUATORSON );
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
428 if (ret != FF_OK) {
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
429 SDL_SetError("Haptic: Unable to enable actuators: %s.", FFStrError(ret));
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
430 goto open_err;
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
431 }
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
432
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
433
b5b8a7f4a965 Reset device and enable actuators when initializing.
Edgar Simo <bobbens@gmail.com>
parents: 2547
diff changeset
434 /* Allocate effects memory. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
435 haptic->effects = (struct haptic_effect *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
436 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
437 if (haptic->effects == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
438 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
439 goto open_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
440 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
441 /* Clear the memory */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
442 SDL_memset(haptic->effects, 0,
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
443 sizeof(struct haptic_effect) * haptic->neffects);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
444
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
445 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
446
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
447 /* Error handling */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
448 open_err:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
449 FFReleaseDevice(haptic->hwdata->device);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
450 creat_err:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
451 if (haptic->hwdata != NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
452 free(haptic->hwdata);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
453 haptic->hwdata = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
454 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
456
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
458
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 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
461 * Opens a haptic device for usage.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
462 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
463 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
464 SDL_SYS_HapticOpen(SDL_Haptic * haptic)
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 return SDL_SYS_HapticOpenFromService(haptic,
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
467 SDL_hapticlist[haptic->index].dev);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
468 }
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
472 * 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
473 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
474 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 SDL_SYS_HapticMouse(void)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
476 {
2641
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
477 int i;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
478
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
479 for (i=0; i<SDL_numhaptics; i++) {
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
480 if ((SDL_hapticlist[i].usagePage == kHIDPage_GenericDesktop) &&
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
481 (SDL_hapticlist[i].usage == kHIDUsage_GD_Mouse))
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
482 return i;
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
483 }
e1e1be935178 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2639
diff changeset
484
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
485 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
486 }
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
490 * 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
491 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
492 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
493 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 {
2637
2f826c229d77 First draft of darwin haptic<->joystick stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2633
diff changeset
495 if (joystick->hwdata->ffservice != 0)
2f826c229d77 First draft of darwin haptic<->joystick stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2633
diff changeset
496 return SDL_TRUE;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
497 return SDL_FALSE;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
498 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
499
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
500
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
501 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
502 * 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
503 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
504 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
505 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
506 {
2639
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
507 if (IOObjectIsEqualTo((io_object_t) haptic->hwdata->device,
668fee3b268a Casting for warnings.
Edgar Simo <bobbens@gmail.com>
parents: 2637
diff changeset
508 joystick->hwdata->ffservice))
2637
2f826c229d77 First draft of darwin haptic<->joystick stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2633
diff changeset
509 return 1;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
510 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
511 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
512
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
513
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
514 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
515 * 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
516 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
517 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
518 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
519 {
2637
2f826c229d77 First draft of darwin haptic<->joystick stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2633
diff changeset
520 return SDL_SYS_HapticOpenFromService(haptic,
2f826c229d77 First draft of darwin haptic<->joystick stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2633
diff changeset
521 joystick->hwdata->ffservice);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
522 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
523
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
524
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 * Closes the haptic device.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
527 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
528 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
529 SDL_SYS_HapticClose(SDL_Haptic * haptic)
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 if (haptic->hwdata) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
532
2561
3696b9ce8a37 Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c.
Edgar Simo <bobbens@gmail.com>
parents: 2559
diff changeset
533 /* Free Effects. */
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
534 SDL_free(haptic->effects);
2561
3696b9ce8a37 Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c.
Edgar Simo <bobbens@gmail.com>
parents: 2559
diff changeset
535 haptic->effects = NULL;
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
536 haptic->neffects = 0;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
537
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
538 /* Clean up */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
539 FFReleaseDevice(haptic->hwdata->device);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
540
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
541 /* Free */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
542 SDL_free(haptic->hwdata);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
543 haptic->hwdata = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
544 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
545 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
546
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
547
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
548 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
549 * 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
550 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
551 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
552 SDL_SYS_HapticQuit(void)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
553 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
554 int i;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
555
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
556 for (i=0; i < SDL_numhaptics; i++) {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
557 /* Opened and not closed haptics are leaked, this is on purpose.
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
558 * Close your haptic devices after usage. */
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
559
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
560 /* Free the io_service_t */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
561 IOObjectRelease(SDL_hapticlist[i].dev);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
562 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
563 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
564
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
565
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
566 /*
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
567 * Converts an SDL trigger button to an FFEFFECT trigger button.
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
568 */
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
569 static DWORD
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
570 FFGetTriggerButton( Uint16 button )
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
571 {
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
572 DWORD dwTriggerButton;
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
573
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
574 dwTriggerButton = FFEB_NOTRIGGER;
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
575
2555
f5bcc926bac4 Not being able to compile locally gets on my nerves.
Edgar Simo <bobbens@gmail.com>
parents: 2554
diff changeset
576 if (button != 0) {
2556
fe346eddd3fb Updated button trigger stuff.
Edgar Simo <bobbens@gmail.com>
parents: 2555
diff changeset
577 dwTriggerButton = FFJOFS_BUTTON(button - 1);
2555
f5bcc926bac4 Not being able to compile locally gets on my nerves.
Edgar Simo <bobbens@gmail.com>
parents: 2554
diff changeset
578 }
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
579
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
580 return dwTriggerButton;
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
581 }
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
582
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
583
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
584 /*
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
585 * Sets the direction.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
586 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
587 static int
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
588 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
589 {
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
590 LONG *rglDir;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
591
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
592 /* Handle no axes a part. */
2528
50414589501e Fixed some typos.
Edgar Simo <bobbens@gmail.com>
parents: 2527
diff changeset
593 if (naxes == 0) {
2559
42b682e85546 Allow effects with no axes.
Edgar Simo <bobbens@gmail.com>
parents: 2557
diff changeset
594 effect->dwFlags |= FFEFF_SPHERICAL; /* Set as default. */
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
595 effect->rglDirection = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
596 return 0;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
597 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
598
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
599 /* Has axes. */
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
600 rglDir = SDL_malloc( sizeof(LONG) * naxes );
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
601 if (rglDir == NULL) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
602 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
603 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
604 }
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
605 SDL_memset( rglDir, 0, sizeof(LONG) * naxes );
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
606 effect->rglDirection = rglDir;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
607
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
608 switch (dir->type) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
609 case SDL_HAPTIC_POLAR:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
610 effect->dwFlags |= FFEFF_POLAR;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
611 rglDir[0] = dir->dir[0];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
612 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
613 case SDL_HAPTIC_CARTESIAN:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
614 effect->dwFlags |= FFEFF_CARTESIAN;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
615 rglDir[0] = dir->dir[0];
2604
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
616 if (naxes > 1)
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
617 rglDir[1] = dir->dir[1];
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
618 if (naxes > 2)
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
619 rglDir[2] = dir->dir[2];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
620 return 0;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
621 case SDL_HAPTIC_SPHERICAL:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
622 effect->dwFlags |= FFEFF_SPHERICAL;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
623 rglDir[0] = dir->dir[0];
2604
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
624 if (naxes > 1)
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
625 rglDir[1] = dir->dir[1];
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
626 if (naxes > 2)
4eee4d565368 Better handling of direction axes.
Edgar Simo <bobbens@gmail.com>
parents: 2603
diff changeset
627 rglDir[2] = dir->dir[2];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
628 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
629
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
630 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
631 SDL_SetError("Haptic: Unknown direction type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
632 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
633 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
634 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
636
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
637 /* Clamps and converts. */
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
638 #define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
639 /* Just converts. */
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
640 #define CONVERT(x) (((x)*10000) / 0x7FFF)
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
641 /*
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
642 * 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
643 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644 static int
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
645 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
646 {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
647 int i;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
648 FFCONSTANTFORCE *constant;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 FFPERIODIC *periodic;
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
650 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
651 FFRAMPFORCE *ramp;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652 FFCUSTOMFORCE *custom;
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
653 FFENVELOPE *envelope;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
654 SDL_HapticConstant *hap_constant;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
655 SDL_HapticPeriodic *hap_periodic;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 SDL_HapticCondition *hap_condition;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
657 SDL_HapticRamp *hap_ramp;
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
658 SDL_HapticCustom *hap_custom;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
659 DWORD *axes;
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 /* Set global stuff. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
662 SDL_memset(dest, 0, sizeof(FFEFFECT));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
663 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
664 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
665 dest->dwGain = 10000; /* Gain is set globally, not locally. */
2610
71a835ee438a Added FFEFF_OBJECTOFFSETS to darwin port.
Edgar Simo <bobbens@gmail.com>
parents: 2609
diff changeset
666 dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
667
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
668 /* Envelope. */
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
669 envelope = SDL_malloc( sizeof(FFENVELOPE) );
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
670 if (envelope == NULL) {
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
671 SDL_OutOfMemory();
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
672 return -1;
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
673 }
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
674 SDL_memset(envelope, 0, sizeof(FFENVELOPE));
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
675 dest->lpEnvelope = envelope;
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
676 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
677
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
678 /* Axes. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
679 dest->cAxes = haptic->naxes;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
680 if (dest->cAxes > 0) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
681 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
682 if (axes == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
683 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
684 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
685 }
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
686 axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
687 if (dest->cAxes > 1) {
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
688 axes[1] = haptic->hwdata->axes[1];
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
689 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
690 if (dest->cAxes > 2) {
2627
265ced2079bd Proper axes support for darwin haptic.
Edgar Simo <bobbens@gmail.com>
parents: 2610
diff changeset
691 axes[2] = haptic->hwdata->axes[2];
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
692 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
693 dest->rgdwAxes = axes;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
694 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
695
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
696
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
697 /* 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
698 switch (src->type) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
699 case SDL_HAPTIC_CONSTANT:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
700 hap_constant = &src->constant;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
701 constant = SDL_malloc( sizeof(FFCONSTANTFORCE) );
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
702 if (constant == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
703 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
704 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
705 }
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
706 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
707
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
708 /* Specifics */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
709 constant->lMagnitude = CONVERT(hap_constant->level);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
710 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
711 dest->lpvTypeSpecificParams = constant;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
712
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
713 /* Generics */
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
714 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
715 dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
716 dest->dwTriggerRepeatInterval = hap_constant->interval;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
717 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
718
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
719 /* Direction. */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
720 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
721 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
722 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
723
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
724 /* Envelope */
2565
698c776c642f Fixed broken envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2564
diff changeset
725 if ((hap_constant->attack_length==0) && (hap_constant->fade_length==0)) {
2563
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
726 SDL_free(envelope);
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
727 dest->lpEnvelope = NULL;
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
728 }
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
729 else {
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
730 envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
731 envelope->dwAttackTime = hap_constant->attack_length * 1000;
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
732 envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
733 envelope->dwFadeTime = hap_constant->fade_length * 1000;
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
734 }
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
735
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
736 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
737
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
738 case SDL_HAPTIC_SINE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
739 case SDL_HAPTIC_SQUARE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
740 case SDL_HAPTIC_TRIANGLE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
741 case SDL_HAPTIC_SAWTOOTHUP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
742 case SDL_HAPTIC_SAWTOOTHDOWN:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
743 hap_periodic = &src->periodic;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
744 periodic = SDL_malloc(sizeof(FFPERIODIC));
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
745 if (periodic == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
746 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
747 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
748 }
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
749 SDL_memset(periodic, 0, sizeof(FFPERIODIC));
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
750
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
751 /* Specifics */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
752 periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
753 periodic->lOffset = CONVERT(hap_periodic->offset);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
754 periodic->dwPhase = hap_periodic->phase;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
755 periodic->dwPeriod = hap_periodic->period * 1000;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
756 dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
757 dest->lpvTypeSpecificParams = periodic;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
758
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
759 /* Generics */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
760 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
761 dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button);
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
762 dest->dwTriggerRepeatInterval = hap_periodic->interval;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
763 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
764
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
765 /* Direction. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
766 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
767 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
768 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
769
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
770 /* Envelope */
2565
698c776c642f Fixed broken envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2564
diff changeset
771 if ((hap_periodic->attack_length==0) && (hap_periodic->fade_length==0)) {
2563
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
772 SDL_free(envelope);
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
773 dest->lpEnvelope = NULL;
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
774 }
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
775 else {
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
776 envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
777 envelope->dwAttackTime = hap_periodic->attack_length * 1000;
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
778 envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
779 envelope->dwFadeTime = hap_periodic->fade_length * 1000;
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
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 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
783
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
784 case SDL_HAPTIC_SPRING:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
785 case SDL_HAPTIC_DAMPER:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
786 case SDL_HAPTIC_INERTIA:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
787 case SDL_HAPTIC_FRICTION:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
788 hap_condition = &src->condition;
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
789 condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
790 if (condition == NULL) {
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
791 SDL_OutOfMemory();
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
792 return -1;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
793 }
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
794 SDL_memset(condition, 0, sizeof(FFCONDITION));
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
795
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
796 /* Specifics */
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
797 for (i=0; i<dest->cAxes; i++) {
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
798 condition[i].lOffset = CONVERT(hap_condition->center[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
799 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
800 condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]);
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
801 condition[i].dwPositiveSaturation = CCONVERT(hap_condition->right_sat[i]);
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
802 condition[i].dwNegativeSaturation = CCONVERT(hap_condition->left_sat[i]);
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
803 condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i]);
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
804 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
805 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
806 dest->lpvTypeSpecificParams = condition;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
807
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
808 /* Generics */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
809 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
810 dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button);
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
811 dest->dwTriggerRepeatInterval = hap_condition->interval;
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
812 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
813
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
814 /* Direction. */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
815 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
816 return -1;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
817 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
818
2629
43a0416b3707 Removed TODO.
Edgar Simo <bobbens@gmail.com>
parents: 2628
diff changeset
819 /* Envelope - Not actually supported by most CONDITION implementations. */
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
820 SDL_free(dest->lpEnvelope);
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
821 dest->lpEnvelope = NULL;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
822
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
823 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
824
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
825 case SDL_HAPTIC_RAMP:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
826 hap_ramp = &src->ramp;
2533
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
827 ramp = SDL_malloc(sizeof(FFRAMPFORCE));
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
828 if (ramp == NULL) {
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
829 SDL_OutOfMemory();
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
830 return -1;
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
831 }
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
832 SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
2533
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
833
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
834 /* Specifics */
2534
e597de8dccd5 Was a typo in the mac os x documentation.
Edgar Simo <bobbens@gmail.com>
parents: 2533
diff changeset
835 ramp->lStart = CONVERT(hap_ramp->start);
2533
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
836 ramp->lEnd = CONVERT(hap_ramp->end);
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
837 dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE);
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
838 dest->lpvTypeSpecificParams = ramp;
2533
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
839
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
840 /* Generics */
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
841 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
842 dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button);
2533
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
843 dest->dwTriggerRepeatInterval = hap_ramp->interval;
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
844 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
845
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
846 /* Direction. */
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
847 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
848 return -1;
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
849 }
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
850
0c8cea99c4b8 Added SDL_HAPTIC_RAMP support for darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2532
diff changeset
851 /* Envelope */
2565
698c776c642f Fixed broken envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2564
diff changeset
852 if ((hap_ramp->attack_length==0) && (hap_ramp->fade_length==0)) {
2563
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
853 SDL_free(envelope);
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
854 dest->lpEnvelope = NULL;
2564
c9348710a98a Missed a bracket.
Edgar Simo <bobbens@gmail.com>
parents: 2563
diff changeset
855 }
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
856 else {
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
857 envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
858 envelope->dwAttackTime = hap_ramp->attack_length * 1000;
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
859 envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
860 envelope->dwFadeTime = hap_ramp->fade_length * 1000;
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
861 }
2520
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 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
864
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
865 case SDL_HAPTIC_CUSTOM:
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
866 hap_custom = &src->custom;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
867 custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
868 if (custom == NULL) {
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
869 SDL_OutOfMemory();
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
870 return -1;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
871 }
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
872 SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
873
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
874 /* Specifics */
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
875 custom->cChannels = hap_custom->channels;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
876 custom->dwSamplePeriod = hap_custom->period * 1000;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
877 custom->cSamples = hap_custom->samples;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
878 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
879 for (i=0; i<hap_custom->samples*hap_custom->channels; i++) { /* Copy data. */
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
880 custom->rglForceData[i] = CCONVERT(hap_custom->data[i]);
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
881 }
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
882 dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE);
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
883 dest->lpvTypeSpecificParams = custom;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
884
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
885 /* Generics */
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
886 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
2554
2681a04c2d3d Warn about using button triggers.
Edgar Simo <bobbens@gmail.com>
parents: 2553
diff changeset
887 dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button);
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
888 dest->dwTriggerRepeatInterval = hap_custom->interval;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
889 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
890
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
891 /* Direction. */
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
892 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
893 return -1;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
894 }
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
895
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
896 /* Envelope */
2565
698c776c642f Fixed broken envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2564
diff changeset
897 if ((hap_custom->attack_length==0) && (hap_custom->fade_length==0)) {
2563
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
898 SDL_free(envelope);
be2ea885d70b More verbose about envelopes.
Edgar Simo <bobbens@gmail.com>
parents: 2562
diff changeset
899 dest->lpEnvelope = NULL;
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
900 }
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
901 else {
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
902 envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
903 envelope->dwAttackTime = hap_custom->attack_length * 1000;
2628
bfbda6c656e5 Should remove warnings on compilation.
Edgar Simo <bobbens@gmail.com>
parents: 2627
diff changeset
904 envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
2557
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
905 envelope->dwFadeTime = hap_custom->fade_length * 1000;
30778d9d8bff Made envelopes behave correctly with length of 0.
Edgar Simo <bobbens@gmail.com>
parents: 2556
diff changeset
906 }
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
907
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
908 break;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
909
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
910
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
911 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
912 SDL_SetError("Haptic: Unknown effect type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
913 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
914 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
915
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
916 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
917 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
918
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
919
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
920 /*
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
921 * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT.
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
922 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
923 static void
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
924 SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect, int type )
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
925 {
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
926 FFCUSTOMFORCE *custom;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
927
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
928 if (effect->lpEnvelope != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
929 SDL_free(effect->lpEnvelope);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
930 effect->lpEnvelope = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
931 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
932 if (effect->rgdwAxes != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
933 SDL_free(effect->rgdwAxes);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
934 effect->rgdwAxes = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
935 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
936 if (effect->lpvTypeSpecificParams != NULL) {
2535
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
937 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
938 custom = (FFCUSTOMFORCE*) effect->lpvTypeSpecificParams;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
939 SDL_free(custom->rglForceData);
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
940 custom->rglForceData = NULL;
f0ed8471497d Added custom effect with support on darwin.
Edgar Simo <bobbens@gmail.com>
parents: 2534
diff changeset
941 }
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
942 SDL_free(effect->lpvTypeSpecificParams);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
943 effect->lpvTypeSpecificParams = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
944 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
945 if (effect->rglDirection != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
946 SDL_free(effect->rglDirection);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
947 effect->rglDirection = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
948 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
949 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
950
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
951
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
952 /*
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
953 * 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
954 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
955 CFUUIDRef
2552
ee048e7bc909 Removed invalid type check.
Edgar Simo <bobbens@gmail.com>
parents: 2550
diff changeset
956 SDL_SYS_HapticEffectType( Uint16 type )
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
957 {
2552
ee048e7bc909 Removed invalid type check.
Edgar Simo <bobbens@gmail.com>
parents: 2550
diff changeset
958 switch (type) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
959 case SDL_HAPTIC_CONSTANT:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
960 return kFFEffectType_ConstantForce_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
961
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
962 case SDL_HAPTIC_RAMP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
963 return kFFEffectType_RampForce_ID;
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 case SDL_HAPTIC_SQUARE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
966 return kFFEffectType_Square_ID;
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 case SDL_HAPTIC_SINE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
969 return kFFEffectType_Sine_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
970
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
971 case SDL_HAPTIC_TRIANGLE:
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
972 return kFFEffectType_Triangle_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
973
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
974 case SDL_HAPTIC_SAWTOOTHUP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
975 return kFFEffectType_SawtoothUp_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
976
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
977 case SDL_HAPTIC_SAWTOOTHDOWN:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
978 return kFFEffectType_SawtoothDown_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
979
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
980 case SDL_HAPTIC_SPRING:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
981 return kFFEffectType_Spring_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
982
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
983 case SDL_HAPTIC_DAMPER:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
984 return kFFEffectType_Damper_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
985
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
986 case SDL_HAPTIC_INERTIA:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
987 return kFFEffectType_Inertia_ID;
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 case SDL_HAPTIC_FRICTION:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
990 return kFFEffectType_Friction_ID;
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 case SDL_HAPTIC_CUSTOM:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
993 return kFFEffectType_CustomForce_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
994
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
995 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
996 SDL_SetError("Haptic: Unknown effect type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
997 return NULL;
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 }
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1002 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1003 * Creates a new haptic effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1004 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1005 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1006 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
1007 SDL_HapticEffect * base)
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 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1010 CFUUIDRef type;
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 /* Alloc the effect. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1013 effect->hweffect = (struct haptic_hweffect *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1014 SDL_malloc(sizeof(struct haptic_hweffect));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1015 if (effect->hweffect == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1016 SDL_OutOfMemory();
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1017 goto err_hweffect;
2520
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1020 /* Get the type. */
2553
3f853f075bc0 Fixed typo.
Edgar Simo <bobbens@gmail.com>
parents: 2552
diff changeset
1021 type = SDL_SYS_HapticEffectType(base->type);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1022 if (type == NULL) {
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1023 goto err_hweffect;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1024 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1025
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1026 /* Get the effect. */
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1027 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
1028 goto err_effectdone;
2520
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
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1031 /* Create the actual effect. */
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1032 ret = FFDeviceCreateEffect(haptic->hwdata->device, type,
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1033 &effect->hweffect->effect, &effect->hweffect->ref);
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1034 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1035 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
1036 goto err_effectdone;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1037 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1038
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1039 return 0;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1040
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1041 err_effectdone:
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1042 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type);
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1043 err_hweffect:
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1044 if (effect->hweffect != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1045 SDL_free(effect->hweffect);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1046 effect->hweffect = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1047 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
1048 return -1;
2520
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 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1053 * Updates an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1054 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
1055 int
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
1056 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
1057 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
1058 {
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1059 HRESULT ret;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1060 FFEffectParameterFlag flags;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1061 FFEFFECT temp;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1062
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1063 /* Get the effect. */
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1064 SDL_memset(&temp, 0, sizeof(FFEFFECT));
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1065 if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) {
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1066 goto err_update;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1067 }
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1068
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1069 /* 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
1070 * only change those parameters. */
2608
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1071 flags = FFEP_DIRECTION |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1072 FFEP_DURATION |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1073 FFEP_ENVELOPE |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1074 FFEP_STARTDELAY |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1075 FFEP_TRIGGERBUTTON |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1076 FFEP_TRIGGERREPEATINTERVAL |
7c7a63f22afa Using same syntax as the windows port for updating effects.
Edgar Simo <bobbens@gmail.com>
parents: 2604
diff changeset
1077 FFEP_TYPESPECIFICPARAMS;
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1078
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1079 /* Create the actual effect. */
2542
4e055fa7acb9 Fixed some stupid mistakes.
Edgar Simo <bobbens@gmail.com>
parents: 2541
diff changeset
1080 ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags);
2538
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1081 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1082 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
1083 goto err_update;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1084 }
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1085
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1086 /* Copy it over. */
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1087 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type);
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1088 SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT));
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1089
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1090 return 0;
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1091
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1092 err_update:
1f9c20580ab4 Improved correctiveness in CreateEffect.
Edgar Simo <bobbens@gmail.com>
parents: 2537
diff changeset
1093 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
1094 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1095 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1096
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1097
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1098 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1099 * Runs an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1100 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1101 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1102 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
1103 Uint32 iterations)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1104 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1105 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1106 Uint32 iter;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1107
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1108 /* Check if it's infinite. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1109 if (iterations == SDL_HAPTIC_INFINITY) {
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
1110 iter = FF_INFINITE;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1111 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1112 else
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1113 iter = iterations;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1114
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1115 /* Run the effect. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1116 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
1117 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1118 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
1119 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1120 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1121
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1122 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1123 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1124
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1125
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1126 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1127 * Stops an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1128 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1129 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1130 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
1131 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1132 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1133
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1134 ret = FFEffectStop(effect->hweffect->ref);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1135 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1136 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
1137 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1138 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1139
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1140 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1141 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1142
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1143
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1144 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1145 * Frees the effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1146 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1147 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1148 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
1149 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1150 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1151
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1152 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
1153 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1154 SDL_SetError("Haptic: Error removing the effect from the device: %s.",
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1155 FFStrError(ret));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1156 }
2562
c284ce0cd8e0 Fixed memory leak.
Edgar Simo <bobbens@gmail.com>
parents: 2561
diff changeset
1157 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, effect->effect.type);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1158 SDL_free(effect->hweffect);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1159 effect->hweffect = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1160 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1161
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1162
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1163 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1164 * 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
1165 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1166 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1167 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
1168 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1169 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1170 FFEffectStatusFlag status;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1171
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
1172 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
1173 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1174 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
1175 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1176 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1177
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1178 if (status == 0) return SDL_FALSE;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1179 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
1180 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1181
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1182
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1183 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1184 * Sets the gain.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1185 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1186 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1187 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
1188 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1189 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1190 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1191
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1192 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
1193 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
1194 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1195 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
1196 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1197 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1198
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1199 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1200 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1201
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1202
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1203 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1204 * Sets the autocentering.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1205 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1206 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1207 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
1208 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1209 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1210 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1211
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1212 /* 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
1213 if (autocenter == 0) val = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1214 else val = 1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1215
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1216 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
1217 FFPROP_AUTOCENTER, &val);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1218 if (ret != FF_OK) {
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1219 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
1220 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1221 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1222
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1223 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1224
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1225 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1226
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1227
2541
f2649eaa552e More verbose errors.
Edgar Simo <bobbens@gmail.com>
parents: 2538
diff changeset
1228 #endif /* SDL_HAPTIC_IOKIT */