diff --git a/input/connect/connect_kade.c b/input/connect/connect_kade.c index fafc5d2847..4d99e7f76c 100644 --- a/input/connect/connect_kade.c +++ b/input/connect/connect_kade.c @@ -47,7 +47,7 @@ static void* hidpad_kade_init(void* data, uint32_t slot, hid_driver_t* driver) } device->connection = connection; - device->slot = slot; + device->slot = slot; return device; } @@ -73,10 +73,7 @@ static void hidpad_kade_get_buttons(void* data, input_bits_t* state) /*This is being implemented for use with an arcade stick, so there are no axis values on this control, only a hat values . If your device with kade firmware uses analog controls this function must be implemented.*/ -static int16_t hidpad_kade_get_axis(void* data, unsigned axis) -{ - return 0; -} +static int16_t hidpad_kade_get_axis(void* data, unsigned axis) { return 0; } #define KADE_H_GET(a) (a & 0x0F) /*HAT MASK = 0x0F */ #define KADE_H_LEFT(a) (a == 0x05) || (a == 0x06) || (a == 0x07) @@ -130,17 +127,11 @@ static void hidpad_kade_packet_handler(void* data, uint8_t* packet, uint16_t siz } static void hidpad_kade_set_rumble(void* data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char* hidpad_kade_get_name(void* data) { - (void)data; - /* For now we return a single static name */ return "KADE: Kick Ass Dynamic Encoder"; } diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index b2ee5ac81d..3677f00af7 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -126,17 +126,11 @@ static void hidpad_nesusb_packet_handler(void *data, } static void hidpad_nesusb_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char * hidpad_nesusb_get_name(void *data) { - (void)data; - /* For now we return a single static name */ return "Generic NES USB Controller"; } diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index 2914330be7..09dba546b6 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -147,8 +147,7 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 memcpy(device->data, packet, size); device->buttons = 0; - - pressed_keys = device->data[7] | (device->data[6] << 8); + pressed_keys = device->data[7] | (device->data[6] << 8); for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) @@ -163,17 +162,11 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 } static void hidpad_ps2adapter_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char * hidpad_ps2adapter_get_name(void *data) { - (void)data; - /* For now we return a single static name */ return "PS2/PSX Controller Adapter"; } diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index ae9e79cb20..24e64483f2 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -136,10 +136,13 @@ static void* hidpad_ps4_init(void *data, uint32_t slot, hid_driver_t *driver) calloc(1, sizeof(struct hidpad_ps4_data)); if (!device) - goto error; + return NULL; if (!connection) - goto error; + { + free(device); + return NULL; + } device->connection = connection; device->driver = driver; @@ -156,11 +159,6 @@ static void* hidpad_ps4_init(void *data, uint32_t slot, hid_driver_t *driver) hidpad_ps4_send_control(device); return device; - -error: - if (device) - free(device); - return NULL; } static void hidpad_ps4_deinit(void *data) @@ -244,7 +242,8 @@ static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; int val = rpt ? rpt->hatvalue[axis] : 0; val = (val << 8) - 0x8000; - return (abs(val) > 0x1000) ? val : 0; + if (abs(val) > 0x1000) + return val; } return 0; diff --git a/input/connect/connect_ps4_hori_mini.c b/input/connect/connect_ps4_hori_mini.c index d30fe0478e..b5cc8ca0b4 100644 --- a/input/connect/connect_ps4_hori_mini.c +++ b/input/connect/connect_ps4_hori_mini.c @@ -160,29 +160,22 @@ static void hidpad_ps4_hori_mini_packet_handler(void *data, break; } - pressed_keys = ((device->data[5] & 0xF0) >> 4) | - (device->data[6] << 4) | - (device->data[7] << 12); + pressed_keys = ( + (device->data[5] & 0xF0) >> 4) + | (device->data[6] << 4) + | (device->data[7] << 12); for (i = 0; i < 15; i++) - { device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; - } } static void hidpad_ps4_hori_mini_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char * hidpad_ps4_hori_mini_get_name(void *data) { - (void)data; - /* For now we return a single static name */ return "HORI mini wired PS4"; } diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index ca0a12725e..9eff4623db 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -174,17 +174,11 @@ static void hidpad_psxadapter_packet_handler(void *data, } static void hidpad_psxadapter_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char * hidpad_psxadapter_get_name(void *data) { - (void)data; - /* For now we return a single static name */ return "PSX to PS3 Controller Adapter"; } diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index b9e201e4fe..e24be861a7 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -28,10 +28,7 @@ #define RETRODE_TYPE_DEVICE 0x00 #define RETRODE_TYPE_PAD 0x01 -typedef struct hidpad_retrode_pad_data retrode_pad_data_t; -typedef struct hidpad_retrode_data retrode_device_data_t; - -struct hidpad_retrode_pad_data +typedef struct hidpad_retrode_pad_data { uint8_t datatype; retrode_device_data_t *device_data; @@ -39,16 +36,16 @@ struct hidpad_retrode_pad_data int pad_index; uint32_t buttons; uint8_t data[64]; -}; +} hidpad_retrode_pad_data_t; -struct hidpad_retrode_data +typedef struct hidpad_retrode_data { uint8_t datatype; void *handle; hid_driver_t *driver; retrode_pad_data_t pad_data[RETRODE_MAX_PAD]; uint8_t data[64]; -}; +} hidpad_retrode_data_t; static void* hidpad_retrode_init(void *data, uint32_t slot, hid_driver_t *driver) { @@ -111,7 +108,7 @@ static void hidpad_retrode_get_buttons(void *pad_data, input_bits_t *state) static int16_t hidpad_retrode_get_axis(void *pad_data, unsigned axis) { int val; - retrode_pad_data_t *pad = (retrode_pad_data_t *)pad_data; + retrode_pad_data_t *pad = (retrode_pad_data_t *)pad_data; retrode_device_data_t *device = (retrode_device_data_t *)pad_data; if (!pad || axis >= 2) diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index e12b214ac7..919adfa70e 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -31,7 +31,8 @@ struct hidpad_snesusb_data uint8_t data[64]; }; -static void* hidpad_snesusb_init(void *data, uint32_t slot, hid_driver_t *driver) +static void* hidpad_snesusb_init(void *data, + uint32_t slot, hid_driver_t *driver) { struct pad_connection* connection = (struct pad_connection*)data; struct hidpad_snesusb_data* device = (struct hidpad_snesusb_data*) @@ -87,7 +88,8 @@ static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) return 0; } -static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t size) +static void hidpad_snesusb_packet_handler(void *data, + uint8_t *packet, uint16_t size) { uint32_t i, pressed_keys; static const uint32_t button_mapping[16] = @@ -122,21 +124,16 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) + ? (1 << button_mapping[i]) : 0; } static void hidpad_snesusb_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char * hidpad_snesusb_get_name(void *data) { - (void)data; - /* For now we return a single static name */ return "Generic SNES USB Controller"; } diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index 1de05ab535..37e60209f1 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -313,14 +313,8 @@ static void classic_ctrl_event(struct connect_wii_classic_ctrl_t* cc, uint8_t* m */ static void wiimote_handle_expansion(struct connect_wii_wiimote_t* wm, uint8_t* msg) { - switch (wm->exp.type) - { - case EXP_CLASSIC: - classic_ctrl_event(&wm->exp.cc.classic, msg); - break; - default: - break; - } + if (wm->exp.type == EXP_CLASSIC) + classic_ctrl_event(&wm->exp.cc.classic, msg); } /* @@ -608,26 +602,26 @@ static int16_t hidpad_wii_get_axis(void *data, unsigned axis) { struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; - if (!device) - return 0; - - switch (device->exp.type) + if (device) { - case EXP_CLASSIC: - 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; - } - break; - default: - break; + switch (device->exp.type) + { + case EXP_CLASSIC: + 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; + } + break; + default: + break; + } } return 0; @@ -675,13 +669,7 @@ static void hidpad_wii_packet_handler(void *data, } static void hidpad_wii_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - /* TODO */ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } /* TODO: implement hidpad_wii_button(). */ diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index f65f4c93ca..3d24992da6 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -173,21 +173,19 @@ static void update_button_state(gca_pad_data_t *pad) static void update_analog_state(gca_pad_data_t *pad) { int pad_axis; - int16_t interpolated; - unsigned stick, axis; /* GameCube analog axis are 8-bit unsigned, where 128/128 is center. * So, we subtract 128 to get a signed, 0-based value and then mulitply * by 256 to get the 16-bit range RetroArch expects. */ for (pad_axis = 0; pad_axis < 4; pad_axis++) { - axis = (pad_axis % 2) ? 0 : 1; - stick = pad_axis / 2; - interpolated = pad->data[3 + pad_axis]; + unsigned axis = (pad_axis % 2) ? 0 : 1; + unsigned stick = pad_axis / 2; + int16_t interpolated = pad->data[3 + pad_axis]; /* libretro requires "up" to be negative, so we invert the y axis */ - interpolated = (axis) ? - ((interpolated - 128) * 256) : - ((interpolated - 128) * -256); + interpolated = axis + ? ((interpolated - 128) * 256) + : ((interpolated - 128) * -256); pad->analog[stick][axis] = interpolated; } @@ -206,9 +204,6 @@ static void hidpad_wiiugca_pad_packet_handler(gca_pad_data_t *pad, uint8_t *pack static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, uint16_t size) { uint32_t i; - int port; - unsigned char port_connected; - gca_device_data_t *device = (gca_device_data_t *)device_data; if (!device) @@ -218,8 +213,8 @@ static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, ui for (i = 1; i < 37; i += 9) { - port = i / 9; - port_connected = device->data[i]; + int port = i / 9; + unsigned char port_connected = device->data[i]; if (port_connected > GCA_PORT_POWERED) { @@ -232,12 +227,7 @@ static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, ui } static void hidpad_wiiugca_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } const char *hidpad_wiiugca_get_name(void *pad_data) { diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 182ae53eb5..b39b58630e 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -84,10 +84,13 @@ static void* hidpad_wiiupro_init(void *data, calloc(1, sizeof(struct hidpad_wiiupro_data)); if (!device) - goto error; + return NULL; if (!connection) - goto error; + { + free(device); + return NULL; + } device->connection = connection; device->slot = slot; @@ -98,11 +101,6 @@ static void* hidpad_wiiupro_init(void *data, hidpad_wiiupro_send_control(device); return device; - -error: - if (device) - free(device); - return NULL; } static void hidpad_wiiupro_deinit(void *data) @@ -189,13 +187,13 @@ static void hidpad_wiiupro_packet_handler(void *data, if (!device->have_led) { hidpad_wiiupro_send_control(device); - device->have_led = true; + device->have_led = true; } #endif - packet[0x0C] ^= 0xFF; - packet[0x0D] ^= 0xFF; - packet[0x0E] ^= 0xFF; + packet[0x0C] ^= 0xFF; + packet[0x0D] ^= 0xFF; + packet[0x0E] ^= 0xFF; memset(&device->data, 0, sizeof(struct wiiupro)); @@ -241,60 +239,60 @@ static void hidpad_wiiupro_packet_handler(void *data, } } +/* TODO/FIXME */ static void hidpad_wiiupro_set_rumble(void *data, - enum retro_rumble_effect effect, uint16_t strength) -{ - /* TODO */ -} + enum retro_rumble_effect effect, uint16_t strength) { } static int32_t hidpad_wiiupro_button(void *data, uint16_t joykey) { struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; - struct wiiupro *rpt = device ? - (struct wiiupro*)&device->data : NULL; + struct wiiupro *rpt = device + ? (struct wiiupro*)&device->data : NULL; - if (!device || !rpt) - return 0; - - switch(joykey) { - case RETRO_DEVICE_ID_JOYPAD_R3: - return rpt->btn.r3; - case RETRO_DEVICE_ID_JOYPAD_L3: - return rpt->btn.l3; - case RETRO_DEVICE_ID_JOYPAD_START: - return rpt->btn.plus; - case RETRO_DEVICE_ID_JOYPAD_SELECT: - return rpt->btn.minus; - case RETRO_DEVICE_ID_JOYPAD_R2: - return rpt->btn.zr; - case RETRO_DEVICE_ID_JOYPAD_L2: - return rpt->btn.zl; - case RETRO_DEVICE_ID_JOYPAD_R: - return rpt->btn.r; - case RETRO_DEVICE_ID_JOYPAD_L: - return rpt->btn.l; - case RETRO_DEVICE_ID_JOYPAD_X: - return rpt->btn.x; - case RETRO_DEVICE_ID_JOYPAD_A: - return rpt->btn.a; - case RETRO_DEVICE_ID_JOYPAD_B: - return rpt->btn.b; - case RETRO_DEVICE_ID_JOYPAD_Y: - return rpt->btn.y; - case RETRO_DEVICE_ID_JOYPAD_LEFT: - return rpt->btn.left; - case RETRO_DEVICE_ID_JOYPAD_RIGHT: - return rpt->btn.right; - case RETRO_DEVICE_ID_JOYPAD_DOWN: - return rpt->btn.down; - case RETRO_DEVICE_ID_JOYPAD_UP: - return rpt->btn.up; - case RARCH_MENU_TOGGLE: - return rpt->btn.home; - default: - return 0; + if (device && rpt) + { + switch (joykey) + { + case RETRO_DEVICE_ID_JOYPAD_R3: + return rpt->btn.r3; + case RETRO_DEVICE_ID_JOYPAD_L3: + return rpt->btn.l3; + case RETRO_DEVICE_ID_JOYPAD_START: + return rpt->btn.plus; + case RETRO_DEVICE_ID_JOYPAD_SELECT: + return rpt->btn.minus; + case RETRO_DEVICE_ID_JOYPAD_R2: + return rpt->btn.zr; + case RETRO_DEVICE_ID_JOYPAD_L2: + return rpt->btn.zl; + case RETRO_DEVICE_ID_JOYPAD_R: + return rpt->btn.r; + case RETRO_DEVICE_ID_JOYPAD_L: + return rpt->btn.l; + case RETRO_DEVICE_ID_JOYPAD_X: + return rpt->btn.x; + case RETRO_DEVICE_ID_JOYPAD_A: + return rpt->btn.a; + case RETRO_DEVICE_ID_JOYPAD_B: + return rpt->btn.b; + case RETRO_DEVICE_ID_JOYPAD_Y: + return rpt->btn.y; + case RETRO_DEVICE_ID_JOYPAD_LEFT: + return rpt->btn.left; + case RETRO_DEVICE_ID_JOYPAD_RIGHT: + return rpt->btn.right; + case RETRO_DEVICE_ID_JOYPAD_DOWN: + return rpt->btn.down; + case RETRO_DEVICE_ID_JOYPAD_UP: + return rpt->btn.up; + case RARCH_MENU_TOGGLE: + return rpt->btn.home; + default: + break; + } } + return 0; } pad_connection_interface_t pad_connection_wiiupro = { diff --git a/input/connect/connect_zerodelay_dragonrise.c b/input/connect/connect_zerodelay_dragonrise.c index 88a81d9aa9..5139a6869a 100644 --- a/input/connect/connect_zerodelay_dragonrise.c +++ b/input/connect/connect_zerodelay_dragonrise.c @@ -151,17 +151,11 @@ static void hidpad_dragonrise_packet_handler(void* data, } static void hidpad_dragonrise_set_rumble(void* data, - enum retro_rumble_effect effect, uint16_t strength) -{ - (void)data; - (void)effect; - (void)strength; -} + enum retro_rumble_effect effect, uint16_t strength) { } +/* For now we return a single static name */ const char* hidpad_dragonrise_get_name(void* data) { - (void)data; - /* For now we return a single static name */ return "DRAGONRISE Zero Delay Encoder"; }