1 /*
2  *	wiiuse
3  *
4  *	Written By:
5  *		Michael Laforest	< para >
6  *		Email: < thepara (--AT--) g m a i l [--DOT--] com >
7  *
8  *	Copyright 2006-2007
9  *
10  *	This file is part of wiiuse.
11  *
12  *	This program is free software; you can redistribute it and/or modify
13  *	it under the terms of the GNU General Public License as published by
14  *	the Free Software Foundation; either version 3 of the License, or
15  *	(at your option) any later version.
16  *
17  *	This program is distributed in the hope that it will be useful,
18  *	but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *	GNU General Public License for more details.
21  *
22  *	You should have received a copy of the GNU General Public License
23  *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
24  *
25  *	$Header$
26  *
27  */
28 
29 /**
30  *	@file
31  *
32  *	@brief API header file.
33  *
34  *	If this file is included from inside the wiiuse source
35  *	and not from a third party program, then wiimote_internal.h
36  *	is also included which extends this file.
37  */
38 
39 #pragma once
40 
41 #ifdef _WIN32
42 	/* windows */
43 	#include <windows.h>
44 #else
45 	/* nix */
46 	#include <bluetooth/bluetooth.h>
47 #endif
48 
49 #ifdef WIIUSE_INTERNAL_H_INCLUDED
50 	#define WCONST
51 #else
52 	#define WCONST		const
53 #endif
54 
55 /* led bit masks */
56 #define WIIMOTE_LED_NONE				0x00
57 #define WIIMOTE_LED_1					0x10
58 #define WIIMOTE_LED_2					0x20
59 #define WIIMOTE_LED_3					0x40
60 #define WIIMOTE_LED_4					0x80
61 
62 /* button codes */
63 #define WIIMOTE_BUTTON_TWO				0x0001
64 #define WIIMOTE_BUTTON_ONE				0x0002
65 #define WIIMOTE_BUTTON_B				0x0004
66 #define WIIMOTE_BUTTON_A				0x0008
67 #define WIIMOTE_BUTTON_MINUS			0x0010
68 #define WIIMOTE_BUTTON_ZACCEL_BIT6		0x0020
69 #define WIIMOTE_BUTTON_ZACCEL_BIT7		0x0040
70 #define WIIMOTE_BUTTON_HOME				0x0080
71 #define WIIMOTE_BUTTON_LEFT				0x0100
72 #define WIIMOTE_BUTTON_RIGHT			0x0200
73 #define WIIMOTE_BUTTON_DOWN				0x0400
74 #define WIIMOTE_BUTTON_UP				0x0800
75 #define WIIMOTE_BUTTON_PLUS				0x1000
76 #define WIIMOTE_BUTTON_ZACCEL_BIT4		0x2000
77 #define WIIMOTE_BUTTON_ZACCEL_BIT5		0x4000
78 #define WIIMOTE_BUTTON_UNKNOWN			0x8000
79 #define WIIMOTE_BUTTON_ALL				0x1F9F
80 
81 /* nunchul button codes */
82 #define NUNCHUK_BUTTON_Z				0x01
83 #define NUNCHUK_BUTTON_C				0x02
84 #define NUNCHUK_BUTTON_ALL				0x03
85 
86 /* classic controller button codes */
87 #define CLASSIC_CTRL_BUTTON_UP			0x0001
88 #define CLASSIC_CTRL_BUTTON_LEFT		0x0002
89 #define CLASSIC_CTRL_BUTTON_ZR			0x0004
90 #define CLASSIC_CTRL_BUTTON_X			0x0008
91 #define CLASSIC_CTRL_BUTTON_A			0x0010
92 #define CLASSIC_CTRL_BUTTON_Y			0x0020
93 #define CLASSIC_CTRL_BUTTON_B			0x0040
94 #define CLASSIC_CTRL_BUTTON_ZL			0x0080
95 #define CLASSIC_CTRL_BUTTON_FULL_R		0x0200
96 #define CLASSIC_CTRL_BUTTON_PLUS		0x0400
97 #define CLASSIC_CTRL_BUTTON_HOME		0x0800
98 #define CLASSIC_CTRL_BUTTON_MINUS		0x1000
99 #define CLASSIC_CTRL_BUTTON_FULL_L		0x2000
100 #define CLASSIC_CTRL_BUTTON_DOWN		0x4000
101 #define CLASSIC_CTRL_BUTTON_RIGHT		0x8000
102 #define CLASSIC_CTRL_BUTTON_ALL			0xFEFF
103 
104 /* guitar hero 3 button codes */
105 #define GUITAR_HERO_3_BUTTON_STRUM_UP	0x0001
106 #define GUITAR_HERO_3_BUTTON_YELLOW		0x0008
107 #define GUITAR_HERO_3_BUTTON_GREEN		0x0010
108 #define GUITAR_HERO_3_BUTTON_BLUE		0x0020
109 #define GUITAR_HERO_3_BUTTON_RED		0x0040
110 #define GUITAR_HERO_3_BUTTON_ORANGE		0x0080
111 #define GUITAR_HERO_3_BUTTON_PLUS		0x0400
112 #define GUITAR_HERO_3_BUTTON_MINUS		0x1000
113 #define GUITAR_HERO_3_BUTTON_STRUM_DOWN	0x4000
114 #define GUITAR_HERO_3_BUTTON_ALL		0xFEFF
115 
116 
117 /* wiimote option flags */
118 #define WIIUSE_SMOOTHING				0x01
119 #define WIIUSE_CONTINUOUS				0x02
120 #define WIIUSE_ORIENT_THRESH			0x04
121 #define WIIUSE_INIT_FLAGS				(WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH)
122 
123 #define WIIUSE_ORIENT_PRECISION			100.0f
124 
125 /* expansion codes */
126 #define EXP_NONE						0
127 #define EXP_NUNCHUK						1
128 #define EXP_CLASSIC						2
129 #define EXP_GUITAR_HERO_3				3
130 
131 /* IR correction types */
132 typedef enum ir_position_t {
133 	WIIUSE_IR_ABOVE,
134 	WIIUSE_IR_BELOW
135 } ir_position_t;
136 
137 /**
138  *	@brief Check if a button is pressed.
139  *	@param dev		Pointer to a wiimote_t or expansion structure.
140  *	@param button	The button you are interested in.
141  *	@return 1 if the button is pressed, 0 if not.
142  */
143 #define IS_PRESSED(dev, button)		((dev->btns & button) == button)
144 
145 /**
146  *	@brief Check if a button is being held.
147  *	@param dev		Pointer to a wiimote_t or expansion structure.
148  *	@param button	The button you are interested in.
149  *	@return 1 if the button is held, 0 if not.
150  */
151 #define IS_HELD(dev, button)			((dev->btns_held & button) == button)
152 
153 /**
154  *	@brief Check if a button is released on this event.					\n\n
155  *			This does not mean the button is not pressed, it means		\n
156  *			this button was just now released.
157  *	@param dev		Pointer to a wiimote_t or expansion structure.
158  *	@param button	The button you are interested in.
159  *	@return 1 if the button is released, 0 if not.
160  *
161  */
162 #define IS_RELEASED(dev, button)		((dev->btns_released & button) == button)
163 
164 /**
165  *	@brief Check if a button has just been pressed this event.
166  *	@param dev		Pointer to a wiimote_t or expansion structure.
167  *	@param button	The button you are interested in.
168  *	@return 1 if the button is pressed, 0 if not.
169  */
170 #define IS_JUST_PRESSED(dev, button)	(IS_PRESSED(dev, button) && !IS_HELD(dev, button))
171 
172 /**
173  *	@brief Return the IR sensitivity level.
174  *	@param wm		Pointer to a wiimote_t structure.
175  *	@param lvl		[out] Pointer to an int that will hold the level setting.
176  *	If no level is set 'lvl' will be set to 0.
177  */
178 #define WIIUSE_GET_IR_SENSITIVITY(dev, lvl)									\
179 			do {														\
180 				if ((wm->state & 0x0200) == 0x0200) 		*lvl = 1;	\
181 				else if ((wm->state & 0x0400) == 0x0400) 	*lvl = 2;	\
182 				else if ((wm->state & 0x0800) == 0x0800) 	*lvl = 3;	\
183 				else if ((wm->state & 0x1000) == 0x1000) 	*lvl = 4;	\
184 				else if ((wm->state & 0x2000) == 0x2000) 	*lvl = 5;	\
185 				else									*lvl = 0;		\
186 			} while (0)
187 
188 #define WIIUSE_USING_ACC(wm)			((wm->state & 0x020) == 0x020)
189 #define WIIUSE_USING_EXP(wm)			((wm->state & 0x040) == 0x040)
190 #define WIIUSE_USING_IR(wm)				((wm->state & 0x080) == 0x080)
191 #define WIIUSE_USING_SPEAKER(wm)		((wm->state & 0x100) == 0x100)
192 
193 #define WIIUSE_IS_LED_SET(wm, num)		((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
194 
195 /*
196  *	Largest known payload is 21 bytes.
197  *	Add 2 for the prefix and round up to a power of 2.
198  */
199 #define MAX_PAYLOAD			32
200 
201 /*
202  *	This is left over from an old hack, but it may actually
203  *	be a useful feature to keep so it wasn't removed.
204  */
205 #ifdef WIN32
206 	#define WIIMOTE_DEFAULT_TIMEOUT		10
207 	#define WIIMOTE_EXP_TIMEOUT			10
208 #endif
209 
210 typedef unsigned char byte;
211 typedef char sbyte;
212 
213 struct wiimote_t;
214 struct vec3b_t;
215 struct orient_t;
216 struct gforce_t;
217 
218 
219 /**
220  *      @brief Callback that handles a read event.
221  *
222  *      @param wm               Pointer to a wiimote_t structure.
223  *      @param data             Pointer to the filled data block.
224  *      @param len              Length in bytes of the data block.
225  *
226  *      @see wiiuse_init()
227  *
228  *      A registered function of this type is called automatically by the wiiuse
229  *      library when the wiimote has returned the full data requested by a previous
230  *      call to wiiuse_read_data().
231  */
232 typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len);
233 
234 
235 /**
236  *	@struct read_req_t
237  *	@brief Data read request structure.
238  */
239 struct read_req_t {
240 	wiiuse_read_cb cb;			/**< read data callback											*/
241 	byte* buf;					/**< buffer where read data is written							*/
242 	unsigned int addr;			/**< the offset that the read started at						*/
243 	unsigned short size;		/**< the length of the data read								*/
244 	unsigned short wait;		/**< num bytes still needed to finish read						*/
245 	byte dirty;					/**< set to 1 if not using callback and needs to be cleaned up	*/
246 
247 	struct read_req_t* next;	/**< next read request in the queue								*/
248 };
249 
250 
251 /**
252  *	@struct vec2b_t
253  *	@brief Unsigned x,y byte vector.
254  */
255 typedef struct vec2b_t {
256 	byte x, y;
257 } vec2b_t;
258 
259 
260 /**
261  *	@struct vec3b_t
262  *	@brief Unsigned x,y,z byte vector.
263  */
264 typedef struct vec3b_t {
265 	byte x, y, z;
266 } vec3b_t;
267 
268 
269 /**
270  *	@struct vec3f_t
271  *	@brief Signed x,y,z float struct.
272  */
273 typedef struct vec3f_t {
274 	float x, y, z;
275 } vec3f_t;
276 
277 
278 /**
279  *	@struct orient_t
280  *	@brief Orientation struct.
281  *
282  *	Yaw, pitch, and roll range from -180 to 180 degrees.
283  */
284 typedef struct orient_t {
285 	float roll;						/**< roll, this may be smoothed if enabled	*/
286 	float pitch;					/**< pitch, this may be smoothed if enabled	*/
287 	float yaw;
288 
289 	float a_roll;					/**< absolute roll, unsmoothed				*/
290 	float a_pitch;					/**< absolute pitch, unsmoothed				*/
291 } orient_t;
292 
293 
294 /**
295  *	@struct gforce_t
296  *	@brief Gravity force struct.
297  */
298 typedef struct gforce_t {
299 	float x, y, z;
300 } gforce_t;
301 
302 
303 /**
304  *	@struct accel_t
305  *	@brief Accelerometer struct. For any device with an accelerometer.
306  */
307 typedef struct accel_t {
308 	struct vec3b_t cal_zero;		/**< zero calibration					*/
309 	struct vec3b_t cal_g;			/**< 1g difference around 0cal			*/
310 
311 	float st_roll;					/**< last smoothed roll value			*/
312 	float st_pitch;					/**< last smoothed roll pitch			*/
313 	float st_alpha;					/**< alpha value for smoothing [0-1]	*/
314 } accel_t;
315 
316 
317 /**
318  *	@struct ir_dot_t
319  *	@brief A single IR source.
320  */
321 typedef struct ir_dot_t {
322 	byte visible;					/**< if the IR source is visible		*/
323 
324 	unsigned int x;					/**< interpolated X coordinate			*/
325 	unsigned int y;					/**< interpolated Y coordinate			*/
326 
327 	short rx;						/**< raw X coordinate (0-1023)			*/
328 	short ry;						/**< raw Y coordinate (0-767)			*/
329 
330 	byte order;						/**< increasing order by x-axis value	*/
331 
332 	byte size;						/**< size of the IR dot (0-15)			*/
333 } ir_dot_t;
334 
335 
336 /**
337  *	@enum aspect_t
338  *	@brief Screen aspect ratio.
339  */
340 typedef enum aspect_t {
341 	WIIUSE_ASPECT_4_3,
342 	WIIUSE_ASPECT_16_9
343 } aspect_t;
344 
345 
346 /**
347  *	@struct ir_t
348  *	@brief IR struct. Hold all data related to the IR tracking.
349  */
350 typedef struct ir_t {
351 	struct ir_dot_t dot[4];			/**< IR dots							*/
352 	byte num_dots;					/**< number of dots at this time		*/
353 
354 	enum aspect_t aspect;			/**< aspect ratio of the screen			*/
355 
356 	enum ir_position_t pos;			/**< IR sensor bar position				*/
357 
358 	unsigned int vres[2];			/**< IR virtual screen resolution		*/
359 	int offset[2];					/**< IR XY correction offset			*/
360 	int state;						/**< keeps track of the IR state		*/
361 
362 	int ax;							/**< absolute X coordinate				*/
363 	int ay;							/**< absolute Y coordinate				*/
364 
365 	int x;							/**< calculated X coordinate			*/
366 	int y;							/**< calculated Y coordinate			*/
367 
368 	float distance;					/**< pixel distance between first 2 dots*/
369 	float z;						/**< calculated distance				*/
370 } ir_t;
371 
372 
373 /**
374  *	@struct joystick_t
375  *	@brief Joystick calibration structure.
376  *
377  *	The angle \a ang is relative to the positive y-axis into quadrant I
378  *	and ranges from 0 to 360 degrees.  So if the joystick is held straight
379  *	upwards then angle is 0 degrees.  If it is held to the right it is 90,
380  *	down is 180, and left is 270.
381  *
382  *	The magnitude \a mag is the distance from the center to where the
383  *	joystick is being held.  The magnitude ranges from 0 to 1.
384  *	If the joystick is only slightly tilted from the center the magnitude
385  *	will be low, but if it is closer to the outter edge the value will
386  *	be higher.
387  */
388 typedef struct joystick_t {
389 	struct vec2b_t max;				/**< maximum joystick values	*/
390 	struct vec2b_t min;				/**< minimum joystick values	*/
391 	struct vec2b_t center;			/**< center joystick values		*/
392 
393 	float ang;						/**< angle the joystick is being held		*/
394 	float mag;						/**< magnitude of the joystick (range 0-1)	*/
395 } joystick_t;
396 
397 
398 /**
399  *	@struct nunchuk_t
400  *	@brief Nunchuk expansion device.
401  */
402 typedef struct nunchuk_t {
403 	struct accel_t accel_calib;		/**< nunchuk accelerometer calibration		*/
404 	struct joystick_t js;			/**< joystick calibration					*/
405 
406 	int* flags;						/**< options flag (points to wiimote_t.flags) */
407 
408 	byte btns;						/**< what buttons have just been pressed	*/
409 	byte btns_held;					/**< what buttons are being held down		*/
410 	byte btns_released;				/**< what buttons were just released this	*/
411 
412 	float orient_threshold;			/**< threshold for orient to generate an event */
413 	int accel_threshold;			/**< threshold for accel to generate an event */
414 
415 	struct vec3b_t accel;			/**< current raw acceleration data			*/
416 	struct orient_t orient;			/**< current orientation on each axis		*/
417 	struct gforce_t gforce;			/**< current gravity forces on each axis	*/
418 } nunchuk_t;
419 
420 
421 /**
422  *	@struct classic_ctrl_t
423  *	@brief Classic controller expansion device.
424  */
425 typedef struct classic_ctrl_t {
426 	short btns;						/**< what buttons have just been pressed	*/
427 	short btns_held;				/**< what buttons are being held down		*/
428 	short btns_released;			/**< what buttons were just released this	*/
429 
430 	float r_shoulder;				/**< right shoulder button (range 0-1)		*/
431 	float l_shoulder;				/**< left shoulder button (range 0-1)		*/
432 
433 	struct joystick_t ljs;			/**< left joystick calibration				*/
434 	struct joystick_t rjs;			/**< right joystick calibration				*/
435 } classic_ctrl_t;
436 
437 
438 /**
439  *	@struct guitar_hero_3_t
440  *	@brief Guitar Hero 3 expansion device.
441  */
442 typedef struct guitar_hero_3_t {
443 	short btns;						/**< what buttons have just been pressed	*/
444 	short btns_held;				/**< what buttons are being held down		*/
445 	short btns_released;			/**< what buttons were just released this	*/
446 
447 	float whammy_bar;				/**< whammy bar (range 0-1)					*/
448 
449 	struct joystick_t js;			/**< joystick calibration					*/
450 } guitar_hero_3_t;
451 
452 
453 /**
454  *	@struct expansion_t
455  *	@brief Generic expansion device plugged into wiimote.
456  */
457 typedef struct expansion_t {
458 	int type;						/**< type of expansion attached				*/
459 
460 	union {
461 		struct nunchuk_t nunchuk;
462 		struct classic_ctrl_t classic;
463 		struct guitar_hero_3_t gh3;
464 	};
465 } expansion_t;
466 
467 
468 /**
469  *	@enum win32_bt_stack_t
470  *	@brief	Available bluetooth stacks for Windows.
471  */
472 typedef enum win_bt_stack_t {
473 	WIIUSE_STACK_UNKNOWN,
474 	WIIUSE_STACK_MS,
475 	WIIUSE_STACK_BLUESOLEIL
476 } win_bt_stack_t;
477 
478 
479 /**
480  *	@struct wiimote_state_t
481  *	@brief Significant data from the previous event.
482  */
483 typedef struct wiimote_state_t {
484 	/* expansion_t */
485 	float exp_ljs_ang;
486 	float exp_rjs_ang;
487 	float exp_ljs_mag;
488 	float exp_rjs_mag;
489 	unsigned short exp_btns;
490 	struct orient_t exp_orient;
491 	struct vec3b_t exp_accel;
492 	float exp_r_shoulder;
493 	float exp_l_shoulder;
494 
495 	/* ir_t */
496 	int ir_ax;
497 	int ir_ay;
498 	float ir_distance;
499 
500 	struct orient_t orient;
501 	unsigned short btns;
502 
503 	struct vec3b_t accel;
504 } wiimote_state_t;
505 
506 
507 /**
508  *	@enum WIIUSE_EVENT_TYPE
509  *	@brief Events that wiiuse can generate from a poll.
510  */
511 typedef enum WIIUSE_EVENT_TYPE {
512 	WIIUSE_NONE = 0,
513 	WIIUSE_EVENT,
514 	WIIUSE_STATUS,
515 	WIIUSE_CONNECT,
516 	WIIUSE_DISCONNECT,
517 	WIIUSE_UNEXPECTED_DISCONNECT,
518 	WIIUSE_READ_DATA,
519 	WIIUSE_NUNCHUK_INSERTED,
520 	WIIUSE_NUNCHUK_REMOVED,
521 	WIIUSE_CLASSIC_CTRL_INSERTED,
522 	WIIUSE_CLASSIC_CTRL_REMOVED,
523 	WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
524 	WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
525 } WIIUSE_EVENT_TYPE;
526 
527 /**
528  *	@struct wiimote_t
529  *	@brief Wiimote structure.
530  */
531 typedef struct wiimote_t {
532 	WCONST int unid;						/**< user specified id						*/
533 
534 	#ifndef WIN32
535 		WCONST bdaddr_t bdaddr;				/**< bt address								*/
536 		WCONST char bdaddr_str[18];			/**< readable bt address					*/
537 		WCONST int out_sock;				/**< output socket							*/
538 		WCONST int in_sock;					/**< input socket 							*/
539 	#else
540 		WCONST HANDLE dev_handle;			/**< HID handle								*/
541 		WCONST OVERLAPPED hid_overlap;		/**< overlap handle							*/
542 		WCONST enum win_bt_stack_t stack;	/**< type of bluetooth stack to use			*/
543 		WCONST int timeout;					/**< read timeout							*/
544 		WCONST byte normal_timeout;			/**< normal timeout							*/
545 		WCONST byte exp_timeout;			/**< timeout for expansion handshake		*/
546 	#endif
547 
548 	WCONST int state;						/**< various state flags					*/
549 	WCONST byte leds;						/**< currently lit leds						*/
550 	WCONST float battery_level;				/**< battery level							*/
551 
552 	WCONST int flags;						/**< options flag							*/
553 
554 	WCONST byte handshake_state;			/**< the state of the connection handshake	*/
555 
556 	WCONST struct read_req_t* read_req;		/**< list of data read requests				*/
557 	WCONST struct accel_t accel_calib;		/**< wiimote accelerometer calibration		*/
558 	WCONST struct expansion_t exp;			/**< wiimote expansion device				*/
559 
560 	WCONST struct vec3b_t accel;			/**< current raw acceleration data			*/
561 	WCONST struct orient_t orient;			/**< current orientation on each axis		*/
562 	WCONST struct gforce_t gforce;			/**< current gravity forces on each axis	*/
563 
564 	WCONST struct ir_t ir;					/**< IR data								*/
565 
566 	WCONST unsigned short btns;				/**< what buttons have just been pressed	*/
567 	WCONST unsigned short btns_held;		/**< what buttons are being held down		*/
568 	WCONST unsigned short btns_released;	/**< what buttons were just released this	*/
569 
570 	WCONST float orient_threshold;			/**< threshold for orient to generate an event */
571 	WCONST int accel_threshold;				/**< threshold for accel to generate an event */
572 
573 	WCONST struct wiimote_state_t lstate;	/**< last saved state						*/
574 
575 	WCONST WIIUSE_EVENT_TYPE event;			/**< type of event that occurred				*/
576 	WCONST byte event_buf[MAX_PAYLOAD];		/**< event buffer							*/
577 } wiimote;
578 
579 
580 /*****************************************
581  *
582  *	Include API specific stuff
583  *
584  *****************************************/
585 
586 #ifdef _WIN32
587 	#define WIIUSE_EXPORT_DECL __declspec(dllexport)
588 	#define WIIUSE_IMPORT_DECL __declspec(dllimport)
589 #else
590 	#define WIIUSE_EXPORT_DECL
591 	#define WIIUSE_IMPORT_DECL
592 #endif
593 
594 #ifdef WIIUSE_COMPILE_LIB
595 	#define WIIUSE_EXPORT WIIUSE_EXPORT_DECL
596 #else
597 	#define WIIUSE_EXPORT WIIUSE_IMPORT_DECL
598 #endif
599 
600 #ifdef __cplusplus
601 extern "C" {
602 #endif
603 
604 /* wiiuse.c */
605 WIIUSE_EXPORT extern const char* wiiuse_version();
606 
607 WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes);
608 WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm);
609 WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
610 WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
611 WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm);
612 WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
613 WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status);
614 WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len);
615 WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
616 WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm);
617 WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid);
618 WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable);
619 WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha);
620 WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type);
621 WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold);
622 WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm);
623 WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout);
624 WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold);
625 
626 /* connect.c */
627 WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
628 WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
629 WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
630 
631 /* events.c */
632 WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
633 
634 /* ir.c */
635 WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status);
636 WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y);
637 WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos);
638 WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
639 WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
640 
641 /* nunchuk.c */
642 WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
643 WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
644 
645 
646 #ifdef __cplusplus
647 }
648 #endif
649 
650