summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhondres <hinsbart@users.noreply.github.com>2016-01-02 03:52:44 +0100
committerhondres <hinsbart@users.noreply.github.com>2016-01-02 03:52:44 +0100
commitc60e1648ba17489d5c762dcbe42d2019e540b0b9 (patch)
treea5b9731ba9edd9eba0879910abfcc61fe226491f
parent117ae93cf16bbac6c15cce186182597675409c42 (diff)
make num_buttons local, no need to keep in joystick struct
-rw-r--r--platform/x11/joystick_linux.cpp15
-rw-r--r--platform/x11/joystick_linux.h2
2 files changed, 9 insertions, 8 deletions
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp
index 1a513c778f..050fdac2b8 100644
--- a/platform/x11/joystick_linux.cpp
+++ b/platform/x11/joystick_linux.cpp
@@ -45,11 +45,11 @@ static const char* ignore_str = "/dev/input/js";
joystick_linux::Joystick::Joystick() {
fd = -1;
dpad = 0;
+ dev = NULL;
+ devpath = "";
}
void joystick_linux::Joystick::reset() {
- num_buttons = 0;
- num_axes = 0;
dpad = 0;
fd = -1;
for (int i=0; i < MAX_ABS; i++) {
@@ -225,20 +225,23 @@ static String _hex_str(uint8_t p_byte) {
void joystick_linux::setup_joystick_properties(int p_id) {
Joystick* joy = &joysticks[p_id];
-
libevdev* dev = joy->dev;
+
+ int num_buttons = 0;
+ int num_axes = 0;
+
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
if (libevdev_has_event_code(dev, EV_KEY, i)) {
- joy->key_map[i] = joy->num_buttons++;
+ joy->key_map[i] = num_buttons++;
}
}
for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
if (libevdev_has_event_code(dev, EV_KEY, i)) {
- joy->key_map[i] = joy->num_buttons++;
+ joy->key_map[i] = num_buttons++;
}
}
for (int i = 0; i < ABS_MISC; ++i) {
@@ -249,7 +252,7 @@ void joystick_linux::setup_joystick_properties(int p_id) {
}
if (libevdev_has_event_code(dev, EV_ABS, i)) {
- joy->abs_map[i] = joy->num_axes++;
+ joy->abs_map[i] = num_axes++;
}
}
}
diff --git a/platform/x11/joystick_linux.h b/platform/x11/joystick_linux.h
index 45324cbf34..9d22a6c754 100644
--- a/platform/x11/joystick_linux.h
+++ b/platform/x11/joystick_linux.h
@@ -56,8 +56,6 @@ private:
struct Joystick {
int key_map[MAX_KEY - BT_MISC];
int abs_map[MAX_ABS];
- int num_buttons;
- int num_axes;
int dpad;
int fd;