Mercurial > sdl-ios-xcode
annotate src/haptic/darwin/SDL_syshaptic.c @ 2520:6aee9eb4fc6d gsoc2008_force_feedback
Adding initial darwin port of haptic subsystem - broken atm.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 15 Jul 2008 16:35:14 +0000 |
parents | |
children | 7aa91c21ce5f |
rev | line source |
---|---|
2520
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
1 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2008 Edgar Simo |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
4 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
9 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
14 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
18 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
21 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
23 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
24 #ifdef SDL_HAPTIC_IOKIT |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
25 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
26 #include "SDL_haptic.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
27 #include "../SDL_syshaptic.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
28 #include "SDL_joystick.h" |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
29 #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
30 /*#include "../../joystick/dawrin/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
31 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
32 #include <ForceFeedback/ForceFeedback.h> |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
33 #include <ForceFeedback/ForceFeedbackConstants.h> |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
34 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
35 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
36 #define MAX_HAPTICS 32 |
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 |
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 * List of available haptic devices. |
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 static struct |
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 io_service_t dev; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
45 SDL_Haptic *haptic; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
46 } SDL_hapticlist[MAX_HAPTICS]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
47 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
48 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
49 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
50 * Haptic system hardware data. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
51 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
52 struct haptic_hwdata |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
53 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
54 FFDeviceObjectReference device; /* Hardware device. */ |
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 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
59 * Haptic system effect data. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
60 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
61 struct haptic_hweffect |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
62 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
63 FFEffectObjectReference ref; /* Reference. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
64 struct FFEFFECT effect; /* Hardware effect. */ |
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 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
69 * Initializes the haptic subsystem. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
70 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
71 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
72 SDL_SYS_HapticInit(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
73 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
74 int numhaptics; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
75 IOReturn result; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
76 io_iterator_t iter; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
77 CFDictionaryRef match; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
78 io_sercive_t device; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
79 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
80 /* Get HID devices. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
81 match = IOServiceMatching(kIOHIDDeviceKey); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
82 if (match == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
83 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
|
84 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
85 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
86 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
87 /* 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
|
88 result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
89 if (result != kIOReturnSuccess) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
90 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
|
91 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
92 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
93 /* IOServiceGetMatchingServices consumes dictionary. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
94 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
95 numhaptics = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
96 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
|
97 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
98 /* Check for force feedback. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
99 if (FFIsForceFeedback(device) == FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
100 SDL_hapticlist[numhaptics].dev = device; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
101 SDL_hapticlist[numhaptics].haptic = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
102 numhaptics++; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
103 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
104 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
105 /* Reached haptic limit. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
106 if (numhaptics >= MAX_HAPTICS) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
107 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
108 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
109 IOObjectRelease(iter); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
110 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
111 return numhaptics; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
112 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
113 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
114 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
115 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
116 * 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
|
117 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
118 const char * |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
119 SDL_SYS_HapticName(int index) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
120 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
121 return NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
122 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
123 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
124 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
125 #define FF_TEST(ff, s) \ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
126 if (features.supportedEffects & ff) supported |= s |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
127 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
128 * Gets supported features. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
129 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
130 static unsigned int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
131 GetSupportedFeatures(FFDeviceObjectReference device, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
132 int *neffects, int *nplaying) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
133 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
134 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
135 FFCAPABILITIES features; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
136 unsigned int supported; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
137 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
138 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
139 ret = FFDeviceGetForceFeedbackCapabilities(device, &features); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
140 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
141 SDL_SetError("Haptic: Unable to get device's supported features."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
142 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
143 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
144 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
145 supported = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
146 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
147 /* Get maximum effects. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
148 *neffects = features.storageCapacity; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
149 *nplaying = features.playbackCapacity; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
150 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
151 /* Test for effects. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
165 /* Check if supports gain. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
166 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
167 val, sizeof(val)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
168 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
|
169 else if (ret != FFERR_UNSUPPORTED) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
170 SDL_SetError("Haptic: Unable to get if device supports gain."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
171 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
172 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
173 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
174 /* Checks if supports autocenter. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
175 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFAUTOCENTER, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
176 val, sizeof(val)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
177 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
|
178 else if (ret != FFERR_UNSUPPORTED) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
179 SDL_SetError("Haptic: Unable to get if device supports autocenter."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
180 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
181 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
182 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
183 /* Always supported features. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
184 supported |= SDL_HAPTIC_STATUS; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
185 return supported; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
186 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
187 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
188 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
189 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
190 * 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
|
191 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
192 static int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
193 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
|
194 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
195 /* Allocate the hwdata */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
196 haptic->hwdata = (struct haptic_hwdata *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
197 SDL_malloc(sizeof(*haptic->hwdata)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
198 if (haptic->hwdata == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
199 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
200 goto creat_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
201 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
202 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
|
203 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
204 /* Open the device */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
205 if (FFCreateDevice( &service, &haptic->hwdata->device ) != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
206 SDL_SetError("Haptic: Unable to create device from service."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
207 goto creat_err; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
208 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
209 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
210 /* Get supported features. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
211 haptic->supported = GetSupportedFeatures(haptic->hwdata->device, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
212 &haptic->neffects, &haptic->nplaying); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
213 if (haptic->supported == 0) { /* Error since device supports nothing. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
214 goto open_err; |
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 haptic->effects = (struct haptic_effect *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
217 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
|
218 if (haptic->effects == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
219 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
220 goto open_err; |
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 /* Clear the memory */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
223 SDL_memset(haptic->effects, 0, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
224 sizeof(struct haptic_effect) * haptic->neffects); |
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 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
227 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
228 /* Error handling */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
229 open_err: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
230 FFReleaseDevice(haptic->hwdata->device); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
231 creat_err: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
232 if (haptic->hwdata != NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
233 free(haptic->hwdata); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
234 haptic->hwdata = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
235 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
236 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
237 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
238 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
239 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
240 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
241 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
242 * Opens a haptic device for usage. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
243 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
244 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
245 SDL_SYS_HapticOpen(SDL_Haptic * haptic) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
246 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
247 return SDL_SYS_HapticOpenFromService(haptic, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
248 SDL_hapticlist[haptic->index].device); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
249 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
250 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
251 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
252 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
253 * 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
|
254 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
255 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
256 SDL_SYS_HapticMouse(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
257 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
258 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
259 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
260 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
261 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
262 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
263 * 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
|
264 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
265 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
266 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
267 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
268 return SDL_FALSE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
269 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
270 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
271 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
272 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
273 * 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
|
274 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
275 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
276 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
|
277 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
278 if (SDL_strcmp(joystick->name,haptic->name)==0) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
279 return 1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
280 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
281 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
282 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
283 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
284 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
285 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
286 * 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
|
287 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
288 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
289 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
|
290 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
291 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
292 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
293 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
294 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
295 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
296 * Closes the haptic device. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
297 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
298 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
299 SDL_SYS_HapticClose(SDL_Haptic * haptic) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
300 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
301 int i; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
302 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
303 if (haptic->hwdata) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
304 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
305 /* Clean up */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
306 FFReleaseDevice(haptic->hwdata->device); |
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 /* Free */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
309 SDL_free(haptic->hwdata); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
310 haptic->hwdata = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
311 for (i=0; i<haptic->neffects; i++) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
312 if (haptic->effects[i].hweffect != NULL) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
313 SDL_free(haptic->effects[i].hweffect->effect.lpvTypeSpecificParams); |
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 SDL_free(haptic->effects); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
316 haptic->neffects = 0; |
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 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
319 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
320 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
321 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
322 * 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
|
323 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
324 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
325 SDL_SYS_HapticQuit(void) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
326 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
327 int i; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
328 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
329 for (i=0; i < SDL_numhaptics; i++) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
330 IOObjectRelease(SDL_hapticlist[i].dev); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
331 /* TODO free effects. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
332 } |
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 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
335 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
336 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
337 * Sets the direction. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
338 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
339 static int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
340 SDL_SYS_SetDirection( FFEFFECT * effect, SDL_HapticDirection *dir, int axes ) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
341 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
342 LONG *dir; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
343 dir = SDL_malloc( sizeof(LONG) * axes ); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
344 if (dir == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
345 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
346 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
347 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
348 SDL_memset( dir, 0, sizeof(LONG) * axes ); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
349 effect->rglDirection = dir; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
350 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
351 switch (dir->type) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
352 case SDL_HAPTIC_POLAR: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
353 effect->dwFlags |= FFEFF_POLAR; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
354 dir[0] = dir->dir[0]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
355 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
356 case SDL_HAPTIC_CARTESIAN: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
357 effects->dwFlags |= FFEFF_CARTESIAN; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
358 dir[0] = dir->dir[0]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
359 dir[1] = dir->dir[1]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
360 dir[2] = dir->dir[2]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
361 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
362 case SDL_HAPTIC_SHPERICAL: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
363 effects->dwFlags |= FFEFF_SPHERICAL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
364 dir[0] = dir->dir[0]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
365 dir[1] = dir->dir[1]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
366 dir[2] = dir->dir[2]; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
367 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
368 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
369 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
370 SDL_SetError("Haptic: Unknown direction type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
371 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
372 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
373 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
374 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
375 #define CONVERT(x) (((x)*10000) / 0xFFFF ) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
376 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
377 * Creates the FFStruct |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
378 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
379 static int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
380 SDL_SYS_ToFFEFFECT( FFEFFECT * dest, SDL_HapticEffect * src ) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
381 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
382 FFCONSTANTFORCE *constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
383 FFPERIODIC *periodic; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
384 FFCONDITION *condition; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
385 FFRAMPFORCE *ramp; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
386 FFCUSTOMFORCE *custom; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
387 SDL_HapticConstant *hap_constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
388 SDL_HapticPeriodic *hap-periodic; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
389 SDL_HapticCondition *hap_condition; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
390 SDL_HapticRamp *hap_ramp; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
391 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
392 /* Set global stuff. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
393 SDL_memset(dest, 0, sizeof(FFEFFECT)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
394 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
|
395 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
|
396 dest->dwGain = 10000; /* Gain is set globally, not locally. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
397 dest->lpEnvelope.dwSize = sizeof(FFENVELOPE); /* Always should be this. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
398 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
399 switch (src->type) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
400 case SDL_HAPTIC_CONSTANT: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
401 hap_constant = &src->constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
402 constant = SDL_malloc( sizeof(FFCONSTANTFORCE) ); |
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 /* Specifics */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
405 constant->lMagnitude = CONVERT(hap_constant->level); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
406 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
407 dest->lpvTypeSpecificParams = constant; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
408 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
409 /* Generics */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
410 dest->dwDuration = src->length * 1000; /* In microseconds. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
411 dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
412 dest->dwTriggerRepeatInterval = hap_constant->interval; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
413 dest->dwStartDelay = src->delay * 1000; /* In microseconds. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
414 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
415 /* Axes */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
416 dest->cAxes = 2; /* TODO handle */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
417 dest->rgdwAxes = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
418 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
419 /* Direction. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
420 if (SDL_SYS_SetDirection(dest, hap_constant->direction, dest->cAxes) < 0) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
421 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
422 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
423 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
424 /* Envelope */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
425 dest->lpEnvelope.dwAttackLevel = CONVERT(hap_constant->attack_level); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
426 dest->lpEnvelope.dwAttackTime = hap_constant->attack_length * 1000; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
427 dest->lpEnvelope.dwFadeLevel = CONVERT(hap_constant->fade_level); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
428 dest->lpEnvelope.dwFadeTime = hap_constant->fade_length * 1000; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
429 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
430 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
431 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
432 /* TODO finish */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
433 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
434 case SDL_HAPTIC_SINE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
435 case SDL_HAPTIC_SQUARE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
436 case SDL_HAPTIC_TRIANGLE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
437 case SDL_HAPTIC_SAWTOOTHUP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
438 case SDL_HAPTIC_SAWTOOTHDOWN: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
439 periodic = &src->periodic; |
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 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
442 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
443 case SDL_HAPTIC_SPRING: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
444 case SDL_HAPTIC_DAMPER: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
445 case SDL_HAPTIC_INERTIA: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
446 case SDL_HAPTIC_FRICTION: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
447 condition = &src->condition; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
448 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
449 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
450 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
451 case SDL_HAPTIC_RAMP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
452 ramp = &src->ramp; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
453 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
454 break; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
455 |
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 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
458 SDL_SetError("Haptic: Unknown effect type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
459 return -1; |
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 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
462 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
463 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
464 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
465 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
466 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
467 * 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
|
468 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
469 CFUUIDRef SDL_SYS_HapticEffectType(struct haptic_effect * effect) |
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 switch (effect->effect->type) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
472 case SDL_HAPTIC_CONSTANT: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
473 return kFFEffectType_ConstantForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
474 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
475 case SDL_HAPTIC_RAMP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
476 return kFFEffectType_RampForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
477 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
478 case SDL_HAPTIC_SQUARE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
479 return kFFEffectType_Square_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
480 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
481 case SDL_HAPTIC_SINE: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
482 return kFFEffectType_Sine_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
483 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
484 case SDL_HAPTIC_TRIANGLE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
485 return kFFEffectType_Triangle_ID; |
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 case SDL_HAPTIC_SAWTOOTHUP: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
488 return kFFEffectType_SawtoothUp_ID; |
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 case SDL_HAPTIC_SAWTOOTHDOWN: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
491 return kFFEffectType_SawtoothDown_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
492 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
493 case SDL_HAPTIC_SPRING: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
494 return kFFEffectType_Spring_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
495 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
496 case SDL_HAPTIC_DAMPER: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
497 return kFFEffectType_Damper_ID; |
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 case SDL_HAPTIC_INERTIA: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
500 return kFFEffectType_Inertia_ID; |
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 case SDL_HAPTIC_FRICTION: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
503 return kFFEffectType_Friction_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
504 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
505 case SDL_HAPTIC_CUSTOM: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
506 return kFFEffectType_CustomForce_ID; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
507 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
508 default: |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
509 SDL_SetError("Haptic: Unknown effect type."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
510 return NULL; |
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 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
516 * Creates a new haptic effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
517 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
518 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
519 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
|
520 SDL_HapticEffect * base) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
521 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
522 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
523 CFUUIDRef type; |
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 /* Alloc the effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
526 effect->hweffect = (struct haptic_hweffect *) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
527 SDL_malloc(sizeof(struct haptic_hweffect)); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
528 if (effect->hweffect == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
529 SDL_OutOfMemory(); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
530 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
531 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
532 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
533 /* Get the type. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
534 type = SDL_SYS_HapticEffectType(effect); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
535 if (type == NULL) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
536 SDL_free(effect->hweffect); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
537 effect->hweffect = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
538 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
539 } |
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 /* Get the effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
542 if (SDL_SYS_ToFFEFFECT( &effect->hweffect->effect, &haptic_effect->effect ) < 0) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
543 /* TODO cleanup alloced stuff. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
544 return -1; |
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 ret = FFDeviceCreateEffect( haptic->hwdata->device, type, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
548 &effect->hweffect->effect, &effect->hweffect->ref ); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
549 } |
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 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
552 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
553 * Updates an effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
554 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
555 int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
556 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
|
557 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
558 /* TODO */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
559 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
560 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
561 |
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 * Runs an effect. |
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 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
567 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
|
568 Uint32 iterations) |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
569 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
570 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
571 Uint32 iter; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
572 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
573 /* Check if it's infinite. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
574 if (iterations == SDL_HAPTIC_INFINITY) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
575 iter = INFINITE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
576 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
577 else |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
578 iter = iterations; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
579 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
580 /* Run the effect. */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
581 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
|
582 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
583 SDL_SetError("Haptic: Unable to run the effect."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
584 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
585 } |
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 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
588 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
589 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
590 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
591 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
592 * Stops an effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
593 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
594 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
595 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
|
596 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
597 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
598 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
599 ret = FFEffectStop(effect->hweffect->ref); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
600 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
601 SDL_SetError("Haptic: Unable to stop the effect."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
602 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
603 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
604 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
605 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
606 } |
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 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
609 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
610 * Frees the effect. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
611 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
612 void |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
613 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
|
614 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
615 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
616 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
617 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
|
618 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
619 SDL_SetError("Haptic: Error removing the effect from the device."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
620 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
621 SDL_free(effect->hweffect->effect.lpvTypeSpecificParams); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
622 effect->hweffect->effect.lpvTypeSpecificParams = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
623 SDL_free(effect->hweffect); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
624 effect->hweffect = NULL; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
625 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
626 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
627 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
628 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
629 * 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
|
630 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
631 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
632 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
|
633 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
634 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
635 FFEffectStatusFlag status; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
636 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
637 ret = FFEffectGetEffectStatus(effect->hweffect.ref, &status); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
638 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
639 SDL_SetError("Haptic: Unable to get effect status."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
640 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
641 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
642 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
643 if (status == 0) return SDL_FALSE; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
644 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
|
645 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
646 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
647 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
648 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
649 * Sets the gain. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
650 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
651 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
652 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
|
653 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
654 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
655 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
656 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
657 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
|
658 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
|
659 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
660 SDL_SetError("Haptic: Error setting gain."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
661 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
662 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
663 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
664 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
665 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
666 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
667 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
668 /* |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
669 * Sets the autocentering. |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
670 */ |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
671 int |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
672 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
|
673 { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
674 HRESULT ret; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
675 Uint32 val; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
676 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
677 /* 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
|
678 if (autocenter == 0) val = 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
679 else val = 1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
680 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
681 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
682 FFPROP_FFAUTOCENTER, &val); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
683 if (ret != FF_OK) { |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
684 SDL_SetError("Haptic: Error setting autocenter."); |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
685 return -1; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
686 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
687 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
688 return 0; |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
689 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
690 } |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
691 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
692 |
6aee9eb4fc6d
Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff
changeset
|
693 #endif /* SDL_HAPTIC_LINUX */ |