mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
(Joypad drivers) Simplifications - put char string outside loop
This commit is contained in:
parent
b951a010fd
commit
e7e647d181
@ -194,10 +194,8 @@ retry:
|
||||
else if (event->mask & (IN_CREATE | IN_ATTRIB))
|
||||
{
|
||||
char path[PATH_MAX_LENGTH];
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/input/%s", event->name);
|
||||
strlcpy(path, "/dev/input/", sizeof(path));
|
||||
strlcat(path, event->name, sizeof(path));
|
||||
|
||||
if ( !string_is_empty(linuxraw_pads[idx].ident)
|
||||
&& linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]))
|
||||
@ -219,33 +217,27 @@ retry:
|
||||
|
||||
static void *linuxraw_joypad_init(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
int fd = epoll_create(32);
|
||||
size_t i, _len;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
int fd = epoll_create(32);
|
||||
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
linuxraw_epoll = fd;
|
||||
_len = strlcpy(path, "/dev/input/js", sizeof(path));
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
char path[PATH_MAX_LENGTH];
|
||||
struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i];
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
pad->fd = -1;
|
||||
pad->ident = input_config_get_device_name_ptr(i);
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/input/js%u", i);
|
||||
snprintf(path + _len, sizeof(path) - _len, "%u", i);
|
||||
|
||||
input_autoconfigure_connect(
|
||||
pad->ident,
|
||||
NULL,
|
||||
"linuxraw",
|
||||
i,
|
||||
0,
|
||||
0);
|
||||
input_autoconfigure_connect(pad->ident, NULL, "linuxraw",
|
||||
i, 0, 0);
|
||||
|
||||
if (linuxraw_joypad_init_pad(path, pad))
|
||||
linuxraw_poll_pad(pad);
|
||||
|
@ -230,23 +230,26 @@ static void parport_free_pad(struct parport_joypad *pad)
|
||||
|
||||
static void *parport_joypad_init(void *data)
|
||||
{
|
||||
unsigned i, 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 =
|
||||
strlcpy(path, "/dev/parport", sizeof(path));
|
||||
|
||||
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
struct parport_joypad *pad = &parport_pads[i];
|
||||
|
||||
pad->fd = -1;
|
||||
pad->ident = input_config_get_device_name_ptr(i);
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/parport%u", i);
|
||||
snprintf(path + _len, sizeof(path) - _len, "%u", i);
|
||||
|
||||
if (parport_joypad_init_pad(path, pad))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user