(Apple) More style nit cleanups

This commit is contained in:
twinaphex 2014-04-26 03:18:52 +02:00
parent f72de0030f
commit 366d2d1879
3 changed files with 88 additions and 73 deletions

View File

@ -56,7 +56,7 @@ static void hidpad_ps3_send_control(struct hidpad_ps3_data* device)
static void* hidpad_ps3_connect(struct apple_pad_connection* connection, uint32_t slot)
{
struct hidpad_ps3_data* device = calloc(1, sizeof(struct hidpad_ps3_data));
struct hidpad_ps3_data* device = (struct hidpad_ps3_data*)calloc(1, sizeof(struct hidpad_ps3_data));
device->connection = connection;
device->slot = slot;

View File

@ -24,7 +24,7 @@
static void* hidpad_wii_connect(struct apple_pad_connection* connection, uint32_t slot)
{
struct wiimote_t* device = calloc(1, sizeof(struct wiimote_t));
struct wiimote_t* device = (struct wiimote_t*)calloc(1, sizeof(struct wiimote_t));
device->connection = connection;
device->unid = slot;
@ -47,11 +47,16 @@ static int16_t hidpad_wii_get_axis(struct wiimote_t* device, unsigned axis)
{
switch (axis)
{
case 0: return device->exp.cc.classic.ljs.x.value * 0x7FFF;
case 1: return device->exp.cc.classic.ljs.y.value * 0x7FFF;
case 2: return device->exp.cc.classic.rjs.x.value * 0x7FFF;
case 3: return device->exp.cc.classic.rjs.y.value * 0x7FFF;
default: return 0;
case 0:
return device->exp.cc.classic.ljs.x.value * 0x7FFF;
case 1:
return device->exp.cc.classic.ljs.y.value * 0x7FFF;
case 2:
return device->exp.cc.classic.rjs.x.value * 0x7FFF;
case 3:
return device->exp.cc.classic.rjs.y.value * 0x7FFF;
default:
return 0;
}
}

View File

@ -75,14 +75,15 @@ void wiimote_status(struct wiimote_t* wm)
wiimote_send(wm, WM_CMD_CTRL_STATUS, &buf, 1);
}
void wiimote_data_report(struct wiimote_t* wm, byte type) {
void wiimote_data_report(struct wiimote_t* wm, byte type)
{
byte buf[2] = {0x0,0x0};
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
return;
buf[1] = type;
//CUIDADO es un &buf?
//CUIDADO es un &buf?
wiimote_send(wm, WM_CMD_REPORT_TYPE, buf, 2);
}
@ -95,7 +96,8 @@ void wiimote_data_report(struct wiimote_t* wm, byte type) {
*
* \a leds is a bitwise or of WIIMOTE_LED_1, WIIMOTE_LED_2, WIIMOTE_LED_3, or WIIMOTE_LED_4.
*/
void wiimote_set_leds(struct wiimote_t* wm, int leds) {
void wiimote_set_leds(struct wiimote_t* wm, int leds)
{
byte buf;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
@ -115,7 +117,8 @@ void wiimote_set_leds(struct wiimote_t* wm, int leds) {
* @param wm Pointer to a wiimote_t structure.
* @param msg The message specified in the event packet.
*/
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg) {
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg)
{
short now;
/* convert to big endian */
@ -131,8 +134,10 @@ void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg) {
* @param wm A pointer to a wiimote_t structure.
* @param msg The message specified in the event packet for the expansion.
*/
void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg) {
switch (wm->exp.type) {
void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg)
{
switch (wm->exp.type)
{
case EXP_CLASSIC:
classic_ctrl_event(&wm->exp.cc.classic, msg);
break;
@ -154,7 +159,8 @@ void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg) {
* The handshake will be concluded when the wiimote responds
* with this data.
*/
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned short len) {
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned short len)
{
if (!wm) return 0;
@ -230,7 +236,9 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
wm->handshake_state = 4;
return 0;
} else if (!attachment && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
}
else if (!attachment && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
{
/* attachment removed */
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP);
wm->exp.type = EXP_NONE;
@ -376,7 +384,8 @@ int wiimote_send(struct wiimote_t* wm, byte report_type, byte* msg, int len)
* to a pending list and be sent out when the previous
* finishes.
*/
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len) {
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len)
{
//No puden ser mas de 16 lo leido o vendra en trozos!
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
@ -408,7 +417,8 @@ int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short le
* @param data The data to be written to the memory location.
* @param len The length of the block to be written.
*/
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len) {
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len)
{
byte buf[21] = {0}; /* the payload is always 23 */
if (!wm || !WIIMOTE_IS_CONNECTED(wm))