2 // Copyright by Masayuki Akamatsu
3 // Based on "DarwiinRemote" by Hiroaki Kimura
5 #define BLUETOOTH_VERSION_USE_CURRENT
6 //#include <AvailabilityMacros.h>
8 #include <CoreFoundation/CoreFoundation.h>
9 //#include <CoreFoundation/CFMachPort.h>
10 #include <IOBluetooth/IOBluetoothUserLib.h>
12 typedef unsigned char WiiIRModeType
;
14 kWiiIRModeBasic
= 0x01,
15 kWiiIRModeExtended
= 0x03,
24 unsigned char accX_zero
, accY_zero
, accZ_zero
, accX_1g
, accY_1g
, accZ_1g
;
28 unsigned char x_min
, x_max
, x_center
, y_min
, y_max
, y_center
;
29 } WiiJoyStickCalibData
;
31 typedef UInt16 WiiButtonType
;
48 WiiClassicControllerXButton
,
49 WiiClassicControllerYButton
,
50 WiiClassicControllerAButton
,
51 WiiClassicControllerBButton
,
52 WiiClassicControllerLButton
,
53 WiiClassicControllerRButton
,
54 WiiClassicControllerZLButton
,
55 WiiClassicControllerZRButton
,
56 WiiClassicControllerUpButton
,
57 WiiClassicControllerDownButton
,
58 WiiClassicControllerLeftButton
,
59 WiiClassicControllerRightButton
,
60 WiiClassicControllerMinusButton
,
61 WiiClassicControllerHomeButton
,
62 WiiClassicControllerPlusButton
66 typedef UInt16 WiiExpansionPortType
;
73 typedef UInt16 WiiAccelerationSensorType
;
75 WiiRemoteAccelerationSensor
,
76 WiiNunchukAccelerationSensor
80 typedef UInt16 WiiJoyStickType
;
83 WiiClassicControllerLeftJoyStick
,
84 WiiClassicControllerRightJoyStick
88 typedef struct _WiiRemoteRec
90 IOBluetoothDeviceInquiryRef inquiry
;
91 IOBluetoothDeviceRef device
;
92 IOBluetoothL2CAPChannelRef ichan
;
93 IOBluetoothL2CAPChannelRef cchan
;
100 unsigned short buttonData
;
105 int leftPoint
; // is point 0 or 1 on the left. -1 when not tracking.
112 WiiExpansionPortType expType
;
113 WiiAccCalibData wiiCalibData
, nunchukCalibData
;
114 WiiJoyStickCalibData nunchukJoyStickCalibData
;
115 WiiIRModeType wiiIRMode
;
119 Boolean readingRegister
;
120 Boolean isMotionSensorEnabled
;
121 Boolean isIRSensorEnabled
;
122 Boolean isVibrationEnabled
;
123 Boolean isExpansionPortEnabled
;
125 Boolean isLED1Illuminated
;
126 Boolean isLED2Illuminated
;
127 Boolean isLED3Illuminated
;
128 Boolean isLED4Illuminated
;
130 Boolean isExpansionPortAttached
;
132 IOBluetoothUserNotificationRef disconnectNotification
;
135 unsigned char nStickX
;
136 unsigned char nStickY
;
140 unsigned char nButtonData
;
147 unsigned short cButtonData
;
148 unsigned char cStickX1
;
149 unsigned char cStickY1
;
150 unsigned char cStickX2
;
151 unsigned char cStickY2
;
152 unsigned char cAnalogL
;
153 unsigned char cAnalogR
;
155 } WiiRemoteRec
, *WiiRemoteRef
;
157 void wiiremote_init(WiiRemoteRef wiiremote
);
158 Boolean
wiiremote_isconnected(WiiRemoteRef wiiremote
);
159 Boolean
wiiremote_search(WiiRemoteRef wiiremote
, char *address
);
160 Boolean
wiiremote_stopsearch(WiiRemoteRef wiiremote
);
161 Boolean
wiiremote_connect(WiiRemoteRef wiiremote
);
162 Boolean
wiiremote_disconnect(WiiRemoteRef wiiremote
);
163 void wiiremote_getaddress(WiiRemoteRef wiiremote
, char *address
);
164 Boolean
wiiremote_motionsensor(WiiRemoteRef wiiremote
, Boolean enabled
);
165 Boolean
wiiremote_irsensor(WiiRemoteRef wiiremote
, Boolean enabled
);
166 Boolean
wiiremote_vibration(WiiRemoteRef wiiremote
, Boolean enabled
);
167 Boolean
wiiremote_led(WiiRemoteRef wiiremote
, Boolean enabled1
, Boolean enabled2
, Boolean enabled3
, Boolean enabled4
);
168 Boolean
wiiremote_expansion(WiiRemoteRef wiiremote
, Boolean enabled
);
169 Boolean
wiiremote_getstatus(WiiRemoteRef wiiremote
);