46 #include <bluetooth/bluetooth.h> 49 #ifdef WIIUSE_INTERNAL_H_INCLUDED 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 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 82 #define NUNCHUK_BUTTON_Z 0x01 83 #define NUNCHUK_BUTTON_C 0x02 84 #define NUNCHUK_BUTTON_ALL 0x03 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 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 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) 123 #define WIIUSE_ORIENT_PRECISION 100.0f 127 #define EXP_NUNCHUK 1 128 #define EXP_CLASSIC 2 129 #define EXP_GUITAR_HERO_3 3 132 typedef enum ir_position_t {
143 #define IS_PRESSED(dev, button) ((dev->btns & button) == button) 151 #define IS_HELD(dev, button) ((dev->btns_held & button) == button) 162 #define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) 170 #define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) 178 #define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \ 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; \ 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) 193 #define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) 199 #define MAX_PAYLOAD 32 206 #define WIIMOTE_DEFAULT_TIMEOUT 10 207 #define WIIMOTE_EXP_TIMEOUT 10 210 typedef unsigned char byte;
358 unsigned int vres[2];
472 typedef enum win_bt_stack_t {
473 WIIUSE_STACK_UNKNOWN,
475 WIIUSE_STACK_BLUESOLEIL
489 unsigned short exp_btns;
492 float exp_r_shoulder;
493 float exp_l_shoulder;
517 WIIUSE_UNEXPECTED_DISCONNECT,
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
535 WCONST bdaddr_t bdaddr;
536 WCONST
char bdaddr_str[18];
541 WCONST OVERLAPPED hid_overlap;
542 WCONST
enum win_bt_stack_t stack;
544 WCONST byte normal_timeout;
545 WCONST byte exp_timeout;
550 WCONST
float battery_level;
554 WCONST byte handshake_state;
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;
576 WCONST byte event_buf[MAX_PAYLOAD];
587 #define WIIUSE_EXPORT_DECL __declspec(dllexport) 588 #define WIIUSE_IMPORT_DECL __declspec(dllimport) 590 #define WIIUSE_EXPORT_DECL 591 #define WIIUSE_IMPORT_DECL 594 #ifdef WIIUSE_COMPILE_LIB 595 #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL 597 #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL 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
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