#include
#include
#include "definitions.h"
#include "wiiuse.h"
Defines |
|
#define | WIIUSE_VERSION "0.12" |
#define | WM_OUTPUT_CHANNEL 0x11 |
#define | WM_INPUT_CHANNEL 0x13 |
#define | WM_SET_REPORT 0x50 |
#define | WM_CMD_LED 0x11 |
#define | WM_CMD_REPORT_TYPE 0x12 |
#define | WM_CMD_RUMBLE 0x13 |
#define | WM_CMD_IR 0x13 |
#define | WM_CMD_CTRL_STATUS 0x15 |
#define | WM_CMD_WRITE_DATA 0x16 |
#define | WM_CMD_READ_DATA 0x17 |
#define | WM_CMD_IR_2 0x1A |
#define | WM_RPT_CTRL_STATUS 0x20 |
#define | WM_RPT_READ 0x21 |
#define | WM_RPT_WRITE 0x22 |
#define | WM_RPT_BTN 0x30 |
#define | WM_RPT_BTN_ACC 0x31 |
#define | WM_RPT_BTN_ACC_IR 0x33 |
#define | WM_RPT_BTN_EXP 0x34 |
#define | WM_RPT_BTN_ACC_EXP 0x35 |
#define | WM_RPT_BTN_IR_EXP 0x36 |
#define | WM_RPT_BTN_ACC_IR_EXP 0x37 |
#define | WM_BT_INPUT 0x01 |
#define | WM_BT_OUTPUT 0x02 |
#define | WM_DEV_CLASS_0 0x04 |
#define | WM_DEV_CLASS_1 0x25 |
#define | WM_DEV_CLASS_2 0x00 |
#define | WM_VENDOR_ID 0x057E |
#define | WM_PRODUCT_ID 0x0306 |
#define | WM_MAX_BATTERY_CODE 0xC8 |
#define | WM_MEM_OFFSET_CALIBRATION 0x16 |
#define | WM_EXP_MEM_BASE 0x04A40000 |
#define | WM_EXP_MEM_ENABLE 0x04A40040 |
#define | WM_EXP_MEM_CALIBR 0x04A40020 |
#define | WM_REG_IR 0x04B00030 |
#define | WM_REG_IR_BLOCK1 0x04B00000 |
#define | WM_REG_IR_BLOCK2 0x04B0001A |
#define | WM_REG_IR_MODENUM 0x04B00033 |
#define | WM_IR_BLOCK1_LEVEL1 "\x02\x00\x00\x71\x01\x00\x64\x00\xfe" |
#define | WM_IR_BLOCK2_LEVEL1 "\xfd\x05" |
#define | WM_IR_BLOCK1_LEVEL2 "\x02\x00\x00\x71\x01\x00\x96\x00\xb4" |
#define | WM_IR_BLOCK2_LEVEL2 "\xb3\x04" |
#define | WM_IR_BLOCK1_LEVEL3 "\x02\x00\x00\x71\x01\x00\xaa\x00\x64" |
#define | WM_IR_BLOCK2_LEVEL3 "\x63\x03" |
#define | WM_IR_BLOCK1_LEVEL4 "\x02\x00\x00\x71\x01\x00\xc8\x00\x36" |
#define | WM_IR_BLOCK2_LEVEL4 "\x35\x03" |
#define | WM_IR_BLOCK1_LEVEL5 "\x07\x00\x00\x71\x01\x00\x72\x00\x20" |
#define | WM_IR_BLOCK2_LEVEL5 "\x1f\x03" |
#define | WM_IR_TYPE_BASIC 0x01 |
#define | WM_IR_TYPE_EXTENDED 0x03 |
#define | WM_CTRL_STATUS_BYTE1_ATTACHMENT 0x02 |
#define | WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED 0x04 |
#define | WM_CTRL_STATUS_BYTE1_IR_ENABLED 0x08 |
#define | WM_CTRL_STATUS_BYTE1_LED_1 0x10 |
#define | WM_CTRL_STATUS_BYTE1_LED_2 0x20 |
#define | WM_CTRL_STATUS_BYTE1_LED_3 0x40 |
#define | WM_CTRL_STATUS_BYTE1_LED_4 0x80 |
#define | WM_ASPECT_16_9_X 660 |
#define | WM_ASPECT_16_9_Y 370 |
#define | WM_ASPECT_4_3_X 560 |
#define | WM_ASPECT_4_3_Y 420 |
#define | EXP_ID_CODE_NUNCHUK 0x9A1EFEFE |
#define | EXP_ID_CODE_CLASSIC_CONTROLLER 0x9A1EFDFD |
#define | EXP_ID_CODE_GUITAR 0x9A1EFDFB |
#define | EXP_HANDSHAKE_LEN 224 |
#define | WIIMOTE_STATE_DEV_FOUND 0x0001 |
#define | WIIMOTE_STATE_HANDSHAKE 0x0002 |
#define | WIIMOTE_STATE_HANDSHAKE_COMPLETE 0x0004 |
#define | WIIMOTE_STATE_CONNECTED 0x0008 |
#define | WIIMOTE_STATE_RUMBLE 0x0010 |
#define | WIIMOTE_STATE_ACC 0x0020 |
#define | WIIMOTE_STATE_EXP 0x0040 |
#define | WIIMOTE_STATE_IR 0x0080 |
#define | WIIMOTE_STATE_SPEAKER 0x0100 |
#define | WIIMOTE_STATE_IR_SENS_LVL1 0x0200 |
#define | WIIMOTE_STATE_IR_SENS_LVL2 0x0400 |
#define | WIIMOTE_STATE_IR_SENS_LVL3 0x0800 |
#define | WIIMOTE_STATE_IR_SENS_LVL4 0x1000 |
#define | WIIMOTE_STATE_IR_SENS_LVL5 0x2000 |
#define | WIIMOTE_INIT_STATES (WIIMOTE_STATE_IR_SENS_LVL3) |
#define | WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) |
#define | WIIMOTE_ENABLE_STATE(wm, s) (wm->state |= (s)) |
#define | WIIMOTE_DISABLE_STATE(wm, s) (wm->state &= ~(s)) |
#define | WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s)) |
#define | WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) |
#define | WIIMOTE_ENABLE_FLAG(wm, s) (wm->flags |= (s)) |
#define | WIIMOTE_DISABLE_FLAG(wm, s) (wm->flags &= ~(s)) |
#define | WIIMOTE_TOGGLE_FLAG(wm, s) ((wm->flags & (s)) ? WIIMOTE_DISABLE_FLAG(wm, s) : WIIMOTE_ENABLE_FLAG(wm, s)) |
#define | NUNCHUK_IS_FLAG_SET(wm, s) ((*(wm->flags) & (s)) == (s)) |
#define | WIIMOTE_ID(wm) (wm->unid) |
#define | WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED)) |
#define | WIIUSE_DEFAULT_SMOOTH_ALPHA 0.07f |
#define | SMOOTH_ROLL 0x01 |
#define | SMOOTH_PITCH 0x02 |
Functions |
|
int | wiiuse_set_report_type (struct wiimote_t *wm) |
Set the report type based on the current wiimote state. |
|
void | wiiuse_send_next_pending_read_request (struct wiimote_t *wm) |
Send the next pending data read request to the wiimote. |
|
int | wiiuse_send (struct wiimote_t *wm, byte report_type, byte *msg, int len) |
Send a packet to the wiimote. |
|
int | wiiuse_read_data_cb (struct wiimote_t *wm, wiiuse_read_cb read_cb, byte *buffer, unsigned int offset, unsigned short len) |
Read data from the wiimote (callback version). |
Since Wiiuse is a library, wiiuse.h is a duplicate of the API header.
The code that would normally go in that file, but which is not needed by third party developers, is put here.
So wiiuse_internal.h is included by other files internally, wiiuse.h is included only here.
#define EXP_ID_CODE_NUNCHUK 0x9A1EFEFE |
Expansion stuff
int wiiuse_read_data_cb | ( | struct wiimote_t * | wm, | |
wiiuse_read_cb | read_cb, | |||
byte * | buffer, | |||
unsigned int | addr, | |||
unsigned short | len | |||
) |
Read data from the wiimote (callback version).
wm | Pointer to a wiimote_t structure. | |
read_cb | Function pointer to call when the data arrives from the wiimote. | |
buffer | An allocated buffer to store the data as it arrives from the wiimote. Must be persistent in memory and large enough to hold the data. | |
addr | The address of wiimote memory to read from. | |
len | The length of the block to be read. |
int wiiuse_send | ( | struct wiimote_t * | wm, | |
byte | report_type, | |||
byte * | msg, | |||
int | len | |||
) |
Send a packet to the wiimote.
This function should replace any write()s directly to the wiimote device.void wiiuse_send_next_pending_read_request | ( | struct wiimote_t * | wm | ) |
Send the next pending data read request to the wiimote.
wm | Pointer to a wiimote_t structure. |
int wiiuse_set_report_type | ( | struct wiimote_t * | wm | ) |
Set the report type based on the current wiimote state.
wm | Pointer to a wiimote_t structure. |