annotate src/haptic/darwin/SDL_syshaptic.c @ 2532:688cad3f6090 gsoc2008_force_feedback

More comments. Disabled envelope on condition effects.
author Edgar Simo <bobbens@gmail.com>
date Fri, 18 Jul 2008 19:16:03 +0000
parents 7f2a4c387292
children 0c8cea99c4b8
rev   line source
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 Copyright (C) 2008 Edgar Simo
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13 Lesser General Public License for more details.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
18
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
19 Sam Lantinga
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
20 slouken@libsdl.org
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22 #include "SDL_config.h"
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
23
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
24 #ifdef SDL_HAPTIC_IOKIT
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
25
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26 #include "SDL_haptic.h"
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 #include "../SDL_syshaptic.h"
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 #include "SDL_joystick.h"
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 /*#include "../../joystick/dawrin/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
32 #include <IOKit/IOKitLib.h>
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
33 #include <IOKit/hid/IOHIDKeys.h>
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
34 #include <ForceFeedback/ForceFeedback.h>
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
35 #include <ForceFeedback/ForceFeedbackConstants.h>
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
36
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
37
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 #define MAX_HAPTICS 32
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
39
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
41 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 * List of available haptic devices.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 static struct
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46 io_service_t dev;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47 SDL_Haptic *haptic;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 } SDL_hapticlist[MAX_HAPTICS];
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
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 * Haptic system hardware data.
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 struct haptic_hwdata
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 FFDeviceObjectReference device; /* Hardware device. */
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
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 * Haptic system effect data.
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 struct haptic_hweffect
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 FFEffectObjectReference ref; /* Reference. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
66 struct FFEFFECT effect; /* Hardware effect. */
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
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
69 /*
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
70 * Prototypes.
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
71 */
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
72 static void SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect );
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
73
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
74
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 * Initializes the haptic subsystem.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
78 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
79 SDL_SYS_HapticInit(void)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
80 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
81 int numhaptics;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82 IOReturn result;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
83 io_iterator_t iter;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
84 CFDictionaryRef match;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
85 io_service_t device;
2520
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 /* Get HID devices. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 match = IOServiceMatching(kIOHIDDeviceKey);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 if (match == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90 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
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 /* 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
95 result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96 if (result != kIOReturnSuccess) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 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
98 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100 /* IOServiceGetMatchingServices consumes dictionary. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102 numhaptics = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
103 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
104
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105 /* Check for force feedback. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 if (FFIsForceFeedback(device) == FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 SDL_hapticlist[numhaptics].dev = device;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108 SDL_hapticlist[numhaptics].haptic = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109 numhaptics++;
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112 /* Reached haptic limit. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113 if (numhaptics >= MAX_HAPTICS)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 break;
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 IOObjectRelease(iter);
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 return numhaptics;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 }
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
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 * 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
124 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125 const char *
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 SDL_SYS_HapticName(int index)
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 return NULL;
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132 #define FF_TEST(ff, s) \
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
133 if (features.supportedEffects & ff) supported |= s
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135 * Gets supported features.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
136 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137 static unsigned int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138 GetSupportedFeatures(FFDeviceObjectReference device,
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
139 int *neffects, int *nplaying, int *naxes)
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 FFCAPABILITIES features;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 unsigned int supported;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
145
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 ret = FFDeviceGetForceFeedbackCapabilities(device, &features);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 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
149 return 0;
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 supported = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154 /* Get maximum effects. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
155 *neffects = features.storageCapacity;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
156 *nplaying = features.playbackCapacity;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
157
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 /* Test for effects. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
172 /* Check if supports gain. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
174 &val, sizeof(val));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
175 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
176 else if (ret != FFERR_UNSUPPORTED) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177 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
178 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 /* Checks if supports autocenter. */
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
182 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER,
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
183 &val, sizeof(val));
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
184 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
185 else if (ret != FFERR_UNSUPPORTED) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 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
187 return 0;
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
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
190 /* Check for axes, we have an artificial limit on axes */
2528
50414589501e Fixed some typos.
Edgar Simo <bobbens@gmail.com>
parents: 2527
diff changeset
191 *naxes = ((features.numFfAxes) > 3) ?
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
192 3 : features.numFfAxes;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
193
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
194 /* Always supported features. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 supported |= SDL_HAPTIC_STATUS;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
196 return supported;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
197 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
198
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
199
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
200 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
201 * 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
202 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203 static int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
204 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
205 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
206 /* Allocate the hwdata */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
207 haptic->hwdata = (struct haptic_hwdata *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
208 SDL_malloc(sizeof(*haptic->hwdata));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
209 if (haptic->hwdata == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
210 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
211 goto creat_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
212 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
213 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
214
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
215 /* Open the device */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
216 if (FFCreateDevice( service, &haptic->hwdata->device ) != FF_OK) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
217 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
218 goto creat_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
219 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
220
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
221 /* Get supported features. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
222 haptic->supported = GetSupportedFeatures(haptic->hwdata->device,
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
223 &haptic->neffects, &haptic->nplaying,
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
224 &haptic->naxes);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
225 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
226 goto open_err;
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 haptic->effects = (struct haptic_effect *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 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
230 if (haptic->effects == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
232 goto open_err;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
233 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
234 /* Clear the memory */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
235 SDL_memset(haptic->effects, 0,
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
236 sizeof(struct haptic_effect) * haptic->neffects);
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 return 0;
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 /* Error handling */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
241 open_err:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
242 FFReleaseDevice(haptic->hwdata->device);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
243 creat_err:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
244 if (haptic->hwdata != NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
245 free(haptic->hwdata);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
246 haptic->hwdata = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
247 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
248 return -1;
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 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
254 * Opens a haptic device for usage.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
255 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
256 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
257 SDL_SYS_HapticOpen(SDL_Haptic * haptic)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
258 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
259 return SDL_SYS_HapticOpenFromService(haptic,
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
260 SDL_hapticlist[haptic->index].dev);
2520
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
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 * 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
266 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
267 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
268 SDL_SYS_HapticMouse(void)
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 return -1;
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
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 * 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
276 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
277 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
278 SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
279 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
280 return SDL_FALSE;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
281 }
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 * 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
286 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
287 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
288 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
289 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
290 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
291 }
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 * 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
296 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
297 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
298 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
299 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
300 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
301 }
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
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 * Closes the haptic device.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
306 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
307 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
308 SDL_SYS_HapticClose(SDL_Haptic * haptic)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
309 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 int i;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
311
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
312 if (haptic->hwdata) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
313
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
314 /* Free the effects. */
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
315 for (i=0; i<haptic->neffects; i++) {
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
316 if (haptic->effects[i].hweffect != NULL) {
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
317 SDL_SYS_HapticFreeFFEFFECT(&haptic->effects[i].hweffect->effect);
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
318 SDL_free(haptic->effects[i].hweffect);
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
319 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
320 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
321 SDL_free(haptic->effects);
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
322 haptic->neffects = 0;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
323
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
324 /* Clean up */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
325 FFReleaseDevice(haptic->hwdata->device);
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 /* Free */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
328 SDL_free(haptic->hwdata);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
329 haptic->hwdata = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
330 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
331 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
332
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 * 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
336 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
337 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
338 SDL_SYS_HapticQuit(void)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
340 int i;
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 for (i=0; i < SDL_numhaptics; i++) {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
343 /* Opened and not closed haptics are leaked, this is on purpose.
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
344 * Close your haptic devices after usage. */
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
345
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
346 /* Free the io_service_t */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
347 IOObjectRelease(SDL_hapticlist[i].dev);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
348 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
349 }
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
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
353 * Sets the direction.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
354 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
355 static int
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
356 SDL_SYS_SetDirection( FFEFFECT * effect, SDL_HapticDirection *dir, int naxes )
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
357 {
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
358 LONG *rglDir;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
359
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
360 /* Handle no axes a part. */
2528
50414589501e Fixed some typos.
Edgar Simo <bobbens@gmail.com>
parents: 2527
diff changeset
361 if (naxes == 0) {
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
362 effect->rglDirection = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
363 return 0;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
364 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
365
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
366 /* Has axes. */
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
367 rglDir = SDL_malloc( sizeof(LONG) * naxes );
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
368 if (rglDir == NULL) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
369 SDL_OutOfMemory();
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
370 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371 }
2529
e1d5d16e88a8 Can't believe I missed this typo.
Edgar Simo <bobbens@gmail.com>
parents: 2528
diff changeset
372 SDL_memset( rglDir, 0, sizeof(LONG) * naxes );
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
373 effect->rglDirection = rglDir;
2520
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 switch (dir->type) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
376 case SDL_HAPTIC_POLAR:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
377 effect->dwFlags |= FFEFF_POLAR;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
378 rglDir[0] = dir->dir[0];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
380 case SDL_HAPTIC_CARTESIAN:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
381 effect->dwFlags |= FFEFF_CARTESIAN;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
382 rglDir[0] = dir->dir[0];
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
383 rglDir[1] = dir->dir[1];
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
384 rglDir[2] = dir->dir[2];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
385 return 0;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
386 case SDL_HAPTIC_SPHERICAL:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
387 effect->dwFlags |= FFEFF_SPHERICAL;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
388 rglDir[0] = dir->dir[0];
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
389 rglDir[1] = dir->dir[1];
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
390 rglDir[2] = dir->dir[2];
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
391 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
392
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
393 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
394 SDL_SetError("Haptic: Unknown direction type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
395 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
397 }
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 #define CONVERT(x) (((x)*10000) / 0xFFFF )
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400 /*
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
401 * Creates the FFEFFECT from a SDL_HapticEffect.
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
402 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403 static int
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
404 SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src )
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
405 {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
406 int i;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
407 FFCONSTANTFORCE *constant;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
408 FFPERIODIC *periodic;
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
409 FFCONDITION *condition; /* Actually an array of conditions - one per axis. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
410 FFRAMPFORCE *ramp;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
411 FFCUSTOMFORCE *custom;
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
412 FFENVELOPE *envelope;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
413 SDL_HapticConstant *hap_constant;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
414 SDL_HapticPeriodic *hap_periodic;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
415 SDL_HapticCondition *hap_condition;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
416 SDL_HapticRamp *hap_ramp;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
417 DWORD *axes;
2520
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 /* Set global stuff. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
420 SDL_memset(dest, 0, sizeof(FFEFFECT));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
421 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
422 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
423 dest->dwGain = 10000; /* Gain is set globally, not locally. */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
424
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
425 /* Envelope. */
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
426 envelope = SDL_malloc( sizeof(FFENVELOPE) );
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
427 if (envelope == NULL) {
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
428 SDL_OutOfMemory();
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
429 return -1;
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
430 }
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
431 SDL_memset(envelope, 0, sizeof(FFENVELOPE));
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
432 dest->lpEnvelope = envelope;
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
433 envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
434
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
435 /* Axes. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
436 dest->cAxes = haptic->naxes;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
437 if (dest->cAxes > 0) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
438 axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
439 if (axes == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
440 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
441 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
442 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
443 axes[0] = FFJOFS_X; /* Always at least one axis. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
444 if (dest->cAxes > 1) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
445 axes[1] = FFJOFS_Y;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
446 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
447 if (dest->cAxes > 2) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
448 axes[2] = FFJOFS_Z;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
449 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
450 dest->rgdwAxes = axes;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
451 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
452
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
453
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
454 /* The big type handling switch, even bigger then linux's version. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 switch (src->type) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
456 case SDL_HAPTIC_CONSTANT:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457 hap_constant = &src->constant;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
458 constant = SDL_malloc( sizeof(FFCONSTANTFORCE) );
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
459 if (constant == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
460 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
461 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
462 }
2520
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 /* Specifics */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
465 constant->lMagnitude = CONVERT(hap_constant->level);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
466 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
467 dest->lpvTypeSpecificParams = constant;
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 /* Generics */
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
470 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471 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
472 dest->dwTriggerRepeatInterval = hap_constant->interval;
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
473 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
474
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 /* Direction. */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
476 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
477 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
478 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
479
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
480 /* Envelope */
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
481 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
482 envelope->dwAttackTime = hap_constant->attack_length * 1000;
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
483 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
484 envelope->dwFadeTime = hap_constant->fade_length * 1000;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
485
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
486 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
487
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
488 case SDL_HAPTIC_SINE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489 case SDL_HAPTIC_SQUARE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
490 case SDL_HAPTIC_TRIANGLE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
491 case SDL_HAPTIC_SAWTOOTHUP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
492 case SDL_HAPTIC_SAWTOOTHDOWN:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
493 hap_periodic = &src->periodic;
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
494 periodic = SDL_malloc(sizeof(FFPERIODIC));
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
495 if (periodic == NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
496 SDL_OutOfMemory();
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
497 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
498 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
499
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
500 /* Specifics */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
501 periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
502 periodic->lOffset = CONVERT(hap_periodic->offset);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
503 periodic->dwPhase = hap_periodic->phase;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
504 periodic->dwPeriod = hap_periodic->period * 1000;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
505 dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
506 dest->lpvTypeSpecificParams = periodic;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
507
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
508 /* Generics */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
509 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
510 dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
511 dest->dwTriggerRepeatInterval = hap_periodic->interval;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
512 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
513
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
514 /* Direction. */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
515 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
516 return -1;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
517 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
518
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
519 /* Envelope */
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
520 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
521 envelope->dwAttackTime = hap_periodic->attack_length * 1000;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
522 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
523 envelope->dwFadeTime = hap_periodic->fade_length * 1000;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
524
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
525 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
526
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
527 case SDL_HAPTIC_SPRING:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
528 case SDL_HAPTIC_DAMPER:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
529 case SDL_HAPTIC_INERTIA:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
530 case SDL_HAPTIC_FRICTION:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
531 hap_condition = &src->condition;
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
532 condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
533 if (condition == NULL) {
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
534 SDL_OutOfMemory();
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
535 return -1;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
536 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
537
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
538 /* Specifics */
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
539 for (i=0; i<dest->cAxes; i++) {
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
540 condition[i].lOffset = CONVERT(hap_condition->center[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
541 condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
542 condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
543 condition[i].dwPositiveSaturation = CONVERT(hap_condition->right_sat[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
544 condition[i].dwNegativeSaturation = CONVERT(hap_condition->left_sat[i]);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
545 condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
546 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
547 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
548 dest->lpvTypeSpecificParams = condition;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
549
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
550 /* Generics */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
551 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
552 dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
553 dest->dwTriggerRepeatInterval = hap_condition->interval;
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
554 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
555
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
556 /* Direction. */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
557 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
2530
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
558 return -1;
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
559 }
22ce87690b41 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2529
diff changeset
560
2532
688cad3f6090 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2531
diff changeset
561 /* Envelope */
688cad3f6090 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2531
diff changeset
562 /* TODO Check is envelope actually used.
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
563 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
564 envelope->dwAttackTime = hap_condition->attack_length * 1000;
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
565 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level);
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
566 envelope->dwFadeTime = hap_condition->fade_length * 1000;
2532
688cad3f6090 More comments.
Edgar Simo <bobbens@gmail.com>
parents: 2531
diff changeset
567 */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
568
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
569 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
570
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
571 case SDL_HAPTIC_RAMP:
2522
0877146be013 Now compiles cleanly (has yet to work though).
Edgar Simo <bobbens@gmail.com>
parents: 2521
diff changeset
572 hap_ramp = &src->ramp;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
573
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
574 break;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
575
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 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
578 SDL_SetError("Haptic: Unknown effect type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
579 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
580 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
581
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
582 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
583 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
584
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 /*
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
587 * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT.
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
588 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
589 static void
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
590 SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect )
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
591 {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
592 if (effect->lpEnvelope != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
593 SDL_free(effect->lpEnvelope);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
594 effect->lpEnvelope = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
595 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
596 if (effect->rgdwAxes != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
597 SDL_free(effect->rgdwAxes);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
598 effect->rgdwAxes = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
599 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
600 if (effect->lpvTypeSpecificParams != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
601 SDL_free(effect->lpvTypeSpecificParams);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
602 effect->lpvTypeSpecificParams = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
603 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
604 if (effect->rglDirection != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
605 SDL_free(effect->rglDirection);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
606 effect->rglDirection = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
607 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
608 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
609
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
610
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
611 /*
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
612 * 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
613 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
614 CFUUIDRef
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
615 SDL_SYS_HapticEffectType(struct haptic_effect * effect)
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
616 {
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
617 switch (effect->effect.type) {
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
618 case SDL_HAPTIC_CONSTANT:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
619 return kFFEffectType_ConstantForce_ID;
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 case SDL_HAPTIC_RAMP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
622 return kFFEffectType_RampForce_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
623
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
624 case SDL_HAPTIC_SQUARE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
625 return kFFEffectType_Square_ID;
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 case SDL_HAPTIC_SINE:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
628 return kFFEffectType_Sine_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
629
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
630 case SDL_HAPTIC_TRIANGLE:
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
631 return kFFEffectType_Triangle_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
632
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
633 case SDL_HAPTIC_SAWTOOTHUP:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
634 return kFFEffectType_SawtoothUp_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
636 case SDL_HAPTIC_SAWTOOTHDOWN:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
637 return kFFEffectType_SawtoothDown_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
638
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
639 case SDL_HAPTIC_SPRING:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
640 return kFFEffectType_Spring_ID;
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 case SDL_HAPTIC_DAMPER:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
643 return kFFEffectType_Damper_ID;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
645 case SDL_HAPTIC_INERTIA:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
646 return kFFEffectType_Inertia_ID;
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 case SDL_HAPTIC_FRICTION:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 return kFFEffectType_Friction_ID;
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 case SDL_HAPTIC_CUSTOM:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652 return kFFEffectType_CustomForce_ID;
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 default:
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
655 SDL_SetError("Haptic: Unknown effect type.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 return NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
657 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
658 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
659
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
660
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
661 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
662 * Creates a new haptic effect.
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 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
665 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
666 SDL_HapticEffect * base)
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 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
669 CFUUIDRef type;
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 /* Alloc the effect. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
672 effect->hweffect = (struct haptic_hweffect *)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
673 SDL_malloc(sizeof(struct haptic_hweffect));
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
674 if (effect->hweffect == NULL) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
675 SDL_OutOfMemory();
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
676 goto err_hweffect;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
677 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
678
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
679 /* Get the type. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
680 type = SDL_SYS_HapticEffectType(effect);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
681 if (type == NULL) {
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
682 goto err_hweffect;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
683 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
684
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
685 /* Get the effect. */
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
686 if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, &effect->effect ) < 0) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
687 goto err_effectdone;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
688 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
689
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
690 /* Create the actual effect. */
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
691 ret = FFDeviceCreateEffect( haptic->hwdata->device, type,
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
692 &effect->hweffect->effect, &effect->hweffect->ref );
2527
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
693
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
694 if (ret != FF_OK) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
695 SDL_SetError("Haptic: Unable to create effect.");
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
696 goto err_effectdone;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
697 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
698
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
699 return 0;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
700
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
701 err_effectdone:
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
702 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
703 err_hweffect:
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
704 if (effect->hweffect != NULL) {
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
705 SDL_free(effect->hweffect);
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
706 effect->hweffect = NULL;
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
707 }
924a32719b6f Handle axes for darwin now.
Edgar Simo <bobbens@gmail.com>
parents: 2522
diff changeset
708 return -1;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
709 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
710
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
711
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
712 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
713 * Updates an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
714 */
2531
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
715 int
7f2a4c387292 Fixed some inconsistancies in coding style.
Edgar Simo <bobbens@gmail.com>
parents: 2530
diff changeset
716 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
717 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
718 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
719 /* TODO */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
720 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
721 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
722
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
723
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
724 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
725 * Runs an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
726 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
727 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
728 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
729 Uint32 iterations)
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
730 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
731 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
732 Uint32 iter;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
733
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
734 /* Check if it's infinite. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
735 if (iterations == SDL_HAPTIC_INFINITY) {
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
736 iter = FF_INFINITE;
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
737 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
738 else
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
739 iter = iterations;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
740
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
741 /* Run the effect. */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
742 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
743 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
744 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
745 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
746 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
747
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
748 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
749 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
750
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
751
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
752 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
753 * Stops an effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
754 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
755 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
756 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
757 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
758 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
759
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
760 ret = FFEffectStop(effect->hweffect->ref);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
761 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
762 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
763 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
764 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
765
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
766 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
767 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
768
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
769
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
770 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
771 * Frees the effect.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
772 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
773 void
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
774 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
775 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
776 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
777
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
778 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
779 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
780 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
781 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
782 SDL_free(effect->hweffect->effect.lpvTypeSpecificParams);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
783 effect->hweffect->effect.lpvTypeSpecificParams = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
784 SDL_free(effect->hweffect);
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
785 effect->hweffect = NULL;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
786 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
787
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
788
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
789 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
790 * 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
791 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
792 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
793 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
794 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
795 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
796 FFEffectStatusFlag status;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
797
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
798 ret = FFEffectGetEffectStatus(effect->hweffect->ref, &status);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
799 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
800 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
801 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
802 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
803
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
804 if (status == 0) return SDL_FALSE;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
805 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
806 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
807
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
808
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
809 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
810 * Sets the gain.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
811 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
812 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
813 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
814 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
815 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
816 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
817
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
818 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
819 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
820 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
821 SDL_SetError("Haptic: Error setting gain.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
822 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
823 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
824
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
825 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
826 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
827
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
828
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
829 /*
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
830 * Sets the autocentering.
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
831 */
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
832 int
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
833 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
834 {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
835 HRESULT ret;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
836 Uint32 val;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
837
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
838 /* 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
839 if (autocenter == 0) val = 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
840 else val = 1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
841
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
842 ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
2521
7aa91c21ce5f Many typo and silly mistake fixes.
Edgar Simo <bobbens@gmail.com>
parents: 2520
diff changeset
843 FFPROP_AUTOCENTER, &val);
2520
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
844 if (ret != FF_OK) {
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
845 SDL_SetError("Haptic: Error setting autocenter.");
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
846 return -1;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
847 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
848
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
849 return 0;
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
850
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
851 }
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
852
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
853
6aee9eb4fc6d Adding initial darwin port of haptic subsystem - broken atm.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
854 #endif /* SDL_HAPTIC_LINUX */