Change files that have mixed EOLs and make sure they keep one style from now.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10542 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
254fa42b7c
commit
dde596e0fc
@ -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;
|
||||
|
@ -50,16 +50,16 @@
|
||||
/* Information output macros */
|
||||
#define WIIUSE_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
#ifdef WITH_WIIUSE_DEBUG
|
||||
#ifdef WIN32
|
||||
#define WIIUSE_DEBUG(fmt, ...) do { \
|
||||
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__); \
|
||||
} while (0)
|
||||
#ifdef WITH_WIIUSE_DEBUG
|
||||
#ifdef WIN32
|
||||
#define WIIUSE_DEBUG(fmt, ...) do { \
|
||||
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__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
|
||||
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
#else
|
||||
#define WIIUSE_DEBUG(fmt, ...)
|
||||
|
@ -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
src/wiiuse/events.c
1646
src/wiiuse/events.c
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,7 @@ extern "C" {
|
||||
void wiiuse_pressed_buttons(struct wiimote_t* wm, byte* msg);
|
||||
|
||||
void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len);
|
||||
void disable_expansion(struct wiimote_t* wm);
|
||||
void disable_expansion(struct wiimote_t* wm);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -39,14 +39,14 @@
|
||||
#ifndef OS_H_INCLUDED
|
||||
#define OS_H_INCLUDED
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef WIN32
|
||||
/* windows */
|
||||
#define isnan(x) _isnan(x)
|
||||
#define isinf(x) !_finite(x)
|
||||
|
||||
/* disable warnings I don't care about */
|
||||
#pragma warning(disable:4244) /* possible loss of data conversion */
|
||||
#pragma warning(disable:4273) /* inconsistent dll linkage */
|
||||
/* disable warnings I don't care about */
|
||||
#pragma warning(disable:4244) /* possible loss of data conversion */
|
||||
#pragma warning(disable:4273) /* inconsistent dll linkage */
|
||||
#pragma warning(disable:4217)
|
||||
#else
|
||||
/* nix */
|
||||
|
1406
src/wiiuse/wiiuse.c
1406
src/wiiuse/wiiuse.c
File diff suppressed because it is too large
Load Diff
1228
src/wiiuse/wiiuse.h
1228
src/wiiuse/wiiuse.h
File diff suppressed because it is too large
Load Diff
@ -153,8 +153,8 @@
|
||||
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0x9A1EFDFD
|
||||
#define EXP_ID_CODE_GUITAR 0x9A1EFDFB
|
||||
|
||||
#define EXP_HANDSHAKE_LEN 224
|
||||
|
||||
#define EXP_HANDSHAKE_LEN 224
|
||||
|
||||
/********************
|
||||
*
|
||||
* End Wiimote internal codes
|
||||
@ -205,10 +205,10 @@
|
||||
#define WIIUSE_DEFAULT_SMOOTH_ALPHA 0.07f
|
||||
|
||||
#define SMOOTH_ROLL 0x01
|
||||
#define SMOOTH_PITCH 0x02
|
||||
|
||||
#define SMOOTH_PITCH 0x02
|
||||
|
||||
#include "wiiuse.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user