mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
set svn:eol-type=native for **.c
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1439 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
50
Externals/WiiUseSrc/Src/classic.c
vendored
50
Externals/WiiUseSrc/Src/classic.c
vendored
@ -57,7 +57,7 @@ static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now);
|
||||
* @return Returns 1 if handshake was successful, 0 if not.
|
||||
*/
|
||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
|
||||
int i;
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
cc->btns = 0;
|
||||
@ -69,30 +69,30 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
||||
/* 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.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Classic controller handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Classic controller handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
|
||||
/* joystick stuff */
|
||||
cc->ljs.max.x = data[0 + offset] / 4;
|
||||
|
14
Externals/WiiUseSrc/Src/dynamics.c
vendored
14
Externals/WiiUseSrc/Src/dynamics.c
vendored
@ -107,12 +107,12 @@ void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct ori
|
||||
orient->pitch = y;
|
||||
orient->a_pitch = y;
|
||||
}
|
||||
|
||||
/* smooth the angles if enabled */
|
||||
if (smooth) {
|
||||
apply_smoothing(ac, orient, SMOOTH_ROLL);
|
||||
apply_smoothing(ac, orient, SMOOTH_PITCH);
|
||||
}
|
||||
|
||||
/* smooth the angles if enabled */
|
||||
if (smooth) {
|
||||
apply_smoothing(ac, orient, SMOOTH_ROLL);
|
||||
apply_smoothing(ac, orient, SMOOTH_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +191,7 @@ void calc_joystick_state(struct joystick_t* js, float x, float y) {
|
||||
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
|
||||
switch (type) {
|
||||
case SMOOTH_ROLL:
|
||||
{
|
||||
{
|
||||
/* it's possible last iteration was nan or inf, so set it to 0 if that happened */
|
||||
if (isnan(ac->st_roll) || isinf(ac->st_roll))
|
||||
ac->st_roll = 0.0f;
|
||||
|
1646
Externals/WiiUseSrc/Src/events.c
vendored
1646
Externals/WiiUseSrc/Src/events.c
vendored
File diff suppressed because it is too large
Load Diff
48
Externals/WiiUseSrc/Src/guitar_hero_3.c
vendored
48
Externals/WiiUseSrc/Src/guitar_hero_3.c
vendored
@ -57,7 +57,7 @@ static void guitar_hero_3_pressed_buttons(struct guitar_hero_3_t* gh3, short now
|
||||
* @return Returns 1 if handshake was successful, 0 if not.
|
||||
*/
|
||||
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
|
||||
int i;
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
/*
|
||||
@ -74,29 +74,29 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
||||
/* 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.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Guitar Hero 3 handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Guitar Hero 3 handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
/* joystick stuff */
|
||||
gh3->js.max.x = GUITAR_HERO_3_JS_MAX_X;
|
||||
|
28
Externals/WiiUseSrc/Src/io.c
vendored
28
Externals/WiiUseSrc/Src/io.c
vendored
@ -59,8 +59,8 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
case 0:
|
||||
{
|
||||
/* send request to wiimote for accelerometer calibration */
|
||||
byte* buf;
|
||||
|
||||
byte* buf;
|
||||
|
||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
@ -68,8 +68,8 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
wiiuse_read_data_cb(wm, wiiuse_handshake, buf, WM_MEM_OFFSET_CALIBRATION, 7);
|
||||
wm->handshake_state++;
|
||||
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -94,23 +94,23 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
accel->cal_zero.x, accel->cal_zero.y, accel->cal_zero.z,
|
||||
accel->cal_g.x, accel->cal_g.y, accel->cal_g.z);
|
||||
|
||||
|
||||
/* request the status of the wiimote to see if there is an expansion */
|
||||
wiiuse_status(wm);
|
||||
|
||||
|
||||
/* request the status of the wiimote to see if there is an expansion */
|
||||
wiiuse_status(wm);
|
||||
|
||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||
wm->handshake_state++;
|
||||
|
||||
/* now enable IR if it was set before the handshake completed */
|
||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||
wm->handshake_state++;
|
||||
|
||||
/* now enable IR if it was set before the handshake completed */
|
||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||
WIIUSE_DEBUG("Handshake finished, enabling IR.");
|
||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||
wiiuse_set_ir(wm, 1);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
|
30
Externals/WiiUseSrc/Src/io_win.c
vendored
30
Externals/WiiUseSrc/Src/io_win.c
vendored
@ -32,14 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <hidsdi.h>
|
||||
#include <setupapi.h>
|
||||
|
||||
|
||||
#include "definitions.h"
|
||||
#include "wiiuse_internal.h"
|
||||
#include "io.h"
|
||||
@ -176,8 +176,8 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
if (!ReadFile(wm->dev_handle, wm->event_buf, sizeof(wm->event_buf), &b, &wm->hid_overlap)) {
|
||||
/* partial read */
|
||||
b = GetLastError();
|
||||
|
||||
b = GetLastError();
|
||||
|
||||
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
|
||||
/* remote disconnect */
|
||||
wiiuse_disconnected(wm);
|
||||
@ -186,11 +186,11 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
r = WaitForSingleObject(wm->hid_overlap.hEvent, wm->timeout);
|
||||
if (r == WAIT_TIMEOUT) {
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
CancelIo(wm->dev_handle);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 0;
|
||||
@ -203,25 +203,25 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
||||
DWORD bytes;
|
||||
int i;
|
||||
|
||||
int i;
|
||||
|
||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
switch (wm->stack) {
|
||||
case WIIUSE_STACK_UNKNOWN:
|
||||
{
|
||||
/* try to auto-detect the stack type */
|
||||
if (i = WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap)) {
|
||||
/* bluesoleil will always return 1 here, even if it's not connected */
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
64
Externals/WiiUseSrc/Src/nunchuk.c
vendored
64
Externals/WiiUseSrc/Src/nunchuk.c
vendored
@ -53,9 +53,9 @@ 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;
|
||||
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
nc->btns = 0;
|
||||
nc->btns_held = 0;
|
||||
nc->btns_released = 0;
|
||||
@ -66,29 +66,29 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
|
||||
|
||||
/* 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.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Nunchuk handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
data[i] = (data[i] ^ 0x17) + 0x17;
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Nunchuk handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
nc->accel_calib.cal_zero.x = data[offset + 0];
|
||||
@ -103,16 +103,16 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
|
||||
nc->js.max.y = data[offset + 11];
|
||||
nc->js.min.y = data[offset + 12];
|
||||
nc->js.center.y = data[offset + 13];
|
||||
|
||||
|
||||
/* default the thresholds to the same as the wiimote */
|
||||
nc->orient_threshold = wm->orient_threshold;
|
||||
nc->accel_threshold = wm->accel_threshold;
|
||||
|
||||
/* handshake done */
|
||||
wm->exp.type = EXP_NUNCHUK;
|
||||
|
||||
#ifdef WIN32
|
||||
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
|
||||
/* handshake done */
|
||||
wm->exp.type = EXP_NUNCHUK;
|
||||
|
||||
#ifdef WIN32
|
||||
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
1406
Externals/WiiUseSrc/Src/wiiuse.c
vendored
1406
Externals/WiiUseSrc/Src/wiiuse.c
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user