Merge remote repo native into ext/native/.

This commit is contained in:
Unknown W. Brackets committed 2015-09-06 12:24:17 -07:00
commit f279c2a3c2
378 files changed
+190761

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
set(SRCS
input_state.cpp
gesture_detector.cpp)
set(SRCS ${SRCS})
add_library(input STATIC ${SRCS})
target_link_libraries(input general gfx)
target_link_libraries(input general file)
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)
+110
View File
@@ -0,0 +1,110 @@
// Unfinished.
// TODO:
// Zoom gesture a la http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847
#include "base/logging.h"
#include "base/timeutil.h"
#include "input/gesture_detector.h"
const float estimatedInertiaDamping = 0.75f;
GestureDetector::GestureDetector()
: active_(0),
estimatedInertiaX_(0.0f),
estimatedInertiaY_(0.0f) {
memset(pointers, 0, sizeof(pointers));
}
TouchInput GestureDetector::Update(const TouchInput &touch, const Bounds &bounds) {
// Mouse / 1-finger-touch control.
Pointer &p = pointers[touch.id];
if ((touch.flags & TOUCH_DOWN) && bounds.Contains(touch.x, touch.y)) {
p.down = true;
p.downTime = time_now_d();
p.downX = touch.x;
p.downY = touch.y;
p.lastX = touch.x;
p.lastY = touch.y;
p.distanceX = 0.0f;
p.distanceY = 0.0f;
estimatedInertiaX_ = 0.0f;
estimatedInertiaY_ = 0.0f;
} else if (touch.flags & TOUCH_UP) {
p.down = false;
} else {
p.distanceX += fabsf(touch.x - p.lastX);
p.distanceY += fabsf(touch.y - p.lastY);
estimatedInertiaX_ += touch.x - p.lastX;
estimatedInertiaY_ += touch.y - p.lastY;
estimatedInertiaX_ *= estimatedInertiaDamping;
estimatedInertiaY_ *= estimatedInertiaDamping;
p.lastX = touch.x;
p.lastY = touch.y;
}
if (touch.id == 0 && p.distanceY > p.distanceX) {
if (p.down) {
double timeDown = time_now_d() - p.downTime;
if (!active_ && p.distanceY * timeDown > 3) {
active_ |= GESTURE_DRAG_VERTICAL;
// Kill the drag
TouchInput inp2 = touch;
inp2.flags = TOUCH_UP | TOUCH_CANCEL;
return inp2;
}
} else {
active_ = 0;
}
}
if (touch.id == 0 && p.distanceX > p.distanceY) {
if (p.down) {
double timeDown = time_now_d() - p.downTime;
if (!active_ && p.distanceX * timeDown > 3) {
active_ |= GESTURE_DRAG_HORIZONTAL;
// Kill the drag
TouchInput inp2 = touch;
inp2.flags = TOUCH_UP | TOUCH_CANCEL;
return inp2;
}
} else {
active_ = 0;
}
}
return touch;
}
void GestureDetector::UpdateFrame() {
estimatedInertiaX_ *= estimatedInertiaDamping;
estimatedInertiaY_ *= estimatedInertiaDamping;
}
bool GestureDetector::IsGestureActive(Gesture gesture) const {
return (active_ & gesture) != 0;
}
bool GestureDetector::GetGestureInfo(Gesture gesture, float info[4]) const {
if (!(active_ & gesture)) {
memset(info, 0, sizeof(float) * 4);
return false;
}
memset(info, 0, sizeof(float) * 4);
switch (gesture) {
case GESTURE_DRAG_HORIZONTAL:
info[0] = pointers[0].lastX - pointers[0].downX;
info[1] = estimatedInertiaX_;
return true;
case GESTURE_DRAG_VERTICAL:
info[0] = pointers[0].lastY - pointers[0].downY;
info[1] = estimatedInertiaY_;
return true;
default:
return false;
}
}
+51
View File
@@ -0,0 +1,51 @@
#include "input/input_state.h"
#include "math/geom2d.h"
// Mainly for detecting (multi-)touch gestures but also useable for left button mouse dragging etc.
// Currently only supports simple scroll-drags with inertia.
// TODO: Two-finger zoom/rotate etc.
enum Gesture {
GESTURE_DRAG_VERTICAL = 1,
GESTURE_DRAG_HORIZONTAL = 2,
GESTURE_TWO_FINGER_ZOOM = 4,
GESTURE_TWO_FINGER_ZOOM_ROTATE = 8,
};
// May track multiple gestures at the same time. You simply call GetGestureInfo
// with the gesture you are interested in.
class GestureDetector {
public:
GestureDetector();
TouchInput Update(const TouchInput &touch, const Bounds &bounds);
void UpdateFrame();
bool IsGestureActive(Gesture gesture) const;
bool GetGestureInfo(Gesture gesture, float info[4]) const;
private:
// jazzhands!
enum Locals {
MAX_PTRS = 10,
};
struct Pointer {
bool down;
double downTime;
float lastX;
float lastY;
float downX;
float downY;
float deltaX;
float deltaY;
float distanceX;
float distanceY;
};
Pointer pointers[MAX_PTRS];
uint32_t active_;
// For inertia estimation
float estimatedInertiaX_;
float estimatedInertiaY_;
};
+122
View File
@@ -0,0 +1,122 @@
#include "input/input_state.h"
#include "input/keycodes.h"
#include <vector>
const char *GetDeviceName(int deviceId) {
switch (deviceId) {
case DEVICE_ID_ANY: return "any";
case DEVICE_ID_DEFAULT: return "built-in";
case DEVICE_ID_KEYBOARD: return "kbd";
case DEVICE_ID_PAD_0: return "pad1";
case DEVICE_ID_PAD_1: return "pad2";
case DEVICE_ID_PAD_2: return "pad3";
case DEVICE_ID_PAD_3: return "pad4";
case DEVICE_ID_PAD_4: return "pad5";
case DEVICE_ID_PAD_5: return "pad6";
case DEVICE_ID_PAD_6: return "pad7";
case DEVICE_ID_PAD_7: return "pad8";
case DEVICE_ID_PAD_8: return "pad9";
case DEVICE_ID_PAD_9: return "pad10";
case DEVICE_ID_X360_0: return "x360";
case DEVICE_ID_ACCELEROMETER: return "accelerometer";
case DEVICE_ID_MOUSE: return "mouse";
default:
return "unknown";
}
}
// Default pad mapping to button bits. Used for UI and stuff that doesn't use PPSSPP's key mapping system.
int MapPadButtonFixed(int keycode) {
switch (keycode) {
case NKCODE_BACK: return PAD_BUTTON_BACK; // Back
case NKCODE_MENU: return PAD_BUTTON_MENU; // Menu
case NKCODE_Z:
case NKCODE_SPACE:
case NKCODE_BUTTON_1:
case NKCODE_BUTTON_A: // same as NKCODE_OUYA_BUTTON_O and NKCODE_BUTTON_CROSS_PS3
return PAD_BUTTON_A;
case NKCODE_ESCAPE:
case NKCODE_BUTTON_2:
case NKCODE_BUTTON_B: // same as NKCODE_OUYA_BUTTON_A and NKCODE_BUTTON_CIRCLE_PS3:
return PAD_BUTTON_B;
case NKCODE_DPAD_LEFT: return PAD_BUTTON_LEFT;
case NKCODE_DPAD_RIGHT: return PAD_BUTTON_RIGHT;
case NKCODE_DPAD_UP: return PAD_BUTTON_UP;
case NKCODE_DPAD_DOWN: return PAD_BUTTON_DOWN;
default:
return 0;
}
}
std::vector<KeyDef> dpadKeys;
std::vector<KeyDef> confirmKeys;
std::vector<KeyDef> cancelKeys;
std::vector<KeyDef> tabLeftKeys;
std::vector<KeyDef> tabRightKeys;
static void AppendKeys(std::vector<KeyDef> &keys, const std::vector<KeyDef> &newKeys) {
for (auto iter = newKeys.begin(); iter != newKeys.end(); ++iter) {
keys.push_back(*iter);
}
}
void SetDPadKeys(const std::vector<KeyDef> &leftKey, const std::vector<KeyDef> &rightKey,
const std::vector<KeyDef> &upKey, const std::vector<KeyDef> &downKey) {
dpadKeys.clear();
// Store all directions into one vector for now. In the future it might be
// useful to keep track of the different directions separately.
AppendKeys(dpadKeys, leftKey);
AppendKeys(dpadKeys, rightKey);
AppendKeys(dpadKeys, upKey);
AppendKeys(dpadKeys, downKey);
}
void SetConfirmCancelKeys(const std::vector<KeyDef> &confirm, const std::vector<KeyDef> &cancel) {
confirmKeys = confirm;
cancelKeys = cancel;
}
void SetTabLeftRightKeys(const std::vector<KeyDef> &tabLeft, const std::vector<KeyDef> &tabRight) {
tabLeftKeys = tabLeft;
tabRightKeys = tabRight;
}
uint32_t ButtonTracker::Update() {
pad_buttons_ |= pad_buttons_async_set;
pad_buttons_ &= ~pad_buttons_async_clear;
return pad_buttons_;
}
void ButtonTracker::Process(const KeyInput &input) {
int btn = MapPadButtonFixed(input.keyCode);
if (btn == 0)
return;
// For now, use a fixed mapping. Good enough for the basics on most platforms.
if (input.flags & KEY_DOWN) {
pad_buttons_async_set |= btn;
pad_buttons_async_clear &= ~btn;
}
if (input.flags & KEY_UP) {
pad_buttons_async_set &= ~btn;
pad_buttons_async_clear |= btn;
}
}
ButtonTracker g_buttonTracker;
void UpdateInputState(InputState *input, bool merge) {
uint32_t btns = g_buttonTracker.Update();
input->pad_buttons = merge ? (input->pad_buttons | btns) : btns;
input->pad_buttons_down = (input->pad_last_buttons ^ input->pad_buttons) & input->pad_buttons;
input->pad_buttons_up = (input->pad_last_buttons ^ input->pad_buttons) & input->pad_last_buttons;
}
void EndInputState(InputState *input) {
input->pad_last_buttons = input->pad_buttons;
}
+252
View File
@@ -0,0 +1,252 @@
#pragma once
// InputState is the simple way of getting input. All the input we have is collected
// to a canonical Xbox360-style pad fully automatically.
//
// Recommended for use in game UIs and games that don't have advanced needs.
//
// For more detailed and configurable input, implement NativeTouch, NativeKey and NativeAxis and do your
// own mapping. Might later move the mapping system from PPSSPP to native.
#include <map>
#include <vector>
#include "math/lin/vec3.h"
#include "base/mutex.h"
#include "base/basictypes.h"
#include "input/keycodes.h"
// Default device IDs
enum {
DEVICE_ID_ANY = -1, // Represents any device ID
DEVICE_ID_DEFAULT = 0, // Old Android
DEVICE_ID_KEYBOARD = 1, // PC keyboard, android keyboards
DEVICE_ID_MOUSE = 2, // PC mouse only (not touchscreen!)
DEVICE_ID_PAD_0 = 10, // Generic joypads
DEVICE_ID_PAD_1 = 11, // these should stay as contiguous numbers
DEVICE_ID_PAD_2 = 12,
DEVICE_ID_PAD_3 = 13,
DEVICE_ID_PAD_4 = 14,
DEVICE_ID_PAD_5 = 15,
DEVICE_ID_PAD_6 = 16,
DEVICE_ID_PAD_7 = 17,
DEVICE_ID_PAD_8 = 18,
DEVICE_ID_PAD_9 = 19,
DEVICE_ID_X360_0 = 20, // XInput joypads
DEVICE_ID_ACCELEROMETER = 30,
};
//number of contiguous generic joypad IDs
const int MAX_NUM_PADS = 10;
const char *GetDeviceName(int deviceId);
enum {
PAD_BUTTON_A = 1,
PAD_BUTTON_B = 2,
PAD_BUTTON_X = 4,
PAD_BUTTON_Y = 8,
PAD_BUTTON_LBUMPER = 16,
PAD_BUTTON_RBUMPER = 32,
PAD_BUTTON_START = 64,
PAD_BUTTON_SELECT = 128,
PAD_BUTTON_UP = 256,
PAD_BUTTON_DOWN = 512,
PAD_BUTTON_LEFT = 1024,
PAD_BUTTON_RIGHT = 2048,
PAD_BUTTON_MENU = 4096,
PAD_BUTTON_BACK = 8192,
// For Blackberry and Qt
PAD_BUTTON_JOY_UP = 1<<14,
PAD_BUTTON_JOY_DOWN = 1<<15,
PAD_BUTTON_JOY_LEFT = 1<<16,
PAD_BUTTON_JOY_RIGHT = 1<<17,
PAD_BUTTON_LEFT_THUMB = 1 << 18, // Click left thumb stick on X360
PAD_BUTTON_RIGHT_THUMB = 1 << 19, // Click right thumb stick on X360
PAD_BUTTON_LEFT_TRIGGER = 1 << 21, // Click left thumb stick on X360
PAD_BUTTON_RIGHT_TRIGGER = 1 << 22, // Click left thumb stick on X360
PAD_BUTTON_UNTHROTTLE = 1 << 20, // Click Tab to unthrottle
};
#define MAX_POINTERS 10
#ifndef MAX_KEYQUEUESIZE
#define MAX_KEYQUEUESIZE 20
#endif
// Represents a single bindable key
class KeyDef {
public:
KeyDef() : deviceId(0), keyCode(0) {}
KeyDef(int devId, int k) : deviceId(devId), keyCode(k) {}
int deviceId;
int keyCode;
bool operator < (const KeyDef &other) const {
if (deviceId < other.deviceId) return true;
if (deviceId > other.deviceId) return false;
if (keyCode < other.keyCode) return true;
return false;
}
bool operator == (const KeyDef &other) const {
if (deviceId != other.deviceId && deviceId != DEVICE_ID_ANY && other.deviceId != DEVICE_ID_ANY) return false;
if (keyCode != other.keyCode) return false;
return true;
}
};
// Represents a single bindable axis direction
struct AxisPos {
int axis;
float position;
bool operator < (const AxisPos &other) const {
if (axis < other.axis) return true;
if (axis > other.axis) return false;
return position < other.position;
}
bool operator == (const AxisPos &other) const {
return axis == other.axis && position == other.position;
}
};
// Collection of all possible inputs, and automatically computed
// deltas where applicable.
struct InputState {
// Lock this whenever you access the data in this struct.
mutable recursive_mutex lock;
InputState()
: pad_buttons(0),
pad_last_buttons(0),
pad_buttons_down(0),
pad_buttons_up(0),
mouse_valid(false),
accelerometer_valid(false) {
memset(pointer_down, 0, sizeof(pointer_down));
}
// Gamepad style input. For ease of use.
int pad_buttons; // bitfield
int pad_last_buttons;
int pad_buttons_down; // buttons just pressed this frame
int pad_buttons_up; // buttons just pressed last frame
float pad_lstick_x;
float pad_lstick_y;
float pad_rstick_x;
float pad_rstick_y;
float pad_ltrigger;
float pad_rtrigger;
// Mouse/touch style input
// There are up to 8 mice / fingers.
volatile bool mouse_valid;
int pointer_x[MAX_POINTERS];
int pointer_y[MAX_POINTERS];
bool pointer_down[MAX_POINTERS];
// Accelerometer
bool accelerometer_valid;
Vec3 acc;
private:
DISALLOW_COPY_AND_ASSIGN(InputState);
};
void UpdateInputState(InputState *input, bool merge = false);
void EndInputState(InputState *input);
enum {
TOUCH_MOVE = 1 << 0,
TOUCH_DOWN = 1 << 1,
TOUCH_UP = 1 << 2,
TOUCH_CANCEL = 1 << 3, // Sent by scrollviews to their children when they detect a scroll
TOUCH_WHEEL = 1 << 4, // Scrollwheel event. Usually only affects Y but can potentially affect X.
TOUCH_MOUSE = 1 << 5, // Identifies that this touch event came from a mouse
TOUCH_RELEASE_ALL = 1 << 6, // Useful for app focus switches when events may be lost.
// These are the Android getToolType() codes, shifted by 10.
TOUCH_TOOL_MASK = 7 << 10,
TOUCH_TOOL_UNKNOWN = 0 << 10,
TOUCH_TOOL_FINGER = 1 << 10,
TOUCH_TOOL_STYLUS = 2 << 10,
TOUCH_TOOL_MOUSE = 3 << 10,
TOUCH_TOOL_ERASER = 4 << 10,
};
// Used for asynchronous touch input.
// DOWN is always on its own.
// MOVE and UP can be combined.
struct TouchInput {
float x;
float y;
int id; // can be relied upon to be 0...MAX_POINTERS
int flags;
double timestamp;
};
#undef KEY_DOWN
#undef KEY_UP
enum {
KEY_DOWN = 1 << 0,
KEY_UP = 1 << 1,
KEY_HASWHEELDELTA = 1 << 2,
KEY_IS_REPEAT = 1 << 3,
KEY_CHAR = 1 << 4, // Unicode character input. Cannot detect keyups of these so KEY_DOWN and KEY_UP are zero when this is set.
};
struct KeyInput {
KeyInput() {}
KeyInput(int devId, int code, int fl) : deviceId(devId), keyCode(code), flags(fl) {}
int deviceId;
int keyCode; // Android keycodes are the canonical keycodes, everyone else map to them.
int flags;
};
struct AxisInput {
int deviceId;
int axisId; // Android axis Ids are the canonical ones.
float value;
int flags;
};
class ButtonTracker {
public:
ButtonTracker() { Reset(); }
void Reset() {
pad_buttons_ = 0;
pad_buttons_async_set = 0;
pad_buttons_async_clear = 0;
}
void Process(const KeyInput &input);
uint32_t Update();
uint32_t GetPadButtons() const { return pad_buttons_; }
private:
uint32_t pad_buttons_;
uint32_t pad_buttons_async_set;
uint32_t pad_buttons_async_clear;
};
// Platforms should call g_buttonTracker.Process().
extern ButtonTracker g_buttonTracker;
// Is there a nicer place for this stuff? It's here to avoid dozens of linking errors in UnitTest..
extern std::vector<KeyDef> dpadKeys;
extern std::vector<KeyDef> confirmKeys;
extern std::vector<KeyDef> cancelKeys;
extern std::vector<KeyDef> tabLeftKeys;
extern std::vector<KeyDef> tabRightKeys;
void SetDPadKeys(const std::vector<KeyDef> &leftKey, const std::vector<KeyDef> &rightKey,
const std::vector<KeyDef> &upKey, const std::vector<KeyDef> &downKey);
void SetConfirmCancelKeys(const std::vector<KeyDef> &confirm, const std::vector<KeyDef> &cancel);
void SetTabLeftRightKeys(const std::vector<KeyDef> &tabLeft, const std::vector<KeyDef> &tabRight);
+313
View File
@@ -0,0 +1,313 @@
#pragma once
typedef enum _keycode_t {
NKCODE_BUTTON_CROSS = 23, // trackpad or X button(Xperia Play) is pressed
NKCODE_BUTTON_CROSS_PS3 = 96, // PS3 X button is pressed
NKCODE_BUTTON_CIRCLE = 1004, // Special custom keycode generated from 'O' button by our java code. Or 'O' button if Alt is pressed (TODO)
NKCODE_BUTTON_CIRCLE_PS3 = 97, // PS3 O button is pressed
NKCODE_BUTTON_SQUARE = 99, // Square button(Xperia Play) is pressed
NKCODE_BUTTON_TRIANGLE = 100, // 'Triangle button(Xperia Play) is pressed
NKCODE_DPAD_UP = 19,
NKCODE_DPAD_DOWN = 20,
NKCODE_DPAD_LEFT = 21,
NKCODE_DPAD_RIGHT = 22,
NKCODE_DPAD_CENTER = 23,
NKCODE_UNKNOWN = 0,
NKCODE_SOFT_LEFT = 1,
NKCODE_SOFT_RIGHT = 2,
NKCODE_HOME = 3,
NKCODE_BACK = 4,
NKCODE_CALL = 5,
NKCODE_ENDCALL = 6,
NKCODE_0 = 7,
NKCODE_1 = 8,
NKCODE_2 = 9,
NKCODE_3 = 10,
NKCODE_4 = 11,
NKCODE_5 = 12,
NKCODE_6 = 13,
NKCODE_7 = 14,
NKCODE_8 = 15,
NKCODE_9 = 16,
NKCODE_STAR = 17,
NKCODE_POUND = 18,
NKCODE_VOLUME_UP = 24,
NKCODE_VOLUME_DOWN = 25,
NKCODE_POWER = 26,
NKCODE_CAMERA = 27,
NKCODE_CLEAR = 28,
NKCODE_A = 29,
NKCODE_B = 30,
NKCODE_C = 31,
NKCODE_D = 32,
NKCODE_E = 33,
NKCODE_F = 34,
NKCODE_G = 35,
NKCODE_H = 36,
NKCODE_I = 37,
NKCODE_J = 38,
NKCODE_K = 39,
NKCODE_L = 40,
NKCODE_M = 41,
NKCODE_N = 42,
NKCODE_O = 43,
NKCODE_P = 44,
NKCODE_Q = 45,
NKCODE_R = 46,
NKCODE_S = 47,
NKCODE_T = 48,
NKCODE_U = 49,
NKCODE_V = 50,
NKCODE_W = 51,
NKCODE_X = 52,
NKCODE_Y = 53,
NKCODE_Z = 54,
NKCODE_COMMA = 55,
NKCODE_PERIOD = 56,
NKCODE_ALT_LEFT = 57,
NKCODE_ALT_RIGHT = 58,
NKCODE_SHIFT_LEFT = 59,
NKCODE_SHIFT_RIGHT = 60,
NKCODE_TAB = 61,
NKCODE_SPACE = 62,
NKCODE_SYM = 63,
NKCODE_EXPLORER = 64,
NKCODE_ENVELOPE = 65,
NKCODE_ENTER = 66,
NKCODE_DEL = 67,
NKCODE_GRAVE = 68,
NKCODE_MINUS = 69,
NKCODE_EQUALS = 70,
NKCODE_LEFT_BRACKET = 71,
NKCODE_RIGHT_BRACKET = 72,
NKCODE_BACKSLASH = 73,
NKCODE_SEMICOLON = 74,
NKCODE_APOSTROPHE = 75,
NKCODE_SLASH = 76,
NKCODE_AT = 77,
NKCODE_NUM = 78,
NKCODE_HEADSETHOOK = 79,
NKCODE_FOCUS = 80,
NKCODE_PLUS = 81,
NKCODE_MENU = 82,
NKCODE_NOTIFICATION = 83,
NKCODE_SEARCH = 84,
NKCODE_MEDIA_PLAY_PAUSE = 85,
NKCODE_MEDIA_STOP = 86,
NKCODE_MEDIA_NEXT = 87,
NKCODE_MEDIA_PREVIOUS = 88,
NKCODE_MEDIA_REWIND = 89,
NKCODE_MEDIA_FAST_FORWARD = 90,
NKCODE_MUTE = 91,
NKCODE_PAGE_UP = 92,
NKCODE_PAGE_DOWN = 93,
NKCODE_PICTSYMBOLS = 94,
NKCODE_SWITCH_CHARSET = 95,
NKCODE_BUTTON_A = 96,
NKCODE_BUTTON_B = 97,
NKCODE_BUTTON_C = 98,
NKCODE_BUTTON_X = 99,
NKCODE_BUTTON_Y = 100,
NKCODE_BUTTON_Z = 101,
NKCODE_BUTTON_L1 = 102,
NKCODE_BUTTON_R1 = 103,
NKCODE_BUTTON_L2 = 104,
NKCODE_BUTTON_R2 = 105,
NKCODE_BUTTON_THUMBL = 106,
NKCODE_BUTTON_THUMBR = 107,
NKCODE_BUTTON_START = 108,
NKCODE_BUTTON_SELECT = 109,
NKCODE_BUTTON_MODE = 110,
NKCODE_ESCAPE = 111,
NKCODE_FORWARD_DEL = 112,
NKCODE_CTRL_LEFT = 113,
NKCODE_CTRL_RIGHT = 114,
NKCODE_CAPS_LOCK = 115,
NKCODE_SCROLL_LOCK = 116,
NKCODE_META_LEFT = 117,
NKCODE_META_RIGHT = 118,
NKCODE_FUNCTION = 119,
NKCODE_SYSRQ = 120,
NKCODE_BREAK = 121,
NKCODE_MOVE_HOME = 122,
NKCODE_MOVE_END = 123,
NKCODE_INSERT = 124,
NKCODE_FORWARD = 125,
NKCODE_MEDIA_PLAY = 126,
NKCODE_MEDIA_PAUSE = 127,
NKCODE_MEDIA_CLOSE = 128,
NKCODE_MEDIA_EJECT = 129,
NKCODE_MEDIA_RECORD = 130,
NKCODE_F1 = 131,
NKCODE_F2 = 132,
NKCODE_F3 = 133,
NKCODE_F4 = 134,
NKCODE_F5 = 135,
NKCODE_F6 = 136,
NKCODE_F7 = 137,
NKCODE_F8 = 138,
NKCODE_F9 = 139,
NKCODE_F10 = 140,
NKCODE_F11 = 141,
NKCODE_F12 = 142,
NKCODE_NUM_LOCK = 143,
NKCODE_NUMPAD_0 = 144,
NKCODE_NUMPAD_1 = 145,
NKCODE_NUMPAD_2 = 146,
NKCODE_NUMPAD_3 = 147,
NKCODE_NUMPAD_4 = 148,
NKCODE_NUMPAD_5 = 149,
NKCODE_NUMPAD_6 = 150,
NKCODE_NUMPAD_7 = 151,
NKCODE_NUMPAD_8 = 152,
NKCODE_NUMPAD_9 = 153,
NKCODE_NUMPAD_DIVIDE = 154,
NKCODE_NUMPAD_MULTIPLY = 155,
NKCODE_NUMPAD_SUBTRACT = 156,
NKCODE_NUMPAD_ADD = 157,
NKCODE_NUMPAD_DOT = 158,
NKCODE_NUMPAD_COMMA = 159,
NKCODE_NUMPAD_ENTER = 160,
NKCODE_NUMPAD_EQUALS = 161,
NKCODE_NUMPAD_LEFT_PAREN = 162,
NKCODE_NUMPAD_RIGHT_PAREN = 163,
NKCODE_VOLUME_MUTE = 164,
NKCODE_INFO = 165,
NKCODE_CHANNEL_UP = 166,
NKCODE_CHANNEL_DOWN = 167,
NKCODE_ZOOM_IN = 168,
NKCODE_ZOOM_OUT = 169,
NKCODE_TV = 170,
NKCODE_WINDOW = 171,
NKCODE_GUIDE = 172,
NKCODE_DVR = 173,
NKCODE_BOOKMARK = 174,
NKCODE_CAPTIONS = 175,
NKCODE_SETTINGS = 176,
NKCODE_TV_POWER = 177,
NKCODE_TV_INPUT = 178,
NKCODE_STB_POWER = 179,
NKCODE_STB_INPUT = 180,
NKCODE_AVR_POWER = 181,
NKCODE_AVR_INPUT = 182,
NKCODE_PROG_RED = 183,
NKCODE_PROG_GREEN = 184,
NKCODE_PROG_YELLOW = 185,
NKCODE_PROG_BLUE = 186,
NKCODE_APP_SWITCH = 187,
NKCODE_BUTTON_1 = 188,
NKCODE_BUTTON_2 = 189,
NKCODE_BUTTON_3 = 190,
NKCODE_BUTTON_4 = 191,
NKCODE_BUTTON_5 = 192,
NKCODE_BUTTON_6 = 193,
NKCODE_BUTTON_7 = 194,
NKCODE_BUTTON_8 = 195,
NKCODE_BUTTON_9 = 196,
NKCODE_BUTTON_10 = 197,
NKCODE_BUTTON_11 = 198,
NKCODE_BUTTON_12 = 199,
NKCODE_BUTTON_13 = 200,
NKCODE_BUTTON_14 = 201,
NKCODE_BUTTON_15 = 202,
NKCODE_BUTTON_16 = 203,
NKCODE_LANGUAGE_SWITCH = 204,
NKCODE_MANNER_MODE = 205,
NKCODE_3D_MODE = 206,
NKCODE_CONTACTS = 207,
NKCODE_CALENDAR = 208,
NKCODE_MUSIC = 209,
NKCODE_CALCULATOR = 210,
NKCODE_ZENKAKU_HANKAKU = 211,
NKCODE_EISU = 212,
NKCODE_MUHENKAN = 213,
NKCODE_HENKAN = 214,
NKCODE_KATAKANA_HIRAGANA = 215,
NKCODE_YEN = 216,
NKCODE_RO = 217,
NKCODE_KANA = 218,
NKCODE_ASSIST = 219,
// Ouya buttons. Just here for reference, they map straight to regular android buttons
// and will be mapped the same way.
NKCODE_OUYA_BUTTON_A = 97,
NKCODE_OUYA_BUTTON_DPAD_DOWN = 20,
NKCODE_OUYA_BUTTON_DPAD_LEFT = 21,
NKCODE_OUYA_BUTTON_DPAD_RIGHT = 22,
NKCODE_OUYA_BUTTON_DPAD_UP = 19,
NKCODE_OUYA_BUTTON_L1 = 102,
NKCODE_OUYA_BUTTON_L2 = 104,
NKCODE_OUYA_BUTTON_L3 = 106,
NKCODE_OUYA_BUTTON_MENU = 82,
NKCODE_OUYA_BUTTON_O = 96,
NKCODE_OUYA_BUTTON_R1 = 103,
NKCODE_OUYA_BUTTON_R2 = 105,
NKCODE_OUYA_BUTTON_R3 = 107,
NKCODE_OUYA_BUTTON_U = 99,
NKCODE_OUYA_BUTTON_Y = 100,
// Extended keycodes, not available on Android
NKCODE_EXT_PIPE = 1001, // The key next to Z on euro 102-key keyboards.
NKCODE_EXT_MOUSEBUTTON_1 = 1002,
NKCODE_EXT_MOUSEBUTTON_2 = 1003,
NKCODE_EXT_MOUSEBUTTON_3 = 1004,
NKCODE_EXT_MOUSEWHEEL_UP = 1008,
NKCODE_EXT_MOUSEWHEEL_DOWN = 1009
} keycode_t;
enum AndroidJoystickAxis {
// Field descriptor #15 I
JOYSTICK_AXIS_X = 0,
JOYSTICK_AXIS_Y = 1,
JOYSTICK_AXIS_PRESSURE = 2,
JOYSTICK_AXIS_SIZE = 3,
JOYSTICK_AXIS_TOUCH_MAJOR = 4,
JOYSTICK_AXIS_TOUCH_MINOR = 5,
JOYSTICK_AXIS_TOOL_MAJOR = 6,
JOYSTICK_AXIS_TOOL_MINOR = 7,
JOYSTICK_AXIS_ORIENTATION = 8,
JOYSTICK_AXIS_VSCROLL = 9,
JOYSTICK_AXIS_HSCROLL = 10,
JOYSTICK_AXIS_Z = 11,
JOYSTICK_AXIS_RX = 12,
JOYSTICK_AXIS_RY = 13,
JOYSTICK_AXIS_RZ = 14,
JOYSTICK_AXIS_HAT_X = 15,
JOYSTICK_AXIS_HAT_Y = 16,
JOYSTICK_AXIS_LTRIGGER = 17,
JOYSTICK_AXIS_RTRIGGER = 18,
JOYSTICK_AXIS_THROTTLE = 19,
JOYSTICK_AXIS_RUDDER = 20,
JOYSTICK_AXIS_WHEEL = 21,
JOYSTICK_AXIS_GAS = 22,
JOYSTICK_AXIS_BRAKE = 23,
JOYSTICK_AXIS_DISTANCE = 24,
JOYSTICK_AXIS_TILT = 25,
// Ouya axises. Just here for reference, they map straight to regular android axises
// and will be mapped the same way.
JOYSTICK_OUYA_AXIS_L2 = 17,
JOYSTICK_OUYA_AXIS_LS_X = 0,
JOYSTICK_OUYA_AXIS_LS_Y = 1,
JOYSTICK_OUYA_AXIS_R2 = 18,
JOYSTICK_OUYA_AXIS_RS_X = 11,
JOYSTICK_OUYA_AXIS_RS_Y = 14,
// Relative mouse axis for PC.
JOYSTICK_AXIS_MOUSE_REL_X = 26,
JOYSTICK_AXIS_MOUSE_REL_Y = 27,
// Getting these on Ouya, no clue what they are.
JOYSTICK_AXIS_OUYA_UNKNOWN1 = 32,
JOYSTICK_AXIS_OUYA_UNKNOWN2 = 33,
JOYSTICK_AXIS_OUYA_UNKNOWN3 = 34,
JOYSTICK_AXIS_OUYA_UNKNOWN4 = 35,
// Mobile device accelerometer/gyro
JOYSTICK_AXIS_ACCELEROMETER_X = 40,
JOYSTICK_AXIS_ACCELEROMETER_Y = 41,
JOYSTICK_AXIS_ACCELEROMETER_Z = 42,
JOYSTICK_AXIS_MAX = 44
};