Turn iteration variables into int/size_t types

This commit is contained in:
libretroadmin 2025-08-01 21:53:52 +02:00
parent 320bb32406
commit 83cdca400b
14 changed files with 114 additions and 113 deletions

View File

@ -183,9 +183,11 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller,
mfi_axes[slot][5] = gp.rightTrigger.value * 32767.0f;
}
#if 0
else if (controller.microGamepad)
{
}
#endif
/* GCGamepad is deprecated */
#pragma clang diagnostic push
@ -215,10 +217,12 @@ static void apple_gamecontroller_joypad_poll(void)
for (GCController *controller in [GCController controllers])
{
/* If we have not assigned a slot to this controller yet, ignore it. */
if ( controller &&
(controller.playerIndex >= 0) && (controller.playerIndex < MAX_USERS) &&
!mfi_controller_is_siri_remote(controller))
apple_gamecontroller_joypad_poll_internal(controller, (uint32_t)controller.playerIndex);
if ( controller
&& (controller.playerIndex >= 0)
&& (controller.playerIndex < MAX_USERS)
&& !mfi_controller_is_siri_remote(controller))
apple_gamecontroller_joypad_poll_internal(controller,
(uint32_t)controller.playerIndex);
}
}
@ -267,7 +271,8 @@ static void apple_gamecontroller_joypad_register(GCController *controller)
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START);
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_L);
mfi_buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
});
return;
@ -278,7 +283,8 @@ static void apple_gamecontroller_joypad_register(GCController *controller)
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_L2);
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START);
mfi_buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_L3);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_L3);
});
return;
@ -289,7 +295,8 @@ static void apple_gamecontroller_joypad_register(GCController *controller)
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_R2);
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START);
mfi_buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_R3);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_R3);
});
return;
@ -297,7 +304,8 @@ static void apple_gamecontroller_joypad_register(GCController *controller)
mfi_buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_START);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START);
});
};
@ -473,8 +481,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
else
{
/* Find a new slot for this controller that's unused */
unsigned i;
int i;
for (i = 0; i < MAX_MFI_CONTROLLERS; ++i)
{
if (mfi_controllers[i])
@ -683,7 +690,7 @@ static int16_t apple_gamecontroller_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
@ -724,9 +731,9 @@ static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
if (enable_device_vibration && pad == 0)
{
NSError *error;
id<CHHapticPatternPlayer> player = (type == RETRO_RUMBLE_STRONG ?
apple_gamecontroller_device_haptics_strong_player() :
apple_gamecontroller_device_haptics_weak_player());
id<CHHapticPatternPlayer> player = (type == RETRO_RUMBLE_STRONG
? apple_gamecontroller_device_haptics_strong_player()
: apple_gamecontroller_device_haptics_weak_player());
if (player)
{
if (strength == 0)
@ -735,9 +742,8 @@ static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
{
float str = (float)strength / 65535.0f;
CHHapticDynamicParameter *param = [[CHHapticDynamicParameter alloc]
initWithParameterID:CHHapticDynamicParameterIDHapticIntensityControl
value:str
relativeTime:0];
initWithParameterID:CHHapticDynamicParameterIDHapticIntensityControl
value:str relativeTime:0];
[player sendParameters:[NSArray arrayWithObject:param] atTime:0 error:&error];
if (!error)
[player startAtTime:0 error:&error];
@ -762,9 +768,11 @@ static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
[player stopAtTime:0 error:&error];
else
{
CHHapticDynamicParameter *param = NULL;
float str = (float)strength / 65535.0f;
if (type == RETRO_RUMBLE_WEAK) str *= MFI_WEAK_RUMBLE;
CHHapticDynamicParameter *param = [[CHHapticDynamicParameter alloc]
if (type == RETRO_RUMBLE_WEAK)
str *= MFI_WEAK_RUMBLE;
param = [[CHHapticDynamicParameter alloc]
initWithParameterID:CHHapticDynamicParameterIDHapticIntensityControl
value:str
relativeTime:0];

View File

@ -138,7 +138,7 @@ static bool parport_joypad_init_pad(
/* Found parallel port? */
if (pad->fd >= 0)
{
/* Parport driver does not log failures with
/* Parport driver does not log failures with
* RARCH_ERR because they could be
* a normal result of connected non-joypad devices. */
@ -230,14 +230,14 @@ static void parport_free_pad(struct parport_joypad *pad)
static void *parport_joypad_init(void *data)
{
int j;
size_t i;
unsigned j;
char path[PATH_MAX_LENGTH];
bool found_enabled_button = false;
bool found_disabled_button = false;
char buf[PARPORT_NUM_BUTTONS * 3 + 1] = {0};
char pin[3 + 1] = {0};
size_t _len =
size_t _len =
strlcpy(path, "/dev/parport", sizeof(path));
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
@ -318,8 +318,7 @@ static void *parport_joypad_init(void *data)
static void parport_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < MAX_USERS; i++)
{
struct parport_joypad *pad = (struct parport_joypad*)&parport_pads[i];
@ -351,7 +350,7 @@ static int16_t parport_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
const struct parport_joypad *pad = (const struct parport_joypad*)
@ -366,7 +365,7 @@ static int16_t parport_joypad_state(
const uint64_t joykey = (binds[i].joykey != NO_BTN)
? binds[i].joykey : joypad_info->auto_binds[i].joykey;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& (joykey < PARPORT_NUM_BUTTONS)
&& (BIT32_GET(pad->buttons, (uint16_t)joykey)))
ret |= ( 1 << i);

View File

@ -140,12 +140,12 @@ static int16_t ps2_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (port_idx < DEFAULT_MAX_PADS)
{
int i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
@ -182,13 +182,13 @@ static void ps2_joypad_get_buttons(unsigned port_num, input_bits_t *state)
static void ps2_joypad_poll(void)
{
unsigned player;
int i;
struct padButtonStatus buttons;
for (player = 0; player < DEFAULT_MAX_PADS; player++)
for (i = 0; i < DEFAULT_MAX_PADS; i++)
{
int ps2_slot = player >> 1;
int ps2_port = player & 0x1;
int ps2_slot = i >> 1;
int ps2_port = i & 0x1;
int state = padGetState(ps2_port, ps2_slot);
if (state != PAD_STATE_DISCONN || state != PAD_STATE_EXECCMD || state != PAD_STATE_ERROR)
@ -197,32 +197,32 @@ static void ps2_joypad_poll(void)
if (ret != 0)
{
int32_t state_tmp = 0xffff ^ buttons.btns;
pad_state[player] = 0;
pad_state[i] = 0;
pad_state[player] |= (state_tmp & PAD_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
pad_state[player] |= (state_tmp & PAD_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
pad_state[player] |= (state_tmp & PAD_RIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
pad_state[player] |= (state_tmp & PAD_UP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
pad_state[player] |= (state_tmp & PAD_START) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
pad_state[player] |= (state_tmp & PAD_SELECT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
pad_state[player] |= (state_tmp & PAD_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
pad_state[player] |= (state_tmp & PAD_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
pad_state[player] |= (state_tmp & PAD_CROSS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
pad_state[player] |= (state_tmp & PAD_CIRCLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
pad_state[player] |= (state_tmp & PAD_R1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
pad_state[player] |= (state_tmp & PAD_L1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
pad_state[player] |= (state_tmp & PAD_R2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
pad_state[player] |= (state_tmp & PAD_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
pad_state[player] |= (state_tmp & PAD_R3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
pad_state[player] |= (state_tmp & PAD_L3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
pad_state[i] |= (state_tmp & PAD_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
pad_state[i] |= (state_tmp & PAD_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
pad_state[i] |= (state_tmp & PAD_RIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
pad_state[i] |= (state_tmp & PAD_UP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
pad_state[i] |= (state_tmp & PAD_START) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
pad_state[i] |= (state_tmp & PAD_SELECT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
pad_state[i] |= (state_tmp & PAD_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
pad_state[i] |= (state_tmp & PAD_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
pad_state[i] |= (state_tmp & PAD_CROSS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
pad_state[i] |= (state_tmp & PAD_CIRCLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
pad_state[i] |= (state_tmp & PAD_R1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
pad_state[i] |= (state_tmp & PAD_L1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
pad_state[i] |= (state_tmp & PAD_R2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
pad_state[i] |= (state_tmp & PAD_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
pad_state[i] |= (state_tmp & PAD_R3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
pad_state[i] |= (state_tmp & PAD_L3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
/* Analog */
if (buttons.ljoy_h || buttons.ljoy_v || buttons.rjoy_h || buttons.rjoy_v)
{
analog_state[player][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(buttons.ljoy_h);
analog_state[player][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(buttons.ljoy_v);;
analog_state[player][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(buttons.rjoy_h);;
analog_state[player][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(buttons.rjoy_v);;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(buttons.ljoy_h);
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(buttons.ljoy_v);;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(buttons.rjoy_h);;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(buttons.rjoy_v);;
}
}
@ -237,20 +237,17 @@ static bool ps2_joypad_query_pad(unsigned pad)
}
static bool ps2_joypad_rumble(unsigned pad,
enum retro_rumble_effect effect, uint16_t strength)
{
return false;
}
enum retro_rumble_effect effect, uint16_t strength) { return false; }
static void ps2_joypad_destroy(void)
{
unsigned port;
unsigned slot;
for (port = 0; port < PS2_MAX_PORT; port++)
int i;
for (i = 0; i < PS2_MAX_PORT; i++)
{
for (slot = 0; slot < PS2_MAX_SLOT; slot++)
padPortClose(port, slot);
mtapPortClose(port);
int j;
for (j = 0; j < PS2_MAX_SLOT; j++)
padPortClose(i, j);
mtapPortClose(i);
}
}

View File

@ -143,7 +143,7 @@ static int16_t ps3_joypad_state(
if (port_idx < DEFAULT_MAX_PADS)
{
unsigned i;
int i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
@ -152,12 +152,12 @@ static int16_t ps3_joypad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& pad_state[port_idx] & (UINT64_C(1) << (uint16_t)joykey)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(ps3_joypad_axis_state(port_idx, joyaxis))
((float)abs(ps3_joypad_axis_state(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -87,7 +87,7 @@ static void *ps4_joypad_init(void *data)
if (result == 0)
{
unsigned i;
int i;
for (i = 0; i < SCE_USER_SERVICE_MAX_LOGIN_USERS; i++)
{
SceUserServiceUserId user_id = user_id_list.userId[i];
@ -200,12 +200,12 @@ static int16_t ps4_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (port_idx < PS4_MAX_ORBISPADS)
{
int i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
@ -324,7 +324,7 @@ static void ps4_joypad_destroy(void)
SceUserServiceLoginUserIdList user_id_list;
if (sceUserServiceGetLoginUserIdList(&user_id_list) == 0)
{
unsigned i;
int i;
for (i = 0; i < SCE_USER_SERVICE_MAX_LOGIN_USERS; i++)
{
user_id = user_id_list.userId[i];

View File

@ -118,7 +118,7 @@ static int16_t qnx_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
int16_t ret = 0;
qnx_input_t *qnx =
(qnx_input_t*)input_state_get_ptr()->current_data;
@ -137,13 +137,13 @@ static int16_t qnx_joypad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& (joykey <= 19)
&& ((controller->buttons & (1 << (uint16_t)joykey)) != 0)
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(qnx_joypad_axis_state(qnx, controller, port_idx, joyaxis))
((float)abs(qnx_joypad_axis_state(qnx, controller, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -254,7 +254,7 @@ static void sdl_pad_disconnect(unsigned id)
static void sdl_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < MAX_USERS; i++)
sdl_pad_disconnect(i);
@ -263,7 +263,8 @@ static void sdl_joypad_destroy(void)
static void *sdl_joypad_init(void *data)
{
unsigned i, num_sticks;
size_t i;
unsigned num_sticks;
#ifdef HAVE_SDL2
uint32_t subsystem = SDL_INIT_GAMECONTROLLER;
#else
@ -418,7 +419,7 @@ static int16_t sdl_joypad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port_idx];

View File

@ -116,8 +116,7 @@ static INLINE int16_t udev_compute_axis(const struct input_absinfo *info, int va
static int udev_find_vacant_pad(void)
{
unsigned i;
int i;
for (i = 0; i < MAX_USERS; i++)
if (udev_pads[i].fd < 0)
return i;
@ -316,9 +315,9 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
static void udev_check_device(struct udev_device *dev, const char *path)
{
int i;
int ret;
int pad, fd;
unsigned i;
struct stat st;
if (stat(path, &st) < 0)
@ -366,7 +365,7 @@ static void udev_free_pad(unsigned pad)
static void udev_joypad_remove_device(const char *path)
{
unsigned i;
int i;
for (i = 0; i < MAX_USERS; i++)
{
@ -382,7 +381,7 @@ static void udev_joypad_remove_device(const char *path)
static void udev_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < MAX_USERS; i++)
udev_free_pad(i);
@ -586,7 +585,7 @@ static void udev_joypad_poll(void)
static void *udev_joypad_init(void *data)
{
unsigned i;
int i;
unsigned sorted_count = 0;
struct udev_list_entry *devs = NULL;
struct udev_list_entry *item = NULL;
@ -745,7 +744,7 @@ static int16_t udev_joypad_state(
if (port_idx < MAX_USERS)
{
unsigned i;
int i;
const struct udev_joypad *pad = (const struct udev_joypad*)
&udev_pads[port_idx];
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)

View File

@ -69,12 +69,12 @@ static int16_t hidpad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
if (hidpad_query_pad(port_idx))
{
int i;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
/* Auto-binds are per joypad, not per user. */
@ -88,7 +88,7 @@ static int16_t hidpad_state(
)
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(wiiu_hid.axis(hid_driver_get_data(), port_idx, joyaxis))
((float)abs(wiiu_hid.axis(hid_driver_get_data(), port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -31,12 +31,10 @@ static void kpad_deregister(unsigned channel);
static int to_wiimote_channel(unsigned pad)
{
unsigned i;
int i;
for (i = 0; i < WIIU_WIIMOTE_CHANNELS; i++)
if (joypad_state.kpad.channel_slot_map[i] == pad)
return i;
return -1;
}
@ -120,9 +118,9 @@ static int16_t kpad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
int i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
@ -132,11 +130,11 @@ static int16_t kpad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& kpad_button(port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(kpad_axis(port_idx, joyaxis))
((float)abs(kpad_axis(port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}

View File

@ -29,14 +29,12 @@
static VPADChan wpad_to_gamepad_channel(unsigned pad)
{
unsigned i;
int i;
for (i = 0; i < WIIU_GAMEPAD_CHANNELS; i++)
{
if (joypad_state.wpad.channel_slot_map[i] == pad)
return i;
}
return WPAD_INVALID_CHANNEL;
}
@ -284,9 +282,9 @@ static int16_t wpad_state(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
int i;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{

View File

@ -203,7 +203,7 @@ static int16_t xdk_joypad_state(
if (port_idx < DEFAULT_MAX_PADS)
{
unsigned i;
int i;
XINPUT_GAMEPAD *pad = &(g_xinput_states[port_idx].xstate.Gamepad);
uint16_t btn_word = pad->wButtons;
@ -215,12 +215,12 @@ static int16_t xdk_joypad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& xdk_joypad_button_state(
pad, btn_word, port_idx, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE &&
((float)abs(xdk_joypad_axis_state(pad, port_idx, joyaxis))
((float)abs(xdk_joypad_axis_state(pad, port_idx, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}
@ -302,8 +302,7 @@ static bool xdk_joypad_query_pad(unsigned pad)
static void xdk_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < DEFAULT_MAX_PADS; i++)
{
memset(&g_xinput_states[i], 0, sizeof(xinput_joypad_state));

View File

@ -131,7 +131,8 @@ static bool guid_is_xinput_device(const GUID* product_guid)
{MAKELONG(0x045E, 0x02A1),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}}, /* Wired 360 pad */
{MAKELONG(0x045E, 0x028E),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}} /* wireless 360 pad */
};
unsigned i, num_raw_devs = 0;
size_t i;
unsigned num_raw_devs = 0;
PRAWINPUTDEVICELIST raw_devs = NULL;
/* Check for well known XInput device GUIDs,
@ -330,7 +331,7 @@ enum_iteration_done:
static void dinput_joypad_init_hybrid(void *data)
{
unsigned i;
int i;
g_last_xinput_pad_idx = 0;
@ -356,7 +357,7 @@ static const char *xinput_joypad_name(unsigned pad)
static void *xinput_joypad_init(void *data)
{
unsigned i, j;
int i, j;
XINPUT_STATE dummy_state;
#if defined(HAVE_DYLIB) && !defined(__WINRT__)
@ -543,7 +544,7 @@ static int16_t xinput_joypad_state_func(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
uint16_t btn_word;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
@ -737,7 +738,7 @@ static bool xinput_joypad_rumble(unsigned pad,
static void xinput_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < 4; ++i)
{

View File

@ -126,7 +126,7 @@ static const char *xinput_joypad_name(unsigned pad)
static void *xinput_joypad_init(void *data)
{
unsigned i, j;
int i, j;
XINPUT_STATE dummy_state;
#if defined(HAVE_DYLIB) && !defined(__WINRT__)
@ -266,7 +266,7 @@ static bool xinput_joypad_query_pad(unsigned pad)
static void xinput_joypad_destroy(void)
{
unsigned i;
int i;
for (i = 0; i < 4; ++i)
{
@ -316,7 +316,7 @@ static int16_t xinput_joypad_state_func(
const struct retro_keybind *binds,
unsigned port)
{
unsigned i;
int i;
uint16_t btn_word;
int16_t ret = 0;
uint16_t port_idx = joypad_info->joy_idx;
@ -350,6 +350,8 @@ static int16_t xinput_joypad_state_func(
static void xinput_joypad_poll(void)
{
int i;
/* Hotplugging detection: scanning one port at a time every few frames,
* to avoid polling overload and framerate drops. */
xinput_poll_counter++;
@ -379,7 +381,6 @@ static void xinput_joypad_poll(void)
xinput_hotplug_index = (xinput_hotplug_index + 1) % 4;
}
unsigned i;
for (i = 0; i < 4; ++i)
{
DWORD status;
@ -392,7 +393,7 @@ static void xinput_joypad_poll(void)
status = g_XInputGetStateEx(i, &state->xstate);
success = status == ERROR_SUCCESS;
new_connected = status != ERROR_DEVICE_NOT_CONNECTED;
if (new_connected != state->connected)
{
/* Normally, dinput handles device insertion/removal for us, but
@ -442,7 +443,7 @@ static bool xinput_joypad_rumble(unsigned pad,
now = clock();
time_since_last_rumble = (double)(now - last_rumble_time[xuser]) / CLOCKS_PER_SEC;
/* Rumble interval unelapsed? */
if (time_since_last_rumble < RUMBLE_INTERVAL)
return true;