Added string -> id conversion for evdev

This commit is contained in:
Ingo Ruhnke 2008-12-29 00:34:02 +01:00
parent 62492ba010
commit 08feb93b56
2 changed files with 527 additions and 0 deletions

498
src/evdev_helper.cpp Normal file
View file

@ -0,0 +1,498 @@
/*
** Xbox360 USB Gamepad Userspace Driver
** Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/input.h>
#include <stdexcept>
#include "evdev_helper.hpp"
int str2evbtn(const std::string& name)
{
if (name == "KEY_RESERVED") return KEY_RESERVED;
else if (name == "KEY_ESC") return KEY_ESC;
else if (name == "KEY_1") return KEY_1;
else if (name == "KEY_2") return KEY_2;
else if (name == "KEY_3") return KEY_3;
else if (name == "KEY_4") return KEY_4;
else if (name == "KEY_5") return KEY_5;
else if (name == "KEY_6") return KEY_6;
else if (name == "KEY_7") return KEY_7;
else if (name == "KEY_8") return KEY_8;
else if (name == "KEY_9") return KEY_9;
else if (name == "KEY_0") return KEY_0;
else if (name == "KEY_MINUS") return KEY_MINUS;
else if (name == "KEY_EQUAL") return KEY_EQUAL;
else if (name == "KEY_BACKSPACE") return KEY_BACKSPACE;
else if (name == "KEY_TAB") return KEY_TAB;
else if (name == "KEY_Q") return KEY_Q;
else if (name == "KEY_W") return KEY_W;
else if (name == "KEY_E") return KEY_E;
else if (name == "KEY_R") return KEY_R;
else if (name == "KEY_T") return KEY_T;
else if (name == "KEY_Y") return KEY_Y;
else if (name == "KEY_U") return KEY_U;
else if (name == "KEY_I") return KEY_I;
else if (name == "KEY_O") return KEY_O;
else if (name == "KEY_P") return KEY_P;
else if (name == "KEY_LEFTBRACE") return KEY_LEFTBRACE;
else if (name == "KEY_RIGHTBRACE") return KEY_RIGHTBRACE;
else if (name == "KEY_ENTER") return KEY_ENTER;
else if (name == "KEY_LEFTCTRL") return KEY_LEFTCTRL;
else if (name == "KEY_A") return KEY_A;
else if (name == "KEY_S") return KEY_S;
else if (name == "KEY_D") return KEY_D;
else if (name == "KEY_F") return KEY_F;
else if (name == "KEY_G") return KEY_G;
else if (name == "KEY_H") return KEY_H;
else if (name == "KEY_J") return KEY_J;
else if (name == "KEY_K") return KEY_K;
else if (name == "KEY_L") return KEY_L;
else if (name == "KEY_SEMICOLON") return KEY_SEMICOLON;
else if (name == "KEY_APOSTROPHE") return KEY_APOSTROPHE;
else if (name == "KEY_GRAVE") return KEY_GRAVE;
else if (name == "KEY_LEFTSHIFT") return KEY_LEFTSHIFT;
else if (name == "KEY_BACKSLASH") return KEY_BACKSLASH;
else if (name == "KEY_Z") return KEY_Z;
else if (name == "KEY_X") return KEY_X;
else if (name == "KEY_C") return KEY_C;
else if (name == "KEY_V") return KEY_V;
else if (name == "KEY_B") return KEY_B;
else if (name == "KEY_N") return KEY_N;
else if (name == "KEY_M") return KEY_M;
else if (name == "KEY_COMMA") return KEY_COMMA;
else if (name == "KEY_DOT") return KEY_DOT;
else if (name == "KEY_SLASH") return KEY_SLASH;
else if (name == "KEY_RIGHTSHIFT") return KEY_RIGHTSHIFT;
else if (name == "KEY_KPASTERISK") return KEY_KPASTERISK;
else if (name == "KEY_LEFTALT") return KEY_LEFTALT;
else if (name == "KEY_SPACE") return KEY_SPACE;
else if (name == "KEY_CAPSLOCK") return KEY_CAPSLOCK;
else if (name == "KEY_F1") return KEY_F1;
else if (name == "KEY_F2") return KEY_F2;
else if (name == "KEY_F3") return KEY_F3;
else if (name == "KEY_F4") return KEY_F4;
else if (name == "KEY_F5") return KEY_F5;
else if (name == "KEY_F6") return KEY_F6;
else if (name == "KEY_F7") return KEY_F7;
else if (name == "KEY_F8") return KEY_F8;
else if (name == "KEY_F9") return KEY_F9;
else if (name == "KEY_F10") return KEY_F10;
else if (name == "KEY_NUMLOCK") return KEY_NUMLOCK;
else if (name == "KEY_SCROLLLOCK") return KEY_SCROLLLOCK;
else if (name == "KEY_KP7") return KEY_KP7;
else if (name == "KEY_KP8") return KEY_KP8;
else if (name == "KEY_KP9") return KEY_KP9;
else if (name == "KEY_KPMINUS") return KEY_KPMINUS;
else if (name == "KEY_KP4") return KEY_KP4;
else if (name == "KEY_KP5") return KEY_KP5;
else if (name == "KEY_KP6") return KEY_KP6;
else if (name == "KEY_KPPLUS") return KEY_KPPLUS;
else if (name == "KEY_KP1") return KEY_KP1;
else if (name == "KEY_KP2") return KEY_KP2;
else if (name == "KEY_KP3") return KEY_KP3;
else if (name == "KEY_KP0") return KEY_KP0;
else if (name == "KEY_KPDOT") return KEY_KPDOT;
else if (name == "KEY_ZENKAKUHANKAKU") return KEY_ZENKAKUHANKAKU;
else if (name == "KEY_102ND") return KEY_102ND;
else if (name == "KEY_F11") return KEY_F11;
else if (name == "KEY_F12") return KEY_F12;
else if (name == "KEY_RO") return KEY_RO;
else if (name == "KEY_KATAKANA") return KEY_KATAKANA;
else if (name == "KEY_HIRAGANA") return KEY_HIRAGANA;
else if (name == "KEY_HENKAN") return KEY_HENKAN;
else if (name == "KEY_KATAKANAHIRAGANA") return KEY_KATAKANAHIRAGANA;
else if (name == "KEY_MUHENKAN") return KEY_MUHENKAN;
else if (name == "KEY_KPJPCOMMA") return KEY_KPJPCOMMA;
else if (name == "KEY_KPENTER") return KEY_KPENTER;
else if (name == "KEY_RIGHTCTRL") return KEY_RIGHTCTRL;
else if (name == "KEY_KPSLASH") return KEY_KPSLASH;
else if (name == "KEY_SYSRQ") return KEY_SYSRQ;
else if (name == "KEY_RIGHTALT") return KEY_RIGHTALT;
else if (name == "KEY_LINEFEED") return KEY_LINEFEED;
else if (name == "KEY_HOME") return KEY_HOME;
else if (name == "KEY_UP") return KEY_UP;
else if (name == "KEY_PAGEUP") return KEY_PAGEUP;
else if (name == "KEY_LEFT") return KEY_LEFT;
else if (name == "KEY_RIGHT") return KEY_RIGHT;
else if (name == "KEY_END") return KEY_END;
else if (name == "KEY_DOWN") return KEY_DOWN;
else if (name == "KEY_PAGEDOWN") return KEY_PAGEDOWN;
else if (name == "KEY_INSERT") return KEY_INSERT;
else if (name == "KEY_DELETE") return KEY_DELETE;
else if (name == "KEY_MACRO") return KEY_MACRO;
else if (name == "KEY_MUTE") return KEY_MUTE;
else if (name == "KEY_VOLUMEDOWN") return KEY_VOLUMEDOWN;
else if (name == "KEY_VOLUMEUP") return KEY_VOLUMEUP;
else if (name == "KEY_POWER") return KEY_POWER;
else if (name == "KEY_KPEQUAL") return KEY_KPEQUAL;
else if (name == "KEY_KPPLUSMINUS") return KEY_KPPLUSMINUS;
else if (name == "KEY_PAUSE") return KEY_PAUSE;
else if (name == "KEY_KPCOMMA") return KEY_KPCOMMA;
else if (name == "KEY_HANGEUL") return KEY_HANGEUL;
else if (name == "KEY_HANGUEL") return KEY_HANGUEL;
else if (name == "KEY_HANJA") return KEY_HANJA;
else if (name == "KEY_YEN") return KEY_YEN;
else if (name == "KEY_LEFTMETA") return KEY_LEFTMETA;
else if (name == "KEY_RIGHTMETA") return KEY_RIGHTMETA;
else if (name == "KEY_COMPOSE") return KEY_COMPOSE;
else if (name == "KEY_STOP") return KEY_STOP;
else if (name == "KEY_AGAIN") return KEY_AGAIN;
else if (name == "KEY_PROPS") return KEY_PROPS;
else if (name == "KEY_UNDO") return KEY_UNDO;
else if (name == "KEY_FRONT") return KEY_FRONT;
else if (name == "KEY_COPY") return KEY_COPY;
else if (name == "KEY_OPEN") return KEY_OPEN;
else if (name == "KEY_PASTE") return KEY_PASTE;
else if (name == "KEY_FIND") return KEY_FIND;
else if (name == "KEY_CUT") return KEY_CUT;
else if (name == "KEY_HELP") return KEY_HELP;
else if (name == "KEY_MENU") return KEY_MENU;
else if (name == "KEY_CALC") return KEY_CALC;
else if (name == "KEY_SETUP") return KEY_SETUP;
else if (name == "KEY_SLEEP") return KEY_SLEEP;
else if (name == "KEY_WAKEUP") return KEY_WAKEUP;
else if (name == "KEY_FILE") return KEY_FILE;
else if (name == "KEY_SENDFILE") return KEY_SENDFILE;
else if (name == "KEY_DELETEFILE") return KEY_DELETEFILE;
else if (name == "KEY_XFER") return KEY_XFER;
else if (name == "KEY_PROG1") return KEY_PROG1;
else if (name == "KEY_PROG2") return KEY_PROG2;
else if (name == "KEY_WWW") return KEY_WWW;
else if (name == "KEY_MSDOS") return KEY_MSDOS;
else if (name == "KEY_COFFEE") return KEY_COFFEE;
else if (name == "KEY_SCREENLOCK") return KEY_SCREENLOCK;
else if (name == "KEY_DIRECTION") return KEY_DIRECTION;
else if (name == "KEY_CYCLEWINDOWS") return KEY_CYCLEWINDOWS;
else if (name == "KEY_MAIL") return KEY_MAIL;
else if (name == "KEY_BOOKMARKS") return KEY_BOOKMARKS;
else if (name == "KEY_COMPUTER") return KEY_COMPUTER;
else if (name == "KEY_BACK") return KEY_BACK;
else if (name == "KEY_FORWARD") return KEY_FORWARD;
else if (name == "KEY_CLOSECD") return KEY_CLOSECD;
else if (name == "KEY_EJECTCD") return KEY_EJECTCD;
else if (name == "KEY_EJECTCLOSECD") return KEY_EJECTCLOSECD;
else if (name == "KEY_NEXTSONG") return KEY_NEXTSONG;
else if (name == "KEY_PLAYPAUSE") return KEY_PLAYPAUSE;
else if (name == "KEY_PREVIOUSSONG") return KEY_PREVIOUSSONG;
else if (name == "KEY_STOPCD") return KEY_STOPCD;
else if (name == "KEY_RECORD") return KEY_RECORD;
else if (name == "KEY_REWIND") return KEY_REWIND;
else if (name == "KEY_PHONE") return KEY_PHONE;
else if (name == "KEY_ISO") return KEY_ISO;
else if (name == "KEY_CONFIG") return KEY_CONFIG;
else if (name == "KEY_HOMEPAGE") return KEY_HOMEPAGE;
else if (name == "KEY_REFRESH") return KEY_REFRESH;
else if (name == "KEY_EXIT") return KEY_EXIT;
else if (name == "KEY_MOVE") return KEY_MOVE;
else if (name == "KEY_EDIT") return KEY_EDIT;
else if (name == "KEY_SCROLLUP") return KEY_SCROLLUP;
else if (name == "KEY_SCROLLDOWN") return KEY_SCROLLDOWN;
else if (name == "KEY_KPLEFTPAREN") return KEY_KPLEFTPAREN;
else if (name == "KEY_KPRIGHTPAREN") return KEY_KPRIGHTPAREN;
else if (name == "KEY_NEW") return KEY_NEW;
else if (name == "KEY_REDO") return KEY_REDO;
else if (name == "KEY_F13") return KEY_F13;
else if (name == "KEY_F14") return KEY_F14;
else if (name == "KEY_F15") return KEY_F15;
else if (name == "KEY_F16") return KEY_F16;
else if (name == "KEY_F17") return KEY_F17;
else if (name == "KEY_F18") return KEY_F18;
else if (name == "KEY_F19") return KEY_F19;
else if (name == "KEY_F20") return KEY_F20;
else if (name == "KEY_F21") return KEY_F21;
else if (name == "KEY_F22") return KEY_F22;
else if (name == "KEY_F23") return KEY_F23;
else if (name == "KEY_F24") return KEY_F24;
else if (name == "KEY_PLAYCD") return KEY_PLAYCD;
else if (name == "KEY_PAUSECD") return KEY_PAUSECD;
else if (name == "KEY_PROG3") return KEY_PROG3;
else if (name == "KEY_PROG4") return KEY_PROG4;
else if (name == "KEY_SUSPEND") return KEY_SUSPEND;
else if (name == "KEY_CLOSE") return KEY_CLOSE;
else if (name == "KEY_PLAY") return KEY_PLAY;
else if (name == "KEY_FASTFORWARD") return KEY_FASTFORWARD;
else if (name == "KEY_BASSBOOST") return KEY_BASSBOOST;
else if (name == "KEY_PRINT") return KEY_PRINT;
else if (name == "KEY_HP") return KEY_HP;
else if (name == "KEY_CAMERA") return KEY_CAMERA;
else if (name == "KEY_SOUND") return KEY_SOUND;
else if (name == "KEY_QUESTION") return KEY_QUESTION;
else if (name == "KEY_EMAIL") return KEY_EMAIL;
else if (name == "KEY_CHAT") return KEY_CHAT;
else if (name == "KEY_SEARCH") return KEY_SEARCH;
else if (name == "KEY_CONNECT") return KEY_CONNECT;
else if (name == "KEY_FINANCE") return KEY_FINANCE;
else if (name == "KEY_SPORT") return KEY_SPORT;
else if (name == "KEY_SHOP") return KEY_SHOP;
else if (name == "KEY_ALTERASE") return KEY_ALTERASE;
else if (name == "KEY_CANCEL") return KEY_CANCEL;
else if (name == "KEY_BRIGHTNESSDOWN") return KEY_BRIGHTNESSDOWN;
else if (name == "KEY_BRIGHTNESSUP") return KEY_BRIGHTNESSUP;
else if (name == "KEY_MEDIA") return KEY_MEDIA;
else if (name == "KEY_SWITCHVIDEOMODE") return KEY_SWITCHVIDEOMODE;
else if (name == "KEY_KBDILLUMTOGGLE") return KEY_KBDILLUMTOGGLE;
else if (name == "KEY_KBDILLUMDOWN") return KEY_KBDILLUMDOWN;
else if (name == "KEY_KBDILLUMUP") return KEY_KBDILLUMUP;
else if (name == "KEY_SEND") return KEY_SEND;
else if (name == "KEY_REPLY") return KEY_REPLY;
else if (name == "KEY_FORWARDMAIL") return KEY_FORWARDMAIL;
else if (name == "KEY_SAVE") return KEY_SAVE;
else if (name == "KEY_DOCUMENTS") return KEY_DOCUMENTS;
else if (name == "KEY_BATTERY") return KEY_BATTERY;
else if (name == "KEY_BLUETOOTH") return KEY_BLUETOOTH;
else if (name == "KEY_WLAN") return KEY_WLAN;
else if (name == "KEY_UWB") return KEY_UWB;
else if (name == "KEY_UNKNOWN") return KEY_UNKNOWN;
else if (name == "KEY_VIDEO_NEXT") return KEY_VIDEO_NEXT;
else if (name == "KEY_VIDEO_PREV") return KEY_VIDEO_PREV;
else if (name == "KEY_BRIGHTNESS_CYCLE") return KEY_BRIGHTNESS_CYCLE;
else if (name == "KEY_BRIGHTNESS_ZERO") return KEY_BRIGHTNESS_ZERO;
else if (name == "KEY_DISPLAY_OFF") return KEY_DISPLAY_OFF;
else if (name == "KEY_WIMAX") return KEY_WIMAX;
else if (name == "BTN_MISC") return BTN_MISC;
else if (name == "BTN_0") return BTN_0;
else if (name == "BTN_1") return BTN_1;
else if (name == "BTN_2") return BTN_2;
else if (name == "BTN_3") return BTN_3;
else if (name == "BTN_4") return BTN_4;
else if (name == "BTN_5") return BTN_5;
else if (name == "BTN_6") return BTN_6;
else if (name == "BTN_7") return BTN_7;
else if (name == "BTN_8") return BTN_8;
else if (name == "BTN_9") return BTN_9;
else if (name == "BTN_MOUSE") return BTN_MOUSE;
else if (name == "BTN_LEFT") return BTN_LEFT;
else if (name == "BTN_RIGHT") return BTN_RIGHT;
else if (name == "BTN_MIDDLE") return BTN_MIDDLE;
else if (name == "BTN_SIDE") return BTN_SIDE;
else if (name == "BTN_EXTRA") return BTN_EXTRA;
else if (name == "BTN_FORWARD") return BTN_FORWARD;
else if (name == "BTN_BACK") return BTN_BACK;
else if (name == "BTN_TASK") return BTN_TASK;
else if (name == "BTN_JOYSTICK") return BTN_JOYSTICK;
else if (name == "BTN_TRIGGER") return BTN_TRIGGER;
else if (name == "BTN_THUMB") return BTN_THUMB;
else if (name == "BTN_THUMB2") return BTN_THUMB2;
else if (name == "BTN_TOP") return BTN_TOP;
else if (name == "BTN_TOP2") return BTN_TOP2;
else if (name == "BTN_PINKIE") return BTN_PINKIE;
else if (name == "BTN_BASE") return BTN_BASE;
else if (name == "BTN_BASE2") return BTN_BASE2;
else if (name == "BTN_BASE3") return BTN_BASE3;
else if (name == "BTN_BASE4") return BTN_BASE4;
else if (name == "BTN_BASE5") return BTN_BASE5;
else if (name == "BTN_BASE6") return BTN_BASE6;
else if (name == "BTN_DEAD") return BTN_DEAD;
else if (name == "BTN_GAMEPAD") return BTN_GAMEPAD;
else if (name == "BTN_A") return BTN_A;
else if (name == "BTN_B") return BTN_B;
else if (name == "BTN_C") return BTN_C;
else if (name == "BTN_X") return BTN_X;
else if (name == "BTN_Y") return BTN_Y;
else if (name == "BTN_Z") return BTN_Z;
else if (name == "BTN_TL") return BTN_TL;
else if (name == "BTN_TR") return BTN_TR;
else if (name == "BTN_TL2") return BTN_TL2;
else if (name == "BTN_TR2") return BTN_TR2;
else if (name == "BTN_SELECT") return BTN_SELECT;
else if (name == "BTN_START") return BTN_START;
else if (name == "BTN_MODE") return BTN_MODE;
else if (name == "BTN_THUMBL") return BTN_THUMBL;
else if (name == "BTN_THUMBR") return BTN_THUMBR;
else if (name == "BTN_DIGI") return BTN_DIGI;
else if (name == "BTN_TOOL_PEN") return BTN_TOOL_PEN;
else if (name == "BTN_TOOL_RUBBER") return BTN_TOOL_RUBBER;
else if (name == "BTN_TOOL_BRUSH") return BTN_TOOL_BRUSH;
else if (name == "BTN_TOOL_PENCIL") return BTN_TOOL_PENCIL;
else if (name == "BTN_TOOL_AIRBRUSH") return BTN_TOOL_AIRBRUSH;
else if (name == "BTN_TOOL_FINGER") return BTN_TOOL_FINGER;
else if (name == "BTN_TOOL_MOUSE") return BTN_TOOL_MOUSE;
else if (name == "BTN_TOOL_LENS") return BTN_TOOL_LENS;
else if (name == "BTN_TOUCH") return BTN_TOUCH;
else if (name == "BTN_STYLUS") return BTN_STYLUS;
else if (name == "BTN_STYLUS2") return BTN_STYLUS2;
else if (name == "BTN_TOOL_DOUBLETAP") return BTN_TOOL_DOUBLETAP;
else if (name == "BTN_TOOL_TRIPLETAP") return BTN_TOOL_TRIPLETAP;
else if (name == "BTN_WHEEL") return BTN_WHEEL;
else if (name == "BTN_GEAR_DOWN") return BTN_GEAR_DOWN;
else if (name == "BTN_GEAR_UP") return BTN_GEAR_UP;
else if (name == "KEY_OK") return KEY_OK;
else if (name == "KEY_SELECT") return KEY_SELECT;
else if (name == "KEY_GOTO") return KEY_GOTO;
else if (name == "KEY_CLEAR") return KEY_CLEAR;
else if (name == "KEY_POWER2") return KEY_POWER2;
else if (name == "KEY_OPTION") return KEY_OPTION;
else if (name == "KEY_INFO") return KEY_INFO;
else if (name == "KEY_TIME") return KEY_TIME;
else if (name == "KEY_VENDOR") return KEY_VENDOR;
else if (name == "KEY_ARCHIVE") return KEY_ARCHIVE;
else if (name == "KEY_PROGRAM") return KEY_PROGRAM;
else if (name == "KEY_CHANNEL") return KEY_CHANNEL;
else if (name == "KEY_FAVORITES") return KEY_FAVORITES;
else if (name == "KEY_EPG") return KEY_EPG;
else if (name == "KEY_PVR") return KEY_PVR;
else if (name == "KEY_MHP") return KEY_MHP;
else if (name == "KEY_LANGUAGE") return KEY_LANGUAGE;
else if (name == "KEY_TITLE") return KEY_TITLE;
else if (name == "KEY_SUBTITLE") return KEY_SUBTITLE;
else if (name == "KEY_ANGLE") return KEY_ANGLE;
else if (name == "KEY_ZOOM") return KEY_ZOOM;
else if (name == "KEY_MODE") return KEY_MODE;
else if (name == "KEY_KEYBOARD") return KEY_KEYBOARD;
else if (name == "KEY_SCREEN") return KEY_SCREEN;
else if (name == "KEY_PC") return KEY_PC;
else if (name == "KEY_TV") return KEY_TV;
else if (name == "KEY_TV2") return KEY_TV2;
else if (name == "KEY_VCR") return KEY_VCR;
else if (name == "KEY_VCR2") return KEY_VCR2;
else if (name == "KEY_SAT") return KEY_SAT;
else if (name == "KEY_SAT2") return KEY_SAT2;
else if (name == "KEY_CD") return KEY_CD;
else if (name == "KEY_TAPE") return KEY_TAPE;
else if (name == "KEY_RADIO") return KEY_RADIO;
else if (name == "KEY_TUNER") return KEY_TUNER;
else if (name == "KEY_PLAYER") return KEY_PLAYER;
else if (name == "KEY_TEXT") return KEY_TEXT;
else if (name == "KEY_DVD") return KEY_DVD;
else if (name == "KEY_AUX") return KEY_AUX;
else if (name == "KEY_MP3") return KEY_MP3;
else if (name == "KEY_AUDIO") return KEY_AUDIO;
else if (name == "KEY_VIDEO") return KEY_VIDEO;
else if (name == "KEY_DIRECTORY") return KEY_DIRECTORY;
else if (name == "KEY_LIST") return KEY_LIST;
else if (name == "KEY_MEMO") return KEY_MEMO;
else if (name == "KEY_CALENDAR") return KEY_CALENDAR;
else if (name == "KEY_RED") return KEY_RED;
else if (name == "KEY_GREEN") return KEY_GREEN;
else if (name == "KEY_YELLOW") return KEY_YELLOW;
else if (name == "KEY_BLUE") return KEY_BLUE;
else if (name == "KEY_CHANNELUP") return KEY_CHANNELUP;
else if (name == "KEY_CHANNELDOWN") return KEY_CHANNELDOWN;
else if (name == "KEY_FIRST") return KEY_FIRST;
else if (name == "KEY_LAST") return KEY_LAST;
else if (name == "KEY_AB") return KEY_AB;
else if (name == "KEY_NEXT") return KEY_NEXT;
else if (name == "KEY_RESTART") return KEY_RESTART;
else if (name == "KEY_SLOW") return KEY_SLOW;
else if (name == "KEY_SHUFFLE") return KEY_SHUFFLE;
else if (name == "KEY_BREAK") return KEY_BREAK;
else if (name == "KEY_PREVIOUS") return KEY_PREVIOUS;
else if (name == "KEY_DIGITS") return KEY_DIGITS;
else if (name == "KEY_TEEN") return KEY_TEEN;
else if (name == "KEY_TWEN") return KEY_TWEN;
else if (name == "KEY_VIDEOPHONE") return KEY_VIDEOPHONE;
else if (name == "KEY_GAMES") return KEY_GAMES;
else if (name == "KEY_ZOOMIN") return KEY_ZOOMIN;
else if (name == "KEY_ZOOMOUT") return KEY_ZOOMOUT;
else if (name == "KEY_ZOOMRESET") return KEY_ZOOMRESET;
else if (name == "KEY_WORDPROCESSOR") return KEY_WORDPROCESSOR;
else if (name == "KEY_EDITOR") return KEY_EDITOR;
else if (name == "KEY_SPREADSHEET") return KEY_SPREADSHEET;
else if (name == "KEY_GRAPHICSEDITOR") return KEY_GRAPHICSEDITOR;
else if (name == "KEY_PRESENTATION") return KEY_PRESENTATION;
else if (name == "KEY_DATABASE") return KEY_DATABASE;
else if (name == "KEY_NEWS") return KEY_NEWS;
else if (name == "KEY_VOICEMAIL") return KEY_VOICEMAIL;
else if (name == "KEY_ADDRESSBOOK") return KEY_ADDRESSBOOK;
else if (name == "KEY_MESSENGER") return KEY_MESSENGER;
else if (name == "KEY_DISPLAYTOGGLE") return KEY_DISPLAYTOGGLE;
else if (name == "KEY_SPELLCHECK") return KEY_SPELLCHECK;
else if (name == "KEY_LOGOFF") return KEY_LOGOFF;
else if (name == "KEY_DOLLAR") return KEY_DOLLAR;
else if (name == "KEY_EURO") return KEY_EURO;
else if (name == "KEY_FRAMEBACK") return KEY_FRAMEBACK;
else if (name == "KEY_FRAMEFORWARD") return KEY_FRAMEFORWARD;
else if (name == "KEY_CONTEXT_MENU") return KEY_CONTEXT_MENU;
else if (name == "KEY_MEDIA_REPEAT") return KEY_MEDIA_REPEAT;
else if (name == "KEY_DEL_EOL") return KEY_DEL_EOL;
else if (name == "KEY_DEL_EOS") return KEY_DEL_EOS;
else if (name == "KEY_INS_LINE") return KEY_INS_LINE;
else if (name == "KEY_DEL_LINE") return KEY_DEL_LINE;
else if (name == "KEY_FN") return KEY_FN;
else if (name == "KEY_FN_ESC") return KEY_FN_ESC;
else if (name == "KEY_FN_F1") return KEY_FN_F1;
else if (name == "KEY_FN_F2") return KEY_FN_F2;
else if (name == "KEY_FN_F3") return KEY_FN_F3;
else if (name == "KEY_FN_F4") return KEY_FN_F4;
else if (name == "KEY_FN_F5") return KEY_FN_F5;
else if (name == "KEY_FN_F6") return KEY_FN_F6;
else if (name == "KEY_FN_F7") return KEY_FN_F7;
else if (name == "KEY_FN_F8") return KEY_FN_F8;
else if (name == "KEY_FN_F9") return KEY_FN_F9;
else if (name == "KEY_FN_F10") return KEY_FN_F10;
else if (name == "KEY_FN_F11") return KEY_FN_F11;
else if (name == "KEY_FN_F12") return KEY_FN_F12;
else if (name == "KEY_FN_1") return KEY_FN_1;
else if (name == "KEY_FN_2") return KEY_FN_2;
else if (name == "KEY_FN_D") return KEY_FN_D;
else if (name == "KEY_FN_E") return KEY_FN_E;
else if (name == "KEY_FN_F") return KEY_FN_F;
else if (name == "KEY_FN_S") return KEY_FN_S;
else if (name == "KEY_FN_B") return KEY_FN_B;
else if (name == "KEY_BRL_DOT1") return KEY_BRL_DOT1;
else if (name == "KEY_BRL_DOT2") return KEY_BRL_DOT2;
else if (name == "KEY_BRL_DOT3") return KEY_BRL_DOT3;
else if (name == "KEY_BRL_DOT4") return KEY_BRL_DOT4;
else if (name == "KEY_BRL_DOT5") return KEY_BRL_DOT5;
else if (name == "KEY_BRL_DOT6") return KEY_BRL_DOT6;
else if (name == "KEY_BRL_DOT7") return KEY_BRL_DOT7;
else if (name == "KEY_BRL_DOT8") return KEY_BRL_DOT8;
else if (name == "KEY_BRL_DOT9") return KEY_BRL_DOT9;
else if (name == "KEY_BRL_DOT10") return KEY_BRL_DOT10;
else if (name == "KEY_MIN_INTERESTING") return KEY_MIN_INTERESTING;
else if (name == "KEY_MAX") return KEY_MAX;
else if (name == "KEY_CNT") return KEY_CNT;
else
throw std::runtime_error("str2evbtn: Couldn't convert '" + name + "' to id");
}
int str2evabs(const std::string& name)
{
if (name == "ABS_X") return ABS_X;
else if (name == "ABS_Y") return ABS_Y;
else if (name == "ABS_Z") return ABS_Z;
else if (name == "ABS_RX") return ABS_RX;
else if (name == "ABS_RY") return ABS_RY;
else if (name == "ABS_RZ") return ABS_RZ;
else if (name == "ABS_THROTTLE") return ABS_THROTTLE;
else if (name == "ABS_RUDDER") return ABS_RUDDER;
else if (name == "ABS_WHEEL") return ABS_WHEEL;
else if (name == "ABS_GAS") return ABS_GAS;
else if (name == "ABS_BRAKE") return ABS_BRAKE;
else if (name == "ABS_HAT0X") return ABS_HAT0X;
else if (name == "ABS_HAT0Y") return ABS_HAT0Y;
else if (name == "ABS_HAT1X") return ABS_HAT1X;
else if (name == "ABS_HAT1Y") return ABS_HAT1Y;
else if (name == "ABS_HAT2X") return ABS_HAT2X;
else if (name == "ABS_HAT2Y") return ABS_HAT2Y;
else if (name == "ABS_HAT3X") return ABS_HAT3X;
else if (name == "ABS_HAT3Y") return ABS_HAT3Y;
else if (name == "ABS_PRESSURE") return ABS_PRESSURE;
else if (name == "ABS_DISTANCE") return ABS_DISTANCE;
else if (name == "ABS_TILT_X") return ABS_TILT_X;
else if (name == "ABS_TILT_Y") return ABS_TILT_Y;
else if (name == "ABS_TOOL_WIDTH") return ABS_TOOL_WIDTH;
else if (name == "ABS_VOLUME") return ABS_VOLUME;
else if (name == "ABS_MISC") return ABS_MISC;
else if (name == "ABS_MAX") return ABS_MAX;
else if (name == "ABS_CNT") return ABS_CNT;
else
throw std::runtime_error("str2evabs: Couldn't convert '" + name + "' to id");
}
/* EOF */

29
src/evdev_helper.hpp Normal file
View file

@ -0,0 +1,29 @@
/*
** Xbox360 USB Gamepad Userspace Driver
** Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HEADER_EVDEV_HELPER_HPP
#define HEADER_EVDEV_HELPER_HPP
#include <string>
int str2evbtn(const std::string& name);
int str2evabs(const std::string& name);
#endif
/* EOF */