xbmc
wiiuse.h
Go to the documentation of this file.
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 
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 
143 #define IS_PRESSED(dev, button) ((dev->btns & button) == button)
144 
151 #define IS_HELD(dev, button) ((dev->btns_held & button) == button)
152 
162 #define IS_RELEASED(dev, button) ((dev->btns_released & button) == button)
163 
170 #define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
171 
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 
232 typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len);
233 
234 
239 struct read_req_t {
241  byte* buf;
242  unsigned int addr;
243  unsigned short size;
244  unsigned short wait;
245  byte dirty;
247  struct read_req_t* next;
248 };
249 
250 
255 typedef struct vec2b_t {
256  byte x, y;
257 } vec2b_t;
258 
259 
264 typedef struct vec3b_t {
265  byte x, y, z;
266 } vec3b_t;
267 
268 
273 typedef struct vec3f_t {
274  float x, y, z;
275 } vec3f_t;
276 
277 
284 typedef struct orient_t {
285  float roll;
286  float pitch;
287  float yaw;
288 
289  float a_roll;
290  float a_pitch;
291 } orient_t;
292 
293 
298 typedef struct gforce_t {
299  float x, y, z;
300 } gforce_t;
301 
302 
307 typedef struct accel_t {
308  struct vec3b_t cal_zero;
309  struct vec3b_t cal_g;
311  float st_roll;
312  float st_pitch;
313  float st_alpha;
314 } accel_t;
315 
316 
321 typedef struct ir_dot_t {
322  byte visible;
324  unsigned int x;
325  unsigned int y;
327  short rx;
328  short ry;
330  byte order;
332  byte size;
333 } ir_dot_t;
334 
335 
340 typedef enum aspect_t {
341  WIIUSE_ASPECT_4_3,
342  WIIUSE_ASPECT_16_9
343 } aspect_t;
344 
345 
350 typedef struct ir_t {
351  struct ir_dot_t dot[4];
352  byte num_dots;
354  enum aspect_t aspect;
356  enum ir_position_t pos;
358  unsigned int vres[2];
359  int offset[2];
360  int state;
362  int ax;
363  int ay;
365  int x;
366  int y;
368  float distance;
369  float z;
370 } ir_t;
371 
372 
388 typedef struct joystick_t {
389  struct vec2b_t max;
390  struct vec2b_t min;
391  struct vec2b_t center;
393  float ang;
394  float mag;
395 } joystick_t;
396 
397 
402 typedef struct nunchuk_t {
403  struct accel_t accel_calib;
404  struct joystick_t js;
406  int* flags;
408  byte btns;
409  byte btns_held;
415  struct vec3b_t accel;
416  struct orient_t orient;
417  struct gforce_t gforce;
418 } nunchuk_t;
419 
420 
425 typedef struct classic_ctrl_t {
426  short btns;
427  short btns_held;
430  float r_shoulder;
431  float l_shoulder;
433  struct joystick_t ljs;
434  struct joystick_t rjs;
436 
437 
442 typedef struct guitar_hero_3_t {
443  short btns;
444  short btns_held;
447  float whammy_bar;
449  struct joystick_t js;
451 
452 
457 typedef struct expansion_t {
458  int type;
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 
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 
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;
505 
506 
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
526 
531 typedef struct wiimote_t {
532  WCONST int unid;
534  #ifndef WIN32
535  WCONST bdaddr_t bdaddr;
536  WCONST char bdaddr_str[18];
537  WCONST int out_sock;
538  WCONST int in_sock;
539  #else
540  WCONST HANDLE dev_handle;
541  WCONST OVERLAPPED hid_overlap;
542  WCONST enum win_bt_stack_t stack;
543  WCONST int timeout;
544  WCONST byte normal_timeout;
545  WCONST byte exp_timeout;
546  #endif
547 
548  WCONST int state;
549  WCONST byte leds;
550  WCONST float battery_level;
552  WCONST int flags;
554  WCONST byte handshake_state;
556  WCONST struct read_req_t* read_req;
557  WCONST struct accel_t accel_calib;
558  WCONST struct expansion_t exp;
560  WCONST struct vec3b_t accel;
561  WCONST struct orient_t orient;
562  WCONST struct gforce_t gforce;
564  WCONST struct ir_t ir;
566  WCONST unsigned short btns;
567  WCONST unsigned short btns_held;
568  WCONST unsigned short btns_released;
570  WCONST float orient_threshold;
571  WCONST int accel_threshold;
573  WCONST struct wiimote_state_t lstate;
575  WCONST WIIUSE_EVENT_TYPE event;
576  WCONST byte event_buf[MAX_PAYLOAD];
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 
int x
calculated X coordinate
Definition: wiiuse.h:365
Nunchuk expansion device.
Definition: wiiuse.h:402
Significant data from the previous event.
Definition: wiiuse.h:483
Definition: XHandle.h:21
WIIUSE_EXPORT float wiiuse_set_smooth_alpha(struct wiimote_t *wm, float alpha)
Set the wiimote smoothing alpha value.
Definition: wiiuse.c:666
WIIUSE_EXPORT void wiiuse_resync(struct wiimote_t *wm)
Try to resync with the wiimote by starting a new handshake.
Definition: wiiuse.c:737
float orient_threshold
threshold for orient to generate an event
Definition: wiiuse.h:412
float pitch
pitch, this may be smoothed if enabled
Definition: wiiuse.h:286
short rx
raw X coordinate (0-1023)
Definition: wiiuse.h:327
byte visible
if the IR source is visible
Definition: wiiuse.h:322
Wiimote structure.
Definition: wiiuse.h:531
WIIUSE_EXPORT void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t *wm, float threshold)
Set the orientation event threshold for the nunchuk.
Definition: nunchuk.c:191
Accelerometer struct.
Definition: wiiuse.h:307
A single IR source.
Definition: wiiuse.h:321
int type
type of expansion attached
Definition: wiiuse.h:458
float st_roll
last smoothed roll value
Definition: wiiuse.h:311
wiiuse_read_cb cb
read data callback
Definition: wiiuse.h:240
float st_alpha
alpha value for smoothing [0-1]
Definition: wiiuse.h:313
short btns_held
what buttons are being held down
Definition: wiiuse.h:427
float roll
roll, this may be smoothed if enabled
Definition: wiiuse.h:285
byte order
increasing order by x-axis value
Definition: wiiuse.h:330
WIIUSE_EXPORT int wiiuse_poll(struct wiimote_t **wm, int wiimotes)
Poll the wiimotes for any events.
Definition: events.c:83
struct read_req_t * next
next read request in the queue
Definition: wiiuse.h:247
WIIUSE_EXPORT int wiiuse_write_data(struct wiimote_t *wm, unsigned int addr, byte *data, byte len)
Write data to the wiimote.
Definition: wiiuse.c:526
byte num_dots
number of dots at this time
Definition: wiiuse.h:352
short btns_released
what buttons were just released this
Definition: wiiuse.h:428
WIIUSE_EXPORT void wiiuse_set_ir(struct wiimote_t *wm, int status)
Set if the wiimote should track IR targets.
Definition: ir.c:61
float distance
pixel distance between first 2 dots
Definition: wiiuse.h:368
WIIUSE_EXPORT void wiiuse_set_ir_vres(struct wiimote_t *wm, unsigned int x, unsigned int y)
Set the virtual screen resolution for IR tracking.
Definition: ir.c:193
int accel_threshold
threshold for accel to generate an event
Definition: wiiuse.h:413
WIIUSE_EXPORT void wiiuse_set_bluetooth_stack(struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t type)
Set the bluetooth stack type to use.
Definition: wiiuse.c:690
int y
calculated Y coordinate
Definition: wiiuse.h:366
short btns_released
what buttons were just released this
Definition: wiiuse.h:445
float whammy_bar
whammy bar (range 0-1)
Definition: wiiuse.h:447
float st_pitch
last smoothed roll pitch
Definition: wiiuse.h:312
WIIUSE_EXPORT void wiiuse_set_ir_position(struct wiimote_t *wm, enum ir_position_t pos)
Set the XY position for the IR cursor.
Definition: ir.c:206
WIIUSE_EXPORT struct wiimote_t * wiiuse_get_by_id(struct wiimote_t **wm, int wiimotes, int unid)
Find a wiimote_t structure by its unique identifier.
Definition: wiiuse.c:506
int * flags
options flag (points to wiimote_t.flags)
Definition: wiiuse.h:406
WCONST byte leds
currently lit leds
Definition: wiiuse.h:549
unsigned int addr
the offset that the read started at
Definition: wiiuse.h:242
int state
keeps track of the IR state
Definition: wiiuse.h:360
Unsigned x,y byte vector.
Definition: wiiuse.h:255
WIIUSE_EXPORT void wiiuse_disconnect(struct wiimote_t *wm)
Disconnect a wiimote.
Definition: io_nix.c:243
WIIUSE_EXPORT int wiiuse_connect(struct wiimote_t **wm, int wiimotes)
Connect to a wiimote or wiimotes once an address is known.
Definition: io_nix.c:145
Classic controller expansion device.
Definition: wiiuse.h:425
aspect_t
Screen aspect ratio.
Definition: wiiuse.h:340
Gravity force struct.
Definition: wiiuse.h:298
WIIUSE_EXPORT void wiiuse_set_aspect_ratio(struct wiimote_t *wm, enum aspect_t aspect)
Set the aspect ratio of the TV/monitor.
Definition: ir.c:245
unsigned short size
the length of the data read
Definition: wiiuse.h:243
byte * buf
buffer where read data is written
Definition: wiiuse.h:241
byte dirty
set to 1 if not using callback and needs to be cleaned up
Definition: wiiuse.h:245
WIIUSE_EXPORT void wiiuse_set_leds(struct wiimote_t *wm, int leds)
Set the enabled LEDs.
Definition: wiiuse.c:244
float a_roll
absolute roll, unsmoothed
Definition: wiiuse.h:289
Guitar Hero 3 expansion device.
Definition: wiiuse.h:442
IR struct.
Definition: wiiuse.h:350
Orientation struct.
Definition: wiiuse.h:284
byte btns_released
what buttons were just released this
Definition: wiiuse.h:410
WIIUSE_EXPORT void wiiuse_set_accel_threshold(struct wiimote_t *wm, int threshold)
Set the accelerometer event threshold.
Definition: wiiuse.c:725
Definition: LibInputPointer.h:13
unsigned int x
interpolated X coordinate
Definition: wiiuse.h:324
Data read request structure.
Definition: wiiuse.h:239
byte btns_held
what buttons are being held down
Definition: wiiuse.h:409
WIIUSE_EXPORT void wiiuse_status(struct wiimote_t *wm)
Request the wiimote controller status.
Definition: wiiuse.c:485
int ax
absolute X coordinate
Definition: wiiuse.h:362
WIIUSE_EXPORT void wiiuse_rumble(struct wiimote_t *wm, int status)
Enable or disable the rumble.
Definition: wiiuse.c:198
float mag
magnitude of the joystick (range 0-1)
Definition: wiiuse.h:394
Generic expansion device plugged into wiimote.
Definition: wiiuse.h:457
WIIUSE_EXPORT void wiiuse_toggle_rumble(struct wiimote_t *wm)
Toggle the state of the rumble.
Definition: wiiuse.c:229
void(* wiiuse_read_cb)(struct wiimote_t *wm, byte *data, unsigned short len)
Callback that handles a read event.
Definition: wiiuse.h:232
WIIUSE_EXPORT void wiiuse_set_orient_threshold(struct wiimote_t *wm, float threshold)
Set the orientation event threshold.
Definition: wiiuse.c:712
WIIUSE_EXPORT void wiiuse_motion_sensing(struct wiimote_t *wm, int status)
Set if the wiimote should report motion sensing.
Definition: wiiuse.c:273
unsigned short wait
num bytes still needed to finish read
Definition: wiiuse.h:244
WIIUSE_EXPORT int wiiuse_set_flags(struct wiimote_t *wm, int enable, int disable)
Set flags for the specified wiimote.
Definition: wiiuse.c:639
WIIUSE_EXPORT void wiiuse_disconnected(struct wiimote_t *wm)
The wiimote disconnected.
Definition: wiiuse.c:163
float a_pitch
absolute pitch, unsmoothed
Definition: wiiuse.h:290
WIIUSE_EXPORT struct wiimote_t ** wiiuse_init(int wiimotes)
Initialize an array of wiimote structures.
Definition: wiiuse.c:96
WIIUSE_EXPORT void wiiuse_cleanup(struct wiimote_t **wm, int wiimotes)
Clean up wiimote_t array created by wiiuse_init()
Definition: wiiuse.c:65
byte size
size of the IR dot (0-15)
Definition: wiiuse.h:332
short btns
what buttons have just been pressed
Definition: wiiuse.h:426
float l_shoulder
left shoulder button (range 0-1)
Definition: wiiuse.h:431
short btns_held
what buttons are being held down
Definition: wiiuse.h:444
WIIUSE_EXPORT const char * wiiuse_version()
Returns the version of the library.
Definition: wiiuse.c:57
Unsigned x,y,z byte vector.
Definition: wiiuse.h:264
WIIUSE_EXPORT void wiiuse_set_timeout(struct wiimote_t **wm, int wiimotes, byte normal_timeout, byte exp_timeout)
Set the normal and expansion handshake timeouts.
Definition: wiiuse.c:753
unsigned int y
interpolated Y coordinate
Definition: wiiuse.h:325
WIIUSE_EXPORT int wiiuse_read_data(struct wiimote_t *wm, byte *buffer, unsigned int offset, unsigned short len)
Read data from the wiimote (event version).
Definition: wiiuse.c:404
float ang
angle the joystick is being held
Definition: wiiuse.h:393
WIIUSE_EXPORT int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)
Find a wiimote or wiimotes.
Definition: io_nix.c:67
WIIUSE_EXPORT void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t *wm, int threshold)
Set the accelerometer event threshold for the nunchuk.
Definition: nunchuk.c:206
int ay
absolute Y coordinate
Definition: wiiuse.h:363
short btns
what buttons have just been pressed
Definition: wiiuse.h:443
short ry
raw Y coordinate (0-767)
Definition: wiiuse.h:328
Signed x,y,z float struct.
Definition: wiiuse.h:273
float r_shoulder
right shoulder button (range 0-1)
Definition: wiiuse.h:430
WCONST int unid
user specified id
Definition: wiiuse.h:532
WIIUSE_EVENT_TYPE
Events that wiiuse can generate from a poll.
Definition: wiiuse.h:511
WIIUSE_EXPORT void wiiuse_set_ir_sensitivity(struct wiimote_t *wm, int level)
Set the IR sensitivity.
Definition: ir.c:272
Joystick calibration structure.
Definition: wiiuse.h:388
float z
calculated distance
Definition: wiiuse.h:369
byte btns
what buttons have just been pressed
Definition: wiiuse.h:408