Merge pull request #90 from daniel-dressler/master

Add key code pass through to applications
This commit is contained in:
Henrik Rydgård 2013-07-02 11:24:17 -07:00
commit d28b58a203
8 changed files with 471 additions and 215 deletions

View File

@ -39,6 +39,7 @@ static float left_joystick_x_async;
static float left_joystick_y_async;
static float right_joystick_x_async;
static float right_joystick_y_async;
static int key_queue_async[MAX_KEYQUEUESIZE];
static uint32_t pad_buttons_down;
@ -148,6 +149,8 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
right_joystick_x_async = 0;
right_joystick_y_async = 0;
KeyQueueBlank(key_queue_async);
std::string apkPath = GetJavaString(env, japkpath);
ILOG("NativeApp::Init: APK path: %s", apkPath.c_str());
VFSRegister("", new ZipAssetReader(apkPath.c_str(), "assets/"));
@ -260,6 +263,7 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeRenderer_displayRender(JN
pad_buttons_down |= pad_buttons_async_set;
pad_buttons_down &= ~pad_buttons_async_clear;
input_state.pad_buttons = pad_buttons_down;
KeyQueueCopyQueue(key_queue_async, input_state.key_queue);
UpdateInputState(&input_state);
}
@ -369,6 +373,8 @@ static inline void AsyncUp(int padbutton) {
}
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyDown(JNIEnv *, jclass, jint key) {
KeyQueueAddKey(key_queue_async, key);
switch (key) {
case 1: AsyncDown (PAD_BUTTON_BACK); break; // Back
case 2: AsyncDown (PAD_BUTTON_MENU); break; // Menu
@ -396,6 +402,8 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyDown(JNIEnv *, jcl
}
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_keyUp(JNIEnv *, jclass, jint key) {
KeyQueueRemoveKey(key_queue_async, key);
switch (key) {
case 1: AsyncUp (PAD_BUTTON_BACK); break; // Back
case 2: AsyncUp (PAD_BUTTON_MENU); break; // Menu

View File

@ -1,218 +1,9 @@
#pragma once
// For Xperia Play support
enum AndroidKeyCodes {
KEYCODE_BUTTON_CROSS = 23, // trackpad or X button(Xperia Play) is pressed
KEYCODE_BUTTON_CROSS_PS3 = 96, // PS3 X button is pressed
KEYCODE_BUTTON_CIRCLE = 1004, // Special custom keycode generated from 'O' button by our java code. Or 'O' button if Alt is pressed (TODO)
KEYCODE_BUTTON_CIRCLE_PS3 = 97, // PS3 O button is pressed
KEYCODE_BUTTON_SQUARE = 99, // Square button(Xperia Play) is pressed
KEYCODE_BUTTON_TRIANGLE = 100, // 'Triangle button(Xperia Play) is pressed
KEYCODE_DPAD_LEFT = 21,
KEYCODE_DPAD_UP = 19,
KEYCODE_DPAD_RIGHT = 22,
KEYCODE_DPAD_DOWN = 20,
KEYCODE_DPAD_CENTER = 23,
KEYCODE_UNKNOWN = 0,
KEYCODE_SOFT_LEFT = 1,
KEYCODE_SOFT_RIGHT = 2,
KEYCODE_HOME = 3,
KEYCODE_BACK = 4,
KEYCODE_CALL = 5,
KEYCODE_ENDCALL = 6,
KEYCODE_0 = 7,
KEYCODE_1 = 8,
KEYCODE_2 = 9,
KEYCODE_3 = 10,
KEYCODE_4 = 11,
KEYCODE_5 = 12,
KEYCODE_6 = 13,
KEYCODE_7 = 14,
KEYCODE_8 = 15,
KEYCODE_9 = 16,
KEYCODE_STAR = 17,
KEYCODE_POUND = 18,
KEYCODE_VOLUME_UP = 24,
KEYCODE_VOLUME_DOWN = 25,
KEYCODE_POWER = 26,
KEYCODE_CAMERA = 27,
KEYCODE_CLEAR = 28,
KEYCODE_A = 29,
KEYCODE_B = 30,
KEYCODE_C = 31,
KEYCODE_D = 32,
KEYCODE_E = 33,
KEYCODE_F = 34,
KEYCODE_G = 35,
KEYCODE_H = 36,
KEYCODE_I = 37,
KEYCODE_J = 38,
KEYCODE_K = 39,
KEYCODE_L = 40,
KEYCODE_M = 41,
KEYCODE_N = 42,
KEYCODE_O = 43,
KEYCODE_P = 44,
KEYCODE_Q = 45,
KEYCODE_R = 46,
KEYCODE_S = 47,
KEYCODE_T = 48,
KEYCODE_U = 49,
KEYCODE_V = 50,
KEYCODE_W = 51,
KEYCODE_X = 52,
KEYCODE_Y = 53,
KEYCODE_Z = 54,
KEYCODE_COMMA = 55,
KEYCODE_PERIOD = 56,
KEYCODE_ALT_LEFT = 57,
KEYCODE_ALT_RIGHT = 58,
KEYCODE_SHIFT_LEFT = 59,
KEYCODE_SHIFT_RIGHT = 60,
KEYCODE_TAB = 61,
KEYCODE_SPACE = 62,
KEYCODE_SYM = 63,
KEYCODE_EXPLORER = 64,
KEYCODE_ENVELOPE = 65,
KEYCODE_ENTER = 66,
KEYCODE_DEL = 67,
KEYCODE_GRAVE = 68,
KEYCODE_MINUS = 69,
KEYCODE_EQUALS = 70,
KEYCODE_LEFT_BRACKET = 71,
KEYCODE_RIGHT_BRACKET = 72,
KEYCODE_BACKSLASH = 73,
KEYCODE_SEMICOLON = 74,
KEYCODE_APOSTROPHE = 75,
KEYCODE_SLASH = 76,
KEYCODE_AT = 77,
KEYCODE_NUM = 78,
KEYCODE_HEADSETHOOK = 79,
KEYCODE_FOCUS = 80,
KEYCODE_PLUS = 81,
KEYCODE_MENU = 82,
KEYCODE_NOTIFICATION = 83,
KEYCODE_SEARCH = 84,
KEYCODE_MEDIA_PLAY_PAUSE = 85,
KEYCODE_MEDIA_STOP = 86,
KEYCODE_MEDIA_NEXT = 87,
KEYCODE_MEDIA_PREVIOUS = 88,
KEYCODE_MEDIA_REWIND = 89,
KEYCODE_MEDIA_FAST_FORWARD = 90,
KEYCODE_MUTE = 91,
KEYCODE_PAGE_UP = 92,
KEYCODE_PAGE_DOWN = 93,
KEYCODE_PICTSYMBOLS = 94,
KEYCODE_SWITCH_CHARSET = 95,
KEYCODE_BUTTON_A = 96,
KEYCODE_BUTTON_B = 97,
KEYCODE_BUTTON_C = 98,
KEYCODE_BUTTON_X = 99,
KEYCODE_BUTTON_Y = 100,
KEYCODE_BUTTON_Z = 101,
KEYCODE_BUTTON_L1 = 102,
KEYCODE_BUTTON_R1 = 103,
KEYCODE_BUTTON_L2 = 104,
KEYCODE_BUTTON_R2 = 105,
KEYCODE_BUTTON_THUMBL = 106,
KEYCODE_BUTTON_THUMBR = 107,
KEYCODE_BUTTON_START = 108,
KEYCODE_BUTTON_SELECT = 109,
KEYCODE_BUTTON_MODE = 110,
KEYCODE_ESCAPE = 111,
KEYCODE_FORWARD_DEL = 112,
KEYCODE_CTRL_LEFT = 113,
KEYCODE_CTRL_RIGHT = 114,
KEYCODE_CAPS_LOCK = 115,
KEYCODE_SCROLL_LOCK = 116,
KEYCODE_META_LEFT = 117,
KEYCODE_META_RIGHT = 118,
KEYCODE_FUNCTION = 119,
KEYCODE_SYSRQ = 120,
KEYCODE_BREAK = 121,
KEYCODE_MOVE_HOME = 122,
KEYCODE_MOVE_END = 123,
KEYCODE_INSERT = 124,
KEYCODE_FORWARD = 125,
KEYCODE_MEDIA_PLAY = 126,
KEYCODE_MEDIA_PAUSE = 127,
KEYCODE_MEDIA_CLOSE = 128,
KEYCODE_MEDIA_EJECT = 129,
KEYCODE_MEDIA_RECORD = 130,
KEYCODE_F1 = 131,
KEYCODE_F2 = 132,
KEYCODE_F3 = 133,
KEYCODE_F4 = 134,
KEYCODE_F5 = 135,
KEYCODE_F6 = 136,
KEYCODE_F7 = 137,
KEYCODE_F8 = 138,
KEYCODE_F9 = 139,
KEYCODE_F10 = 140,
KEYCODE_F11 = 141,
KEYCODE_F12 = 142,
KEYCODE_NUM_LOCK = 143,
KEYCODE_NUMPAD_0 = 144,
KEYCODE_NUMPAD_1 = 145,
KEYCODE_NUMPAD_2 = 146,
KEYCODE_NUMPAD_3 = 147,
KEYCODE_NUMPAD_4 = 148,
KEYCODE_NUMPAD_5 = 149,
KEYCODE_NUMPAD_6 = 150,
KEYCODE_NUMPAD_7 = 151,
KEYCODE_NUMPAD_8 = 152,
KEYCODE_NUMPAD_9 = 153,
KEYCODE_NUMPAD_DIVIDE = 154,
KEYCODE_NUMPAD_MULTIPLY = 155,
KEYCODE_NUMPAD_SUBTRACT = 156,
KEYCODE_NUMPAD_ADD = 157,
KEYCODE_NUMPAD_DOT = 158,
KEYCODE_NUMPAD_COMMA = 159,
KEYCODE_NUMPAD_ENTER = 160,
KEYCODE_NUMPAD_EQUALS = 161,
KEYCODE_NUMPAD_LEFT_PAREN = 162,
KEYCODE_NUMPAD_RIGHT_PAREN = 163,
KEYCODE_VOLUME_MUTE = 164,
KEYCODE_INFO = 165,
KEYCODE_CHANNEL_UP = 166,
KEYCODE_CHANNEL_DOWN = 167,
KEYCODE_ZOOM_IN = 168,
KEYCODE_ZOOM_OUT = 169,
KEYCODE_TV = 170,
KEYCODE_WINDOW = 171,
KEYCODE_GUIDE = 172,
KEYCODE_DVR = 173,
KEYCODE_BOOKMARK = 174,
KEYCODE_CAPTIONS = 175,
KEYCODE_SETTINGS = 176,
KEYCODE_TV_POWER = 177,
KEYCODE_TV_INPUT = 178,
KEYCODE_STB_POWER = 179,
KEYCODE_STB_INPUT = 180,
KEYCODE_AVR_POWER = 181,
KEYCODE_AVR_INPUT = 182,
KEYCODE_PROG_RED = 183,
KEYCODE_PROG_GREEN = 184,
KEYCODE_PROG_YELLOW = 185,
KEYCODE_PROG_BLUE = 186,
KEYCODE_APP_SWITCH = 187,
KEYCODE_BUTTON_1 = 188,
KEYCODE_BUTTON_2 = 189,
KEYCODE_BUTTON_3 = 190,
KEYCODE_BUTTON_4 = 191,
KEYCODE_BUTTON_5 = 192,
KEYCODE_BUTTON_6 = 193,
KEYCODE_BUTTON_7 = 194,
KEYCODE_BUTTON_8 = 195,
KEYCODE_BUTTON_9 = 196,
KEYCODE_BUTTON_10 = 197,
KEYCODE_BUTTON_11 = 198,
KEYCODE_BUTTON_12 = 199,
KEYCODE_BUTTON_13 = 200,
KEYCODE_BUTTON_14 = 201,
KEYCODE_BUTTON_15 = 202,
KEYCODE_BUTTON_16 = 203,
};
// Compatability we alias the keycodes
// since native's keycodes are based on
// android keycodes.
typedef enum _keycode_t enum AndroidKeyCodes;
enum AndroidJoystickAxis {
// Field descriptor #15 I

View File

@ -0,0 +1,95 @@
#include "util/const_map.h"
#include <map>
// TODO: Add any missing keys
static const std::map<int, int> KeyMapRawSDLtoNative = InitConstMap<int, int>
(SDLK_p, KEYCODE_P)
(SDLK_o, KEYCODE_O)
(SDLK_i, KEYCODE_I)
(SDLK_u, KEYCODE_U)
(SDLK_y, KEYCODE_Y)
(SDLK_t, KEYCODE_T)
(SDLK_r, KEYCODE_R)
(SDLK_e, KEYCODE_E)
(SDLK_w, KEYCODE_W)
(SDLK_q, KEYCODE_Q)
(SDLK_l, KEYCODE_L)
(SDLK_k, KEYCODE_K)
(SDLK_j, KEYCODE_J)
(SDLK_h, KEYCODE_H)
(SDLK_g, KEYCODE_G)
(SDLK_f, KEYCODE_F)
(SDLK_d, KEYCODE_D)
(SDLK_s, KEYCODE_S)
(SDLK_a, KEYCODE_A)
(SDLK_m, KEYCODE_M)
(SDLK_n, KEYCODE_N)
(SDLK_b, KEYCODE_B)
(SDLK_v, KEYCODE_V)
(SDLK_c, KEYCODE_C)
(SDLK_x, KEYCODE_X)
(SDLK_z, KEYCODE_Z)
(SDLK_COMMA, KEYCODE_COMMA)
(SDLK_PERIOD, KEYCODE_PERIOD)
(SDLK_LALT, KEYCODE_ALT_LEFT)
(SDLK_RALT, KEYCODE_ALT_RIGHT)
(SDLK_LSHIFT, KEYCODE_SHIFT_LEFT)
(SDLK_RSHIFT, KEYCODE_SHIFT_RIGHT)
(SDLK_TAB, KEYCODE_TAB)
(SDLK_SPACE, KEYCODE_SPACE)
(SDLK_RETURN, KEYCODE_ENTER)
(SDLK_MINUS, KEYCODE_MINUS)
(SDLK_EQUALS, KEYCODE_EQUALS)
(SDLK_LEFTBRACKET, KEYCODE_LEFT_BRACKET)
(SDLK_RIGHTBRACKET, KEYCODE_RIGHT_BRACKET)
(SDLK_BACKSLASH, KEYCODE_BACKSLASH)
(SDLK_SEMICOLON, KEYCODE_SEMICOLON)
// (SDLK_, KEYCODE_APOSTROPHE) // I cannot find the SDL equiv
(SDLK_SLASH, KEYCODE_SLASH)
(SDLK_AT, KEYCODE_AT)
(SDLK_PLUS, KEYCODE_PLUS)
(SDLK_PAGEUP, KEYCODE_PAGE_UP)
(SDLK_PAGEDOWN, KEYCODE_PAGE_DOWN)
(SDLK_ESCAPE, KEYCODE_ESCAPE)
(SDLK_DELETE, KEYCODE_FORWARD_DEL)
(SDLK_LCTRL, KEYCODE_CTRL_LEFT)
(SDLK_RCTRL, KEYCODE_CTRL_RIGHT)
(SDLK_CAPSLOCK, KEYCODE_CAPS_LOCK)
(SDLK_HOME, KEYCODE_MOVE_HOME)
(SDLK_END, KEYCODE_MOVE_END)
(SDLK_INSERT, KEYCODE_INSERT)
/* Somehow these are undefined
* on my comp?
(SDLK_KP_0, KEYCODE_NUMPAD_0)
(SDLK_KP_1, KEYCODE_NUMPAD_1)
(SDLK_KP_2, KEYCODE_NUMPAD_2)
(SDLK_KP_3, KEYCODE_NUMPAD_3)
(SDLK_KP_4, KEYCODE_NUMPAD_4)
(SDLK_KP_5, KEYCODE_NUMPAD_5)
(SDLK_KP_6, KEYCODE_NUMPAD_6)
(SDLK_KP_7, KEYCODE_NUMPAD_7)
(SDLK_KP_8, KEYCODE_NUMPAD_8)
(SDLK_KP_9, KEYCODE_NUMPAD_9)
*/
(SDLK_KP_DIVIDE, KEYCODE_NUMPAD_DIVIDE)
(SDLK_KP_MULTIPLY, KEYCODE_NUMPAD_MULTIPLY)
(SDLK_KP_MINUS, KEYCODE_NUMPAD_SUBTRACT)
(SDLK_KP_PLUS, KEYCODE_NUMPAD_ADD)
(SDLK_KP_PERIOD, KEYCODE_NUMPAD_DOT)
(SDLK_KP_ENTER, KEYCODE_NUMPAD_ENTER)
(SDLK_KP_EQUALS, KEYCODE_NUMPAD_EQUALS)
(SDLK_1, KEYCODE_1)
(SDLK_2, KEYCODE_2)
(SDLK_3, KEYCODE_3)
(SDLK_4, KEYCODE_4)
(SDLK_5, KEYCODE_5)
(SDLK_6, KEYCODE_6)
(SDLK_7, KEYCODE_7)
(SDLK_8, KEYCODE_8)
(SDLK_9, KEYCODE_9)
(SDLK_0, KEYCODE_0)
(SDLK_LEFT, KEYCODE_DPAD_LEFT)
(SDLK_UP, KEYCODE_DPAD_UP)
(SDLK_RIGHT, KEYCODE_DPAD_RIGHT)
(SDLK_DOWN, KEYCODE_DPAD_DOWN);

View File

@ -14,6 +14,7 @@
#endif
#include <string>
#include <map>
#ifdef _WIN32
#include "SDL/SDL.h"
#include "SDL/SDL_timer.h"
@ -32,9 +33,11 @@
#include "gfx_es2/glsl_program.h"
#include "file/zip_read.h"
#include "input/input_state.h"
#include "input/keycodes.h"
#include "base/KeyCodeTranslationFromSDL.h"
#include "base/NativeApp.h"
#include "net/resolve.h"
#include "util/const_map.h"
#if defined(MAEMO) || defined(PANDORA)
#define EGL
@ -247,6 +250,7 @@ void LaunchEmail(const char *email_address)
InputState input_state;
const int buttonMappings[14] = {
#ifdef PANDORA
SDLK_PAGEDOWN, //X => cross
@ -285,10 +289,12 @@ void SimulateGamepad(const uint8 *keys, InputState *input) {
input->pad_lstick_y = 0;
input->pad_rstick_x = 0;
input->pad_rstick_y = 0;
/*
for (int b = 0; b < 14; b++) {
if (keys[buttonMappings[b]])
input->pad_buttons |= (1<<b);
}
*/
#ifdef PANDORA
if ((ljoy)||(rjoy)) {
@ -532,6 +538,14 @@ int main(int argc, char *argv[]) {
if (event.key.keysym.sym == SDLK_ESCAPE) {
quitRequested = 1;
}
KeyQueueAttemptTranslatedAdd(input_state.key_queue,
KeyMapRawSDLtoNative,
event.key.keysym.sym);
} else if (event.type == SDL_KEYUP) {
KeyQueueAttemptTranslatedRemove(input_state.key_queue,
KeyMapRawSDLtoNative,
event.key.keysym.sym);
} else if (event.type == SDL_MOUSEBUTTONDOWN) {
if (event.button.button == SDL_BUTTON_LEFT) {
input_state.pointer_x[0] = mx;

96
input/input_state.cpp Normal file
View File

@ -0,0 +1,96 @@
#include "input_state.h"
#include <iostream>
#define max_queue MAX_KEYQUEUESIZE
void MakeRoomInQueueFront(int queue[])
{
// shift queue elements from front towards back
for (int i = max_queue - 1; i > 0; i--) {
queue[i] = queue[i - 1];
}
queue[0] = 0;
}
void FillGap(int queue[], int gap_loc)
{
// shift elements from back towards front
// until gap location is filled
for (int i = gap_loc; i < max_queue; i++) {
queue[i] = queue[i + 1];
}
queue[max_queue - 1] = 0;
}
void KeyQueueAddKey(int queue[], int key)
{
for (int i = 0; i < max_queue; i++) {
if (queue[i] == key)
return;
if (queue[i] == 0) {
queue[i] = key;
return;
}
}
// queue was full
MakeRoomInQueueFront(queue);
queue[0] = key;
}
void KeyQueueRemoveKey(int queue[], int key)
{
for (int i = 0; i < max_queue; i++)
if (queue[i] == key)
FillGap(queue, i);
}
void KeyQueueCopyQueue(int src[], int dst[])
{
for (int i = 0; i < max_queue; i++)
dst[i] = src[i];
}
void KeyQueueBlank(int queue[])
{
for (int i = 0; i < max_queue; i++)
queue[i] = 0;
}
int AttemptTranslate(const std::map<int, int> trans_table, int plat_key)
{
std::map<int, int>::const_iterator iter;
iter = trans_table.find(plat_key);
if (iter == trans_table.end())
return 0;
return iter->second;
}
void KeyQueueAttemptTranslatedAdd(int queue[],
const std::map<int, int> translation_table,
int platform_key)
{
int key = AttemptTranslate(translation_table, platform_key);
if (key == 0) {
std::cerr << "Warning: Platform key code translation table missing "
<< "(" << platform_key << ")\n";
return;
}
KeyQueueAddKey(queue, key);
}
void KeyQueueAttemptTranslatedRemove(int queue[],
const std::map<int, int> translation_table,
int platform_key)
{
int key = AttemptTranslate(translation_table, platform_key);
if (key == 0)
return;
KeyQueueRemoveKey(queue, key);
}

View File

@ -3,6 +3,7 @@
#include "math/lin/vec3.h"
#include "base/mutex.h"
#include "base/basictypes.h"
#include <map>
enum {
PAD_BUTTON_A = 1,
@ -39,6 +40,10 @@ enum {
#ifndef MAX_POINTERS
#define MAX_POINTERS 8
#endif
#ifndef MAX_KEYQUEUESIZE
#define MAX_KEYQUEUESIZE 20
#endif
// Collection of all possible inputs, and automatically computed
// deltas where applicable.
@ -79,7 +84,7 @@ struct InputState {
bool accelerometer_valid;
Vec3 acc;
// TODO: Add key arrays
int key_queue[MAX_KEYQUEUESIZE];
private:
DISALLOW_COPY_AND_ASSIGN(InputState);
@ -113,3 +118,11 @@ struct TouchInput {
double timestamp;
};
// Key Queue Helpers
void KeyQueueAddKey(int [], int);
void KeyQueueRemoveKey(int [], int);
void KeyQueueCopyQueue(int src[], int dst[]);
void KeyQueueBlank(int []);
void KeyQueueAttemptTranslatedAdd(int [], const std::map<int, int>, int);
void KeyQueueAttemptTranslatedRemove(int [], const std::map<int, int>, int);

215
input/keycodes.h Normal file
View File

@ -0,0 +1,215 @@
#pragma once
typedef enum _keycode_t {
KEYCODE_BUTTON_CROSS = 23, // trackpad or X button(Xperia Play) is pressed
KEYCODE_BUTTON_CROSS_PS3 = 96, // PS3 X button is pressed
KEYCODE_BUTTON_CIRCLE = 1004, // Special custom keycode generated from 'O' button by our java code. Or 'O' button if Alt is pressed (TODO)
KEYCODE_BUTTON_CIRCLE_PS3 = 97, // PS3 O button is pressed
KEYCODE_BUTTON_SQUARE = 99, // Square button(Xperia Play) is pressed
KEYCODE_BUTTON_TRIANGLE = 100, // 'Triangle button(Xperia Play) is pressed
KEYCODE_DPAD_LEFT = 21,
KEYCODE_DPAD_UP = 19,
KEYCODE_DPAD_RIGHT = 22,
KEYCODE_DPAD_DOWN = 20,
KEYCODE_DPAD_CENTER = 23,
KEYCODE_UNKNOWN = 0,
KEYCODE_SOFT_LEFT = 1,
KEYCODE_SOFT_RIGHT = 2,
KEYCODE_HOME = 3,
KEYCODE_BACK = 4,
KEYCODE_CALL = 5,
KEYCODE_ENDCALL = 6,
KEYCODE_0 = 7,
KEYCODE_1 = 8,
KEYCODE_2 = 9,
KEYCODE_3 = 10,
KEYCODE_4 = 11,
KEYCODE_5 = 12,
KEYCODE_6 = 13,
KEYCODE_7 = 14,
KEYCODE_8 = 15,
KEYCODE_9 = 16,
KEYCODE_STAR = 17,
KEYCODE_POUND = 18,
KEYCODE_VOLUME_UP = 24,
KEYCODE_VOLUME_DOWN = 25,
KEYCODE_POWER = 26,
KEYCODE_CAMERA = 27,
KEYCODE_CLEAR = 28,
KEYCODE_A = 29,
KEYCODE_B = 30,
KEYCODE_C = 31,
KEYCODE_D = 32,
KEYCODE_E = 33,
KEYCODE_F = 34,
KEYCODE_G = 35,
KEYCODE_H = 36,
KEYCODE_I = 37,
KEYCODE_J = 38,
KEYCODE_K = 39,
KEYCODE_L = 40,
KEYCODE_M = 41,
KEYCODE_N = 42,
KEYCODE_O = 43,
KEYCODE_P = 44,
KEYCODE_Q = 45,
KEYCODE_R = 46,
KEYCODE_S = 47,
KEYCODE_T = 48,
KEYCODE_U = 49,
KEYCODE_V = 50,
KEYCODE_W = 51,
KEYCODE_X = 52,
KEYCODE_Y = 53,
KEYCODE_Z = 54,
KEYCODE_COMMA = 55,
KEYCODE_PERIOD = 56,
KEYCODE_ALT_LEFT = 57,
KEYCODE_ALT_RIGHT = 58,
KEYCODE_SHIFT_LEFT = 59,
KEYCODE_SHIFT_RIGHT = 60,
KEYCODE_TAB = 61,
KEYCODE_SPACE = 62,
KEYCODE_SYM = 63,
KEYCODE_EXPLORER = 64,
KEYCODE_ENVELOPE = 65,
KEYCODE_ENTER = 66,
KEYCODE_DEL = 67,
KEYCODE_GRAVE = 68,
KEYCODE_MINUS = 69,
KEYCODE_EQUALS = 70,
KEYCODE_LEFT_BRACKET = 71,
KEYCODE_RIGHT_BRACKET = 72,
KEYCODE_BACKSLASH = 73,
KEYCODE_SEMICOLON = 74,
KEYCODE_APOSTROPHE = 75,
KEYCODE_SLASH = 76,
KEYCODE_AT = 77,
KEYCODE_NUM = 78,
KEYCODE_HEADSETHOOK = 79,
KEYCODE_FOCUS = 80,
KEYCODE_PLUS = 81,
KEYCODE_MENU = 82,
KEYCODE_NOTIFICATION = 83,
KEYCODE_SEARCH = 84,
KEYCODE_MEDIA_PLAY_PAUSE = 85,
KEYCODE_MEDIA_STOP = 86,
KEYCODE_MEDIA_NEXT = 87,
KEYCODE_MEDIA_PREVIOUS = 88,
KEYCODE_MEDIA_REWIND = 89,
KEYCODE_MEDIA_FAST_FORWARD = 90,
KEYCODE_MUTE = 91,
KEYCODE_PAGE_UP = 92,
KEYCODE_PAGE_DOWN = 93,
KEYCODE_PICTSYMBOLS = 94,
KEYCODE_SWITCH_CHARSET = 95,
KEYCODE_BUTTON_A = 96,
KEYCODE_BUTTON_B = 97,
KEYCODE_BUTTON_C = 98,
KEYCODE_BUTTON_X = 99,
KEYCODE_BUTTON_Y = 100,
KEYCODE_BUTTON_Z = 101,
KEYCODE_BUTTON_L1 = 102,
KEYCODE_BUTTON_R1 = 103,
KEYCODE_BUTTON_L2 = 104,
KEYCODE_BUTTON_R2 = 105,
KEYCODE_BUTTON_THUMBL = 106,
KEYCODE_BUTTON_THUMBR = 107,
KEYCODE_BUTTON_START = 108,
KEYCODE_BUTTON_SELECT = 109,
KEYCODE_BUTTON_MODE = 110,
KEYCODE_ESCAPE = 111,
KEYCODE_FORWARD_DEL = 112,
KEYCODE_CTRL_LEFT = 113,
KEYCODE_CTRL_RIGHT = 114,
KEYCODE_CAPS_LOCK = 115,
KEYCODE_SCROLL_LOCK = 116,
KEYCODE_META_LEFT = 117,
KEYCODE_META_RIGHT = 118,
KEYCODE_FUNCTION = 119,
KEYCODE_SYSRQ = 120,
KEYCODE_BREAK = 121,
KEYCODE_MOVE_HOME = 122,
KEYCODE_MOVE_END = 123,
KEYCODE_INSERT = 124,
KEYCODE_FORWARD = 125,
KEYCODE_MEDIA_PLAY = 126,
KEYCODE_MEDIA_PAUSE = 127,
KEYCODE_MEDIA_CLOSE = 128,
KEYCODE_MEDIA_EJECT = 129,
KEYCODE_MEDIA_RECORD = 130,
KEYCODE_F1 = 131,
KEYCODE_F2 = 132,
KEYCODE_F3 = 133,
KEYCODE_F4 = 134,
KEYCODE_F5 = 135,
KEYCODE_F6 = 136,
KEYCODE_F7 = 137,
KEYCODE_F8 = 138,
KEYCODE_F9 = 139,
KEYCODE_F10 = 140,
KEYCODE_F11 = 141,
KEYCODE_F12 = 142,
KEYCODE_NUM_LOCK = 143,
KEYCODE_NUMPAD_0 = 144,
KEYCODE_NUMPAD_1 = 145,
KEYCODE_NUMPAD_2 = 146,
KEYCODE_NUMPAD_3 = 147,
KEYCODE_NUMPAD_4 = 148,
KEYCODE_NUMPAD_5 = 149,
KEYCODE_NUMPAD_6 = 150,
KEYCODE_NUMPAD_7 = 151,
KEYCODE_NUMPAD_8 = 152,
KEYCODE_NUMPAD_9 = 153,
KEYCODE_NUMPAD_DIVIDE = 154,
KEYCODE_NUMPAD_MULTIPLY = 155,
KEYCODE_NUMPAD_SUBTRACT = 156,
KEYCODE_NUMPAD_ADD = 157,
KEYCODE_NUMPAD_DOT = 158,
KEYCODE_NUMPAD_COMMA = 159,
KEYCODE_NUMPAD_ENTER = 160,
KEYCODE_NUMPAD_EQUALS = 161,
KEYCODE_NUMPAD_LEFT_PAREN = 162,
KEYCODE_NUMPAD_RIGHT_PAREN = 163,
KEYCODE_VOLUME_MUTE = 164,
KEYCODE_INFO = 165,
KEYCODE_CHANNEL_UP = 166,
KEYCODE_CHANNEL_DOWN = 167,
KEYCODE_ZOOM_IN = 168,
KEYCODE_ZOOM_OUT = 169,
KEYCODE_TV = 170,
KEYCODE_WINDOW = 171,
KEYCODE_GUIDE = 172,
KEYCODE_DVR = 173,
KEYCODE_BOOKMARK = 174,
KEYCODE_CAPTIONS = 175,
KEYCODE_SETTINGS = 176,
KEYCODE_TV_POWER = 177,
KEYCODE_TV_INPUT = 178,
KEYCODE_STB_POWER = 179,
KEYCODE_STB_INPUT = 180,
KEYCODE_AVR_POWER = 181,
KEYCODE_AVR_INPUT = 182,
KEYCODE_PROG_RED = 183,
KEYCODE_PROG_GREEN = 184,
KEYCODE_PROG_YELLOW = 185,
KEYCODE_PROG_BLUE = 186,
KEYCODE_APP_SWITCH = 187,
KEYCODE_BUTTON_1 = 188,
KEYCODE_BUTTON_2 = 189,
KEYCODE_BUTTON_3 = 190,
KEYCODE_BUTTON_4 = 191,
KEYCODE_BUTTON_5 = 192,
KEYCODE_BUTTON_6 = 193,
KEYCODE_BUTTON_7 = 194,
KEYCODE_BUTTON_8 = 195,
KEYCODE_BUTTON_9 = 196,
KEYCODE_BUTTON_10 = 197,
KEYCODE_BUTTON_11 = 198,
KEYCODE_BUTTON_12 = 199,
KEYCODE_BUTTON_13 = 200,
KEYCODE_BUTTON_14 = 201,
KEYCODE_BUTTON_15 = 202,
KEYCODE_BUTTON_16 = 203,
} keycode_t;

24
util/const_map.h Normal file
View File

@ -0,0 +1,24 @@
#pragma once
template <typename T, typename U>
class InitConstMap
{
private:
std::map<T, U> m_map;
public:
InitConstMap(const T& key, const U& val)
{
m_map[key] = val;
}
InitConstMap<T, U>& operator()(const T& key, const U& val)
{
m_map[key] = val;
return *this;
}
operator std::map<T, U>()
{
return m_map;
}
};