Move stuff around

This commit is contained in:
twinaphex 2015-01-11 00:07:59 +01:00
parent 5e85c874ab
commit d7f36af446
7 changed files with 173 additions and 167 deletions

View File

@ -158,6 +158,7 @@ static bool android_input_lookup_name_gingerbread(char *buf,
jclass class;
jmethodID method, getName;
jobject device, name;
const char *str = NULL;
JNIEnv *env = (JNIEnv*)jni_thread_getenv();
if (!env)
@ -197,7 +198,7 @@ static bool android_input_lookup_name_gingerbread(char *buf,
buf[0] = '\0';
const char *str = (*env)->GetStringUTFChars(env, name, 0);
str = (*env)->GetStringUTFChars(env, name, 0);
if (str)
strlcpy(buf, str, size);
(*env)->ReleaseStringUTFChars(env, name, str);
@ -215,6 +216,7 @@ static bool android_input_lookup_name_post_gingerbread(char *buf,
jclass class;
jmethodID method, getName, getVendorId, getProductId;
jobject device, name;
const char *str = NULL;
JNIEnv *env = (JNIEnv*)jni_thread_getenv();
if (!env)
@ -254,7 +256,7 @@ static bool android_input_lookup_name_post_gingerbread(char *buf,
buf[0] = '\0';
const char *str = (*env)->GetStringUTFChars(env, name, 0);
str = (*env)->GetStringUTFChars(env, name, 0);
if (str)
strlcpy(buf, str, size);
(*env)->ReleaseStringUTFChars(env, name, str);
@ -297,6 +299,7 @@ static void *android_input_init(void)
{
int32_t major, minor, bugfix;
android_input_t *android = (android_input_t*)calloc(1, sizeof(*android));
if (!android)
return NULL;
@ -349,6 +352,7 @@ static inline int android_input_poll_event_type_motion(
{
float x, y;
int pointer_max = min(AMotionEvent_getPointerCount(event), MAX_TOUCH);
for (motion_pointer = 0; motion_pointer < pointer_max; motion_pointer++)
{
x = AMotionEvent_getX(event, motion_pointer);
@ -619,7 +623,7 @@ static void android_input_poll(void *data)
{
int ident;
struct android_app *android_app = (struct android_app*)g_android;
android_input_t *android = (android_input_t*)data;
android_input_t *android = (android_input_t*)data;
while ((ident =
ALooper_pollAll((driver.input->key_pressed(driver.input_data, RARCH_PAUSE_TOGGLE))
@ -841,9 +845,9 @@ static float android_input_get_sensor_input(void *data,
static const rarch_joypad_driver_t *android_input_get_joypad_driver(void *data)
{
android_input_t *android = (android_input_t*)data;
if (android)
return android->joypad;
return NULL;
if (!android)
return NULL;
return android->joypad;
}
input_driver_t input_android = {

View File

@ -89,15 +89,14 @@ static bool android_joypad_button(unsigned port, uint16_t joykey)
static int16_t android_joypad_axis(unsigned port, uint32_t joyaxis)
{
android_input_t *android = (android_input_t*)driver.input_data;
if (!android || joyaxis == AXIS_NONE || port >= MAX_PADS)
return 0;
int val = 0;
int axis = -1;
bool is_neg = false;
bool is_pos = false;
android_input_t *android = (android_input_t*)driver.input_data;
if (!android || joyaxis == AXIS_NONE || port >= MAX_PADS)
return 0;
if (AXIS_NEG_GET(joyaxis) < MAX_AXIS)
{

View File

@ -147,15 +147,17 @@ static void hid_device_report(void* context, IOReturn result, void *sender,
{
struct pad_connection* connection = (struct pad_connection*)context;
if (connection)
pad_connection_packet(&slots[connection->slot], connection->slot,
connection->data, reportLength + 1);
if (!connection)
return;
pad_connection_packet(&slots[connection->slot], connection->slot,
connection->data, reportLength + 1);
}
static void add_device(void* context, IOReturn result,
void* sender, IOHIDDeviceRef device)
{
char device_name[PATH_MAX];
char device_name[PATH_MAX_LENGTH];
CFStringRef device_name_ref;
CFNumberRef vendorID, productID;
struct pad_connection* connection = (struct pad_connection*)
@ -208,13 +210,11 @@ static void add_device(void* context, IOReturn result,
static void append_matching_dictionary(CFMutableArrayRef array,
uint32_t page, uint32_t use)
{
CFNumberRef pagen, usen;
CFMutableDictionaryRef matcher;
matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
CFNumberRef usen;
CFMutableDictionaryRef matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFNumberRef pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
CFRelease(pagen);
@ -286,6 +286,7 @@ static bool apple_joypad_button(unsigned port, uint16_t joykey)
{
apple_input_data_t *apple = (apple_input_data_t*)driver.input_data;
uint32_t buttons = pad_connection_get_buttons(&slots[port], port);
if (!apple || joykey == NO_BTN)
return false;

View File

@ -15,6 +15,7 @@
*/
#include "input_common.h"
#include "input_keymaps.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
@ -168,6 +169,27 @@ const char *input_config_get_prefix(unsigned user, bool meta)
return NULL;
}
static enum retro_key find_rk_bind(const char *str)
{
size_t i;
for (i = 0; input_config_key_map[i].str; i++)
{
if (strcasecmp(input_config_key_map[i].str, str) == 0)
return input_config_key_map[i].key;
}
RARCH_WARN("Key name %s not found.\n", str);
return RETROK_UNKNOWN;
}
enum retro_key input_translate_str_to_rk(const char *str)
{
if (strlen(str) == 1 && isalpha(*str))
return (enum retro_key)(RETROK_a + (tolower(*str) - (int)'a'));
return find_rk_bind(str);
}
/**
* input_translate_str_to_bind_id:
* @str : String to translate to bind ID.

View File

@ -56,6 +56,7 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind,
const struct retro_keybind *auto_bind, size_t size);
void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size);
enum retro_key input_translate_str_to_rk(const char *str);
const char *input_config_get_prefix(unsigned user, bool meta);

View File

@ -105,153 +105,6 @@ const char* config_get_joypad_driver_options(void)
return options;
}
const struct input_key_map input_config_key_map[] = {
{ "left", RETROK_LEFT },
{ "right", RETROK_RIGHT },
{ "up", RETROK_UP },
{ "down", RETROK_DOWN },
{ "enter", RETROK_RETURN },
{ "kp_enter", RETROK_KP_ENTER },
{ "tab", RETROK_TAB },
{ "insert", RETROK_INSERT },
{ "del", RETROK_DELETE },
{ "end", RETROK_END },
{ "home", RETROK_HOME },
{ "rshift", RETROK_RSHIFT },
{ "shift", RETROK_LSHIFT },
{ "ctrl", RETROK_LCTRL },
{ "alt", RETROK_LALT },
{ "space", RETROK_SPACE },
{ "escape", RETROK_ESCAPE },
{ "add", RETROK_KP_PLUS },
{ "subtract", RETROK_KP_MINUS },
{ "kp_plus", RETROK_KP_PLUS },
{ "kp_minus", RETROK_KP_MINUS },
{ "f1", RETROK_F1 },
{ "f2", RETROK_F2 },
{ "f3", RETROK_F3 },
{ "f4", RETROK_F4 },
{ "f5", RETROK_F5 },
{ "f6", RETROK_F6 },
{ "f7", RETROK_F7 },
{ "f8", RETROK_F8 },
{ "f9", RETROK_F9 },
{ "f10", RETROK_F10 },
{ "f11", RETROK_F11 },
{ "f12", RETROK_F12 },
{ "num0", RETROK_0 },
{ "num1", RETROK_1 },
{ "num2", RETROK_2 },
{ "num3", RETROK_3 },
{ "num4", RETROK_4 },
{ "num5", RETROK_5 },
{ "num6", RETROK_6 },
{ "num7", RETROK_7 },
{ "num8", RETROK_8 },
{ "num9", RETROK_9 },
{ "pageup", RETROK_PAGEUP },
{ "pagedown", RETROK_PAGEDOWN },
{ "keypad0", RETROK_KP0 },
{ "keypad1", RETROK_KP1 },
{ "keypad2", RETROK_KP2 },
{ "keypad3", RETROK_KP3 },
{ "keypad4", RETROK_KP4 },
{ "keypad5", RETROK_KP5 },
{ "keypad6", RETROK_KP6 },
{ "keypad7", RETROK_KP7 },
{ "keypad8", RETROK_KP8 },
{ "keypad9", RETROK_KP9 },
{ "period", RETROK_PERIOD },
{ "capslock", RETROK_CAPSLOCK },
{ "numlock", RETROK_NUMLOCK },
{ "backspace", RETROK_BACKSPACE },
{ "multiply", RETROK_KP_MULTIPLY },
{ "divide", RETROK_KP_DIVIDE },
{ "print_screen", RETROK_PRINT },
{ "scroll_lock", RETROK_SCROLLOCK },
{ "tilde", RETROK_BACKQUOTE },
{ "backquote", RETROK_BACKQUOTE },
{ "pause", RETROK_PAUSE },
/* Keys that weren't mappable before */
{ "quote", RETROK_QUOTE },
{ "comma", RETROK_COMMA },
{ "minus", RETROK_MINUS },
{ "slash", RETROK_SLASH },
{ "semicolon", RETROK_SEMICOLON },
{ "equals", RETROK_EQUALS },
{ "leftbracket", RETROK_LEFTBRACKET },
{ "backslash", RETROK_BACKSLASH },
{ "rightbracket", RETROK_RIGHTBRACKET },
{ "kp_period", RETROK_KP_PERIOD },
{ "kp_equals", RETROK_KP_EQUALS },
{ "rctrl", RETROK_RCTRL },
{ "ralt", RETROK_RALT },
/* Keys not referenced in any keyboard mapping
* (except perhaps rarch_key_map_apple_hid) */
{ "caret", RETROK_CARET },
{ "underscore", RETROK_UNDERSCORE },
{ "exclaim", RETROK_EXCLAIM },
{ "quotedbl", RETROK_QUOTEDBL },
{ "hash", RETROK_HASH },
{ "dollar", RETROK_DOLLAR },
{ "ampersand", RETROK_AMPERSAND },
{ "leftparen", RETROK_LEFTPAREN },
{ "rightparen", RETROK_RIGHTPAREN },
{ "asterisk", RETROK_ASTERISK },
{ "plus", RETROK_PLUS },
{ "colon", RETROK_COLON },
{ "less", RETROK_LESS },
{ "greater", RETROK_GREATER },
{ "question", RETROK_QUESTION },
{ "at", RETROK_AT },
{ "f13", RETROK_F13 },
{ "f14", RETROK_F14 },
{ "f15", RETROK_F15 },
{ "rmeta", RETROK_RMETA },
{ "lmeta", RETROK_LMETA },
{ "lsuper", RETROK_LSUPER },
{ "rsuper", RETROK_RSUPER },
{ "mode", RETROK_MODE },
{ "compose", RETROK_COMPOSE },
{ "help", RETROK_HELP },
{ "sysreq", RETROK_SYSREQ },
{ "break", RETROK_BREAK },
{ "menu", RETROK_MENU },
{ "power", RETROK_POWER },
{ "euro", RETROK_EURO },
{ "undo", RETROK_UNDO },
{ "clear", RETROK_CLEAR },
{ "nul", RETROK_UNKNOWN },
{ NULL, RETROK_UNKNOWN },
};
static enum retro_key find_rk_bind(const char *str)
{
size_t i;
for (i = 0; input_config_key_map[i].str; i++)
{
if (strcasecmp(input_config_key_map[i].str, str) == 0)
return input_config_key_map[i].key;
}
RARCH_WARN("Key name %s not found.\n", str);
return RETROK_UNKNOWN;
}
enum retro_key input_translate_str_to_rk(const char *str)
{
if (strlen(str) == 1 && isalpha(*str))
return (enum retro_key)(RETROK_a + (tolower(*str) - (int)'a'));
return find_rk_bind(str);
}
/**
* input_joypad_init_driver:
* @ident : identifier of driver to initialize.

View File

@ -47,6 +47,132 @@
#include <linux/kd.h>
#endif
const struct input_key_map input_config_key_map[] = {
{ "left", RETROK_LEFT },
{ "right", RETROK_RIGHT },
{ "up", RETROK_UP },
{ "down", RETROK_DOWN },
{ "enter", RETROK_RETURN },
{ "kp_enter", RETROK_KP_ENTER },
{ "tab", RETROK_TAB },
{ "insert", RETROK_INSERT },
{ "del", RETROK_DELETE },
{ "end", RETROK_END },
{ "home", RETROK_HOME },
{ "rshift", RETROK_RSHIFT },
{ "shift", RETROK_LSHIFT },
{ "ctrl", RETROK_LCTRL },
{ "alt", RETROK_LALT },
{ "space", RETROK_SPACE },
{ "escape", RETROK_ESCAPE },
{ "add", RETROK_KP_PLUS },
{ "subtract", RETROK_KP_MINUS },
{ "kp_plus", RETROK_KP_PLUS },
{ "kp_minus", RETROK_KP_MINUS },
{ "f1", RETROK_F1 },
{ "f2", RETROK_F2 },
{ "f3", RETROK_F3 },
{ "f4", RETROK_F4 },
{ "f5", RETROK_F5 },
{ "f6", RETROK_F6 },
{ "f7", RETROK_F7 },
{ "f8", RETROK_F8 },
{ "f9", RETROK_F9 },
{ "f10", RETROK_F10 },
{ "f11", RETROK_F11 },
{ "f12", RETROK_F12 },
{ "num0", RETROK_0 },
{ "num1", RETROK_1 },
{ "num2", RETROK_2 },
{ "num3", RETROK_3 },
{ "num4", RETROK_4 },
{ "num5", RETROK_5 },
{ "num6", RETROK_6 },
{ "num7", RETROK_7 },
{ "num8", RETROK_8 },
{ "num9", RETROK_9 },
{ "pageup", RETROK_PAGEUP },
{ "pagedown", RETROK_PAGEDOWN },
{ "keypad0", RETROK_KP0 },
{ "keypad1", RETROK_KP1 },
{ "keypad2", RETROK_KP2 },
{ "keypad3", RETROK_KP3 },
{ "keypad4", RETROK_KP4 },
{ "keypad5", RETROK_KP5 },
{ "keypad6", RETROK_KP6 },
{ "keypad7", RETROK_KP7 },
{ "keypad8", RETROK_KP8 },
{ "keypad9", RETROK_KP9 },
{ "period", RETROK_PERIOD },
{ "capslock", RETROK_CAPSLOCK },
{ "numlock", RETROK_NUMLOCK },
{ "backspace", RETROK_BACKSPACE },
{ "multiply", RETROK_KP_MULTIPLY },
{ "divide", RETROK_KP_DIVIDE },
{ "print_screen", RETROK_PRINT },
{ "scroll_lock", RETROK_SCROLLOCK },
{ "tilde", RETROK_BACKQUOTE },
{ "backquote", RETROK_BACKQUOTE },
{ "pause", RETROK_PAUSE },
/* Keys that weren't mappable before */
{ "quote", RETROK_QUOTE },
{ "comma", RETROK_COMMA },
{ "minus", RETROK_MINUS },
{ "slash", RETROK_SLASH },
{ "semicolon", RETROK_SEMICOLON },
{ "equals", RETROK_EQUALS },
{ "leftbracket", RETROK_LEFTBRACKET },
{ "backslash", RETROK_BACKSLASH },
{ "rightbracket", RETROK_RIGHTBRACKET },
{ "kp_period", RETROK_KP_PERIOD },
{ "kp_equals", RETROK_KP_EQUALS },
{ "rctrl", RETROK_RCTRL },
{ "ralt", RETROK_RALT },
/* Keys not referenced in any keyboard mapping
* (except perhaps rarch_key_map_apple_hid) */
{ "caret", RETROK_CARET },
{ "underscore", RETROK_UNDERSCORE },
{ "exclaim", RETROK_EXCLAIM },
{ "quotedbl", RETROK_QUOTEDBL },
{ "hash", RETROK_HASH },
{ "dollar", RETROK_DOLLAR },
{ "ampersand", RETROK_AMPERSAND },
{ "leftparen", RETROK_LEFTPAREN },
{ "rightparen", RETROK_RIGHTPAREN },
{ "asterisk", RETROK_ASTERISK },
{ "plus", RETROK_PLUS },
{ "colon", RETROK_COLON },
{ "less", RETROK_LESS },
{ "greater", RETROK_GREATER },
{ "question", RETROK_QUESTION },
{ "at", RETROK_AT },
{ "f13", RETROK_F13 },
{ "f14", RETROK_F14 },
{ "f15", RETROK_F15 },
{ "rmeta", RETROK_RMETA },
{ "lmeta", RETROK_LMETA },
{ "lsuper", RETROK_LSUPER },
{ "rsuper", RETROK_RSUPER },
{ "mode", RETROK_MODE },
{ "compose", RETROK_COMPOSE },
{ "help", RETROK_HELP },
{ "sysreq", RETROK_SYSREQ },
{ "break", RETROK_BREAK },
{ "menu", RETROK_MENU },
{ "power", RETROK_POWER },
{ "euro", RETROK_EURO },
{ "undo", RETROK_UNDO },
{ "clear", RETROK_CLEAR },
{ "nul", RETROK_UNKNOWN },
{ NULL, RETROK_UNKNOWN },
};
#ifdef HAVE_X11
const struct rarch_key_map rarch_key_map_x11[] = {
{ XK_BackSpace, RETROK_BACKSPACE },