Several minor modifications and some cleanup.

This commit is contained in:
2011-12-31 14:50:33 +00:00
parent 55ee59d3aa
commit b2b22001c6
47 changed files with 303 additions and 5607 deletions

View File

@@ -183,4 +183,5 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

View File

@@ -54,8 +54,8 @@
char* file = __FILE__; \
int i = strlen(file) - 1; \
for (; i && (file[i] != '\\'); --i); \
fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
fflush(stderr); \
fprintf(stdout, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
fflush(stdout); \
} while (0)
#else
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)

View File

@@ -640,7 +640,7 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
if (!data) {
byte* handshake_buf;
byte buf = 0x00;
byte buf = 0x55;
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
disable_expansion(wm);
@@ -651,7 +651,9 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
wm->timeout = wm->exp_timeout;
#endif
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1);
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE1, &buf, 1);
buf = 0x00;
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE2, &buf, 1);
/* get the calibration data */
handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));

View File

@@ -53,7 +53,6 @@ static void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now);
* @return Returns 1 if handshake was successful, 0 if not.
*/
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len) {
int i;
int offset = 0;
nc->btns = 0;
@@ -64,10 +63,6 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
nc->flags = &wm->flags;
nc->accel_calib.st_alpha = wm->accel_calib.st_alpha;
/* decrypt data */
for (i = 0; i < len; ++i)
data[i] = (data[i] ^ 0x17) + 0x17;
if (data[offset] == 0xFF) {
/*
* Sometimes the data returned here is not correct.
@@ -137,12 +132,6 @@ void nunchuk_disconnected(struct nunchuk_t* nc) {
* @param msg The message specified in the event packet.
*/
void nunchuk_event(struct nunchuk_t* nc, byte* msg) {
int i;
/* decrypt data */
for (i = 0; i < 6; ++i)
msg[i] = (msg[i] ^ 0x17) + 0x17;
/* get button states */
nunchuk_pressed_buttons(nc, msg[5]);

View File

@@ -87,6 +87,7 @@
#define WM_RPT_BTN_ACC_EXP 0x35
#define WM_RPT_BTN_IR_EXP 0x36
#define WM_RPT_BTN_ACC_IR_EXP 0x37
#define WM_RPT_BALANCE_BOARD 0x40
#define WM_BT_INPUT 0x01
#define WM_BT_OUTPUT 0x02
@@ -104,7 +105,8 @@
/* offsets in wiimote memory */
#define WM_MEM_OFFSET_CALIBRATION 0x16
#define WM_EXP_MEM_BASE 0x04A40000
#define WM_EXP_MEM_ENABLE 0x04A40040
#define WM_EXP_MEM_ENABLE1 0x04A400F0
#define WM_EXP_MEM_ENABLE2 0x04A400FB
#define WM_EXP_MEM_CALIBR 0x04A40020
#define WM_REG_IR 0x04B00030
@@ -149,9 +151,9 @@
*/
/* encrypted expansion id codes (located at 0x04A400FC) */
#define EXP_ID_CODE_NUNCHUK 0x9A1EFEFE
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0x9A1EFDFD
#define EXP_ID_CODE_GUITAR 0x9A1EFDFB
#define EXP_ID_CODE_NUNCHUK 0xA4200000
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0xA4200101
#define EXP_ID_CODE_GUITAR 0xA4200103
#define EXP_ID_CODE_BALANCE_BOARD 0xA4200402
#define EXP_HANDSHAKE_LEN 224

Binary file not shown.