From f37ac166f46b93111300f683b4ae5e2ee543a7f4 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 12 Apr 2012 17:38:57 +0300 Subject: [PATCH 1/6] Refactor joystick support Refactor the common parts of joystick support to library/joyfun --- include/library/joyfun.hpp | 189 +++++++++++++++ src/library/joyfun.cpp | 169 +++++++++++++- src/platform/evdev/joystick.cpp | 351 +++++++--------------------- src/platform/win32mm/joystick.cpp | 161 ++++++------- src/platform/wxwidgets/joystick.cpp | 150 ++++++------ 5 files changed, 577 insertions(+), 443 deletions(-) diff --git a/include/library/joyfun.hpp b/include/library/joyfun.hpp index 96cdcd0d..57189047 100644 --- a/include/library/joyfun.hpp +++ b/include/library/joyfun.hpp @@ -2,6 +2,9 @@ #define _library__joyfun__hpp__included__ #include +#include +#include +#include /** * Perform axis calibration correction. @@ -38,4 +41,190 @@ template bool make_equal(T& a, const T& b) return r; } +/** + * Joystick. + */ +class joystick_model +{ +public: +/** + * Set name of joystick field. + */ + void name(const std::string& newn); +/** + * Get name of joystick field. + */ + const std::string& name(); +/** + * Create a new axis. + * + * Parameter id: The id of the axis. + * Parameter minv: The minimal calibration value. + * Parameter maxv: The maximal calibration value. + * Parameter xname: The name of axis. + * Returns: The number of axis. + */ + unsigned new_axis(uint64_t id, int64_t minv, int64_t maxv, const std::string& xname); +/** + * Create a new button. + * + * Parameter id: The id of button. + * Parameter xname: The name of button. + * Returns: The number of button. + */ + unsigned new_button(uint64_t id, const std::string& xname); +/** + * Create a new hat from pair of axes. + * + * Parameter id_x: The id of x axis of the hat. + * Parameter id_y: The id of y axis of the hat. + * Parameter min_dev: The smallest deviation from zero to react to. + * Parameter xname_x: The name of x axis. + * Parameter xname_y: The name of y axis. + * Returns: The number of hat. + */ + unsigned new_hat(uint64_t id_x, uint64_t id_y, int64_t min_dev, const std::string& xname_x, + const std::string& xname_y); +/** + * Create a new hat from POV control. + * + * Parameter id: The id of POV control. + * Parameter xname: The name of POV control. + * Returns: The number of hat. + */ + unsigned new_hat(uint64_t id, const std::string& xname); +/** + * Get the number of axes. + */ + unsigned axes() { return size_common(_axes); } +/** + * Get the number of buttons. + */ + unsigned buttons() { return size_common(_buttons); } +/** + * Get the number of hats. + */ + unsigned hats() { return size_common(_hats); } +/** + * Report on specified axis. + * + * Parameter id: The number of axis to report. + * Parameter res: Place to write the calibrated axis value to. + * Returns: True if value has changed since last call, false otherwise. + */ + bool axis(unsigned id, short& res) { return read_common(_axes, id, res); } +/** + * Report on specified button. + * + * Parameter id: The number of button to report. + * Parameter res: Place to write the value to. + * Returns: True if value has changed since last call, false otherwise. + */ + bool button(unsigned id, short& res) { return read_common(_buttons, id, res); } +/** + * Report on specified hat. + * + * Parameter id: The number of hat to report. + * Parameter res: Place to write the value to. + * Returns: True if value has changed since last call, false otherwise. + */ + bool hat(unsigned id, short& res) { return read_common(_hats, id, res); } +/** + * Return name of axis. + * + * Parameter id: The axis number. + * Returns: The name of the axis, or "" if not found. + */ + std::string axisname(unsigned id); +/** + * Return axis calibration data. + * + * Parameter id: The axis number. + * Returns: The axis calibration (first minimum, then maximum). + */ + std::pair axiscalibration(unsigned id); +/** + * Return name of button. + * + * Parameter id: The button number. + * Returns: The name of the button, or "" if not found. + */ + std::string buttonname(unsigned id); +/** + * Return name of hat. + * + * Parameter id: The hat number. + * Returns: The name of the hat, or "" if not found. + */ + std::string hatname(unsigned id); +/** + * Report possible change in axis value. + * + * Requests to update unknown axes are ignored. + * + * Parameter id: The ID of axis. + * Parameter value: The value. + */ + void report_axis(uint64_t id, int64_t value); +/** + * Report possible change in button value. + * + * Requests to update unknown buttons are ignored. + * + * Parameter id: The ID of button. + * Parameter value: The value. + */ + void report_button(uint64_t id, bool value); +/** + * Report possible change in POV value. + * + * Requests to update unknown POVs are ignored. + * + * Parameter id: The ID of POV. + * Parameter value: The angle in hundredths of degree clockwise from up, or negative if centered. + */ + void report_pov(uint64_t id, int angle); +/** + * Report on joystick. + */ + std::string compose_report(unsigned jnum); +private: + struct change_info + { + change_info(); + void update(short newv); + bool read(short& val); + private: + bool has_been_read; + short last_read; + short last_known; + }; + struct hat_info + { + int xstate; + int ystate; + }; + struct hat_axis_info + { + bool yflag; //Set on y axis, clear on x axis. + int64_t mindev; + unsigned hnum; + }; + bool read_common(std::vector& i, unsigned id, short& res); + unsigned size_common(std::vector& i); + std::vector _axes; + std::vector _buttons; + std::vector _hats; + std::map button_map; + std::map axis_map; //No hats here! + std::map pov_map; + std::map> aranges; + std::vector hatinfos; + std::map hataxis_map; + std::map axisnames; + std::map buttonnames; + std::map hatnames; + std::string joyname; +}; + #endif diff --git a/src/library/joyfun.cpp b/src/library/joyfun.cpp index fa7b75a3..7f3a9998 100644 --- a/src/library/joyfun.cpp +++ b/src/library/joyfun.cpp @@ -1,5 +1,7 @@ #include "library/joyfun.hpp" - +#include "library/string.hpp" +#include +#include short calibration_correction(int64_t v, int64_t low, int64_t high) { @@ -28,3 +30,168 @@ short angle_to_bitmask(int pov) m |= 8; return m; } + +joystick_model::change_info::change_info() +{ + has_been_read = false; + last_read = 0; + last_known = 0; +} + +void joystick_model::change_info::update(short newv) +{ + last_known = newv; +} + +bool joystick_model::change_info::read(short& val) +{ + bool r = (last_known != last_read || !has_been_read); + has_been_read = true; + val = last_read = last_known; + return r; +} + +bool joystick_model::read_common(std::vector& i, unsigned id, short& res) +{ + if(id >= i.size()) + return false; + return i[id].read(res); +} + +unsigned joystick_model::size_common(std::vector& i) +{ + return i.size(); +} + +void joystick_model::report_button(uint64_t id, bool value) +{ + if(button_map.count(id)) + _buttons[button_map[id]].update(value ? 1 : 0); +} + +void joystick_model::report_pov(uint64_t id, int angle) +{ + if(pov_map.count(id)) + _hats[pov_map[id]].update(angle_to_bitmask(angle)); +} + +void joystick_model::report_axis(uint64_t id, int64_t value) +{ + //The axis case. + if(axis_map.count(id)) + _axes[axis_map[id]].update(calibration_correction(value, aranges[id].first, aranges[id].second)); + //It isn't known axis. See if it is connected with axis pair for hat. + else if(hataxis_map.count(id)) { + struct hat_axis_info& ai = hataxis_map[id]; + struct hat_info& hi = hatinfos[ai.hnum]; + short v = 0; + if(value <= -ai.mindev) v = -1; + if(value >= ai.mindev) v = 1; + if(ai.yflag) hi.ystate = v; + else hi.xstate = v; + v = 0; + if(hi.ystate < 0) v |= 1; + if(hi.xstate > 0) v |= 2; + if(hi.ystate > 0) v |= 4; + if(hi.xstate < 0) v |= 8; + _hats[ai.hnum].update(v); + } +} + +unsigned joystick_model::new_axis(uint64_t id, int64_t minv, int64_t maxv, const std::string& xname) +{ + unsigned n = axes(); + aranges[id] = std::make_pair(minv, maxv); + _axes.resize(n + 1); + axis_map[id] = n; + axisnames[n] = xname; + return n; +} + +unsigned joystick_model::new_button(uint64_t id, const std::string& xname) +{ + unsigned n = buttons(); + _buttons.resize(n + 1); + button_map[id] = n; + buttonnames[n] = xname; + return n; +} + +unsigned joystick_model::new_hat(uint64_t id_x, uint64_t id_y, int64_t min_dev, const std::string& xname_x, + const std::string& xname_y) +{ + unsigned n = hats(); + hatinfos.resize(n + 1); + hatinfos[n].xstate = 0; + hatinfos[n].ystate = 0; + _hats.resize(n + 1); + hataxis_map[id_x].yflag = false; + hataxis_map[id_x].hnum = n; + hataxis_map[id_x].mindev = min_dev; + hataxis_map[id_y].yflag = true; + hataxis_map[id_y].hnum = n; + hataxis_map[id_y].mindev = min_dev; + hatnames[n] = ""; + return n; +} + +unsigned joystick_model::new_hat(uint64_t id, const std::string& xname) +{ + unsigned n = hats(); + _hats.resize(n + 1); + pov_map[id] = n; + hatnames[n] = xname; + return n; +} + +std::pair joystick_model::axiscalibration(unsigned id) +{ + for(auto i : axis_map) + if(i.second == id) + return aranges[i.first]; + return std::make_pair(0, 0); +} + +std::string joystick_model::axisname(unsigned id) +{ + if(axisnames.count(id)) return axisnames[id]; + else return ""; +} + +std::string joystick_model::buttonname(unsigned id) +{ + if(buttonnames.count(id)) return buttonnames[id]; + else return ""; +} + +std::string joystick_model::hatname(unsigned id) +{ + if(hatnames.count(id)) return hatnames[id]; + else return ""; +} + +void joystick_model::name(const std::string& newn) +{ + joyname = newn; +} + +const std::string& joystick_model::name() +{ + return joyname; +} + +std::string joystick_model::compose_report(unsigned jnum) +{ + std::ostringstream out; + out << "Joystick #" << jnum << ": " << joyname << std::endl; + for(size_t i = 0; i < _axes.size(); i++) { + auto c = axiscalibration(i); + out << " Axis #" << i << ": " << axisnames[i] << "(" << c.first << " - " << c.second << ")" + << std::endl; + } + for(size_t i = 0; i < _buttons.size(); i++) + out << " Button #" << i << ": " << buttonnames[i] << std::endl; + for(size_t i = 0; i < _hats.size(); i++) + out << " Hat #" << i << ": " << hatnames[i] << std::endl; + return out.str(); +} diff --git a/src/platform/evdev/joystick.cpp b/src/platform/evdev/joystick.cpp index c7a4a997..f9522b0e 100644 --- a/src/platform/evdev/joystick.cpp +++ b/src/platform/evdev/joystick.cpp @@ -2,6 +2,7 @@ #include "core/keymapper.hpp" #include "core/window.hpp" #include "library/joyfun.hpp" +#include "library/string.hpp" #include #include @@ -26,212 +27,63 @@ namespace { const char* axisnames[ABS_MAX + 1] = {0}; const char* buttonnames[KEY_MAX + 1] = {0}; + std::map joysticks; + std::map joystick_nums; + std::map, keygroup*> axes; + std::map, keygroup*> buttons; + std::map, keygroup*> hats; + unsigned joystick_count = 0; - enum event_type + std::string get_button_name(uint16_t code) { - ET_BUTTON, - ET_AXIS, - ET_HAT_X, - ET_HAT_Y - }; - - struct event_mapping - { - uint16_t joystick; - uint32_t tevcode; - enum event_type type; - uint16_t controlnum; - int32_t axis_min; - int32_t axis_max; - int32_t current_status; - uint32_t paired_mapping; //Only hats. - class keygroup* group; - }; - - struct event_mapping dummy_event_mapping = { - 9999, //Joystick (don't care). - 99999, //Tyep&Event code (don't care). - ET_BUTTON, //Not really. - 9999, //Control num (don't care). - 0, //Axis minimum (don't care). - 0, //Axis maximum (don't care). - 0, //Current status (don't care). - 0, //This is not a hat, so don't care about paired mapping. - NULL //No associated key group. - }; - - std::set keygroups; - std::map event_map; - std::map joystick_map; - std::set joysticks; - std::map joystick_names; - uint16_t connected_joysticks = 0; - - uint16_t get_joystick_number(int fd) - { - if(joystick_map.count(fd)) - return joystick_map[fd]; - else - return (joystick_map[fd] = connected_joysticks++); + if(code <= KEY_MAX && buttonnames[code]) + return buttonnames[code]; + else { + std::ostringstream str; + str << "Unknown button #" << code << std::endl; + return str.str(); + } } - uint64_t get_ev_id(uint16_t joystick, uint16_t type, uint16_t evcode) + std::string get_axis_name(uint16_t code) { - return (static_cast(joystick) << 32) | - (static_cast(type) << 16) | - static_cast(evcode); - }; - - uint64_t get_ev_id(uint16_t joystick, uint32_t tevcode) - { - return (static_cast(joystick) << 32) | - static_cast(tevcode); - }; - - void create_button(int fd, uint16_t type, uint16_t evcode, uint16_t buttonnum) - { - uint16_t joynum = get_joystick_number(fd); - std::ostringstream _name; - _name << "joystick" << joynum << "button" << buttonnum; - std::string name = _name.str(); - keygroup* grp = new keygroup(name, "joystick", keygroup::KT_KEY); - keygroups.insert(grp); - struct event_mapping evmap; - evmap.joystick = joynum; - evmap.tevcode = (static_cast(type) << 16) | static_cast(evcode); - evmap.type = ET_BUTTON; - evmap.controlnum = buttonnum; - evmap.axis_min = evmap.axis_max = 0; - evmap.current_status = 0; - evmap.paired_mapping = 0; - evmap.group = grp; - event_map[get_ev_id(joynum, evmap.tevcode)] = evmap; + if(code <= ABS_MAX && axisnames[code]) + return axisnames[code]; + else { + std::ostringstream str; + str << "Unknown axis #" << code << std::endl; + return str.str(); + } } - void create_axis(int fd, uint16_t type, uint16_t evcode, uint16_t axisnum, int32_t min, int32_t max) + void create_button(int fd, unsigned jnum, uint16_t code) { - uint16_t joynum = get_joystick_number(fd); - std::ostringstream _name; - _name << "joystick" << joynum << "axis" << axisnum; - std::string name = _name.str(); - keygroup* grp; + unsigned n = joysticks[fd].new_button(code, get_button_name(code)); + std::string name = (stringfmt() << "joystick" << jnum << "button" << n).str(); + buttons[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); + } + + void create_axis(int fd, unsigned jnum, uint16_t code, int32_t min, int32_t max) + { + unsigned n = joysticks[fd].new_axis(code, min, max, get_axis_name(code)); + std::string name = (stringfmt() << "joystick" << jnum << "axis" << n).str(); if(min < 0) - grp = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); + axes[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); else - grp = new keygroup(name, "joystick", keygroup::KT_PRESSURE_MP); - keygroups.insert(grp); - struct event_mapping evmap; - evmap.joystick = joynum; - evmap.tevcode = (static_cast(type) << 16) | static_cast(evcode); - evmap.type = ET_AXIS; - evmap.controlnum = axisnum; - evmap.axis_min = min; - evmap.axis_max = max; - evmap.current_status = 0; - evmap.paired_mapping = 0; - evmap.group = grp; - event_map[get_ev_id(joynum, evmap.tevcode)] = evmap; + axes[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_PRESSURE_MP); } - void create_hat(int fd, uint16_t type, uint16_t evcodeX, uint16_t evcodeY, uint16_t hatnum) + void create_hat(int fd, unsigned jnum, uint16_t codeX, uint16_t codeY) { - uint16_t joynum = get_joystick_number(fd); - std::ostringstream _name; - _name << "joystick" << joynum << "hat" << hatnum; - std::string name = _name.str(); - keygroup* grp = new keygroup(name, "joystick", keygroup::KT_HAT); - keygroups.insert(grp); - struct event_mapping evmap1; - evmap1.joystick = joynum; - evmap1.tevcode = (static_cast(type) << 16) | static_cast(evcodeX); - evmap1.type = ET_HAT_X; - evmap1.controlnum = hatnum; - evmap1.axis_min = -1; - evmap1.axis_max = 1; - evmap1.current_status = 0; - evmap1.group = grp; - struct event_mapping evmap2; - evmap2.joystick = joynum; - evmap2.tevcode = (static_cast(type) << 16) | static_cast(evcodeY); - evmap2.type = ET_HAT_Y; - evmap2.controlnum = hatnum; - evmap2.axis_min = -1; - evmap1.axis_max = 1; - evmap2.current_status = 0; - evmap2.group = grp; - evmap1.paired_mapping = get_ev_id(joynum, evmap2.tevcode); - evmap2.paired_mapping = get_ev_id(joynum, evmap1.tevcode); - event_map[get_ev_id(joynum, evmap1.tevcode)] = evmap1; - event_map[get_ev_id(joynum, evmap2.tevcode)] = evmap2; - } - - struct event_mapping& get_mapping_for(uint16_t joystick, uint16_t type, uint16_t evcode) - { - uint64_t evid = get_ev_id(joystick, type, evcode); - if(event_map.count(evid)) - return event_map[evid]; - else - return dummy_event_mapping; - } - - struct event_mapping& get_mapping_for(uint16_t joystick, uint32_t tevcode) - { - uint64_t evid = get_ev_id(joystick, tevcode); - if(event_map.count(evid)) - return event_map[evid]; - else - return dummy_event_mapping; - } - - struct event_mapping& get_mapping_for_fd(int fd, uint16_t type, uint16_t evcode) - { - if(joystick_map.count(fd)) - return get_mapping_for(joystick_map[fd], type, evcode); - else - return dummy_event_mapping; - } - - void update_mapping_for_fd(int fd, uint16_t type, uint16_t evcode, int32_t value) - { - struct event_mapping& e = get_mapping_for_fd(fd, type, evcode); - e.current_status = value; - if(!e.group) - return; //Dummy. - int16_t v = 0; - switch(e.type) { - case ET_BUTTON: - v = (e.current_status != 0); - break; - case ET_AXIS: - v = calibration_correction(e.current_status, e.axis_min, e.axis_max); - break; - case ET_HAT_X: - case ET_HAT_Y: { - uint32_t xaxis, yaxis; - if(e.type == ET_HAT_X) { - xaxis = get_ev_id(e.joystick, e.tevcode); - yaxis = e.paired_mapping; - } else { - yaxis = get_ev_id(e.joystick, e.tevcode); - xaxis = e.paired_mapping; - } - if(event_map[yaxis].current_status < 0) - v |= 1; - if(event_map[xaxis].current_status > 0) - v |= 2; - if(event_map[yaxis].current_status > 0) - v |= 4; - if(event_map[xaxis].current_status < 0) - v |= 8; - break; - } - } - platform::queue(keypress(modifier_set(), *e.group, v)); - //e.group->set_position(v, modifier_set()); + unsigned n = joysticks[fd].new_hat(codeX, codeY, 1, get_axis_name(codeX), get_axis_name(codeY)); + std::string name = (stringfmt() << "joystick" << jnum << "hat" << n).str(); + hats[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); } bool read_one_input_event(int fd) { + short x; + joystick_model& m = joysticks[fd]; struct input_event ev; int r = read(fd, &ev, sizeof(ev)); if(r < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) @@ -241,7 +93,10 @@ namespace << std::endl; return false; } - update_mapping_for_fd(fd, ev.type, ev.code, ev.value); + if(ev.type == EV_KEY) + m.report_button(ev.code, ev.value != 0); + if(ev.type == EV_ABS) + m.report_axis(ev.code, ev.value); return true; } @@ -283,16 +138,19 @@ namespace << std::endl; return false; } + joysticks[fd].name(namebuffer); + unsigned jnum = joystick_count++; + joystick_nums[fd] = jnum; + for(unsigned i = 0; i <= KEY_MAX; i++) { if(keys[i / div] & (1ULL << (i % div))) { - create_button(fd, EV_KEY, i, button_count++); + create_button(fd, jnum, i); + button_count++; } } for(unsigned i = 0; i <= ABS_MAX; i++) { if(axes[i / div] & (1ULL << (i % div))) { if(i < ABS_HAT0X || i > ABS_HAT3Y) { - int32_t min; - int32_t max; int32_t V[5]; if(ioctl(fd, EVIOCGABS(i), V) < 0) { int merrno = errno; @@ -300,34 +158,19 @@ namespace << fd << "): " << strerror(merrno) << std::endl; continue; } - min = V[1]; - max = V[2]; - create_axis(fd, EV_ABS, i, axis_count++, min, max); + create_axis(fd, jnum, i, V[1], V[2]); + axis_count++; } else if(i % 2 == 0) { - create_hat(fd, EV_ABS, i, i + 1, hat_count++); + create_hat(fd, jnum, i, i + 1); + hat_count++; } } } - uint16_t joynum = get_joystick_number(fd); - joystick_names[joynum] = namebuffer; messages << "Found '" << namebuffer << "' (" << button_count << " buttons, " << axis_count << " axes, " << hat_count << " hats)" << std::endl; - joysticks.insert(fd); return true; } - void open_and_probe(const std::string& filename) - { - int r = open(filename.c_str(), O_RDONLY | O_NONBLOCK); - if(r < 0) { - return; - } - if(!probe_joystick(r, filename)) { - close(r); - } - return; - } - void probe_all_joysticks() { DIR* d = opendir("/dev/input"); @@ -345,54 +188,21 @@ namespace for(size_t i = 5; dentry->d_name[i]; i++) if(!isdigit(static_cast(dentry->d_name[i]))) continue; - open_and_probe(std::string("/dev/input/") + dentry->d_name); + std::string filename = std::string("/dev/input/") + dentry->d_name; + int r = open(filename.c_str(), O_RDONLY | O_NONBLOCK); + if(r < 0) + continue; + if(!probe_joystick(r, filename)) + close(r); } closedir(d); } - std::string get_button_name(uint16_t code) - { - if(code <= KEY_MAX && buttonnames[code]) - return buttonnames[code]; - else { - std::ostringstream str; - str << "Unknown button #" << code << std::endl; - return str.str(); - } - } - - std::string get_axis_name(uint16_t code) - { - if(code <= ABS_MAX && axisnames[code]) - return axisnames[code]; - else { - std::ostringstream str; - str << "Unknown axis #" << code << std::endl; - return str.str(); - } - } - function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", "Syntax: show-joysticks\nShow joystick data.\n", []() throw(std::bad_alloc, std::runtime_error) { - for(auto i : joystick_names) { - messages << "Joystick #" << i.first << ": " << i.second << std::endl; - for(auto j : event_map) { - if(j.second.joystick != i.first) - continue; - if(j.second.type == ET_BUTTON) - messages << j.second.group->name() << ": " - << get_button_name(j.second.tevcode & 0xFFFF) << std::endl; - if(j.second.type == ET_AXIS) - messages << j.second.group->name() << ": " - << get_axis_name(j.second.tevcode & 0xFFFF) - << "[" << j.second.axis_min << "," << j.second.axis_max - << "]" << std::endl; - if(j.second.type == ET_HAT_X || j.second.type == ET_HAT_Y) - messages << j.second.group->name() << ": " - << get_axis_name(j.second.tevcode & 0xFFFF) << std::endl; - } - } + for(auto i : joystick_nums) + messages << joysticks[i.first].compose_report(i.second) << std::endl; }); volatile bool quit_signaled = false; @@ -401,9 +211,9 @@ namespace void joystick_plugin::init() throw() { - probe_all_joysticks(); evdev_init_buttons(buttonnames); evdev_init_axes(axisnames); + probe_all_joysticks(); quit_ack = quit_signaled = false; } @@ -411,18 +221,15 @@ void joystick_plugin::quit() throw() { quit_signaled = true; while(!quit_ack); - for(int fd : joysticks) - close(fd); - for(auto i : keygroups) - delete i; - keygroups.clear(); - joystick_map.clear(); + for(auto i : joysticks) close(i.first); + for(auto i : axes) delete i.second; + for(auto i : buttons) delete i.second; + for(auto i : hats) delete i.second; joysticks.clear(); - joystick_names.clear(); - std::map event_map; - std::map joystick_map; - std::set joysticks; - std::map joystick_names; + joystick_nums.clear(); + axes.clear(); + buttons.clear(); + hats.clear(); } #define POLL_WAIT 20000 @@ -430,8 +237,18 @@ void joystick_plugin::quit() throw() void joystick_plugin::thread_fn() throw() { while(!quit_signaled) { - for(int fd : joysticks) - while(read_one_input_event(fd)); + for(auto fd : joysticks) + while(read_one_input_event(fd.first)); + short x; + for(auto i : buttons) + if(joysticks[i.first.first].button(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : axes) + if(joysticks[i.first.first].axis(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : hats) + if(joysticks[i.first.first].hat(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); usleep(POLL_WAIT); } quit_ack = true; diff --git a/src/platform/win32mm/joystick.cpp b/src/platform/win32mm/joystick.cpp index f6e4da16..f92ad2cb 100644 --- a/src/platform/win32mm/joystick.cpp +++ b/src/platform/win32mm/joystick.cpp @@ -19,47 +19,39 @@ namespace { - std::set keygroups; - std::map, keygroup*> buttons; + std::map joysticks; std::map, keygroup*> axes; - std::map hats; - std::map, short> lbuttons; - std::map, short> laxes; - std::map lhats; - std::set joysticks; - std::map capabilities; + std::map, keygroup*> buttons; + std::map, keygroup*> hats; volatile bool quit_signaled; volatile bool quit_ack; + const char* axisnames[] = {"X", "Y", "Z", "Rudder", "U", "V"}; + const char* buttonnames[] = {"Button1", "Button2", "Button3", "Button4", "Button5", "Button6", "Button7", + "Button8", "Button9", "Button10", "Button11", "Button12", "Button13", "Button14", "Button15", + "Button16", "Button17", "Button18", "Button19", "Button20", "Button21", "Button22", "Button23", + "Button24", "Button25", "Button26", "Button27", "Button28", "Button29", "Button30", "Button31", + "Button32"}; + void create_hat(unsigned i, unsigned j = 0) { - std::string n = (stringfmt() << "joystick" << i << "hat" << j).str(); - keygroup* k = new keygroup(n, "joystick", keygroup::KT_HAT); - hats[i] = k; + unsigned n = joysticks[i].new_hat(j, "POV"); + std::string name = (stringfmt() << "joystick" << i << "hat" << n).str(); + hats[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); } void create_button(unsigned i, unsigned j) { - std::string n = (stringfmt() << "joystick" << i << "button" << j).str(); - keygroup* k = new keygroup(n, "joystick", keygroup::KT_KEY); - buttons[std::make_pair(i, j)] = k; + unsigned n = joysticks[i].new_button(j, buttonnames[j]); + std::string name = (stringfmt() << "joystick" << i << "button" << n).str(); + buttons[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); } void create_axis(unsigned i, unsigned j, unsigned min, unsigned max) { - std::string n = (stringfmt() << "joystick" << i << "axis" << j).str(); - keygroup* k; - k = new keygroup(n, "joystick", keygroup::KT_AXIS_PAIR); - axes[std::make_pair(i, j)] = k; - } - - void read_axis(unsigned i, unsigned j, unsigned pos, unsigned pmin, unsigned pmax) - { - auto key = std::make_pair(i, j); - if(!axes.count(key)) - return; - if(make_equal(laxes[key], calibration_correction(pos, pmin, pmax))) - platform::queue(keypress(modifier_set(), *axes[key], laxes[key])); + unsigned n = joysticks[i].new_axis(j, min, max, axisnames[j]); + std::string name = (stringfmt() << "joystick" << i << "axis" << n).str(); + axes[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); } void init_joysticks() @@ -76,84 +68,32 @@ namespace continue; //Not usable. if(joyGetDevCaps(i, &caps, sizeof(caps)) != JOYERR_NOERROR) continue; //Not usable. - joysticks.insert(i); - capabilities[i] = caps; messages << "Joystick #" << i << ": " << caps.szPname << " (by '" << caps.szOEMVxD << "')" << std::endl; + joystick_model& m = joysticks[i]; + m.name(caps.szPname); if(caps.wCaps & JOYCAPS_HASPOV) create_hat(i); for(unsigned j = 0; j < caps.wNumButtons && j < 32; j++) create_button(i, j); - unsigned axcount = 2; create_axis(i, 0, caps.wXmin, caps.wXmax); create_axis(i, 1, caps.wYmin, caps.wYmax); - if(caps.wCaps & JOYCAPS_HASZ) { - create_axis(i, 2, caps.wZmin, caps.wZmax); - axcount++; - } - if(caps.wCaps & JOYCAPS_HASR) { - create_axis(i, 3, caps.wRmin, caps.wRmax); - axcount++; - } - if(caps.wCaps & JOYCAPS_HASU) { - create_axis(i, 4, caps.wUmin, caps.wUmax); - axcount++; - } - if(caps.wCaps & JOYCAPS_HASV) { - create_axis(i, 5, caps.wVmin, caps.wVmax); - axcount++; - } + if(caps.wCaps & JOYCAPS_HASZ) create_axis(i, 2, caps.wZmin, caps.wZmax); + if(caps.wCaps & JOYCAPS_HASR) create_axis(i, 3, caps.wRmin, caps.wRmax); + if(caps.wCaps & JOYCAPS_HASU) create_axis(i, 4, caps.wUmin, caps.wUmax); + if(caps.wCaps & JOYCAPS_HASV) create_axis(i, 5, caps.wVmin, caps.wVmax); if(caps.wCaps & JOYCAPS_HASPOV) messages << "1 hat, "; - messages << axcount << " axes, " << min((int)caps.wNumButtons, 32) << " buttons" << std::endl; + messages << m.axes() << " axes, " << m.buttons() << " buttons" << std::endl; } } - void quit_joysticks() - { - for(auto i : keygroups) - delete i; - buttons.clear(); - axes.clear(); - hats.clear(); - keygroups.clear(); - joysticks.clear(); - capabilities.clear(); - } - - void poll_joysticks() - { - modifier_set mod; - for(auto i : capabilities) { - unsigned jnum = i.first; - JOYINFOEX info; - JOYCAPS caps = capabilities[jnum]; - info.dwSize = sizeof(info); - info.dwFlags = JOY_RETURNALL; - if(joyGetPosEx(jnum, &info) != JOYERR_NOERROR) - continue; //Not usable. - if(caps.wCaps & JOYCAPS_HASPOV) - if(make_equal(lhats[jnum], angle_to_bitmask(info.dwPOV))) - platform::queue(keypress(modifier_set(), *hats[jnum], lhats[jnum])); - for(unsigned j = 0; j < caps.wMaxButtons; j++) { - //Read buttons - auto key = std::make_pair(jnum, j); - if(buttons.count(key) && make_equal(lbuttons[key], - static_cast((info.dwButtons >> j) & 1))) - platform::queue(keypress(modifier_set(), *buttons[key], lbuttons[key])); - } - read_axis(jnum, 0, info.dwXpos, caps.wXmin, caps.wXmax); - read_axis(jnum, 1, info.dwYpos, caps.wYmin, caps.wYmax); - if(caps.wCaps & JOYCAPS_HASZ) - read_axis(jnum, 2, info.dwZpos, caps.wZmin, caps.wZmax); - if(caps.wCaps & JOYCAPS_HASR) - read_axis(jnum, 3, info.dwRpos, caps.wRmin, caps.wRmax); - if(caps.wCaps & JOYCAPS_HASU) - read_axis(jnum, 4, info.dwUpos, caps.wUmin, caps.wUmax); - if(caps.wCaps & JOYCAPS_HASV) - read_axis(jnum, 5, info.dwVpos, caps.wVmin, caps.wVmax); - } - } + function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", + "Syntax: show-joysticks\nShow joystick data.\n", + []() throw(std::bad_alloc, std::runtime_error) { + for(auto i : joysticks) + messages << i.second.compose_report(i.first) << std::endl; + }); } void joystick_plugin::init() throw() @@ -166,7 +106,14 @@ void joystick_plugin::quit() throw() { quit_signaled = true; while(!quit_ack); - quit_joysticks(); + for(auto i : joysticks) close(i.first); + for(auto i : axes) delete i.second; + for(auto i : buttons) delete i.second; + for(auto i : hats) delete i.second; + joysticks.clear(); + axes.clear(); + buttons.clear(); + hats.clear(); } #define POLL_WAIT 20000 @@ -174,7 +121,33 @@ void joystick_plugin::quit() throw() void joystick_plugin::thread_fn() throw() { while(!quit_signaled) { - poll_joysticks(); + for(auto i : joysticks) { + joystick_model& m = joysticks[i.first]; + JOYINFOEX info; + info.dwSize = sizeof(info); + info.dwFlags = JOY_RETURNALL; + if(joyGetPosEx(i.first, &info) != JOYERR_NOERROR) + continue; //Not usable. + m.report_pov(0, info.dwPOV); + for(unsigned j = 0; j < 32; j++) + m.report_button(j, (info.dwButtons >> j) & 1); + m.report_axis(0, info.dwXpos); + m.report_axis(1, info.dwYpos); + m.report_axis(2, info.dwZpos); + m.report_axis(3, info.dwRpos); + m.report_axis(4, info.dwUpos); + m.report_axis(5, info.dwVpos); + } + short x; + for(auto i : buttons) + if(joysticks[i.first.first].button(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : axes) + if(joysticks[i.first.first].axis(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : hats) + if(joysticks[i.first.first].hat(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); usleep(POLL_WAIT); } quit_ack = true; diff --git a/src/platform/wxwidgets/joystick.cpp b/src/platform/wxwidgets/joystick.cpp index 69e40e58..2cb23cf4 100644 --- a/src/platform/wxwidgets/joystick.cpp +++ b/src/platform/wxwidgets/joystick.cpp @@ -21,46 +21,41 @@ namespace { - std::set keygroups; - std::map, keygroup*> buttons; + std::map joysticks; std::map, keygroup*> axes; - std::map hats; - std::map, short> lbuttons; - std::map, short> laxes; - std::map lhats; - std::map joysticks; + std::map, keygroup*> buttons; + std::map, keygroup*> hats; + std::map jobjects; + volatile bool quit_signaled; + volatile bool quit_ack; volatile bool ready = false; + const char* axisnames[] = {"X", "Y", "Z", "Rudder", "U", "V"}; + const char* buttonnames[] = {"Button1", "Button2", "Button3", "Button4", "Button5", "Button6", "Button7", + "Button8", "Button9", "Button10", "Button11", "Button12", "Button13", "Button14", "Button15", + "Button16", "Button17", "Button18", "Button19", "Button20", "Button21", "Button22", "Button23", + "Button24", "Button25", "Button26", "Button27", "Button28", "Button29", "Button30", "Button31", + "Button32"}; + void create_hat(unsigned i, unsigned j = 0) { - std::string n = (stringfmt() << "joystick" << i << "hat" << j).str(); - keygroup* k = new keygroup(n, "joystick", keygroup::KT_HAT); - hats[i] = k; + unsigned n = joysticks[i].new_hat(j, "POV"); + std::string name = (stringfmt() << "joystick" << i << "hat" << n).str(); + hats[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); } void create_button(unsigned i, unsigned j) { - std::string n = (stringfmt() << "joystick" << i << "button" << j).str(); - keygroup* k = new keygroup(n, "joystick", keygroup::KT_KEY); - buttons[std::make_pair(i, j)] = k; + unsigned n = joysticks[i].new_button(j, buttonnames[j]); + std::string name = (stringfmt() << "joystick" << i << "button" << n).str(); + buttons[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); } void create_axis(unsigned i, unsigned j, int min, int max) { - messages << "axis #" << j << ": " << min << " " << max << std::endl; - std::string n = (stringfmt() << "joystick" << i << "axis" << j).str(); - keygroup* k; - k = new keygroup(n, "joystick", keygroup::KT_AXIS_PAIR); - axes[std::make_pair(i, j)] = k; - } - - void read_axis(unsigned i, unsigned j, int pos, int pmin, int pmax) - { - auto key = std::make_pair(i, j); - if(!axes.count(key)) - return; - if(make_equal(laxes[key], calibration_correction(pos, pmin, pmax))) - platform::queue(keypress(modifier_set(), *axes[key], laxes[key])); + unsigned n = joysticks[i].new_axis(j, min, max, axisnames[j]); + std::string name = (stringfmt() << "joystick" << i << "axis" << n).str(); + axes[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); } void init_joysticks() @@ -75,34 +70,22 @@ namespace delete joy; continue; } - joysticks[i] = joy; + jobjects[i] = joy; + joysticks[i].name(joy->GetProductName()); messages << "Joystick #" << i << ": " << joy->GetProductName() << std::endl; if(joy->HasPOV()) create_hat(i); for(unsigned j = 0; j < joy->GetNumberButtons() && j < 32; j++) create_button(i, j); - unsigned axcount = 2; create_axis(i, 0, joy->GetXMin(), joy->GetXMax()); create_axis(i, 1, joy->GetYMin(), joy->GetYMax()); - if(joy->HasZ()) { - create_axis(i, 2, joy->GetZMin(), joy->GetZMax()); - axcount++; - } - if(joy->HasRudder()) { - create_axis(i, 3, joy->GetRudderMin(), joy->GetRudderMax()); - axcount++; - } - if(joy->HasU()) { - create_axis(i, 4, joy->GetUMin(), joy->GetUMax()); - axcount++; - } - if(joy->HasV()) { - create_axis(i, 5, joy->GetVMin(), joy->GetVMax()); - axcount++; - } + if(joy->HasZ()) create_axis(i, 2, joy->GetZMin(), joy->GetZMax()); + if(joy->HasRudder()) create_axis(i, 3, joy->GetRudderMin(), joy->GetRudderMax()); + if(joy->HasU()) create_axis(i, 4, joy->GetUMin(), joy->GetUMax()); + if(joy->HasV()) create_axis(i, 5, joy->GetVMin(), joy->GetVMax()); if(joy->HasPOV()) messages << "1 hat, "; - messages << axcount << " axes, " << min((int)joy->GetNumberButtons(), 32) << " buttons" + messages << joysticks[i].axes() << " axes, " << joysticks[i].buttons() << " buttons" << std::endl; } ready = true; @@ -112,33 +95,31 @@ namespace { if(!ready) return; - modifier_set mod; - for(auto i : joysticks) { - unsigned jnum = i.first; - wxJoystick* joy = i.second; - if(joy->HasPOV()) - if(make_equal(lhats[jnum], angle_to_bitmask(joy->GetPOVCTSPosition()))) - platform::queue(keypress(modifier_set(), *hats[jnum], lhats[jnum])); - uint32_t bmask = joy->GetButtonState(); - for(unsigned j = 0; j < 32; j++) { - //Read buttons - auto key = std::make_pair(jnum, j); - if(buttons.count(key) && make_equal(lbuttons[key], static_cast((bmask >> j) & - 1))) - platform::queue(keypress(modifier_set(), *buttons[key], lbuttons[key])); - } - wxPoint xy = joy->GetPosition(); - read_axis(jnum, 0, xy.x, joy->GetXMin(), joy->GetXMax()); - read_axis(jnum, 1, xy.y, joy->GetYMin(), joy->GetYMax()); - if(joy->HasZ()) - read_axis(jnum, 2, joy->GetZPosition(), joy->GetZMin(), joy->GetZMax()); - if(joy->HasRudder()) - read_axis(jnum, 3, joy->GetRudderPosition(), joy->GetRudderMin(), joy->GetRudderMax()); - if(joy->HasU()) - read_axis(jnum, 4, joy->GetUPosition(), joy->GetUMin(), joy->GetUMax()); - if(joy->HasV()) - read_axis(jnum, 5, joy->GetVPosition(), joy->GetUMin(), joy->GetUMax()); + for(auto i : jobjects) { + joystick_model& m = joysticks[i.first]; + wxJoystick& j = *i.second; + m.report_pov(0, j.GetPOVCTSPosition()); + uint32_t bmask = j.GetButtonState(); + for(unsigned j = 0; j < 32; j++) + m.report_button(j, (bmask >> j) & 1); + wxPoint xy = j.GetPosition(); + m.report_axis(0, xy.x); + m.report_axis(1, xy.y); + m.report_axis(2, j.GetZPosition()); + m.report_axis(3, j.GetRudderPosition()); + m.report_axis(4, j.GetUPosition()); + m.report_axis(5, j.GetVPosition()); } + short x; + for(auto i : buttons) + if(joysticks[i.first.first].button(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : axes) + if(joysticks[i.first.first].axis(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : hats) + if(joysticks[i.first.first].hat(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); } struct joystick_timer : public wxTimer @@ -148,6 +129,13 @@ namespace void stop() { Stop(); } void Notify() { poll_joysticks(); } }* jtimer; + + function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", + "Syntax: show-joysticks\nShow joystick data.\n", + []() throw(std::bad_alloc, std::runtime_error) { + for(auto i : joysticks) + messages << i.second.compose_report(i.first) << std::endl; + }); } void joystick_plugin::init() throw() @@ -163,16 +151,16 @@ void joystick_plugin::quit() throw() jtimer = NULL; ready = false; usleep(50000); - for(auto i : keygroups) - delete i; - for(auto i : joysticks) - delete i.second; - usleep(500000); - buttons.clear(); - axes.clear(); - hats.clear(); - keygroups.clear(); + + for(auto i : jobjects) delete i.second; + for(auto i : axes) delete i.second; + for(auto i : buttons) delete i.second; + for(auto i : hats) delete i.second; joysticks.clear(); + jobjects.clear(); + axes.clear(); + buttons.clear(); + hats.clear(); } void joystick_plugin::thread_fn() throw() From e9fa95f34c068141f2245a94fa9ae0b37fe4810b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 13 Apr 2012 11:15:00 +0300 Subject: [PATCH 2/6] Refactor joystick support more --- include/core/joystick.hpp | 105 +++++++++++++++++ src/core/joystick.cpp | 139 +++++++++++++++++++++++ src/platform/evdev/joystick.cpp | 99 +++------------- src/platform/win32mm/joystick.cpp | 138 +++++++---------------- src/platform/wxwidgets/joystick.cpp | 169 +++++++++------------------- 5 files changed, 356 insertions(+), 294 deletions(-) create mode 100644 include/core/joystick.hpp create mode 100644 src/core/joystick.cpp diff --git a/include/core/joystick.hpp b/include/core/joystick.hpp new file mode 100644 index 00000000..90fe24ea --- /dev/null +++ b/include/core/joystick.hpp @@ -0,0 +1,105 @@ +#ifndef _joystick__hpp__included__ +#define _joystick__hpp__included__ + +#include "core/keymapper.hpp" + +/** + * Create a new joystick. + * + * Parameter id: The id of new joystick. + * Parameter xname: The name of new joystick. + */ +void joystick_create(uint64_t id, const std::string& xname); +/** + * Free all joysticks. + */ +void joystick_quit(); +/** + * Create a new axis. + * + * Parameter jid: The id of joystick. + * Parameter id: The id of the axis. + * Parameter minv: The minimal calibration value. + * Parameter maxv: The maximal calibration value. + * Parameter xname: The name of axis. + * Parameter atype: The axis type. + */ +void joystick_new_axis(uint64_t jid, uint64_t id, int64_t minv, int64_t maxv, const std::string& xname, + enum keygroup::type atype); +/** + * Create a new button. + * + * Parameter jid: The id of joystick. + * Parameter id: The id of button. + * Parameter xname: The name of button. + * Returns: The number of button. + */ +void joystick_new_button(uint64_t jid, uint64_t id, const std::string& xname); +/** + * Create a new hat from pair of axes. + * + * Parameter jid: The id of joystick. + * Parameter id_x: The id of x axis of the hat. + * Parameter id_y: The id of y axis of the hat. + * Parameter min_dev: The smallest deviation from zero to react to. + * Parameter xname_x: The name of x axis. + * Parameter xname_y: The name of y axis. + * Returns: The number of hat. + */ +void joystick_new_hat(uint64_t jid, uint64_t id_x, uint64_t id_y, int64_t min_dev, const std::string& xname_x, + const std::string& xname_y); +/** + * Create a new hat from POV control. + * + * Parameter jid: The id of joystick. + * Parameter id: The id of POV control. + * Parameter xname: The name of POV control. + * Returns: The number of hat. + */ +void joystick_new_hat(uint64_t jid, uint64_t id, const std::string& xname); +/** + * Report possible change in axis value. + * + * Requests to update unknown axes are ignored. + * + * Parameter jid: The id of joystick. + * Parameter id: The ID of axis. + * Parameter value: The value. + */ +void joystick_report_axis(uint64_t jid, uint64_t id, int64_t value); +/** + * Report possible change in button value. + * + * Requests to update unknown buttons are ignored. + * + * Parameter jid: The id of joystick. + * Parameter id: The ID of button. + * Parameter value: The value. + */ +void joystick_report_button(uint64_t jid, uint64_t id, bool value); +/** + * Report possible change in POV value. + * + * Requests to update unknown POVs are ignored. + * + * Parameter jid: The id of joystick. + * Parameter id: The ID of POV. + * Parameter value: The angle in hundredths of degree clockwise from up, or negative if centered. + */ +void joystick_report_pov(uint64_t jid, uint64_t id, int angle); +/** + * Print message about joystick. + * + * Parameter jid: The joystick id. + */ +void joystick_message(uint64_t jid); +/** + * Get set of all joysticks. + */ +std::set joystick_set(); +/** + * Flush all pending joystick requests. + */ +void joystick_flush(); + +#endif diff --git a/src/core/joystick.cpp b/src/core/joystick.cpp new file mode 100644 index 00000000..c32837eb --- /dev/null +++ b/src/core/joystick.cpp @@ -0,0 +1,139 @@ +#include "core/command.hpp" +#include "core/joystick.hpp" +#include "core/window.hpp" +#include "library/string.hpp" +#include "library/joyfun.hpp" +#include +#include + +namespace +{ + std::map joysticks; + std::map joynumbers; + std::map, keygroup*> axes; + std::map, keygroup*> buttons; + std::map, keygroup*> hats; + unsigned joystick_count = 0; + + function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", + "Syntax: show-joysticks\nShow joystick data.\n", + []() throw(std::bad_alloc, std::runtime_error) { + for(auto i : joynumbers) + messages << joysticks[i.first].compose_report(i.second) << std::endl; + }); +} + +void joystick_create(uint64_t id, const std::string& xname) +{ + joynumbers[id] = joystick_count++; + joysticks[id].name(xname); +} + +void joystick_quit() +{ + for(auto i : axes) + delete i.second; + for(auto i : buttons) + delete i.second; + for(auto i : hats) + delete i.second; + joysticks.clear(); + joynumbers.clear(); + axes.clear(); + buttons.clear(); + hats.clear(); + joystick_count = 0; +} + +void joystick_new_axis(uint64_t jid, uint64_t id, int64_t minv, int64_t maxv, const std::string& xname, + enum keygroup::type atype) +{ + if(!joysticks.count(jid)) + return; + unsigned jnum = joynumbers[jid]; + unsigned n = joysticks[jid].new_axis(id, minv, maxv, xname); + std::string name = (stringfmt() << "joystick" << jnum << "axis" << n).str(); + axes[std::make_pair(jid, n)] = new keygroup(name, "joystick", atype); +} + +void joystick_new_button(uint64_t jid, uint64_t id, const std::string& xname) +{ + if(!joysticks.count(jid)) + return; + unsigned jnum = joynumbers[jid]; + unsigned n = joysticks[jid].new_button(id, xname); + std::string name = (stringfmt() << "joystick" << jnum << "button" << n).str(); + buttons[std::make_pair(jid, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); +} + +void joystick_new_hat(uint64_t jid, uint64_t id_x, uint64_t id_y, int64_t min_dev, const std::string& xname_x, + const std::string& xname_y) +{ + if(!joysticks.count(jid)) + return; + unsigned jnum = joynumbers[jid]; + unsigned n = joysticks[jid].new_hat(id_x, id_y, min_dev, xname_x, xname_y); + std::string name = (stringfmt() << "joystick" << jnum << "hat" << n).str(); + hats[std::make_pair(jid, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); +} + +void joystick_new_hat(uint64_t jid, uint64_t id, const std::string& xname) +{ + if(!joysticks.count(jid)) + return; + unsigned jnum = joynumbers[jid]; + unsigned n = joysticks[jid].new_hat(id, xname); + std::string name = (stringfmt() << "joystick" << jnum << "hat" << n).str(); + hats[std::make_pair(jid, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); +} + +void joystick_report_axis(uint64_t jid, uint64_t id, int64_t value) +{ + if(!joysticks.count(jid)) + return; + joysticks[jid].report_axis(id, value); +} + +void joystick_report_button(uint64_t jid, uint64_t id, bool value) +{ + if(!joysticks.count(jid)) + return; + joysticks[jid].report_button(id, value); +} + +void joystick_report_pov(uint64_t jid, uint64_t id, int angle) +{ + if(!joysticks.count(jid)) + return; + joysticks[jid].report_pov(id, angle); +} + +void joystick_message(uint64_t jid) +{ + if(!joysticks.count(jid)) + return; + messages << "Found '" << joysticks[jid].name() << "' (" << joysticks[jid].buttons() << " buttons, " + << joysticks[jid].axes() << " axes, " << joysticks[jid].hats() << " hats)" << std::endl; +} + +std::set joystick_set() +{ + std::set x; + for(auto i : joynumbers) + x.insert(i.first); + return x; +} + +void joystick_flush() +{ + short x; + for(auto i : buttons) + if(joysticks[i.first.first].button(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : axes) + if(joysticks[i.first.first].axis(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto i : hats) + if(joysticks[i.first.first].hat(i.first.second, x)) + platform::queue(keypress(modifier_set(), *i.second, x)); +} diff --git a/src/platform/evdev/joystick.cpp b/src/platform/evdev/joystick.cpp index f9522b0e..d215ce41 100644 --- a/src/platform/evdev/joystick.cpp +++ b/src/platform/evdev/joystick.cpp @@ -1,7 +1,7 @@ #include "core/command.hpp" #include "core/keymapper.hpp" +#include "core/joystick.hpp" #include "core/window.hpp" -#include "library/joyfun.hpp" #include "library/string.hpp" #include @@ -27,63 +27,26 @@ namespace { const char* axisnames[ABS_MAX + 1] = {0}; const char* buttonnames[KEY_MAX + 1] = {0}; - std::map joysticks; - std::map joystick_nums; - std::map, keygroup*> axes; - std::map, keygroup*> buttons; - std::map, keygroup*> hats; - unsigned joystick_count = 0; std::string get_button_name(uint16_t code) { if(code <= KEY_MAX && buttonnames[code]) return buttonnames[code]; - else { - std::ostringstream str; - str << "Unknown button #" << code << std::endl; - return str.str(); - } + else + return (stringfmt() << "Unknown button #" << code).str(); } std::string get_axis_name(uint16_t code) { if(code <= ABS_MAX && axisnames[code]) return axisnames[code]; - else { - std::ostringstream str; - str << "Unknown axis #" << code << std::endl; - return str.str(); - } - } - - void create_button(int fd, unsigned jnum, uint16_t code) - { - unsigned n = joysticks[fd].new_button(code, get_button_name(code)); - std::string name = (stringfmt() << "joystick" << jnum << "button" << n).str(); - buttons[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); - } - - void create_axis(int fd, unsigned jnum, uint16_t code, int32_t min, int32_t max) - { - unsigned n = joysticks[fd].new_axis(code, min, max, get_axis_name(code)); - std::string name = (stringfmt() << "joystick" << jnum << "axis" << n).str(); - if(min < 0) - axes[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); else - axes[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_PRESSURE_MP); - } - - void create_hat(int fd, unsigned jnum, uint16_t codeX, uint16_t codeY) - { - unsigned n = joysticks[fd].new_hat(codeX, codeY, 1, get_axis_name(codeX), get_axis_name(codeY)); - std::string name = (stringfmt() << "joystick" << jnum << "hat" << n).str(); - hats[std::make_pair(fd, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); + return (stringfmt() << "Unknown axis #" << code).str(); } bool read_one_input_event(int fd) { short x; - joystick_model& m = joysticks[fd]; struct input_event ev; int r = read(fd, &ev, sizeof(ev)); if(r < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) @@ -94,9 +57,9 @@ namespace return false; } if(ev.type == EV_KEY) - m.report_button(ev.code, ev.value != 0); + joystick_report_button(fd, ev.code, ev.value != 0); if(ev.type == EV_ABS) - m.report_axis(ev.code, ev.value); + joystick_report_axis(fd, ev.code, ev.value); return true; } @@ -138,13 +101,10 @@ namespace << std::endl; return false; } - joysticks[fd].name(namebuffer); - unsigned jnum = joystick_count++; - joystick_nums[fd] = jnum; - + joystick_create(fd, namebuffer); for(unsigned i = 0; i <= KEY_MAX; i++) { if(keys[i / div] & (1ULL << (i % div))) { - create_button(fd, jnum, i); + joystick_new_button(fd, i, get_button_name(i)); button_count++; } } @@ -158,16 +118,17 @@ namespace << fd << "): " << strerror(merrno) << std::endl; continue; } - create_axis(fd, jnum, i, V[1], V[2]); + if(V[1] < 0) + joystick_new_axis(fd, i, V[1], V[2], get_axis_name(i), + (V[1] < 0) ? keygroup::KT_AXIS_PAIR : keygroup::KT_PRESSURE_MP); axis_count++; } else if(i % 2 == 0) { - create_hat(fd, jnum, i, i + 1); + joystick_new_hat(fd, i, i + 1, 1, get_axis_name(i), get_axis_name(i + 1)); hat_count++; } } } - messages << "Found '" << namebuffer << "' (" << button_count << " buttons, " << axis_count - << " axes, " << hat_count << " hats)" << std::endl; + joystick_message(fd); return true; } @@ -197,14 +158,6 @@ namespace } closedir(d); } - - function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", - "Syntax: show-joysticks\nShow joystick data.\n", - []() throw(std::bad_alloc, std::runtime_error) { - for(auto i : joystick_nums) - messages << joysticks[i.first].compose_report(i.second) << std::endl; - }); - volatile bool quit_signaled = false; volatile bool quit_ack = false; } @@ -221,15 +174,7 @@ void joystick_plugin::quit() throw() { quit_signaled = true; while(!quit_ack); - for(auto i : joysticks) close(i.first); - for(auto i : axes) delete i.second; - for(auto i : buttons) delete i.second; - for(auto i : hats) delete i.second; - joysticks.clear(); - joystick_nums.clear(); - axes.clear(); - buttons.clear(); - hats.clear(); + joystick_quit(); } #define POLL_WAIT 20000 @@ -237,18 +182,9 @@ void joystick_plugin::quit() throw() void joystick_plugin::thread_fn() throw() { while(!quit_signaled) { - for(auto fd : joysticks) - while(read_one_input_event(fd.first)); - short x; - for(auto i : buttons) - if(joysticks[i.first.first].button(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : axes) - if(joysticks[i.first.first].axis(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : hats) - if(joysticks[i.first.first].hat(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); + for(auto fd : joystick_set()) + while(read_one_input_event(fd)); + joystick_flush(); usleep(POLL_WAIT); } quit_ack = true; @@ -257,6 +193,7 @@ void joystick_plugin::thread_fn() throw() void joystick_plugin::signal() throw() { quit_signaled = true; + while(!quit_ack); } const char* joystick_plugin::name = "Evdev joystick plugin"; diff --git a/src/platform/win32mm/joystick.cpp b/src/platform/win32mm/joystick.cpp index f92ad2cb..1c750950 100644 --- a/src/platform/win32mm/joystick.cpp +++ b/src/platform/win32mm/joystick.cpp @@ -1,10 +1,10 @@ #include "core/command.hpp" #include "core/framerate.hpp" +#include "core/joystick.hpp" #include "core/keymapper.hpp" #include "core/window.hpp" #include "library/minmax.hpp" #include "library/string.hpp" -#include "library/joyfun.hpp" #include #include @@ -19,86 +19,44 @@ namespace { - std::map joysticks; - std::map, keygroup*> axes; - std::map, keygroup*> buttons; - std::map, keygroup*> hats; volatile bool quit_signaled; volatile bool quit_ack; - const char* axisnames[] = {"X", "Y", "Z", "Rudder", "U", "V"}; const char* buttonnames[] = {"Button1", "Button2", "Button3", "Button4", "Button5", "Button6", "Button7", "Button8", "Button9", "Button10", "Button11", "Button12", "Button13", "Button14", "Button15", "Button16", "Button17", "Button18", "Button19", "Button20", "Button21", "Button22", "Button23", "Button24", "Button25", "Button26", "Button27", "Button28", "Button29", "Button30", "Button31", "Button32"}; - - void create_hat(unsigned i, unsigned j = 0) - { - unsigned n = joysticks[i].new_hat(j, "POV"); - std::string name = (stringfmt() << "joystick" << i << "hat" << n).str(); - hats[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); - } - - void create_button(unsigned i, unsigned j) - { - unsigned n = joysticks[i].new_button(j, buttonnames[j]); - std::string name = (stringfmt() << "joystick" << i << "button" << n).str(); - buttons[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); - } - - void create_axis(unsigned i, unsigned j, unsigned min, unsigned max) - { - unsigned n = joysticks[i].new_axis(j, min, max, axisnames[j]); - std::string name = (stringfmt() << "joystick" << i << "axis" << n).str(); - axes[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); - } - - void init_joysticks() - { - unsigned max_joysticks = joyGetNumDevs(); - if(!max_joysticks) - return; //No joystick support. - for(unsigned i = 0; i < max_joysticks; i++) { - JOYINFOEX info; - JOYCAPS caps; - info.dwSize = sizeof(info); - info.dwFlags = JOY_RETURNALL; - if(joyGetPosEx(i, &info) != JOYERR_NOERROR) - continue; //Not usable. - if(joyGetDevCaps(i, &caps, sizeof(caps)) != JOYERR_NOERROR) - continue; //Not usable. - messages << "Joystick #" << i << ": " << caps.szPname << " (by '" << caps.szOEMVxD << "')" - << std::endl; - joystick_model& m = joysticks[i]; - m.name(caps.szPname); - if(caps.wCaps & JOYCAPS_HASPOV) - create_hat(i); - for(unsigned j = 0; j < caps.wNumButtons && j < 32; j++) - create_button(i, j); - create_axis(i, 0, caps.wXmin, caps.wXmax); - create_axis(i, 1, caps.wYmin, caps.wYmax); - if(caps.wCaps & JOYCAPS_HASZ) create_axis(i, 2, caps.wZmin, caps.wZmax); - if(caps.wCaps & JOYCAPS_HASR) create_axis(i, 3, caps.wRmin, caps.wRmax); - if(caps.wCaps & JOYCAPS_HASU) create_axis(i, 4, caps.wUmin, caps.wUmax); - if(caps.wCaps & JOYCAPS_HASV) create_axis(i, 5, caps.wVmin, caps.wVmax); - if(caps.wCaps & JOYCAPS_HASPOV) - messages << "1 hat, "; - messages << m.axes() << " axes, " << m.buttons() << " buttons" << std::endl; - } - } - - function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", - "Syntax: show-joysticks\nShow joystick data.\n", - []() throw(std::bad_alloc, std::runtime_error) { - for(auto i : joysticks) - messages << i.second.compose_report(i.first) << std::endl; - }); } void joystick_plugin::init() throw() { - init_joysticks(); + unsigned max_joysticks = joyGetNumDevs(); + if(!max_joysticks) + return; //No joystick support. + for(unsigned i = 0; i < max_joysticks; i++) { + JOYINFOEX info; + JOYCAPS caps; + info.dwSize = sizeof(info); + info.dwFlags = JOY_RETURNALL; + if(joyGetPosEx(i, &info) != JOYERR_NOERROR) + continue; //Not usable. + if(joyGetDevCaps(i, &caps, sizeof(caps)) != JOYERR_NOERROR) + continue; //Not usable. + joystick_create(i, caps.szPname); + if(caps.wCaps & JOYCAPS_HASPOV) + joystick_new_hat(i, 0, "POV"); + for(unsigned j = 0; j < caps.wNumButtons && j < 32; j++) + joystick_new_button(i, j, buttonnames[j]); + keygroup::type t = keygroup::KT_AXIS_PAIR; + joystick_new_axis(i, 0, caps.wXmin, caps.wXmax, "X", t); + joystick_new_axis(i, 1, caps.wYmin, caps.wYmax, "Y", t); + if(caps.wCaps & JOYCAPS_HASZ) joystick_new_axis(i, 2, caps.wZmin, caps.wZmax, "Z", t); + if(caps.wCaps & JOYCAPS_HASR) joystick_new_axis(i, 3, caps.wRmin, caps.wRmax, "Rudder", t); + if(caps.wCaps & JOYCAPS_HASU) joystick_new_axis(i, 4, caps.wUmin, caps.wUmax, "U", t); + if(caps.wCaps & JOYCAPS_HASV) joystick_new_axis(i, 5, caps.wVmin, caps.wVmax, "V", t); + joystick_message(i); + } quit_ack = quit_signaled = false; } @@ -106,14 +64,7 @@ void joystick_plugin::quit() throw() { quit_signaled = true; while(!quit_ack); - for(auto i : joysticks) close(i.first); - for(auto i : axes) delete i.second; - for(auto i : buttons) delete i.second; - for(auto i : hats) delete i.second; - joysticks.clear(); - axes.clear(); - buttons.clear(); - hats.clear(); + joystick_quit(); } #define POLL_WAIT 20000 @@ -121,33 +72,23 @@ void joystick_plugin::quit() throw() void joystick_plugin::thread_fn() throw() { while(!quit_signaled) { - for(auto i : joysticks) { - joystick_model& m = joysticks[i.first]; + for(auto i : joystick_set()) { JOYINFOEX info; info.dwSize = sizeof(info); info.dwFlags = JOY_RETURNALL; - if(joyGetPosEx(i.first, &info) != JOYERR_NOERROR) + if(joyGetPosEx(i, &info) != JOYERR_NOERROR) continue; //Not usable. - m.report_pov(0, info.dwPOV); + joystick_report_pov(i, 0, info.dwPOV); for(unsigned j = 0; j < 32; j++) - m.report_button(j, (info.dwButtons >> j) & 1); - m.report_axis(0, info.dwXpos); - m.report_axis(1, info.dwYpos); - m.report_axis(2, info.dwZpos); - m.report_axis(3, info.dwRpos); - m.report_axis(4, info.dwUpos); - m.report_axis(5, info.dwVpos); + joystick_report_button(i, j, (info.dwButtons >> j) & 1); + joystick_report_axis(i, 0, info.dwXpos); + joystick_report_axis(i, 1, info.dwYpos); + joystick_report_axis(i, 2, info.dwZpos); + joystick_report_axis(i, 3, info.dwRpos); + joystick_report_axis(i, 4, info.dwUpos); + joystick_report_axis(i, 5, info.dwVpos); } - short x; - for(auto i : buttons) - if(joysticks[i.first.first].button(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : axes) - if(joysticks[i.first.first].axis(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : hats) - if(joysticks[i.first.first].hat(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); + joystick_flush(); usleep(POLL_WAIT); } quit_ack = true; @@ -156,6 +97,7 @@ void joystick_plugin::thread_fn() throw() void joystick_plugin::signal() throw() { quit_signaled = true; + while(!quit_ack); } const char* joystick_plugin::name = "Win32mm joystick plugin"; diff --git a/src/platform/wxwidgets/joystick.cpp b/src/platform/wxwidgets/joystick.cpp index 2cb23cf4..e753e020 100644 --- a/src/platform/wxwidgets/joystick.cpp +++ b/src/platform/wxwidgets/joystick.cpp @@ -2,10 +2,10 @@ #include "core/command.hpp" #include "core/framerate.hpp" #include "core/keymapper.hpp" +#include "core/joystick.hpp" #include "core/window.hpp" #include "library/minmax.hpp" #include "library/string.hpp" -#include "library/joyfun.hpp" #include #include @@ -21,146 +21,85 @@ namespace { - std::map joysticks; - std::map, keygroup*> axes; - std::map, keygroup*> buttons; - std::map, keygroup*> hats; - std::map jobjects; - volatile bool quit_signaled; - volatile bool quit_ack; - volatile bool ready = false; + volatile bool ready; - const char* axisnames[] = {"X", "Y", "Z", "Rudder", "U", "V"}; const char* buttonnames[] = {"Button1", "Button2", "Button3", "Button4", "Button5", "Button6", "Button7", "Button8", "Button9", "Button10", "Button11", "Button12", "Button13", "Button14", "Button15", "Button16", "Button17", "Button18", "Button19", "Button20", "Button21", "Button22", "Button23", "Button24", "Button25", "Button26", "Button27", "Button28", "Button29", "Button30", "Button31", "Button32"}; - void create_hat(unsigned i, unsigned j = 0) - { - unsigned n = joysticks[i].new_hat(j, "POV"); - std::string name = (stringfmt() << "joystick" << i << "hat" << n).str(); - hats[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_HAT); - } - - void create_button(unsigned i, unsigned j) - { - unsigned n = joysticks[i].new_button(j, buttonnames[j]); - std::string name = (stringfmt() << "joystick" << i << "button" << n).str(); - buttons[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_KEY); - } - - void create_axis(unsigned i, unsigned j, int min, int max) - { - unsigned n = joysticks[i].new_axis(j, min, max, axisnames[j]); - std::string name = (stringfmt() << "joystick" << i << "axis" << n).str(); - axes[std::make_pair(i, n)] = new keygroup(name, "joystick", keygroup::KT_AXIS_PAIR); - } - - void init_joysticks() - { - unsigned max_joysticks = wxJoystick::GetNumberJoysticks(); - if(!max_joysticks) - return; //No joystick support. - for(unsigned i = 0; i < max_joysticks; i++) { - wxJoystick* joy = new wxJoystick(i); - if(!joy->IsOk()) { - //Not usable. - delete joy; - continue; - } - jobjects[i] = joy; - joysticks[i].name(joy->GetProductName()); - messages << "Joystick #" << i << ": " << joy->GetProductName() << std::endl; - if(joy->HasPOV()) - create_hat(i); - for(unsigned j = 0; j < joy->GetNumberButtons() && j < 32; j++) - create_button(i, j); - create_axis(i, 0, joy->GetXMin(), joy->GetXMax()); - create_axis(i, 1, joy->GetYMin(), joy->GetYMax()); - if(joy->HasZ()) create_axis(i, 2, joy->GetZMin(), joy->GetZMax()); - if(joy->HasRudder()) create_axis(i, 3, joy->GetRudderMin(), joy->GetRudderMax()); - if(joy->HasU()) create_axis(i, 4, joy->GetUMin(), joy->GetUMax()); - if(joy->HasV()) create_axis(i, 5, joy->GetVMin(), joy->GetVMax()); - if(joy->HasPOV()) - messages << "1 hat, "; - messages << joysticks[i].axes() << " axes, " << joysticks[i].buttons() << " buttons" - << std::endl; - } - ready = true; - } - - void poll_joysticks() - { - if(!ready) - return; - for(auto i : jobjects) { - joystick_model& m = joysticks[i.first]; - wxJoystick& j = *i.second; - m.report_pov(0, j.GetPOVCTSPosition()); - uint32_t bmask = j.GetButtonState(); - for(unsigned j = 0; j < 32; j++) - m.report_button(j, (bmask >> j) & 1); - wxPoint xy = j.GetPosition(); - m.report_axis(0, xy.x); - m.report_axis(1, xy.y); - m.report_axis(2, j.GetZPosition()); - m.report_axis(3, j.GetRudderPosition()); - m.report_axis(4, j.GetUPosition()); - m.report_axis(5, j.GetVPosition()); - } - short x; - for(auto i : buttons) - if(joysticks[i.first.first].button(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : axes) - if(joysticks[i.first.first].axis(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - for(auto i : hats) - if(joysticks[i.first.first].hat(i.first.second, x)) - platform::queue(keypress(modifier_set(), *i.second, x)); - } - struct joystick_timer : public wxTimer { joystick_timer() { start(); } void start() { Start(POLL_WAIT / 1000); } void stop() { Stop(); } - void Notify() { poll_joysticks(); } + void Notify() + { + if(!ready) + return; + for(auto i : joystick_set()) { + wxJoystick& j = *reinterpret_cast(i); + joystick_report_pov(i, 0, j.GetPOVCTSPosition()); + uint32_t bmask = j.GetButtonState(); + for(unsigned j = 0; j < 32; j++) + joystick_report_button(i, j, (bmask >> j) & 1); + wxPoint xy = j.GetPosition(); + joystick_report_axis(i, 0, xy.x); + joystick_report_axis(i, 1, xy.y); + joystick_report_axis(i, 2, j.GetZPosition()); + joystick_report_axis(i, 3, j.GetRudderPosition()); + joystick_report_axis(i, 4, j.GetUPosition()); + joystick_report_axis(i, 5, j.GetVPosition()); + } + joystick_flush(); + } }* jtimer; - - function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", - "Syntax: show-joysticks\nShow joystick data.\n", - []() throw(std::bad_alloc, std::runtime_error) { - for(auto i : joysticks) - messages << i.second.compose_report(i.first) << std::endl; - }); } void joystick_plugin::init() throw() { - init_joysticks(); + unsigned max_joysticks = wxJoystick::GetNumberJoysticks(); + if(!max_joysticks) + return; //No joystick support. + for(unsigned i = 0; i < max_joysticks; i++) { + wxJoystick* joy = new wxJoystick(i); + if(!joy->IsOk()) { + //Not usable. + delete joy; + continue; + } + uint64_t jid = reinterpret_cast(joy); + joystick_create(jid, joy->GetProductName()); + if(joy->HasPOV()) + joystick_new_hat(jid, 0, "POV"); + for(unsigned j = 0; j < joy->GetNumberButtons() && j < 32; j++) + joystick_new_button(jid, j, buttonnames[j]); + keygroup::type t = keygroup::KT_AXIS_PAIR; + const char* R = "Rudder"; + joystick_new_axis(jid, 0, joy->GetXMin(), joy->GetXMax(), "X", t); + joystick_new_axis(jid, 1, joy->GetYMin(), joy->GetYMax(), "Y", t); + if(joy->HasZ()) joystick_new_axis(jid, 2, joy->GetZMin(), joy->GetZMax(), "Z", t); + if(joy->HasRudder()) joystick_new_axis(jid, 3, joy->GetRudderMin(), joy->GetRudderMax(), R, t); + if(joy->HasU()) joystick_new_axis(jid, 4, joy->GetUMin(), joy->GetUMax(), "U", t); + if(joy->HasV()) joystick_new_axis(jid, 5, joy->GetVMin(), joy->GetVMax(), "V", t); + joystick_message(jid); + } + ready = true; jtimer = new joystick_timer(); } void joystick_plugin::quit() throw() { - jtimer->stop(); + if(jtimer) + jtimer->stop(); delete jtimer; jtimer = NULL; ready = false; + for(auto i : joystick_set()) + delete reinterpret_cast(i); usleep(50000); - - for(auto i : jobjects) delete i.second; - for(auto i : axes) delete i.second; - for(auto i : buttons) delete i.second; - for(auto i : hats) delete i.second; - joysticks.clear(); - jobjects.clear(); - axes.clear(); - buttons.clear(); - hats.clear(); + joystick_quit(); } void joystick_plugin::thread_fn() throw() From 80964943a4ab0101a996345f3b0d250655989df6 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 13 Apr 2012 12:16:39 +0300 Subject: [PATCH 3/6] Evdev: Fix pressure-sensitive buttons not showing up --- src/platform/evdev/joystick.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platform/evdev/joystick.cpp b/src/platform/evdev/joystick.cpp index d215ce41..3927ca8f 100644 --- a/src/platform/evdev/joystick.cpp +++ b/src/platform/evdev/joystick.cpp @@ -118,7 +118,6 @@ namespace << fd << "): " << strerror(merrno) << std::endl; continue; } - if(V[1] < 0) joystick_new_axis(fd, i, V[1], V[2], get_axis_name(i), (V[1] < 0) ? keygroup::KT_AXIS_PAIR : keygroup::KT_PRESSURE_MP); axis_count++; From f0bfb5c83c4e4017cb70863b192cd41667c3ce84 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 13 Apr 2012 12:19:39 +0300 Subject: [PATCH 4/6] Print joystick driver name for show-joysticks --- src/core/joystick.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/joystick.cpp b/src/core/joystick.cpp index c32837eb..31854876 100644 --- a/src/core/joystick.cpp +++ b/src/core/joystick.cpp @@ -18,8 +18,11 @@ namespace function_ptr_command<> show_joysticks("show-joysticks", "Show joysticks", "Syntax: show-joysticks\nShow joystick data.\n", []() throw(std::bad_alloc, std::runtime_error) { + messages << "Driver: " << joystick_plugin::name << std::endl; + messages << "--------------------------------------" << std::endl; for(auto i : joynumbers) messages << joysticks[i.first].compose_report(i.second) << std::endl; + messages << "--------------------------------------" << std::endl; }); } From 4a2d7d0563e32f64ff2bd201a32ae729c6734064 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 13 Apr 2012 16:15:02 +0300 Subject: [PATCH 5/6] Evdev: Add BTN_TOOL_QUINTTAP --- src/platform/evdev/buttons.cpp | 3 +++ src/platform/evdev/buttons.tab | 1 + 2 files changed, 4 insertions(+) diff --git a/src/platform/evdev/buttons.cpp b/src/platform/evdev/buttons.cpp index 68d84d3b..0684b119 100644 --- a/src/platform/evdev/buttons.cpp +++ b/src/platform/evdev/buttons.cpp @@ -932,6 +932,9 @@ x[BTN_TOOL_TRIPLETAP] = "Button TOOL_TRIPLETAP"; #ifdef BTN_TOOL_QUADTAP x[BTN_TOOL_QUADTAP] = "Button TOOL_QUADTAP"; #endif +#ifdef BTN_TOOL_QUINTTAP +x[BTN_TOOL_QUINTTAP] = "Button TOOL_QUINTTAP"; +#endif #ifdef BTN_WHEEL x[BTN_WHEEL] = "Button WHEEL"; #endif diff --git a/src/platform/evdev/buttons.tab b/src/platform/evdev/buttons.tab index ccec7884..0a0b6122 100644 --- a/src/platform/evdev/buttons.tab +++ b/src/platform/evdev/buttons.tab @@ -309,6 +309,7 @@ BTN_STYLUS2 Button STYLUS2 BTN_TOOL_DOUBLETAP Button TOOL_DOUBLETAP BTN_TOOL_TRIPLETAP Button TOOL_TRIPLETAP BTN_TOOL_QUADTAP Button TOOL_QUADTAP +BTN_TOOL_QUINTTAP Button TOOL_QUINTTAP BTN_WHEEL Button WHEEL BTN_GEAR_DOWN Button GEAR_DOWN BTN_GEAR_UP Button GEAR_UP From f4a18b5d687f8b7f648cf8f97d9cb411bd167c2e Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 13 Apr 2012 17:04:07 +0300 Subject: [PATCH 6/6] Evdev: Move name tables to joystick.cpp --- src/platform/evdev/axes.cpp | 122 --- src/platform/evdev/axes.tab | 40 - src/platform/evdev/buttons.cpp | 1517 ------------------------------- src/platform/evdev/buttons.tab | 505 ---------- src/platform/evdev/joystick.cpp | 154 +++- src/platform/evdev/mktab.lua | 12 - 6 files changed, 145 insertions(+), 2205 deletions(-) delete mode 100644 src/platform/evdev/axes.cpp delete mode 100644 src/platform/evdev/axes.tab delete mode 100644 src/platform/evdev/buttons.cpp delete mode 100644 src/platform/evdev/buttons.tab delete mode 100644 src/platform/evdev/mktab.lua diff --git a/src/platform/evdev/axes.cpp b/src/platform/evdev/axes.cpp deleted file mode 100644 index eeda5164..00000000 --- a/src/platform/evdev/axes.cpp +++ /dev/null @@ -1,122 +0,0 @@ -extern "C" { -#include -} -void evdev_init_axes(const char** x) { -#ifdef ABS_X -x[ABS_X] = "X"; -#endif -#ifdef ABS_Y -x[ABS_Y] = "Y"; -#endif -#ifdef ABS_Z -x[ABS_Z] = "Z"; -#endif -#ifdef ABS_RX -x[ABS_RX] = "RX"; -#endif -#ifdef ABS_RY -x[ABS_RY] = "RY"; -#endif -#ifdef ABS_RZ -x[ABS_RZ] = "RZ"; -#endif -#ifdef ABS_THROTTLE -x[ABS_THROTTLE] = "THROTTLE"; -#endif -#ifdef ABS_RUDDER -x[ABS_RUDDER] = "RUDDER"; -#endif -#ifdef ABS_WHEEL -x[ABS_WHEEL] = "WHEEL"; -#endif -#ifdef ABS_GAS -x[ABS_GAS] = "GAS"; -#endif -#ifdef ABS_BRAKE -x[ABS_BRAKE] = "BRAKE"; -#endif -#ifdef ABS_HAT0X -x[ABS_HAT0X] = "HAT0X"; -#endif -#ifdef ABS_HAT0Y -x[ABS_HAT0Y] = "HAT0Y"; -#endif -#ifdef ABS_HAT1X -x[ABS_HAT1X] = "HAT1X"; -#endif -#ifdef ABS_HAT1Y -x[ABS_HAT1Y] = "HAT1Y"; -#endif -#ifdef ABS_HAT2X -x[ABS_HAT2X] = "HAT2X"; -#endif -#ifdef ABS_HAT2Y -x[ABS_HAT2Y] = "HAT2Y"; -#endif -#ifdef ABS_HAT3X -x[ABS_HAT3X] = "HAT3X"; -#endif -#ifdef ABS_HAT3Y -x[ABS_HAT3Y] = "HAT3Y"; -#endif -#ifdef ABS_PRESSURE -x[ABS_PRESSURE] = "PRESSURE"; -#endif -#ifdef ABS_DISTANCE -x[ABS_DISTANCE] = "DISTANCE"; -#endif -#ifdef ABS_TILT_X -x[ABS_TILT_X] = "TILT_X"; -#endif -#ifdef ABS_TILT_Y -x[ABS_TILT_Y] = "TILT_Y"; -#endif -#ifdef ABS_TOOL_WIDTH -x[ABS_TOOL_WIDTH] = "TOOL_WIDTH"; -#endif -#ifdef ABS_VOLUME -x[ABS_VOLUME] = "VOLUME"; -#endif -#ifdef ABS_MISC -x[ABS_MISC] = "MISC"; -#endif -#ifdef ABS_MT_SLOT -x[ABS_MT_SLOT] = "MT_SLOT"; -#endif -#ifdef ABS_MT_TOUCH_MAJOR -x[ABS_MT_TOUCH_MAJOR] = "MT_TOUCH_MAJOR"; -#endif -#ifdef ABS_MT_TOUCH_MINOR -x[ABS_MT_TOUCH_MINOR] = "MT_TOUCH_MINOR"; -#endif -#ifdef ABS_MT_WIDTH_MAJOR -x[ABS_MT_WIDTH_MAJOR] = "MT_WIDTH_MAJOR"; -#endif -#ifdef ABS_MT_WIDTH_MINOR -x[ABS_MT_WIDTH_MINOR] = "MT_WIDTH_MINOR"; -#endif -#ifdef ABS_MT_ORIENTATION -x[ABS_MT_ORIENTATION] = "MT_ORIENTATION"; -#endif -#ifdef ABS_MT_POSITION_X -x[ABS_MT_POSITION_X] = "MT_POSITION_X"; -#endif -#ifdef ABS_MT_POSITION_Y -x[ABS_MT_POSITION_Y] = "MT_POSITION_Y"; -#endif -#ifdef ABS_MT_TOOL_TYPE -x[ABS_MT_TOOL_TYPE] = "MT_TOOL_TYPE"; -#endif -#ifdef ABS_MT_BLOB_ID -x[ABS_MT_BLOB_ID] = "MT_BLOB_ID"; -#endif -#ifdef ABS_MT_TRACKING_ID -x[ABS_MT_TRACKING_ID] = "MT_TRACKING_ID"; -#endif -#ifdef ABS_MT_PRESSURE -x[ABS_MT_PRESSURE] = "MT_PRESSURE"; -#endif -#ifdef ABS_MT_DISTANCE -x[ABS_MT_DISTANCE] = "MT_DISTANCE"; -#endif -} diff --git a/src/platform/evdev/axes.tab b/src/platform/evdev/axes.tab deleted file mode 100644 index 774b6a43..00000000 --- a/src/platform/evdev/axes.tab +++ /dev/null @@ -1,40 +0,0 @@ -evdev_init_axes -ABS_X X -ABS_Y Y -ABS_Z Z -ABS_RX RX -ABS_RY RY -ABS_RZ RZ -ABS_THROTTLE THROTTLE -ABS_RUDDER RUDDER -ABS_WHEEL WHEEL -ABS_GAS GAS -ABS_BRAKE BRAKE -ABS_HAT0X HAT0X -ABS_HAT0Y HAT0Y -ABS_HAT1X HAT1X -ABS_HAT1Y HAT1Y -ABS_HAT2X HAT2X -ABS_HAT2Y HAT2Y -ABS_HAT3X HAT3X -ABS_HAT3Y HAT3Y -ABS_PRESSURE PRESSURE -ABS_DISTANCE DISTANCE -ABS_TILT_X TILT_X -ABS_TILT_Y TILT_Y -ABS_TOOL_WIDTH TOOL_WIDTH -ABS_VOLUME VOLUME -ABS_MISC MISC -ABS_MT_SLOT MT_SLOT -ABS_MT_TOUCH_MAJOR MT_TOUCH_MAJOR -ABS_MT_TOUCH_MINOR MT_TOUCH_MINOR -ABS_MT_WIDTH_MAJOR MT_WIDTH_MAJOR -ABS_MT_WIDTH_MINOR MT_WIDTH_MINOR -ABS_MT_ORIENTATION MT_ORIENTATION -ABS_MT_POSITION_X MT_POSITION_X -ABS_MT_POSITION_Y MT_POSITION_Y -ABS_MT_TOOL_TYPE MT_TOOL_TYPE -ABS_MT_BLOB_ID MT_BLOB_ID -ABS_MT_TRACKING_ID MT_TRACKING_ID -ABS_MT_PRESSURE MT_PRESSURE -ABS_MT_DISTANCE MT_DISTANCE diff --git a/src/platform/evdev/buttons.cpp b/src/platform/evdev/buttons.cpp deleted file mode 100644 index 0684b119..00000000 --- a/src/platform/evdev/buttons.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -extern "C" { -#include -} -void evdev_init_buttons(const char** x) { -#ifdef KEY_RESERVED -x[KEY_RESERVED] = "RESERVED"; -#endif -#ifdef KEY_ESC -x[KEY_ESC] = "ESC"; -#endif -#ifdef KEY_1 -x[KEY_1] = "1"; -#endif -#ifdef KEY_2 -x[KEY_2] = "2"; -#endif -#ifdef KEY_3 -x[KEY_3] = "3"; -#endif -#ifdef KEY_4 -x[KEY_4] = "4"; -#endif -#ifdef KEY_5 -x[KEY_5] = "5"; -#endif -#ifdef KEY_6 -x[KEY_6] = "6"; -#endif -#ifdef KEY_7 -x[KEY_7] = "7"; -#endif -#ifdef KEY_8 -x[KEY_8] = "8"; -#endif -#ifdef KEY_9 -x[KEY_9] = "9"; -#endif -#ifdef KEY_0 -x[KEY_0] = "0"; -#endif -#ifdef KEY_MINUS -x[KEY_MINUS] = "MINUS"; -#endif -#ifdef KEY_EQUAL -x[KEY_EQUAL] = "EQUAL"; -#endif -#ifdef KEY_BACKSPACE -x[KEY_BACKSPACE] = "BACKSPACE"; -#endif -#ifdef KEY_TAB -x[KEY_TAB] = "TAB"; -#endif -#ifdef KEY_Q -x[KEY_Q] = "Q"; -#endif -#ifdef KEY_W -x[KEY_W] = "W"; -#endif -#ifdef KEY_E -x[KEY_E] = "E"; -#endif -#ifdef KEY_R -x[KEY_R] = "R"; -#endif -#ifdef KEY_T -x[KEY_T] = "T"; -#endif -#ifdef KEY_Y -x[KEY_Y] = "Y"; -#endif -#ifdef KEY_U -x[KEY_U] = "U"; -#endif -#ifdef KEY_I -x[KEY_I] = "I"; -#endif -#ifdef KEY_O -x[KEY_O] = "O"; -#endif -#ifdef KEY_P -x[KEY_P] = "P"; -#endif -#ifdef KEY_LEFTBRACE -x[KEY_LEFTBRACE] = "LEFTBRACE"; -#endif -#ifdef KEY_RIGHTBRACE -x[KEY_RIGHTBRACE] = "RIGHTBRACE"; -#endif -#ifdef KEY_ENTER -x[KEY_ENTER] = "ENTER"; -#endif -#ifdef KEY_LEFTCTRL -x[KEY_LEFTCTRL] = "LEFTCTRL"; -#endif -#ifdef KEY_A -x[KEY_A] = "A"; -#endif -#ifdef KEY_S -x[KEY_S] = "S"; -#endif -#ifdef KEY_D -x[KEY_D] = "D"; -#endif -#ifdef KEY_F -x[KEY_F] = "F"; -#endif -#ifdef KEY_G -x[KEY_G] = "G"; -#endif -#ifdef KEY_H -x[KEY_H] = "H"; -#endif -#ifdef KEY_J -x[KEY_J] = "J"; -#endif -#ifdef KEY_K -x[KEY_K] = "K"; -#endif -#ifdef KEY_L -x[KEY_L] = "L"; -#endif -#ifdef KEY_SEMICOLON -x[KEY_SEMICOLON] = "SEMICOLON"; -#endif -#ifdef KEY_APOSTROPHE -x[KEY_APOSTROPHE] = "APOSTROPHE"; -#endif -#ifdef KEY_GRAVE -x[KEY_GRAVE] = "GRAVE"; -#endif -#ifdef KEY_LEFTSHIFT -x[KEY_LEFTSHIFT] = "LEFTSHIFT"; -#endif -#ifdef KEY_BACKSLASH -x[KEY_BACKSLASH] = "BACKSLASH"; -#endif -#ifdef KEY_Z -x[KEY_Z] = "Z"; -#endif -#ifdef KEY_X -x[KEY_X] = "X"; -#endif -#ifdef KEY_C -x[KEY_C] = "C"; -#endif -#ifdef KEY_V -x[KEY_V] = "V"; -#endif -#ifdef KEY_B -x[KEY_B] = "B"; -#endif -#ifdef KEY_N -x[KEY_N] = "N"; -#endif -#ifdef KEY_M -x[KEY_M] = "M"; -#endif -#ifdef KEY_COMMA -x[KEY_COMMA] = "COMMA"; -#endif -#ifdef KEY_DOT -x[KEY_DOT] = "DOT"; -#endif -#ifdef KEY_SLASH -x[KEY_SLASH] = "SLASH"; -#endif -#ifdef KEY_RIGHTSHIFT -x[KEY_RIGHTSHIFT] = "RIGHTSHIFT"; -#endif -#ifdef KEY_KPASTERISK -x[KEY_KPASTERISK] = "KPASTERISK"; -#endif -#ifdef KEY_LEFTALT -x[KEY_LEFTALT] = "LEFTALT"; -#endif -#ifdef KEY_SPACE -x[KEY_SPACE] = "SPACE"; -#endif -#ifdef KEY_CAPSLOCK -x[KEY_CAPSLOCK] = "CAPSLOCK"; -#endif -#ifdef KEY_F1 -x[KEY_F1] = "F1"; -#endif -#ifdef KEY_F2 -x[KEY_F2] = "F2"; -#endif -#ifdef KEY_F3 -x[KEY_F3] = "F3"; -#endif -#ifdef KEY_F4 -x[KEY_F4] = "F4"; -#endif -#ifdef KEY_F5 -x[KEY_F5] = "F5"; -#endif -#ifdef KEY_F6 -x[KEY_F6] = "F6"; -#endif -#ifdef KEY_F7 -x[KEY_F7] = "F7"; -#endif -#ifdef KEY_F8 -x[KEY_F8] = "F8"; -#endif -#ifdef KEY_F9 -x[KEY_F9] = "F9"; -#endif -#ifdef KEY_F10 -x[KEY_F10] = "F10"; -#endif -#ifdef KEY_NUMLOCK -x[KEY_NUMLOCK] = "NUMLOCK"; -#endif -#ifdef KEY_SCROLLLOCK -x[KEY_SCROLLLOCK] = "SCROLLLOCK"; -#endif -#ifdef KEY_KP7 -x[KEY_KP7] = "KP7"; -#endif -#ifdef KEY_KP8 -x[KEY_KP8] = "KP8"; -#endif -#ifdef KEY_KP9 -x[KEY_KP9] = "KP9"; -#endif -#ifdef KEY_KPMINUS -x[KEY_KPMINUS] = "KPMINUS"; -#endif -#ifdef KEY_KP4 -x[KEY_KP4] = "KP4"; -#endif -#ifdef KEY_KP5 -x[KEY_KP5] = "KP5"; -#endif -#ifdef KEY_KP6 -x[KEY_KP6] = "KP6"; -#endif -#ifdef KEY_KPPLUS -x[KEY_KPPLUS] = "KPPLUS"; -#endif -#ifdef KEY_KP1 -x[KEY_KP1] = "KP1"; -#endif -#ifdef KEY_KP2 -x[KEY_KP2] = "KP2"; -#endif -#ifdef KEY_KP3 -x[KEY_KP3] = "KP3"; -#endif -#ifdef KEY_KP0 -x[KEY_KP0] = "KP0"; -#endif -#ifdef KEY_KPDOT -x[KEY_KPDOT] = "KPDOT"; -#endif -#ifdef KEY_ZENKAKUHANKAKU -x[KEY_ZENKAKUHANKAKU] = "ZENKAKUHANKAKU"; -#endif -#ifdef KEY_102ND -x[KEY_102ND] = "102ND"; -#endif -#ifdef KEY_F11 -x[KEY_F11] = "F11"; -#endif -#ifdef KEY_F12 -x[KEY_F12] = "F12"; -#endif -#ifdef KEY_RO -x[KEY_RO] = "RO"; -#endif -#ifdef KEY_KATAKANA -x[KEY_KATAKANA] = "KATAKANA"; -#endif -#ifdef KEY_HIRAGANA -x[KEY_HIRAGANA] = "HIRAGANA"; -#endif -#ifdef KEY_HENKAN -x[KEY_HENKAN] = "HENKAN"; -#endif -#ifdef KEY_KATAKANAHIRAGANA -x[KEY_KATAKANAHIRAGANA] = "KATAKANAHIRAGANA"; -#endif -#ifdef KEY_MUHENKAN -x[KEY_MUHENKAN] = "MUHENKAN"; -#endif -#ifdef KEY_KPJPCOMMA -x[KEY_KPJPCOMMA] = "KPJPCOMMA"; -#endif -#ifdef KEY_KPENTER -x[KEY_KPENTER] = "KPENTER"; -#endif -#ifdef KEY_RIGHTCTRL -x[KEY_RIGHTCTRL] = "RIGHTCTRL"; -#endif -#ifdef KEY_KPSLASH -x[KEY_KPSLASH] = "KPSLASH"; -#endif -#ifdef KEY_SYSRQ -x[KEY_SYSRQ] = "SYSRQ"; -#endif -#ifdef KEY_RIGHTALT -x[KEY_RIGHTALT] = "RIGHTALT"; -#endif -#ifdef KEY_LINEFEED -x[KEY_LINEFEED] = "LINEFEED"; -#endif -#ifdef KEY_HOME -x[KEY_HOME] = "HOME"; -#endif -#ifdef KEY_UP -x[KEY_UP] = "UP"; -#endif -#ifdef KEY_PAGEUP -x[KEY_PAGEUP] = "PAGEUP"; -#endif -#ifdef KEY_LEFT -x[KEY_LEFT] = "LEFT"; -#endif -#ifdef KEY_RIGHT -x[KEY_RIGHT] = "RIGHT"; -#endif -#ifdef KEY_END -x[KEY_END] = "END"; -#endif -#ifdef KEY_DOWN -x[KEY_DOWN] = "DOWN"; -#endif -#ifdef KEY_PAGEDOWN -x[KEY_PAGEDOWN] = "PAGEDOWN"; -#endif -#ifdef KEY_INSERT -x[KEY_INSERT] = "INSERT"; -#endif -#ifdef KEY_DELETE -x[KEY_DELETE] = "DELETE"; -#endif -#ifdef KEY_MACRO -x[KEY_MACRO] = "MACRO"; -#endif -#ifdef KEY_MUTE -x[KEY_MUTE] = "MUTE"; -#endif -#ifdef KEY_VOLUMEDOWN -x[KEY_VOLUMEDOWN] = "VOLUMEDOWN"; -#endif -#ifdef KEY_VOLUMEUP -x[KEY_VOLUMEUP] = "VOLUMEUP"; -#endif -#ifdef KEY_POWER -x[KEY_POWER] = "POWER"; -#endif -#ifdef KEY_KPEQUAL -x[KEY_KPEQUAL] = "KPEQUAL"; -#endif -#ifdef KEY_KPPLUSMINUS -x[KEY_KPPLUSMINUS] = "KPPLUSMINUS"; -#endif -#ifdef KEY_PAUSE -x[KEY_PAUSE] = "PAUSE"; -#endif -#ifdef KEY_SCALE -x[KEY_SCALE] = "SCALE"; -#endif -#ifdef KEY_KPCOMMA -x[KEY_KPCOMMA] = "KPCOMMA"; -#endif -#ifdef KEY_HANGEUL -x[KEY_HANGEUL] = "HANGEUL"; -#endif -#ifdef KEY_HANGUEL -x[KEY_HANGUEL] = "HANGUEL"; -#endif -#ifdef KEY_HANJA -x[KEY_HANJA] = "HANJA"; -#endif -#ifdef KEY_YEN -x[KEY_YEN] = "YEN"; -#endif -#ifdef KEY_LEFTMETA -x[KEY_LEFTMETA] = "LEFTMETA"; -#endif -#ifdef KEY_RIGHTMETA -x[KEY_RIGHTMETA] = "RIGHTMETA"; -#endif -#ifdef KEY_COMPOSE -x[KEY_COMPOSE] = "COMPOSE"; -#endif -#ifdef KEY_STOP -x[KEY_STOP] = "STOP"; -#endif -#ifdef KEY_AGAIN -x[KEY_AGAIN] = "AGAIN"; -#endif -#ifdef KEY_PROPS -x[KEY_PROPS] = "PROPS"; -#endif -#ifdef KEY_UNDO -x[KEY_UNDO] = "UNDO"; -#endif -#ifdef KEY_FRONT -x[KEY_FRONT] = "FRONT"; -#endif -#ifdef KEY_COPY -x[KEY_COPY] = "COPY"; -#endif -#ifdef KEY_OPEN -x[KEY_OPEN] = "OPEN"; -#endif -#ifdef KEY_PASTE -x[KEY_PASTE] = "PASTE"; -#endif -#ifdef KEY_FIND -x[KEY_FIND] = "FIND"; -#endif -#ifdef KEY_CUT -x[KEY_CUT] = "CUT"; -#endif -#ifdef KEY_HELP -x[KEY_HELP] = "HELP"; -#endif -#ifdef KEY_MENU -x[KEY_MENU] = "MENU"; -#endif -#ifdef KEY_CALC -x[KEY_CALC] = "CALC"; -#endif -#ifdef KEY_SETUP -x[KEY_SETUP] = "SETUP"; -#endif -#ifdef KEY_SLEEP -x[KEY_SLEEP] = "SLEEP"; -#endif -#ifdef KEY_WAKEUP -x[KEY_WAKEUP] = "WAKEUP"; -#endif -#ifdef KEY_FILE -x[KEY_FILE] = "FILE"; -#endif -#ifdef KEY_SENDFILE -x[KEY_SENDFILE] = "SENDFILE"; -#endif -#ifdef KEY_DELETEFILE -x[KEY_DELETEFILE] = "DELETEFILE"; -#endif -#ifdef KEY_XFER -x[KEY_XFER] = "XFER"; -#endif -#ifdef KEY_PROG1 -x[KEY_PROG1] = "PROG1"; -#endif -#ifdef KEY_PROG2 -x[KEY_PROG2] = "PROG2"; -#endif -#ifdef KEY_WWW -x[KEY_WWW] = "WWW"; -#endif -#ifdef KEY_MSDOS -x[KEY_MSDOS] = "MSDOS"; -#endif -#ifdef KEY_COFFEE -x[KEY_COFFEE] = "COFFEE"; -#endif -#ifdef KEY_SCREENLOCK -x[KEY_SCREENLOCK] = "SCREENLOCK"; -#endif -#ifdef KEY_DIRECTION -x[KEY_DIRECTION] = "DIRECTION"; -#endif -#ifdef KEY_CYCLEWINDOWS -x[KEY_CYCLEWINDOWS] = "CYCLEWINDOWS"; -#endif -#ifdef KEY_MAIL -x[KEY_MAIL] = "MAIL"; -#endif -#ifdef KEY_BOOKMARKS -x[KEY_BOOKMARKS] = "BOOKMARKS"; -#endif -#ifdef KEY_COMPUTER -x[KEY_COMPUTER] = "COMPUTER"; -#endif -#ifdef KEY_BACK -x[KEY_BACK] = "BACK"; -#endif -#ifdef KEY_FORWARD -x[KEY_FORWARD] = "FORWARD"; -#endif -#ifdef KEY_CLOSECD -x[KEY_CLOSECD] = "CLOSECD"; -#endif -#ifdef KEY_EJECTCD -x[KEY_EJECTCD] = "EJECTCD"; -#endif -#ifdef KEY_EJECTCLOSECD -x[KEY_EJECTCLOSECD] = "EJECTCLOSECD"; -#endif -#ifdef KEY_NEXTSONG -x[KEY_NEXTSONG] = "NEXTSONG"; -#endif -#ifdef KEY_PLAYPAUSE -x[KEY_PLAYPAUSE] = "PLAYPAUSE"; -#endif -#ifdef KEY_PREVIOUSSONG -x[KEY_PREVIOUSSONG] = "PREVIOUSSONG"; -#endif -#ifdef KEY_STOPCD -x[KEY_STOPCD] = "STOPCD"; -#endif -#ifdef KEY_RECORD -x[KEY_RECORD] = "RECORD"; -#endif -#ifdef KEY_REWIND -x[KEY_REWIND] = "REWIND"; -#endif -#ifdef KEY_PHONE -x[KEY_PHONE] = "PHONE"; -#endif -#ifdef KEY_ISO -x[KEY_ISO] = "ISO"; -#endif -#ifdef KEY_CONFIG -x[KEY_CONFIG] = "CONFIG"; -#endif -#ifdef KEY_HOMEPAGE -x[KEY_HOMEPAGE] = "HOMEPAGE"; -#endif -#ifdef KEY_REFRESH -x[KEY_REFRESH] = "REFRESH"; -#endif -#ifdef KEY_EXIT -x[KEY_EXIT] = "EXIT"; -#endif -#ifdef KEY_MOVE -x[KEY_MOVE] = "MOVE"; -#endif -#ifdef KEY_EDIT -x[KEY_EDIT] = "EDIT"; -#endif -#ifdef KEY_SCROLLUP -x[KEY_SCROLLUP] = "SCROLLUP"; -#endif -#ifdef KEY_SCROLLDOWN -x[KEY_SCROLLDOWN] = "SCROLLDOWN"; -#endif -#ifdef KEY_KPLEFTPAREN -x[KEY_KPLEFTPAREN] = "KPLEFTPAREN"; -#endif -#ifdef KEY_KPRIGHTPAREN -x[KEY_KPRIGHTPAREN] = "KPRIGHTPAREN"; -#endif -#ifdef KEY_NEW -x[KEY_NEW] = "NEW"; -#endif -#ifdef KEY_REDO -x[KEY_REDO] = "REDO"; -#endif -#ifdef KEY_F13 -x[KEY_F13] = "F13"; -#endif -#ifdef KEY_F14 -x[KEY_F14] = "F14"; -#endif -#ifdef KEY_F15 -x[KEY_F15] = "F15"; -#endif -#ifdef KEY_F16 -x[KEY_F16] = "F16"; -#endif -#ifdef KEY_F17 -x[KEY_F17] = "F17"; -#endif -#ifdef KEY_F18 -x[KEY_F18] = "F18"; -#endif -#ifdef KEY_F19 -x[KEY_F19] = "F19"; -#endif -#ifdef KEY_F20 -x[KEY_F20] = "F20"; -#endif -#ifdef KEY_F21 -x[KEY_F21] = "F21"; -#endif -#ifdef KEY_F22 -x[KEY_F22] = "F22"; -#endif -#ifdef KEY_F23 -x[KEY_F23] = "F23"; -#endif -#ifdef KEY_F24 -x[KEY_F24] = "F24"; -#endif -#ifdef KEY_PLAYCD -x[KEY_PLAYCD] = "PLAYCD"; -#endif -#ifdef KEY_PAUSECD -x[KEY_PAUSECD] = "PAUSECD"; -#endif -#ifdef KEY_PROG3 -x[KEY_PROG3] = "PROG3"; -#endif -#ifdef KEY_PROG4 -x[KEY_PROG4] = "PROG4"; -#endif -#ifdef KEY_DASHBOARD -x[KEY_DASHBOARD] = "DASHBOARD"; -#endif -#ifdef KEY_SUSPEND -x[KEY_SUSPEND] = "SUSPEND"; -#endif -#ifdef KEY_CLOSE -x[KEY_CLOSE] = "CLOSE"; -#endif -#ifdef KEY_PLAY -x[KEY_PLAY] = "PLAY"; -#endif -#ifdef KEY_FASTFORWARD -x[KEY_FASTFORWARD] = "FASTFORWARD"; -#endif -#ifdef KEY_BASSBOOST -x[KEY_BASSBOOST] = "BASSBOOST"; -#endif -#ifdef KEY_PRINT -x[KEY_PRINT] = "PRINT"; -#endif -#ifdef KEY_HP -x[KEY_HP] = "HP"; -#endif -#ifdef KEY_CAMERA -x[KEY_CAMERA] = "CAMERA"; -#endif -#ifdef KEY_SOUND -x[KEY_SOUND] = "SOUND"; -#endif -#ifdef KEY_QUESTION -x[KEY_QUESTION] = "QUESTION"; -#endif -#ifdef KEY_EMAIL -x[KEY_EMAIL] = "EMAIL"; -#endif -#ifdef KEY_CHAT -x[KEY_CHAT] = "CHAT"; -#endif -#ifdef KEY_SEARCH -x[KEY_SEARCH] = "SEARCH"; -#endif -#ifdef KEY_CONNECT -x[KEY_CONNECT] = "CONNECT"; -#endif -#ifdef KEY_FINANCE -x[KEY_FINANCE] = "FINANCE"; -#endif -#ifdef KEY_SPORT -x[KEY_SPORT] = "SPORT"; -#endif -#ifdef KEY_SHOP -x[KEY_SHOP] = "SHOP"; -#endif -#ifdef KEY_ALTERASE -x[KEY_ALTERASE] = "ALTERASE"; -#endif -#ifdef KEY_CANCEL -x[KEY_CANCEL] = "CANCEL"; -#endif -#ifdef KEY_BRIGHTNESSDOWN -x[KEY_BRIGHTNESSDOWN] = "BRIGHTNESSDOWN"; -#endif -#ifdef KEY_BRIGHTNESSUP -x[KEY_BRIGHTNESSUP] = "BRIGHTNESSUP"; -#endif -#ifdef KEY_MEDIA -x[KEY_MEDIA] = "MEDIA"; -#endif -#ifdef KEY_SWITCHVIDEOMODE -x[KEY_SWITCHVIDEOMODE] = "SWITCHVIDEOMODE"; -#endif -#ifdef KEY_KBDILLUMTOGGLE -x[KEY_KBDILLUMTOGGLE] = "KBDILLUMTOGGLE"; -#endif -#ifdef KEY_KBDILLUMDOWN -x[KEY_KBDILLUMDOWN] = "KBDILLUMDOWN"; -#endif -#ifdef KEY_KBDILLUMUP -x[KEY_KBDILLUMUP] = "KBDILLUMUP"; -#endif -#ifdef KEY_SEND -x[KEY_SEND] = "SEND"; -#endif -#ifdef KEY_REPLY -x[KEY_REPLY] = "REPLY"; -#endif -#ifdef KEY_FORWARDMAIL -x[KEY_FORWARDMAIL] = "FORWARDMAIL"; -#endif -#ifdef KEY_SAVE -x[KEY_SAVE] = "SAVE"; -#endif -#ifdef KEY_DOCUMENTS -x[KEY_DOCUMENTS] = "DOCUMENTS"; -#endif -#ifdef KEY_BATTERY -x[KEY_BATTERY] = "BATTERY"; -#endif -#ifdef KEY_BLUETOOTH -x[KEY_BLUETOOTH] = "BLUETOOTH"; -#endif -#ifdef KEY_WLAN -x[KEY_WLAN] = "WLAN"; -#endif -#ifdef KEY_UWB -x[KEY_UWB] = "UWB"; -#endif -#ifdef KEY_UNKNOWN -x[KEY_UNKNOWN] = "UNKNOWN"; -#endif -#ifdef KEY_VIDEO_NEXT -x[KEY_VIDEO_NEXT] = "VIDEO_NEXT"; -#endif -#ifdef KEY_VIDEO_PREV -x[KEY_VIDEO_PREV] = "VIDEO_PREV"; -#endif -#ifdef KEY_BRIGHTNESS_CYCLE -x[KEY_BRIGHTNESS_CYCLE] = "BRIGHTNESS_CYCLE"; -#endif -#ifdef KEY_BRIGHTNESS_ZERO -x[KEY_BRIGHTNESS_ZERO] = "BRIGHTNESS_ZERO"; -#endif -#ifdef KEY_DISPLAY_OFF -x[KEY_DISPLAY_OFF] = "DISPLAY_OFF"; -#endif -#ifdef KEY_WIMAX -x[KEY_WIMAX] = "WIMAX"; -#endif -#ifdef KEY_RFKILL -x[KEY_RFKILL] = "RFKILL"; -#endif -#ifdef KEY_MICMUTE -x[KEY_MICMUTE] = "MICMUTE"; -#endif -#ifdef BTN_MISC -x[BTN_MISC] = "Button MISC"; -#endif -#ifdef BTN_0 -x[BTN_0] = "Button 0"; -#endif -#ifdef BTN_1 -x[BTN_1] = "Button 1"; -#endif -#ifdef BTN_2 -x[BTN_2] = "Button 2"; -#endif -#ifdef BTN_3 -x[BTN_3] = "Button 3"; -#endif -#ifdef BTN_4 -x[BTN_4] = "Button 4"; -#endif -#ifdef BTN_5 -x[BTN_5] = "Button 5"; -#endif -#ifdef BTN_6 -x[BTN_6] = "Button 6"; -#endif -#ifdef BTN_7 -x[BTN_7] = "Button 7"; -#endif -#ifdef BTN_8 -x[BTN_8] = "Button 8"; -#endif -#ifdef BTN_9 -x[BTN_9] = "Button 9"; -#endif -#ifdef BTN_MOUSE -x[BTN_MOUSE] = "Button MOUSE"; -#endif -#ifdef BTN_LEFT -x[BTN_LEFT] = "Button LEFT"; -#endif -#ifdef BTN_RIGHT -x[BTN_RIGHT] = "Button RIGHT"; -#endif -#ifdef BTN_MIDDLE -x[BTN_MIDDLE] = "Button MIDDLE"; -#endif -#ifdef BTN_SIDE -x[BTN_SIDE] = "Button SIDE"; -#endif -#ifdef BTN_EXTRA -x[BTN_EXTRA] = "Button EXTRA"; -#endif -#ifdef BTN_FORWARD -x[BTN_FORWARD] = "Button FORWARD"; -#endif -#ifdef BTN_BACK -x[BTN_BACK] = "Button BACK"; -#endif -#ifdef BTN_TASK -x[BTN_TASK] = "Button TASK"; -#endif -#ifdef BTN_JOYSTICK -x[BTN_JOYSTICK] = "Button JOYSTICK"; -#endif -#ifdef BTN_TRIGGER -x[BTN_TRIGGER] = "Button TRIGGER"; -#endif -#ifdef BTN_THUMB -x[BTN_THUMB] = "Button THUMB"; -#endif -#ifdef BTN_THUMB2 -x[BTN_THUMB2] = "Button THUMB2"; -#endif -#ifdef BTN_TOP -x[BTN_TOP] = "Button TOP"; -#endif -#ifdef BTN_TOP2 -x[BTN_TOP2] = "Button TOP2"; -#endif -#ifdef BTN_PINKIE -x[BTN_PINKIE] = "Button PINKIE"; -#endif -#ifdef BTN_BASE -x[BTN_BASE] = "Button BASE"; -#endif -#ifdef BTN_BASE2 -x[BTN_BASE2] = "Button BASE2"; -#endif -#ifdef BTN_BASE3 -x[BTN_BASE3] = "Button BASE3"; -#endif -#ifdef BTN_BASE4 -x[BTN_BASE4] = "Button BASE4"; -#endif -#ifdef BTN_BASE5 -x[BTN_BASE5] = "Button BASE5"; -#endif -#ifdef BTN_BASE6 -x[BTN_BASE6] = "Button BASE6"; -#endif -#ifdef BTN_DEAD -x[BTN_DEAD] = "Button DEAD"; -#endif -#ifdef BTN_GAMEPAD -x[BTN_GAMEPAD] = "Button GAMEPAD"; -#endif -#ifdef BTN_A -x[BTN_A] = "Button A"; -#endif -#ifdef BTN_B -x[BTN_B] = "Button B"; -#endif -#ifdef BTN_C -x[BTN_C] = "Button C"; -#endif -#ifdef BTN_X -x[BTN_X] = "Button X"; -#endif -#ifdef BTN_Y -x[BTN_Y] = "Button Y"; -#endif -#ifdef BTN_Z -x[BTN_Z] = "Button Z"; -#endif -#ifdef BTN_TL -x[BTN_TL] = "Button TL"; -#endif -#ifdef BTN_TR -x[BTN_TR] = "Button TR"; -#endif -#ifdef BTN_TL2 -x[BTN_TL2] = "Button TL2"; -#endif -#ifdef BTN_TR2 -x[BTN_TR2] = "Button TR2"; -#endif -#ifdef BTN_SELECT -x[BTN_SELECT] = "Button SELECT"; -#endif -#ifdef BTN_START -x[BTN_START] = "Button START"; -#endif -#ifdef BTN_MODE -x[BTN_MODE] = "Button MODE"; -#endif -#ifdef BTN_THUMBL -x[BTN_THUMBL] = "Button THUMBL"; -#endif -#ifdef BTN_THUMBR -x[BTN_THUMBR] = "Button THUMBR"; -#endif -#ifdef BTN_DIGI -x[BTN_DIGI] = "Button DIGI"; -#endif -#ifdef BTN_TOOL_PEN -x[BTN_TOOL_PEN] = "Button TOOL_PEN"; -#endif -#ifdef BTN_TOOL_RUBBER -x[BTN_TOOL_RUBBER] = "Button TOOL_RUBBER"; -#endif -#ifdef BTN_TOOL_BRUSH -x[BTN_TOOL_BRUSH] = "Button TOOL_BRUSH"; -#endif -#ifdef BTN_TOOL_PENCIL -x[BTN_TOOL_PENCIL] = "Button TOOL_PENCIL"; -#endif -#ifdef BTN_TOOL_AIRBRUSH -x[BTN_TOOL_AIRBRUSH] = "Button TOOL_AIRBRUSH"; -#endif -#ifdef BTN_TOOL_FINGER -x[BTN_TOOL_FINGER] = "Button TOOL_FINGER"; -#endif -#ifdef BTN_TOOL_MOUSE -x[BTN_TOOL_MOUSE] = "Button TOOL_MOUSE"; -#endif -#ifdef BTN_TOOL_LENS -x[BTN_TOOL_LENS] = "Button TOOL_LENS"; -#endif -#ifdef BTN_TOUCH -x[BTN_TOUCH] = "Button TOUCH"; -#endif -#ifdef BTN_STYLUS -x[BTN_STYLUS] = "Button STYLUS"; -#endif -#ifdef BTN_STYLUS2 -x[BTN_STYLUS2] = "Button STYLUS2"; -#endif -#ifdef BTN_TOOL_DOUBLETAP -x[BTN_TOOL_DOUBLETAP] = "Button TOOL_DOUBLETAP"; -#endif -#ifdef BTN_TOOL_TRIPLETAP -x[BTN_TOOL_TRIPLETAP] = "Button TOOL_TRIPLETAP"; -#endif -#ifdef BTN_TOOL_QUADTAP -x[BTN_TOOL_QUADTAP] = "Button TOOL_QUADTAP"; -#endif -#ifdef BTN_TOOL_QUINTTAP -x[BTN_TOOL_QUINTTAP] = "Button TOOL_QUINTTAP"; -#endif -#ifdef BTN_WHEEL -x[BTN_WHEEL] = "Button WHEEL"; -#endif -#ifdef BTN_GEAR_DOWN -x[BTN_GEAR_DOWN] = "Button GEAR_DOWN"; -#endif -#ifdef BTN_GEAR_UP -x[BTN_GEAR_UP] = "Button GEAR_UP"; -#endif -#ifdef KEY_OK -x[KEY_OK] = "OK"; -#endif -#ifdef KEY_SELECT -x[KEY_SELECT] = "SELECT"; -#endif -#ifdef KEY_GOTO -x[KEY_GOTO] = "GOTO"; -#endif -#ifdef KEY_CLEAR -x[KEY_CLEAR] = "CLEAR"; -#endif -#ifdef KEY_POWER2 -x[KEY_POWER2] = "POWER2"; -#endif -#ifdef KEY_OPTION -x[KEY_OPTION] = "OPTION"; -#endif -#ifdef KEY_INFO -x[KEY_INFO] = "INFO"; -#endif -#ifdef KEY_TIME -x[KEY_TIME] = "TIME"; -#endif -#ifdef KEY_VENDOR -x[KEY_VENDOR] = "VENDOR"; -#endif -#ifdef KEY_ARCHIVE -x[KEY_ARCHIVE] = "ARCHIVE"; -#endif -#ifdef KEY_PROGRAM -x[KEY_PROGRAM] = "PROGRAM"; -#endif -#ifdef KEY_CHANNEL -x[KEY_CHANNEL] = "CHANNEL"; -#endif -#ifdef KEY_FAVORITES -x[KEY_FAVORITES] = "FAVORITES"; -#endif -#ifdef KEY_EPG -x[KEY_EPG] = "EPG"; -#endif -#ifdef KEY_PVR -x[KEY_PVR] = "PVR"; -#endif -#ifdef KEY_MHP -x[KEY_MHP] = "MHP"; -#endif -#ifdef KEY_LANGUAGE -x[KEY_LANGUAGE] = "LANGUAGE"; -#endif -#ifdef KEY_TITLE -x[KEY_TITLE] = "TITLE"; -#endif -#ifdef KEY_SUBTITLE -x[KEY_SUBTITLE] = "SUBTITLE"; -#endif -#ifdef KEY_ANGLE -x[KEY_ANGLE] = "ANGLE"; -#endif -#ifdef KEY_ZOOM -x[KEY_ZOOM] = "ZOOM"; -#endif -#ifdef KEY_MODE -x[KEY_MODE] = "MODE"; -#endif -#ifdef KEY_KEYBOARD -x[KEY_KEYBOARD] = "KEYBOARD"; -#endif -#ifdef KEY_SCREEN -x[KEY_SCREEN] = "SCREEN"; -#endif -#ifdef KEY_PC -x[KEY_PC] = "PC"; -#endif -#ifdef KEY_TV -x[KEY_TV] = "TV"; -#endif -#ifdef KEY_TV2 -x[KEY_TV2] = "TV2"; -#endif -#ifdef KEY_VCR -x[KEY_VCR] = "VCR"; -#endif -#ifdef KEY_VCR2 -x[KEY_VCR2] = "VCR2"; -#endif -#ifdef KEY_SAT -x[KEY_SAT] = "SAT"; -#endif -#ifdef KEY_SAT2 -x[KEY_SAT2] = "SAT2"; -#endif -#ifdef KEY_CD -x[KEY_CD] = "CD"; -#endif -#ifdef KEY_TAPE -x[KEY_TAPE] = "TAPE"; -#endif -#ifdef KEY_RADIO -x[KEY_RADIO] = "RADIO"; -#endif -#ifdef KEY_TUNER -x[KEY_TUNER] = "TUNER"; -#endif -#ifdef KEY_PLAYER -x[KEY_PLAYER] = "PLAYER"; -#endif -#ifdef KEY_TEXT -x[KEY_TEXT] = "TEXT"; -#endif -#ifdef KEY_DVD -x[KEY_DVD] = "DVD"; -#endif -#ifdef KEY_AUX -x[KEY_AUX] = "AUX"; -#endif -#ifdef KEY_MP3 -x[KEY_MP3] = "MP3"; -#endif -#ifdef KEY_AUDIO -x[KEY_AUDIO] = "AUDIO"; -#endif -#ifdef KEY_VIDEO -x[KEY_VIDEO] = "VIDEO"; -#endif -#ifdef KEY_DIRECTORY -x[KEY_DIRECTORY] = "DIRECTORY"; -#endif -#ifdef KEY_LIST -x[KEY_LIST] = "LIST"; -#endif -#ifdef KEY_MEMO -x[KEY_MEMO] = "MEMO"; -#endif -#ifdef KEY_CALENDAR -x[KEY_CALENDAR] = "CALENDAR"; -#endif -#ifdef KEY_RED -x[KEY_RED] = "RED"; -#endif -#ifdef KEY_GREEN -x[KEY_GREEN] = "GREEN"; -#endif -#ifdef KEY_YELLOW -x[KEY_YELLOW] = "YELLOW"; -#endif -#ifdef KEY_BLUE -x[KEY_BLUE] = "BLUE"; -#endif -#ifdef KEY_CHANNELUP -x[KEY_CHANNELUP] = "CHANNELUP"; -#endif -#ifdef KEY_CHANNELDOWN -x[KEY_CHANNELDOWN] = "CHANNELDOWN"; -#endif -#ifdef KEY_FIRST -x[KEY_FIRST] = "FIRST"; -#endif -#ifdef KEY_LAST -x[KEY_LAST] = "LAST"; -#endif -#ifdef KEY_AB -x[KEY_AB] = "AB"; -#endif -#ifdef KEY_NEXT -x[KEY_NEXT] = "NEXT"; -#endif -#ifdef KEY_RESTART -x[KEY_RESTART] = "RESTART"; -#endif -#ifdef KEY_SLOW -x[KEY_SLOW] = "SLOW"; -#endif -#ifdef KEY_SHUFFLE -x[KEY_SHUFFLE] = "SHUFFLE"; -#endif -#ifdef KEY_BREAK -x[KEY_BREAK] = "BREAK"; -#endif -#ifdef KEY_PREVIOUS -x[KEY_PREVIOUS] = "PREVIOUS"; -#endif -#ifdef KEY_DIGITS -x[KEY_DIGITS] = "DIGITS"; -#endif -#ifdef KEY_TEEN -x[KEY_TEEN] = "TEEN"; -#endif -#ifdef KEY_TWEN -x[KEY_TWEN] = "TWEN"; -#endif -#ifdef KEY_VIDEOPHONE -x[KEY_VIDEOPHONE] = "VIDEOPHONE"; -#endif -#ifdef KEY_GAMES -x[KEY_GAMES] = "GAMES"; -#endif -#ifdef KEY_ZOOMIN -x[KEY_ZOOMIN] = "ZOOMIN"; -#endif -#ifdef KEY_ZOOMOUT -x[KEY_ZOOMOUT] = "ZOOMOUT"; -#endif -#ifdef KEY_ZOOMRESET -x[KEY_ZOOMRESET] = "ZOOMRESET"; -#endif -#ifdef KEY_WORDPROCESSOR -x[KEY_WORDPROCESSOR] = "WORDPROCESSOR"; -#endif -#ifdef KEY_EDITOR -x[KEY_EDITOR] = "EDITOR"; -#endif -#ifdef KEY_SPREADSHEET -x[KEY_SPREADSHEET] = "SPREADSHEET"; -#endif -#ifdef KEY_GRAPHICSEDITOR -x[KEY_GRAPHICSEDITOR] = "GRAPHICSEDITOR"; -#endif -#ifdef KEY_PRESENTATION -x[KEY_PRESENTATION] = "PRESENTATION"; -#endif -#ifdef KEY_DATABASE -x[KEY_DATABASE] = "DATABASE"; -#endif -#ifdef KEY_NEWS -x[KEY_NEWS] = "NEWS"; -#endif -#ifdef KEY_VOICEMAIL -x[KEY_VOICEMAIL] = "VOICEMAIL"; -#endif -#ifdef KEY_ADDRESSBOOK -x[KEY_ADDRESSBOOK] = "ADDRESSBOOK"; -#endif -#ifdef KEY_MESSENGER -x[KEY_MESSENGER] = "MESSENGER"; -#endif -#ifdef KEY_DISPLAYTOGGLE -x[KEY_DISPLAYTOGGLE] = "DISPLAYTOGGLE"; -#endif -#ifdef KEY_SPELLCHECK -x[KEY_SPELLCHECK] = "SPELLCHECK"; -#endif -#ifdef KEY_LOGOFF -x[KEY_LOGOFF] = "LOGOFF"; -#endif -#ifdef KEY_DOLLAR -x[KEY_DOLLAR] = "DOLLAR"; -#endif -#ifdef KEY_EURO -x[KEY_EURO] = "EURO"; -#endif -#ifdef KEY_FRAMEBACK -x[KEY_FRAMEBACK] = "FRAMEBACK"; -#endif -#ifdef KEY_FRAMEFORWARD -x[KEY_FRAMEFORWARD] = "FRAMEFORWARD"; -#endif -#ifdef KEY_CONTEXT_MENU -x[KEY_CONTEXT_MENU] = "CONTEXT_MENU"; -#endif -#ifdef KEY_MEDIA_REPEAT -x[KEY_MEDIA_REPEAT] = "MEDIA_REPEAT"; -#endif -#ifdef KEY_10CHANNELSUP -x[KEY_10CHANNELSUP] = "10CHANNELSUP"; -#endif -#ifdef KEY_10CHANNELSDOWN -x[KEY_10CHANNELSDOWN] = "10CHANNELSDOWN"; -#endif -#ifdef KEY_IMAGES -x[KEY_IMAGES] = "IMAGES"; -#endif -#ifdef KEY_DEL_EOL -x[KEY_DEL_EOL] = "DEL_EOL"; -#endif -#ifdef KEY_DEL_EOS -x[KEY_DEL_EOS] = "DEL_EOS"; -#endif -#ifdef KEY_INS_LINE -x[KEY_INS_LINE] = "INS_LINE"; -#endif -#ifdef KEY_DEL_LINE -x[KEY_DEL_LINE] = "DEL_LINE"; -#endif -#ifdef KEY_FN -x[KEY_FN] = "FN"; -#endif -#ifdef KEY_FN_ESC -x[KEY_FN_ESC] = "FN_ESC"; -#endif -#ifdef KEY_FN_F1 -x[KEY_FN_F1] = "FN_F1"; -#endif -#ifdef KEY_FN_F2 -x[KEY_FN_F2] = "FN_F2"; -#endif -#ifdef KEY_FN_F3 -x[KEY_FN_F3] = "FN_F3"; -#endif -#ifdef KEY_FN_F4 -x[KEY_FN_F4] = "FN_F4"; -#endif -#ifdef KEY_FN_F5 -x[KEY_FN_F5] = "FN_F5"; -#endif -#ifdef KEY_FN_F6 -x[KEY_FN_F6] = "FN_F6"; -#endif -#ifdef KEY_FN_F7 -x[KEY_FN_F7] = "FN_F7"; -#endif -#ifdef KEY_FN_F8 -x[KEY_FN_F8] = "FN_F8"; -#endif -#ifdef KEY_FN_F9 -x[KEY_FN_F9] = "FN_F9"; -#endif -#ifdef KEY_FN_F10 -x[KEY_FN_F10] = "FN_F10"; -#endif -#ifdef KEY_FN_F11 -x[KEY_FN_F11] = "FN_F11"; -#endif -#ifdef KEY_FN_F12 -x[KEY_FN_F12] = "FN_F12"; -#endif -#ifdef KEY_FN_1 -x[KEY_FN_1] = "FN_1"; -#endif -#ifdef KEY_FN_2 -x[KEY_FN_2] = "FN_2"; -#endif -#ifdef KEY_FN_D -x[KEY_FN_D] = "FN_D"; -#endif -#ifdef KEY_FN_E -x[KEY_FN_E] = "FN_E"; -#endif -#ifdef KEY_FN_F -x[KEY_FN_F] = "FN_F"; -#endif -#ifdef KEY_FN_S -x[KEY_FN_S] = "FN_S"; -#endif -#ifdef KEY_FN_B -x[KEY_FN_B] = "FN_B"; -#endif -#ifdef KEY_BRL_DOT1 -x[KEY_BRL_DOT1] = "BRL_DOT1"; -#endif -#ifdef KEY_BRL_DOT2 -x[KEY_BRL_DOT2] = "BRL_DOT2"; -#endif -#ifdef KEY_BRL_DOT3 -x[KEY_BRL_DOT3] = "BRL_DOT3"; -#endif -#ifdef KEY_BRL_DOT4 -x[KEY_BRL_DOT4] = "BRL_DOT4"; -#endif -#ifdef KEY_BRL_DOT5 -x[KEY_BRL_DOT5] = "BRL_DOT5"; -#endif -#ifdef KEY_BRL_DOT6 -x[KEY_BRL_DOT6] = "BRL_DOT6"; -#endif -#ifdef KEY_BRL_DOT7 -x[KEY_BRL_DOT7] = "BRL_DOT7"; -#endif -#ifdef KEY_BRL_DOT8 -x[KEY_BRL_DOT8] = "BRL_DOT8"; -#endif -#ifdef KEY_BRL_DOT9 -x[KEY_BRL_DOT9] = "BRL_DOT9"; -#endif -#ifdef KEY_BRL_DOT10 -x[KEY_BRL_DOT10] = "BRL_DOT10"; -#endif -#ifdef KEY_NUMERIC_0 -x[KEY_NUMERIC_0] = "NUMERIC_0"; -#endif -#ifdef KEY_NUMERIC_1 -x[KEY_NUMERIC_1] = "NUMERIC_1"; -#endif -#ifdef KEY_NUMERIC_2 -x[KEY_NUMERIC_2] = "NUMERIC_2"; -#endif -#ifdef KEY_NUMERIC_3 -x[KEY_NUMERIC_3] = "NUMERIC_3"; -#endif -#ifdef KEY_NUMERIC_4 -x[KEY_NUMERIC_4] = "NUMERIC_4"; -#endif -#ifdef KEY_NUMERIC_5 -x[KEY_NUMERIC_5] = "NUMERIC_5"; -#endif -#ifdef KEY_NUMERIC_6 -x[KEY_NUMERIC_6] = "NUMERIC_6"; -#endif -#ifdef KEY_NUMERIC_7 -x[KEY_NUMERIC_7] = "NUMERIC_7"; -#endif -#ifdef KEY_NUMERIC_8 -x[KEY_NUMERIC_8] = "NUMERIC_8"; -#endif -#ifdef KEY_NUMERIC_9 -x[KEY_NUMERIC_9] = "NUMERIC_9"; -#endif -#ifdef KEY_NUMERIC_STAR -x[KEY_NUMERIC_STAR] = "NUMERIC_STAR"; -#endif -#ifdef KEY_NUMERIC_POUND -x[KEY_NUMERIC_POUND] = "NUMERIC_POUND"; -#endif -#ifdef KEY_CAMERA_FOCUS -x[KEY_CAMERA_FOCUS] = "CAMERA_FOCUS"; -#endif -#ifdef KEY_WPS_BUTTON -x[KEY_WPS_BUTTON] = "WPS_BUTTON"; -#endif -#ifdef KEY_TOUCHPAD_TOGGLE -x[KEY_TOUCHPAD_TOGGLE] = "TOUCHPAD_TOGGLE"; -#endif -#ifdef KEY_TOUCHPAD_ON -x[KEY_TOUCHPAD_ON] = "TOUCHPAD_ON"; -#endif -#ifdef KEY_TOUCHPAD_OFF -x[KEY_TOUCHPAD_OFF] = "TOUCHPAD_OFF"; -#endif -#ifdef KEY_CAMERA_ZOOMIN -x[KEY_CAMERA_ZOOMIN] = "CAMERA_ZOOMIN"; -#endif -#ifdef KEY_CAMERA_ZOOMOUT -x[KEY_CAMERA_ZOOMOUT] = "CAMERA_ZOOMOUT"; -#endif -#ifdef KEY_CAMERA_UP -x[KEY_CAMERA_UP] = "CAMERA_UP"; -#endif -#ifdef KEY_CAMERA_DOWN -x[KEY_CAMERA_DOWN] = "CAMERA_DOWN"; -#endif -#ifdef KEY_CAMERA_LEFT -x[KEY_CAMERA_LEFT] = "CAMERA_LEFT"; -#endif -#ifdef KEY_CAMERA_RIGHT -x[KEY_CAMERA_RIGHT] = "CAMERA_RIGHT"; -#endif -#ifdef BTN_TRIGGER_HAPPY -x[BTN_TRIGGER_HAPPY] = "Button TRIGGER_HAPPY"; -#endif -#ifdef BTN_TRIGGER_HAPPY1 -x[BTN_TRIGGER_HAPPY1] = "Button TRIGGER_HAPPY1"; -#endif -#ifdef BTN_TRIGGER_HAPPY2 -x[BTN_TRIGGER_HAPPY2] = "Button TRIGGER_HAPPY2"; -#endif -#ifdef BTN_TRIGGER_HAPPY3 -x[BTN_TRIGGER_HAPPY3] = "Button TRIGGER_HAPPY3"; -#endif -#ifdef BTN_TRIGGER_HAPPY4 -x[BTN_TRIGGER_HAPPY4] = "Button TRIGGER_HAPPY4"; -#endif -#ifdef BTN_TRIGGER_HAPPY5 -x[BTN_TRIGGER_HAPPY5] = "Button TRIGGER_HAPPY5"; -#endif -#ifdef BTN_TRIGGER_HAPPY6 -x[BTN_TRIGGER_HAPPY6] = "Button TRIGGER_HAPPY6"; -#endif -#ifdef BTN_TRIGGER_HAPPY7 -x[BTN_TRIGGER_HAPPY7] = "Button TRIGGER_HAPPY7"; -#endif -#ifdef BTN_TRIGGER_HAPPY8 -x[BTN_TRIGGER_HAPPY8] = "Button TRIGGER_HAPPY8"; -#endif -#ifdef BTN_TRIGGER_HAPPY9 -x[BTN_TRIGGER_HAPPY9] = "Button TRIGGER_HAPPY9"; -#endif -#ifdef BTN_TRIGGER_HAPPY10 -x[BTN_TRIGGER_HAPPY10] = "Button TRIGGER_HAPPY10"; -#endif -#ifdef BTN_TRIGGER_HAPPY11 -x[BTN_TRIGGER_HAPPY11] = "Button TRIGGER_HAPPY11"; -#endif -#ifdef BTN_TRIGGER_HAPPY12 -x[BTN_TRIGGER_HAPPY12] = "Button TRIGGER_HAPPY12"; -#endif -#ifdef BTN_TRIGGER_HAPPY13 -x[BTN_TRIGGER_HAPPY13] = "Button TRIGGER_HAPPY13"; -#endif -#ifdef BTN_TRIGGER_HAPPY14 -x[BTN_TRIGGER_HAPPY14] = "Button TRIGGER_HAPPY14"; -#endif -#ifdef BTN_TRIGGER_HAPPY15 -x[BTN_TRIGGER_HAPPY15] = "Button TRIGGER_HAPPY15"; -#endif -#ifdef BTN_TRIGGER_HAPPY16 -x[BTN_TRIGGER_HAPPY16] = "Button TRIGGER_HAPPY16"; -#endif -#ifdef BTN_TRIGGER_HAPPY17 -x[BTN_TRIGGER_HAPPY17] = "Button TRIGGER_HAPPY17"; -#endif -#ifdef BTN_TRIGGER_HAPPY18 -x[BTN_TRIGGER_HAPPY18] = "Button TRIGGER_HAPPY18"; -#endif -#ifdef BTN_TRIGGER_HAPPY19 -x[BTN_TRIGGER_HAPPY19] = "Button TRIGGER_HAPPY19"; -#endif -#ifdef BTN_TRIGGER_HAPPY20 -x[BTN_TRIGGER_HAPPY20] = "Button TRIGGER_HAPPY20"; -#endif -#ifdef BTN_TRIGGER_HAPPY21 -x[BTN_TRIGGER_HAPPY21] = "Button TRIGGER_HAPPY21"; -#endif -#ifdef BTN_TRIGGER_HAPPY22 -x[BTN_TRIGGER_HAPPY22] = "Button TRIGGER_HAPPY22"; -#endif -#ifdef BTN_TRIGGER_HAPPY23 -x[BTN_TRIGGER_HAPPY23] = "Button TRIGGER_HAPPY23"; -#endif -#ifdef BTN_TRIGGER_HAPPY24 -x[BTN_TRIGGER_HAPPY24] = "Button TRIGGER_HAPPY24"; -#endif -#ifdef BTN_TRIGGER_HAPPY25 -x[BTN_TRIGGER_HAPPY25] = "Button TRIGGER_HAPPY25"; -#endif -#ifdef BTN_TRIGGER_HAPPY26 -x[BTN_TRIGGER_HAPPY26] = "Button TRIGGER_HAPPY26"; -#endif -#ifdef BTN_TRIGGER_HAPPY27 -x[BTN_TRIGGER_HAPPY27] = "Button TRIGGER_HAPPY27"; -#endif -#ifdef BTN_TRIGGER_HAPPY28 -x[BTN_TRIGGER_HAPPY28] = "Button TRIGGER_HAPPY28"; -#endif -#ifdef BTN_TRIGGER_HAPPY29 -x[BTN_TRIGGER_HAPPY29] = "Button TRIGGER_HAPPY29"; -#endif -#ifdef BTN_TRIGGER_HAPPY30 -x[BTN_TRIGGER_HAPPY30] = "Button TRIGGER_HAPPY30"; -#endif -#ifdef BTN_TRIGGER_HAPPY31 -x[BTN_TRIGGER_HAPPY31] = "Button TRIGGER_HAPPY31"; -#endif -#ifdef BTN_TRIGGER_HAPPY32 -x[BTN_TRIGGER_HAPPY32] = "Button TRIGGER_HAPPY32"; -#endif -#ifdef BTN_TRIGGER_HAPPY33 -x[BTN_TRIGGER_HAPPY33] = "Button TRIGGER_HAPPY33"; -#endif -#ifdef BTN_TRIGGER_HAPPY34 -x[BTN_TRIGGER_HAPPY34] = "Button TRIGGER_HAPPY34"; -#endif -#ifdef BTN_TRIGGER_HAPPY35 -x[BTN_TRIGGER_HAPPY35] = "Button TRIGGER_HAPPY35"; -#endif -#ifdef BTN_TRIGGER_HAPPY36 -x[BTN_TRIGGER_HAPPY36] = "Button TRIGGER_HAPPY36"; -#endif -#ifdef BTN_TRIGGER_HAPPY37 -x[BTN_TRIGGER_HAPPY37] = "Button TRIGGER_HAPPY37"; -#endif -#ifdef BTN_TRIGGER_HAPPY38 -x[BTN_TRIGGER_HAPPY38] = "Button TRIGGER_HAPPY38"; -#endif -#ifdef BTN_TRIGGER_HAPPY39 -x[BTN_TRIGGER_HAPPY39] = "Button TRIGGER_HAPPY39"; -#endif -#ifdef BTN_TRIGGER_HAPPY40 -x[BTN_TRIGGER_HAPPY40] = "Button TRIGGER_HAPPY40"; -#endif -} diff --git a/src/platform/evdev/buttons.tab b/src/platform/evdev/buttons.tab deleted file mode 100644 index 0a0b6122..00000000 --- a/src/platform/evdev/buttons.tab +++ /dev/null @@ -1,505 +0,0 @@ -evdev_init_buttons -KEY_RESERVED RESERVED -KEY_ESC ESC -KEY_1 1 -KEY_2 2 -KEY_3 3 -KEY_4 4 -KEY_5 5 -KEY_6 6 -KEY_7 7 -KEY_8 8 -KEY_9 9 -KEY_0 0 -KEY_MINUS MINUS -KEY_EQUAL EQUAL -KEY_BACKSPACE BACKSPACE -KEY_TAB TAB -KEY_Q Q -KEY_W W -KEY_E E -KEY_R R -KEY_T T -KEY_Y Y -KEY_U U -KEY_I I -KEY_O O -KEY_P P -KEY_LEFTBRACE LEFTBRACE -KEY_RIGHTBRACE RIGHTBRACE -KEY_ENTER ENTER -KEY_LEFTCTRL LEFTCTRL -KEY_A A -KEY_S S -KEY_D D -KEY_F F -KEY_G G -KEY_H H -KEY_J J -KEY_K K -KEY_L L -KEY_SEMICOLON SEMICOLON -KEY_APOSTROPHE APOSTROPHE -KEY_GRAVE GRAVE -KEY_LEFTSHIFT LEFTSHIFT -KEY_BACKSLASH BACKSLASH -KEY_Z Z -KEY_X X -KEY_C C -KEY_V V -KEY_B B -KEY_N N -KEY_M M -KEY_COMMA COMMA -KEY_DOT DOT -KEY_SLASH SLASH -KEY_RIGHTSHIFT RIGHTSHIFT -KEY_KPASTERISK KPASTERISK -KEY_LEFTALT LEFTALT -KEY_SPACE SPACE -KEY_CAPSLOCK CAPSLOCK -KEY_F1 F1 -KEY_F2 F2 -KEY_F3 F3 -KEY_F4 F4 -KEY_F5 F5 -KEY_F6 F6 -KEY_F7 F7 -KEY_F8 F8 -KEY_F9 F9 -KEY_F10 F10 -KEY_NUMLOCK NUMLOCK -KEY_SCROLLLOCK SCROLLLOCK -KEY_KP7 KP7 -KEY_KP8 KP8 -KEY_KP9 KP9 -KEY_KPMINUS KPMINUS -KEY_KP4 KP4 -KEY_KP5 KP5 -KEY_KP6 KP6 -KEY_KPPLUS KPPLUS -KEY_KP1 KP1 -KEY_KP2 KP2 -KEY_KP3 KP3 -KEY_KP0 KP0 -KEY_KPDOT KPDOT -KEY_ZENKAKUHANKAKU ZENKAKUHANKAKU -KEY_102ND 102ND -KEY_F11 F11 -KEY_F12 F12 -KEY_RO RO -KEY_KATAKANA KATAKANA -KEY_HIRAGANA HIRAGANA -KEY_HENKAN HENKAN -KEY_KATAKANAHIRAGANA KATAKANAHIRAGANA -KEY_MUHENKAN MUHENKAN -KEY_KPJPCOMMA KPJPCOMMA -KEY_KPENTER KPENTER -KEY_RIGHTCTRL RIGHTCTRL -KEY_KPSLASH KPSLASH -KEY_SYSRQ SYSRQ -KEY_RIGHTALT RIGHTALT -KEY_LINEFEED LINEFEED -KEY_HOME HOME -KEY_UP UP -KEY_PAGEUP PAGEUP -KEY_LEFT LEFT -KEY_RIGHT RIGHT -KEY_END END -KEY_DOWN DOWN -KEY_PAGEDOWN PAGEDOWN -KEY_INSERT INSERT -KEY_DELETE DELETE -KEY_MACRO MACRO -KEY_MUTE MUTE -KEY_VOLUMEDOWN VOLUMEDOWN -KEY_VOLUMEUP VOLUMEUP -KEY_POWER POWER -KEY_KPEQUAL KPEQUAL -KEY_KPPLUSMINUS KPPLUSMINUS -KEY_PAUSE PAUSE -KEY_SCALE SCALE -KEY_KPCOMMA KPCOMMA -KEY_HANGEUL HANGEUL -KEY_HANGUEL HANGUEL -KEY_HANJA HANJA -KEY_YEN YEN -KEY_LEFTMETA LEFTMETA -KEY_RIGHTMETA RIGHTMETA -KEY_COMPOSE COMPOSE -KEY_STOP STOP -KEY_AGAIN AGAIN -KEY_PROPS PROPS -KEY_UNDO UNDO -KEY_FRONT FRONT -KEY_COPY COPY -KEY_OPEN OPEN -KEY_PASTE PASTE -KEY_FIND FIND -KEY_CUT CUT -KEY_HELP HELP -KEY_MENU MENU -KEY_CALC CALC -KEY_SETUP SETUP -KEY_SLEEP SLEEP -KEY_WAKEUP WAKEUP -KEY_FILE FILE -KEY_SENDFILE SENDFILE -KEY_DELETEFILE DELETEFILE -KEY_XFER XFER -KEY_PROG1 PROG1 -KEY_PROG2 PROG2 -KEY_WWW WWW -KEY_MSDOS MSDOS -KEY_COFFEE COFFEE -KEY_SCREENLOCK SCREENLOCK -KEY_DIRECTION DIRECTION -KEY_CYCLEWINDOWS CYCLEWINDOWS -KEY_MAIL MAIL -KEY_BOOKMARKS BOOKMARKS -KEY_COMPUTER COMPUTER -KEY_BACK BACK -KEY_FORWARD FORWARD -KEY_CLOSECD CLOSECD -KEY_EJECTCD EJECTCD -KEY_EJECTCLOSECD EJECTCLOSECD -KEY_NEXTSONG NEXTSONG -KEY_PLAYPAUSE PLAYPAUSE -KEY_PREVIOUSSONG PREVIOUSSONG -KEY_STOPCD STOPCD -KEY_RECORD RECORD -KEY_REWIND REWIND -KEY_PHONE PHONE -KEY_ISO ISO -KEY_CONFIG CONFIG -KEY_HOMEPAGE HOMEPAGE -KEY_REFRESH REFRESH -KEY_EXIT EXIT -KEY_MOVE MOVE -KEY_EDIT EDIT -KEY_SCROLLUP SCROLLUP -KEY_SCROLLDOWN SCROLLDOWN -KEY_KPLEFTPAREN KPLEFTPAREN -KEY_KPRIGHTPAREN KPRIGHTPAREN -KEY_NEW NEW -KEY_REDO REDO -KEY_F13 F13 -KEY_F14 F14 -KEY_F15 F15 -KEY_F16 F16 -KEY_F17 F17 -KEY_F18 F18 -KEY_F19 F19 -KEY_F20 F20 -KEY_F21 F21 -KEY_F22 F22 -KEY_F23 F23 -KEY_F24 F24 -KEY_PLAYCD PLAYCD -KEY_PAUSECD PAUSECD -KEY_PROG3 PROG3 -KEY_PROG4 PROG4 -KEY_DASHBOARD DASHBOARD -KEY_SUSPEND SUSPEND -KEY_CLOSE CLOSE -KEY_PLAY PLAY -KEY_FASTFORWARD FASTFORWARD -KEY_BASSBOOST BASSBOOST -KEY_PRINT PRINT -KEY_HP HP -KEY_CAMERA CAMERA -KEY_SOUND SOUND -KEY_QUESTION QUESTION -KEY_EMAIL EMAIL -KEY_CHAT CHAT -KEY_SEARCH SEARCH -KEY_CONNECT CONNECT -KEY_FINANCE FINANCE -KEY_SPORT SPORT -KEY_SHOP SHOP -KEY_ALTERASE ALTERASE -KEY_CANCEL CANCEL -KEY_BRIGHTNESSDOWN BRIGHTNESSDOWN -KEY_BRIGHTNESSUP BRIGHTNESSUP -KEY_MEDIA MEDIA -KEY_SWITCHVIDEOMODE SWITCHVIDEOMODE -KEY_KBDILLUMTOGGLE KBDILLUMTOGGLE -KEY_KBDILLUMDOWN KBDILLUMDOWN -KEY_KBDILLUMUP KBDILLUMUP -KEY_SEND SEND -KEY_REPLY REPLY -KEY_FORWARDMAIL FORWARDMAIL -KEY_SAVE SAVE -KEY_DOCUMENTS DOCUMENTS -KEY_BATTERY BATTERY -KEY_BLUETOOTH BLUETOOTH -KEY_WLAN WLAN -KEY_UWB UWB -KEY_UNKNOWN UNKNOWN -KEY_VIDEO_NEXT VIDEO_NEXT -KEY_VIDEO_PREV VIDEO_PREV -KEY_BRIGHTNESS_CYCLE BRIGHTNESS_CYCLE -KEY_BRIGHTNESS_ZERO BRIGHTNESS_ZERO -KEY_DISPLAY_OFF DISPLAY_OFF -KEY_WIMAX WIMAX -KEY_RFKILL RFKILL -KEY_MICMUTE MICMUTE -BTN_MISC Button MISC -BTN_0 Button 0 -BTN_1 Button 1 -BTN_2 Button 2 -BTN_3 Button 3 -BTN_4 Button 4 -BTN_5 Button 5 -BTN_6 Button 6 -BTN_7 Button 7 -BTN_8 Button 8 -BTN_9 Button 9 -BTN_MOUSE Button MOUSE -BTN_LEFT Button LEFT -BTN_RIGHT Button RIGHT -BTN_MIDDLE Button MIDDLE -BTN_SIDE Button SIDE -BTN_EXTRA Button EXTRA -BTN_FORWARD Button FORWARD -BTN_BACK Button BACK -BTN_TASK Button TASK -BTN_JOYSTICK Button JOYSTICK -BTN_TRIGGER Button TRIGGER -BTN_THUMB Button THUMB -BTN_THUMB2 Button THUMB2 -BTN_TOP Button TOP -BTN_TOP2 Button TOP2 -BTN_PINKIE Button PINKIE -BTN_BASE Button BASE -BTN_BASE2 Button BASE2 -BTN_BASE3 Button BASE3 -BTN_BASE4 Button BASE4 -BTN_BASE5 Button BASE5 -BTN_BASE6 Button BASE6 -BTN_DEAD Button DEAD -BTN_GAMEPAD Button GAMEPAD -BTN_A Button A -BTN_B Button B -BTN_C Button C -BTN_X Button X -BTN_Y Button Y -BTN_Z Button Z -BTN_TL Button TL -BTN_TR Button TR -BTN_TL2 Button TL2 -BTN_TR2 Button TR2 -BTN_SELECT Button SELECT -BTN_START Button START -BTN_MODE Button MODE -BTN_THUMBL Button THUMBL -BTN_THUMBR Button THUMBR -BTN_DIGI Button DIGI -BTN_TOOL_PEN Button TOOL_PEN -BTN_TOOL_RUBBER Button TOOL_RUBBER -BTN_TOOL_BRUSH Button TOOL_BRUSH -BTN_TOOL_PENCIL Button TOOL_PENCIL -BTN_TOOL_AIRBRUSH Button TOOL_AIRBRUSH -BTN_TOOL_FINGER Button TOOL_FINGER -BTN_TOOL_MOUSE Button TOOL_MOUSE -BTN_TOOL_LENS Button TOOL_LENS -BTN_TOUCH Button TOUCH -BTN_STYLUS Button STYLUS -BTN_STYLUS2 Button STYLUS2 -BTN_TOOL_DOUBLETAP Button TOOL_DOUBLETAP -BTN_TOOL_TRIPLETAP Button TOOL_TRIPLETAP -BTN_TOOL_QUADTAP Button TOOL_QUADTAP -BTN_TOOL_QUINTTAP Button TOOL_QUINTTAP -BTN_WHEEL Button WHEEL -BTN_GEAR_DOWN Button GEAR_DOWN -BTN_GEAR_UP Button GEAR_UP -KEY_OK OK -KEY_SELECT SELECT -KEY_GOTO GOTO -KEY_CLEAR CLEAR -KEY_POWER2 POWER2 -KEY_OPTION OPTION -KEY_INFO INFO -KEY_TIME TIME -KEY_VENDOR VENDOR -KEY_ARCHIVE ARCHIVE -KEY_PROGRAM PROGRAM -KEY_CHANNEL CHANNEL -KEY_FAVORITES FAVORITES -KEY_EPG EPG -KEY_PVR PVR -KEY_MHP MHP -KEY_LANGUAGE LANGUAGE -KEY_TITLE TITLE -KEY_SUBTITLE SUBTITLE -KEY_ANGLE ANGLE -KEY_ZOOM ZOOM -KEY_MODE MODE -KEY_KEYBOARD KEYBOARD -KEY_SCREEN SCREEN -KEY_PC PC -KEY_TV TV -KEY_TV2 TV2 -KEY_VCR VCR -KEY_VCR2 VCR2 -KEY_SAT SAT -KEY_SAT2 SAT2 -KEY_CD CD -KEY_TAPE TAPE -KEY_RADIO RADIO -KEY_TUNER TUNER -KEY_PLAYER PLAYER -KEY_TEXT TEXT -KEY_DVD DVD -KEY_AUX AUX -KEY_MP3 MP3 -KEY_AUDIO AUDIO -KEY_VIDEO VIDEO -KEY_DIRECTORY DIRECTORY -KEY_LIST LIST -KEY_MEMO MEMO -KEY_CALENDAR CALENDAR -KEY_RED RED -KEY_GREEN GREEN -KEY_YELLOW YELLOW -KEY_BLUE BLUE -KEY_CHANNELUP CHANNELUP -KEY_CHANNELDOWN CHANNELDOWN -KEY_FIRST FIRST -KEY_LAST LAST -KEY_AB AB -KEY_NEXT NEXT -KEY_RESTART RESTART -KEY_SLOW SLOW -KEY_SHUFFLE SHUFFLE -KEY_BREAK BREAK -KEY_PREVIOUS PREVIOUS -KEY_DIGITS DIGITS -KEY_TEEN TEEN -KEY_TWEN TWEN -KEY_VIDEOPHONE VIDEOPHONE -KEY_GAMES GAMES -KEY_ZOOMIN ZOOMIN -KEY_ZOOMOUT ZOOMOUT -KEY_ZOOMRESET ZOOMRESET -KEY_WORDPROCESSOR WORDPROCESSOR -KEY_EDITOR EDITOR -KEY_SPREADSHEET SPREADSHEET -KEY_GRAPHICSEDITOR GRAPHICSEDITOR -KEY_PRESENTATION PRESENTATION -KEY_DATABASE DATABASE -KEY_NEWS NEWS -KEY_VOICEMAIL VOICEMAIL -KEY_ADDRESSBOOK ADDRESSBOOK -KEY_MESSENGER MESSENGER -KEY_DISPLAYTOGGLE DISPLAYTOGGLE -KEY_SPELLCHECK SPELLCHECK -KEY_LOGOFF LOGOFF -KEY_DOLLAR DOLLAR -KEY_EURO EURO -KEY_FRAMEBACK FRAMEBACK -KEY_FRAMEFORWARD FRAMEFORWARD -KEY_CONTEXT_MENU CONTEXT_MENU -KEY_MEDIA_REPEAT MEDIA_REPEAT -KEY_10CHANNELSUP 10CHANNELSUP -KEY_10CHANNELSDOWN 10CHANNELSDOWN -KEY_IMAGES IMAGES -KEY_DEL_EOL DEL_EOL -KEY_DEL_EOS DEL_EOS -KEY_INS_LINE INS_LINE -KEY_DEL_LINE DEL_LINE -KEY_FN FN -KEY_FN_ESC FN_ESC -KEY_FN_F1 FN_F1 -KEY_FN_F2 FN_F2 -KEY_FN_F3 FN_F3 -KEY_FN_F4 FN_F4 -KEY_FN_F5 FN_F5 -KEY_FN_F6 FN_F6 -KEY_FN_F7 FN_F7 -KEY_FN_F8 FN_F8 -KEY_FN_F9 FN_F9 -KEY_FN_F10 FN_F10 -KEY_FN_F11 FN_F11 -KEY_FN_F12 FN_F12 -KEY_FN_1 FN_1 -KEY_FN_2 FN_2 -KEY_FN_D FN_D -KEY_FN_E FN_E -KEY_FN_F FN_F -KEY_FN_S FN_S -KEY_FN_B FN_B -KEY_BRL_DOT1 BRL_DOT1 -KEY_BRL_DOT2 BRL_DOT2 -KEY_BRL_DOT3 BRL_DOT3 -KEY_BRL_DOT4 BRL_DOT4 -KEY_BRL_DOT5 BRL_DOT5 -KEY_BRL_DOT6 BRL_DOT6 -KEY_BRL_DOT7 BRL_DOT7 -KEY_BRL_DOT8 BRL_DOT8 -KEY_BRL_DOT9 BRL_DOT9 -KEY_BRL_DOT10 BRL_DOT10 -KEY_NUMERIC_0 NUMERIC_0 -KEY_NUMERIC_1 NUMERIC_1 -KEY_NUMERIC_2 NUMERIC_2 -KEY_NUMERIC_3 NUMERIC_3 -KEY_NUMERIC_4 NUMERIC_4 -KEY_NUMERIC_5 NUMERIC_5 -KEY_NUMERIC_6 NUMERIC_6 -KEY_NUMERIC_7 NUMERIC_7 -KEY_NUMERIC_8 NUMERIC_8 -KEY_NUMERIC_9 NUMERIC_9 -KEY_NUMERIC_STAR NUMERIC_STAR -KEY_NUMERIC_POUND NUMERIC_POUND -KEY_CAMERA_FOCUS CAMERA_FOCUS -KEY_WPS_BUTTON WPS_BUTTON -KEY_TOUCHPAD_TOGGLE TOUCHPAD_TOGGLE -KEY_TOUCHPAD_ON TOUCHPAD_ON -KEY_TOUCHPAD_OFF TOUCHPAD_OFF -KEY_CAMERA_ZOOMIN CAMERA_ZOOMIN -KEY_CAMERA_ZOOMOUT CAMERA_ZOOMOUT -KEY_CAMERA_UP CAMERA_UP -KEY_CAMERA_DOWN CAMERA_DOWN -KEY_CAMERA_LEFT CAMERA_LEFT -KEY_CAMERA_RIGHT CAMERA_RIGHT -BTN_TRIGGER_HAPPY Button TRIGGER_HAPPY -BTN_TRIGGER_HAPPY1 Button TRIGGER_HAPPY1 -BTN_TRIGGER_HAPPY2 Button TRIGGER_HAPPY2 -BTN_TRIGGER_HAPPY3 Button TRIGGER_HAPPY3 -BTN_TRIGGER_HAPPY4 Button TRIGGER_HAPPY4 -BTN_TRIGGER_HAPPY5 Button TRIGGER_HAPPY5 -BTN_TRIGGER_HAPPY6 Button TRIGGER_HAPPY6 -BTN_TRIGGER_HAPPY7 Button TRIGGER_HAPPY7 -BTN_TRIGGER_HAPPY8 Button TRIGGER_HAPPY8 -BTN_TRIGGER_HAPPY9 Button TRIGGER_HAPPY9 -BTN_TRIGGER_HAPPY10 Button TRIGGER_HAPPY10 -BTN_TRIGGER_HAPPY11 Button TRIGGER_HAPPY11 -BTN_TRIGGER_HAPPY12 Button TRIGGER_HAPPY12 -BTN_TRIGGER_HAPPY13 Button TRIGGER_HAPPY13 -BTN_TRIGGER_HAPPY14 Button TRIGGER_HAPPY14 -BTN_TRIGGER_HAPPY15 Button TRIGGER_HAPPY15 -BTN_TRIGGER_HAPPY16 Button TRIGGER_HAPPY16 -BTN_TRIGGER_HAPPY17 Button TRIGGER_HAPPY17 -BTN_TRIGGER_HAPPY18 Button TRIGGER_HAPPY18 -BTN_TRIGGER_HAPPY19 Button TRIGGER_HAPPY19 -BTN_TRIGGER_HAPPY20 Button TRIGGER_HAPPY20 -BTN_TRIGGER_HAPPY21 Button TRIGGER_HAPPY21 -BTN_TRIGGER_HAPPY22 Button TRIGGER_HAPPY22 -BTN_TRIGGER_HAPPY23 Button TRIGGER_HAPPY23 -BTN_TRIGGER_HAPPY24 Button TRIGGER_HAPPY24 -BTN_TRIGGER_HAPPY25 Button TRIGGER_HAPPY25 -BTN_TRIGGER_HAPPY26 Button TRIGGER_HAPPY26 -BTN_TRIGGER_HAPPY27 Button TRIGGER_HAPPY27 -BTN_TRIGGER_HAPPY28 Button TRIGGER_HAPPY28 -BTN_TRIGGER_HAPPY29 Button TRIGGER_HAPPY29 -BTN_TRIGGER_HAPPY30 Button TRIGGER_HAPPY30 -BTN_TRIGGER_HAPPY31 Button TRIGGER_HAPPY31 -BTN_TRIGGER_HAPPY32 Button TRIGGER_HAPPY32 -BTN_TRIGGER_HAPPY33 Button TRIGGER_HAPPY33 -BTN_TRIGGER_HAPPY34 Button TRIGGER_HAPPY34 -BTN_TRIGGER_HAPPY35 Button TRIGGER_HAPPY35 -BTN_TRIGGER_HAPPY36 Button TRIGGER_HAPPY36 -BTN_TRIGGER_HAPPY37 Button TRIGGER_HAPPY37 -BTN_TRIGGER_HAPPY38 Button TRIGGER_HAPPY38 -BTN_TRIGGER_HAPPY39 Button TRIGGER_HAPPY39 -BTN_TRIGGER_HAPPY40 Button TRIGGER_HAPPY40 diff --git a/src/platform/evdev/joystick.cpp b/src/platform/evdev/joystick.cpp index 3927ca8f..64dd80e5 100644 --- a/src/platform/evdev/joystick.cpp +++ b/src/platform/evdev/joystick.cpp @@ -20,17 +20,155 @@ extern "C" #include } -extern void evdev_init_buttons(const char** x); -extern void evdev_init_axes(const char** x); - namespace { - const char* axisnames[ABS_MAX + 1] = {0}; - const char* buttonnames[KEY_MAX + 1] = {0}; + const char* axisnames[64] = { + "X", "Y", "Z", "RX", "RY", "RZ", "THROTTLE", "RUDDER", "WHEEL", "GAS", "BRAKE", "Unknown axis #11", + "Unknown axis #12", "Unknown axis #13", "Unknown axis #14", "Unknown axis #15", "HAT0X", "HAT0Y", + "HAT1X", "HAT1Y", "HAT2X", "HAT2Y", "HAT3X", "HAT3Y", "PRESSURE", "DISTANCE", "TILT_X", "TILT_Y", + "TOOL_WIDTH", "Unknown axis #29", "Unknown axis #30", "Unknown axis #31", "VOLUME", "Unknown axis #33", + "Unknown axis #34", "Unknown axis #35", "Unknown axis #36", "Unknown axis #37", "Unknown axis #38", + "Unknown axis #39", "MISC", "Unknown axis #41", "Unknown axis #42", "Unknown axis #43", + "Unknown axis #44", "Unknown axis #45", "Unknown axis #46", "MT_SLOT", "MT_TOUCH_MAJOR", + "MT_TOUCH_MINOR", "MT_WIDTH_MAJOR", "MT_WIDTH_MINOR", "MT_ORIENTATION", "MT_POSITION_X", + "MT_POSITION_Y", "MT_TOOL_TYPE", "MT_BLOB_ID", "MT_TRACKING_ID", "MT_PRESSURE", "MT_DISTANCE", + "Unknown axis #60", "Unknown axis #61", "Unknown axis #62", "Unknown axis #63" + }; + const char* buttonnames[768] = { + "RESERVED", "ESC", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUAL", "BACKSPACE", + "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LEFTBRACE", "RIGHTBRACE", "ENTER", + "LEFTCTRL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", + "LEFTSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "DOT", "SLASH", "RIGHTSHIFT", + "KPASTERISK", "LEFTALT", "SPACE", "CAPSLOCK", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", + "F10", "NUMLOCK", "SCROLLLOCK", "KP7", "KP8", "KP9", "KPMINUS", "KP4", "KP5", "KP6", "KPPLUS", "KP1", + "KP2", "KP3", "KP0", "KPDOT", "Unknown button #84", "ZENKAKUHANKAKU", "102ND", "F11", "F12", "RO", + "KATAKANA", "HIRAGANA", "HENKAN", "KATAKANAHIRAGANA", "MUHENKAN", "KPJPCOMMA", "KPENTER", "RIGHTCTRL", + "KPSLASH", "SYSRQ", "RIGHTALT", "LINEFEED", "HOME", "UP", "PAGEUP", "LEFT", "RIGHT", "END", "DOWN", + "PAGEDOWN", "INSERT", "DELETE", "MACRO", "MUTE", "VOLUMEDOWN", "VOLUMEUP", "POWER", "KPEQUAL", + "KPPLUSMINUS", "PAUSE", "SCALE", "KPCOMMA", "HANGUEL", "HANJA", "YEN", "LEFTMETA", "RIGHTMETA", + "COMPOSE", "STOP", "AGAIN", "PROPS", "UNDO", "FRONT", "COPY", "OPEN", "PASTE", "FIND", "CUT", "HELP", + "MENU", "CALC", "SETUP", "SLEEP", "WAKEUP", "FILE", "SENDFILE", "DELETEFILE", "XFER", "PROG1", "PROG2", + "WWW", "MSDOS", "SCREENLOCK", "DIRECTION", "CYCLEWINDOWS", "MAIL", "BOOKMARKS", "COMPUTER", "BACK", + "FORWARD", "CLOSECD", "EJECTCD", "EJECTCLOSECD", "NEXTSONG", "PLAYPAUSE", "PREVIOUSSONG", "STOPCD", + "RECORD", "REWIND", "PHONE", "ISO", "CONFIG", "HOMEPAGE", "REFRESH", "EXIT", "MOVE", "EDIT", + "SCROLLUP", "SCROLLDOWN", "KPLEFTPAREN", "KPRIGHTPAREN", "NEW", "REDO", "F13", "F14", "F15", "F16", + "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "Unknown button #195", "Unknown button #196", + "Unknown button #197", "Unknown button #198", "Unknown button #199", "PLAYCD", "PAUSECD", "PROG3", + "PROG4", "DASHBOARD", "SUSPEND", "CLOSE", "PLAY", "FASTFORWARD", "BASSBOOST", "PRINT", "HP", "CAMERA", + "SOUND", "QUESTION", "EMAIL", "CHAT", "SEARCH", "CONNECT", "FINANCE", "SPORT", "SHOP", "ALTERASE", + "CANCEL", "BRIGHTNESSDOWN", "BRIGHTNESSUP", "MEDIA", "SWITCHVIDEOMODE", "KBDILLUMTOGGLE", + "KBDILLUMDOWN", "KBDILLUMUP", "SEND", "REPLY", "FORWARDMAIL", "SAVE", "DOCUMENTS", "BATTERY", + "BLUETOOTH", "WLAN", "UWB", "UNKNOWN", "VIDEO_NEXT", "VIDEO_PREV", "BRIGHTNESS_CYCLE", + "BRIGHTNESS_ZERO", "DISPLAY_OFF", "WIMAX", "RFKILL", "MICMUTE", "Unknown button #249", + "Unknown button #250", "Unknown button #251", "Unknown button #252", "Unknown button #253", + "Unknown button #254", "Unknown button #255", "Button 0", "Button 1", "Button 2", "Button 3", + "Button 4", "Button 5", "Button 6", "Button 7", "Button 8", "Button 9", "Unknown button #266", + "Unknown button #267", "Unknown button #268", "Unknown button #269", "Unknown button #270", + "Unknown button #271", "Button LEFT", "Button RIGHT", "Button MIDDLE", "Button SIDE", "Button EXTRA", + "Button FORWARD", "Button BACK", "Button TASK", "Unknown button #280", "Unknown button #281", + "Unknown button #282", "Unknown button #283", "Unknown button #284", "Unknown button #285", + "Unknown button #286", "Unknown button #287", "Button TRIGGER", "Button THUMB", "Button THUMB2", + "Button TOP", "Button TOP2", "Button PINKIE", "Button BASE", "Button BASE2", "Button BASE3", + "Button BASE4", "Button BASE5", "Button BASE6", "Unknown button #300", "Unknown button #301", + "Unknown button #302", "Button DEAD", "Button A", "Button B", "Button C", "Button X", "Button Y", + "Button Z", "Button TL", "Button TR", "Button TL2", "Button TR2", "Button SELECT", "Button START", + "Button MODE", "Button THUMBL", "Button THUMBR", "Unknown button #319", "Button TOOL_PEN", + "Button TOOL_RUBBER", "Button TOOL_BRUSH", "Button TOOL_PENCIL", "Button TOOL_AIRBRUSH", + "Button TOOL_FINGER", "Button TOOL_MOUSE", "Button TOOL_LENS", "Button TOOL_QUINTTAP", + "Unknown button #329", "Button TOUCH", "Button STYLUS", "Button STYLUS2", "Button TOOL_DOUBLETAP", + "Button TOOL_TRIPLETAP", "Button TOOL_QUADTAP", "Button GEAR_DOWN", "Button GEAR_UP", + "Unknown button #338", "Unknown button #339", "Unknown button #340", "Unknown button #341", + "Unknown button #342", "Unknown button #343", "Unknown button #344", "Unknown button #345", + "Unknown button #346", "Unknown button #347", "Unknown button #348", "Unknown button #349", + "Unknown button #350", "Unknown button #351", "OK", "SELECT", "GOTO", "CLEAR", "POWER2", "OPTION", + "INFO", "TIME", "VENDOR", "ARCHIVE", "PROGRAM", "CHANNEL", "FAVORITES", "EPG", "PVR", "MHP", + "LANGUAGE", "TITLE", "SUBTITLE", "ANGLE", "ZOOM", "MODE", "KEYBOARD", "SCREEN", "PC", "TV", "TV2", + "VCR", "VCR2", "SAT", "SAT2", "CD", "TAPE", "RADIO", "TUNER", "PLAYER", "TEXT", "DVD", "AUX", "MP3", + "AUDIO", "VIDEO", "DIRECTORY", "LIST", "MEMO", "CALENDAR", "RED", "GREEN", "YELLOW", "BLUE", + "CHANNELUP", "CHANNELDOWN", "FIRST", "LAST", "AB", "NEXT", "RESTART", "SLOW", "SHUFFLE", "BREAK", + "PREVIOUS", "DIGITS", "TEEN", "TWEN", "VIDEOPHONE", "GAMES", "ZOOMIN", "ZOOMOUT", "ZOOMRESET", + "WORDPROCESSOR", "EDITOR", "SPREADSHEET", "GRAPHICSEDITOR", "PRESENTATION", "DATABASE", "NEWS", + "VOICEMAIL", "ADDRESSBOOK", "MESSENGER", "DISPLAYTOGGLE", "SPELLCHECK", "LOGOFF", "DOLLAR", "EURO", + "FRAMEBACK", "FRAMEFORWARD", "CONTEXT_MENU", "MEDIA_REPEAT", "10CHANNELSUP", "10CHANNELSDOWN", + "IMAGES", "Unknown button #443", "Unknown button #444", "Unknown button #445", "Unknown button #446", + "Unknown button #447", "DEL_EOL", "DEL_EOS", "INS_LINE", "DEL_LINE", "Unknown button #452", + "Unknown button #453", "Unknown button #454", "Unknown button #455", "Unknown button #456", + "Unknown button #457", "Unknown button #458", "Unknown button #459", "Unknown button #460", + "Unknown button #461", "Unknown button #462", "Unknown button #463", "FN", "FN_ESC", "FN_F1", "FN_F2", + "FN_F3", "FN_F4", "FN_F5", "FN_F6", "FN_F7", "FN_F8", "FN_F9", "FN_F10", "FN_F11", "FN_F12", "FN_1", + "FN_2", "FN_D", "FN_E", "FN_F", "FN_S", "FN_B", "Unknown button #485", "Unknown button #486", + "Unknown button #487", "Unknown button #488", "Unknown button #489", "Unknown button #490", + "Unknown button #491", "Unknown button #492", "Unknown button #493", "Unknown button #494", + "Unknown button #495", "Unknown button #496", "BRL_DOT1", "BRL_DOT2", "BRL_DOT3", "BRL_DOT4", + "BRL_DOT5", "BRL_DOT6", "BRL_DOT7", "BRL_DOT8", "BRL_DOT9", "BRL_DOT10", "Unknown button #507", + "Unknown button #508", "Unknown button #509", "Unknown button #510", "Unknown button #511", + "NUMERIC_0", "NUMERIC_1", "NUMERIC_2", "NUMERIC_3", "NUMERIC_4", "NUMERIC_5", "NUMERIC_6", "NUMERIC_7", + "NUMERIC_8", "NUMERIC_9", "NUMERIC_STAR", "NUMERIC_POUND", "Unknown button #524", + "Unknown button #525", "Unknown button #526", "Unknown button #527", "CAMERA_FOCUS", "WPS_BUTTON", + "TOUCHPAD_TOGGLE", "TOUCHPAD_ON", "TOUCHPAD_OFF", "CAMERA_ZOOMIN", "CAMERA_ZOOMOUT", "CAMERA_UP", + "CAMERA_DOWN", "CAMERA_LEFT", "CAMERA_RIGHT", "Unknown button #539", "Unknown button #540", + "Unknown button #541", "Unknown button #542", "Unknown button #543", "Unknown button #544", + "Unknown button #545", "Unknown button #546", "Unknown button #547", "Unknown button #548", + "Unknown button #549", "Unknown button #550", "Unknown button #551", "Unknown button #552", + "Unknown button #553", "Unknown button #554", "Unknown button #555", "Unknown button #556", + "Unknown button #557", "Unknown button #558", "Unknown button #559", "Unknown button #560", + "Unknown button #561", "Unknown button #562", "Unknown button #563", "Unknown button #564", + "Unknown button #565", "Unknown button #566", "Unknown button #567", "Unknown button #568", + "Unknown button #569", "Unknown button #570", "Unknown button #571", "Unknown button #572", + "Unknown button #573", "Unknown button #574", "Unknown button #575", "Unknown button #576", + "Unknown button #577", "Unknown button #578", "Unknown button #579", "Unknown button #580", + "Unknown button #581", "Unknown button #582", "Unknown button #583", "Unknown button #584", + "Unknown button #585", "Unknown button #586", "Unknown button #587", "Unknown button #588", + "Unknown button #589", "Unknown button #590", "Unknown button #591", "Unknown button #592", + "Unknown button #593", "Unknown button #594", "Unknown button #595", "Unknown button #596", + "Unknown button #597", "Unknown button #598", "Unknown button #599", "Unknown button #600", + "Unknown button #601", "Unknown button #602", "Unknown button #603", "Unknown button #604", + "Unknown button #605", "Unknown button #606", "Unknown button #607", "Unknown button #608", + "Unknown button #609", "Unknown button #610", "Unknown button #611", "Unknown button #612", + "Unknown button #613", "Unknown button #614", "Unknown button #615", "Unknown button #616", + "Unknown button #617", "Unknown button #618", "Unknown button #619", "Unknown button #620", + "Unknown button #621", "Unknown button #622", "Unknown button #623", "Unknown button #624", + "Unknown button #625", "Unknown button #626", "Unknown button #627", "Unknown button #628", + "Unknown button #629", "Unknown button #630", "Unknown button #631", "Unknown button #632", + "Unknown button #633", "Unknown button #634", "Unknown button #635", "Unknown button #636", + "Unknown button #637", "Unknown button #638", "Unknown button #639", "Unknown button #640", + "Unknown button #641", "Unknown button #642", "Unknown button #643", "Unknown button #644", + "Unknown button #645", "Unknown button #646", "Unknown button #647", "Unknown button #648", + "Unknown button #649", "Unknown button #650", "Unknown button #651", "Unknown button #652", + "Unknown button #653", "Unknown button #654", "Unknown button #655", "Unknown button #656", + "Unknown button #657", "Unknown button #658", "Unknown button #659", "Unknown button #660", + "Unknown button #661", "Unknown button #662", "Unknown button #663", "Unknown button #664", + "Unknown button #665", "Unknown button #666", "Unknown button #667", "Unknown button #668", + "Unknown button #669", "Unknown button #670", "Unknown button #671", "Unknown button #672", + "Unknown button #673", "Unknown button #674", "Unknown button #675", "Unknown button #676", + "Unknown button #677", "Unknown button #678", "Unknown button #679", "Unknown button #680", + "Unknown button #681", "Unknown button #682", "Unknown button #683", "Unknown button #684", + "Unknown button #685", "Unknown button #686", "Unknown button #687", "Unknown button #688", + "Unknown button #689", "Unknown button #690", "Unknown button #691", "Unknown button #692", + "Unknown button #693", "Unknown button #694", "Unknown button #695", "Unknown button #696", + "Unknown button #697", "Unknown button #698", "Unknown button #699", "Unknown button #700", + "Unknown button #701", "Unknown button #702", "Unknown button #703", "Button TRIGGER_HAPPY1", + "Button TRIGGER_HAPPY2", "Button TRIGGER_HAPPY3", "Button TRIGGER_HAPPY4", "Button TRIGGER_HAPPY5", + "Button TRIGGER_HAPPY6", "Button TRIGGER_HAPPY7", "Button TRIGGER_HAPPY8", "Button TRIGGER_HAPPY9", + "Button TRIGGER_HAPPY10", "Button TRIGGER_HAPPY11", "Button TRIGGER_HAPPY12", "Button TRIGGER_HAPPY13", + "Button TRIGGER_HAPPY14", "Button TRIGGER_HAPPY15", "Button TRIGGER_HAPPY16", "Button TRIGGER_HAPPY17", + "Button TRIGGER_HAPPY18", "Button TRIGGER_HAPPY19", "Button TRIGGER_HAPPY20", "Button TRIGGER_HAPPY21", + "Button TRIGGER_HAPPY22", "Button TRIGGER_HAPPY23", "Button TRIGGER_HAPPY24", "Button TRIGGER_HAPPY25", + "Button TRIGGER_HAPPY26", "Button TRIGGER_HAPPY27", "Button TRIGGER_HAPPY28", "Button TRIGGER_HAPPY29", + "Button TRIGGER_HAPPY30", "Button TRIGGER_HAPPY31", "Button TRIGGER_HAPPY32", "Button TRIGGER_HAPPY33", + "Button TRIGGER_HAPPY34", "Button TRIGGER_HAPPY35", "Button TRIGGER_HAPPY36", "Button TRIGGER_HAPPY37", + "Button TRIGGER_HAPPY38", "Button TRIGGER_HAPPY39", "Button TRIGGER_HAPPY40", "Unknown button #744", + "Unknown button #745", "Unknown button #746", "Unknown button #747", "Unknown button #748", + "Unknown button #749", "Unknown button #750", "Unknown button #751", "Unknown button #752", + "Unknown button #753", "Unknown button #754", "Unknown button #755", "Unknown button #756", + "Unknown button #757", "Unknown button #758", "Unknown button #759", "Unknown button #760", + "Unknown button #761", "Unknown button #762", "Unknown button #763", "Unknown button #764", + "Unknown button #765", "Unknown button #766", "Unknown button #767" + }; std::string get_button_name(uint16_t code) { - if(code <= KEY_MAX && buttonnames[code]) + if(code <= sizeof(buttonnames)/sizeof(buttonnames[0]) && buttonnames[code]) return buttonnames[code]; else return (stringfmt() << "Unknown button #" << code).str(); @@ -38,7 +176,7 @@ namespace std::string get_axis_name(uint16_t code) { - if(code <= ABS_MAX && axisnames[code]) + if(code <= sizeof(axisnames)/sizeof(axisnames[0]) && axisnames[code]) return axisnames[code]; else return (stringfmt() << "Unknown axis #" << code).str(); @@ -163,8 +301,6 @@ namespace void joystick_plugin::init() throw() { - evdev_init_buttons(buttonnames); - evdev_init_axes(axisnames); probe_all_joysticks(); quit_ack = quit_signaled = false; } diff --git a/src/platform/evdev/mktab.lua b/src/platform/evdev/mktab.lua deleted file mode 100644 index b3a47b1a..00000000 --- a/src/platform/evdev/mktab.lua +++ /dev/null @@ -1,12 +0,0 @@ -name = io.stdin:read("*l"); -print("extern \"C\" {"); -print("#include "); -print("}"); -print("void " .. name .. "(const char** x) {"); -for line in io.stdin:lines() do -a,b = string.match(line, "(%S+)%s+(.*)"); -print("#ifdef " .. a); -print("x[" .. a .. "] = \"" .. b .. "\";"); -print("#endif"); -end -print("}");