Mercurial > sdl-ios-xcode
comparison src/joystick/darwin/SDL_sysjoystick.c @ 1077:f122afdfa025
The Darwin/MacOSX joystick code is largely copied from the HID Utilities
package...make the symbols defined by HID Utilities static inside SDL so that
an app can link against their own copy of this package without symbol clash.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 15 Jun 2005 23:41:57 +0000 |
parents | 5db50aa5bf08 |
children | 604d73db6802 |
comparison
equal
deleted
inserted
replaced
1076:8d3b95ece376 | 1077:f122afdfa025 |
---|---|
102 | 102 |
103 /* Linked list of all available devices */ | 103 /* Linked list of all available devices */ |
104 static recDevice *gpDeviceList = NULL; | 104 static recDevice *gpDeviceList = NULL; |
105 | 105 |
106 | 106 |
107 void HIDReportErrorNum (char * strError, long numError) | 107 static void HIDReportErrorNum (char * strError, long numError) |
108 { | 108 { |
109 SDL_SetError(strError); | 109 SDL_SetError(strError); |
110 } | 110 } |
111 | 111 |
112 static void HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties, recDevice *pDevice); | 112 static void HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties, recDevice *pDevice); |
113 | 113 |
114 /* returns current value for element, polling element | 114 /* returns current value for element, polling element |
115 * will return 0 on error conditions which should be accounted for by application | 115 * will return 0 on error conditions which should be accounted for by application |
116 */ | 116 */ |
117 | 117 |
118 SInt32 HIDGetElementValue (recDevice *pDevice, recElement *pElement) | 118 static SInt32 HIDGetElementValue (recDevice *pDevice, recElement *pElement) |
119 { | 119 { |
120 IOReturn result = kIOReturnSuccess; | 120 IOReturn result = kIOReturnSuccess; |
121 IOHIDEventStruct hidEvent; | 121 IOHIDEventStruct hidEvent; |
122 hidEvent.value = 0; | 122 hidEvent.value = 0; |
123 | 123 |
138 return hidEvent.value; | 138 return hidEvent.value; |
139 } | 139 } |
140 | 140 |
141 /* similiar to HIDGetElementValue, but auto-calibrates the value before returning it */ | 141 /* similiar to HIDGetElementValue, but auto-calibrates the value before returning it */ |
142 | 142 |
143 SInt32 HIDCalibratedValue (recDevice *pDevice, recElement *pElement) | 143 static SInt32 HIDCalibratedValue (recDevice *pDevice, recElement *pElement) |
144 { | 144 { |
145 float deviceScale = pElement->max - pElement->min; | 145 float deviceScale = pElement->max - pElement->min; |
146 float readScale = pElement->maxReport - pElement->minReport; | 146 float readScale = pElement->maxReport - pElement->minReport; |
147 SInt32 value = HIDGetElementValue(pDevice, pElement); | 147 SInt32 value = HIDGetElementValue(pDevice, pElement); |
148 if (readScale == 0) | 148 if (readScale == 0) |
151 return ((value - pElement->minReport) * deviceScale / readScale) + pElement->min; | 151 return ((value - pElement->minReport) * deviceScale / readScale) + pElement->min; |
152 } | 152 } |
153 | 153 |
154 /* similiar to HIDCalibratedValue but calibrates to an arbitrary scale instead of the elements default scale */ | 154 /* similiar to HIDCalibratedValue but calibrates to an arbitrary scale instead of the elements default scale */ |
155 | 155 |
156 SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long min, long max) | 156 static SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long min, long max) |
157 { | 157 { |
158 float deviceScale = max - min; | 158 float deviceScale = max - min; |
159 float readScale = pElement->maxReport - pElement->minReport; | 159 float readScale = pElement->maxReport - pElement->minReport; |
160 SInt32 value = HIDGetElementValue(pDevice, pElement); | 160 SInt32 value = HIDGetElementValue(pDevice, pElement); |
161 if (readScale == 0) | 161 if (readScale == 0) |
179 | 179 |
180 /* Create and open an interface to device, required prior to extracting values or building queues. | 180 /* Create and open an interface to device, required prior to extracting values or building queues. |
181 * Note: appliction now owns the device and must close and release it prior to exiting | 181 * Note: appliction now owns the device and must close and release it prior to exiting |
182 */ | 182 */ |
183 | 183 |
184 IOReturn HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice *pDevice) | 184 static IOReturn HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice *pDevice) |
185 { | 185 { |
186 IOReturn result = kIOReturnSuccess; | 186 IOReturn result = kIOReturnSuccess; |
187 HRESULT plugInResult = S_OK; | 187 HRESULT plugInResult = S_OK; |
188 SInt32 score = 0; | 188 SInt32 score = 0; |
189 IOCFPlugInInterface ** ppPlugInInterface = NULL; | 189 IOCFPlugInInterface ** ppPlugInInterface = NULL; |
220 * Note: will have no affect if device or interface do not exist | 220 * Note: will have no affect if device or interface do not exist |
221 * application will "own" the device if interface is not closed | 221 * application will "own" the device if interface is not closed |
222 * (device may have to be plug and re-plugged in different location to get it working again without a restart) | 222 * (device may have to be plug and re-plugged in different location to get it working again without a restart) |
223 */ | 223 */ |
224 | 224 |
225 IOReturn HIDCloseReleaseInterface (recDevice *pDevice) | 225 static IOReturn HIDCloseReleaseInterface (recDevice *pDevice) |
226 { | 226 { |
227 IOReturn result = kIOReturnSuccess; | 227 IOReturn result = kIOReturnSuccess; |
228 | 228 |
229 if ((NULL != pDevice) && (NULL != pDevice->interface)) | 229 if ((NULL != pDevice) && (NULL != pDevice->interface)) |
230 { | 230 { |