evdev: modernize variable declaration in evdev_device_is_joystick_or_gamepad

Declare the variables used to keep track of joystick buttons and
keyboard keys right before they are used for better readability and
consistency.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
This commit is contained in:
José Expósito 2022-03-02 08:35:23 +01:00
parent ea568a7bcb
commit 5664007013

View file

@ -1870,7 +1870,7 @@ evdev_device_is_joystick_or_gamepad(struct evdev_device *device)
enum evdev_device_udev_tags udev_tags;
bool has_joystick_tags;
struct libevdev *evdev = device->evdev;
unsigned int code, num_joystick_btns = 0, num_keys = 0;
unsigned int code;
/* The EVDEV_UDEV_TAG_JOYSTICK is set when a joystick or gamepad button
* is found. However, it can not be used to identify joysticks or
@ -1905,6 +1905,8 @@ evdev_device_is_joystick_or_gamepad(struct evdev_device *device)
if (num_well_known_keys >= 4) /* should not have 4 well-known keys */
return false;
unsigned int num_joystick_btns = 0;
for (code = BTN_JOYSTICK; code < BTN_DIGI; code++) {
if (libevdev_has_event_code(evdev, EV_KEY, code))
num_joystick_btns++;
@ -1918,6 +1920,7 @@ evdev_device_is_joystick_or_gamepad(struct evdev_device *device)
if (num_joystick_btns < 2) /* require at least 2 joystick buttons */
return false;
unsigned int num_keys = 0;
for (code = KEY_ESC; code <= KEY_MICMUTE; code++) {
if (libevdev_has_event_code(evdev, EV_KEY, code) )