From 5664007013b057c6dca265c47859ebaab42aab78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Wed, 2 Mar 2022 08:35:23 +0100 Subject: [PATCH] evdev: modernize variable declaration in evdev_device_is_joystick_or_gamepad MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/evdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/evdev.c b/src/evdev.c index 453ac3f..d0090c8 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -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) ) -- 2.7.4