mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
Merge branch 'master' of github.com:Themaister/RetroArch
This commit is contained in:
commit
a00f2ae254
@ -17,47 +17,14 @@
|
|||||||
#include <android/keycodes.h>
|
#include <android/keycodes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "android_general.h"
|
#include "android_general.h"
|
||||||
|
#include "input_autodetect.h"
|
||||||
#include "../../../input/input_common.h"
|
#include "../../../input/input_common.h"
|
||||||
#include "../../../performance.h"
|
#include "../../../performance.h"
|
||||||
#include "../../../general.h"
|
#include "../../../general.h"
|
||||||
#include "../../../driver.h"
|
#include "../../../driver.h"
|
||||||
|
|
||||||
#define AKEY_EVENT_NO_ACTION 255
|
|
||||||
#define MAX_PADS 8
|
|
||||||
#define MAX_TOUCH 8
|
#define MAX_TOUCH 8
|
||||||
|
|
||||||
enum {
|
|
||||||
AKEYCODE_ESCAPE = 111,
|
|
||||||
AKEYCODE_BREAK = 121,
|
|
||||||
AKEYCODE_F2 = 132,
|
|
||||||
AKEYCODE_F3 = 133,
|
|
||||||
AKEYCODE_F4 = 134,
|
|
||||||
AKEYCODE_F5 = 135,
|
|
||||||
AKEYCODE_F6 = 136,
|
|
||||||
AKEYCODE_F7 = 137,
|
|
||||||
AKEYCODE_F8 = 138,
|
|
||||||
AKEYCODE_F9 = 139,
|
|
||||||
AKEYCODE_BUTTON_1 = 188,
|
|
||||||
AKEYCODE_BUTTON_2 = 189,
|
|
||||||
AKEYCODE_BUTTON_3 = 190,
|
|
||||||
AKEYCODE_BUTTON_4 = 191,
|
|
||||||
AKEYCODE_BUTTON_5 = 192,
|
|
||||||
AKEYCODE_BUTTON_6 = 193,
|
|
||||||
AKEYCODE_BUTTON_7 = 194,
|
|
||||||
AKEYCODE_BUTTON_8 = 195,
|
|
||||||
AKEYCODE_BUTTON_9 = 196,
|
|
||||||
AKEYCODE_BUTTON_10 = 197,
|
|
||||||
AKEYCODE_BUTTON_11 = 198,
|
|
||||||
AKEYCODE_BUTTON_12 = 199,
|
|
||||||
AKEYCODE_BUTTON_13 = 200,
|
|
||||||
AKEYCODE_BUTTON_14 = 201,
|
|
||||||
AKEYCODE_BUTTON_15 = 202,
|
|
||||||
AKEYCODE_BUTTON_16 = 203,
|
|
||||||
AKEYCODE_ASSIST = 219,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define LAST_KEYCODE AKEYCODE_ASSIST
|
|
||||||
|
|
||||||
#define PRESSED_UP(x, y) ((-0.80f > y) && (x >= -1.00f))
|
#define PRESSED_UP(x, y) ((-0.80f > y) && (x >= -1.00f))
|
||||||
#define PRESSED_DOWN(x, y) ((0.80f < y) && (y <= 1.00f))
|
#define PRESSED_DOWN(x, y) ((0.80f < y) && (y <= 1.00f))
|
||||||
#define PRESSED_LEFT(x, y) ((-0.80f > x) && (x >= -1.00f))
|
#define PRESSED_LEFT(x, y) ((-0.80f > x) && (x >= -1.00f))
|
||||||
@ -68,7 +35,6 @@ enum {
|
|||||||
static unsigned pads_connected;
|
static unsigned pads_connected;
|
||||||
static uint64_t state[MAX_PADS];
|
static uint64_t state[MAX_PADS];
|
||||||
static int8_t state_device_ids[MAX_DEVICE_IDS];
|
static int8_t state_device_ids[MAX_DEVICE_IDS];
|
||||||
static uint64_t keycode_lut[LAST_KEYCODE];
|
|
||||||
|
|
||||||
struct input_pointer
|
struct input_pointer
|
||||||
{
|
{
|
||||||
@ -78,348 +44,6 @@ struct input_pointer
|
|||||||
static struct input_pointer pointer[MAX_TOUCH];
|
static struct input_pointer pointer[MAX_TOUCH];
|
||||||
static unsigned pointer_count;
|
static unsigned pointer_count;
|
||||||
|
|
||||||
static void get_device_name(char *buf, size_t size, int id)
|
|
||||||
{
|
|
||||||
JavaVM *vm = g_android.app->activity->vm;
|
|
||||||
JNIEnv *env = NULL;
|
|
||||||
(*vm)->AttachCurrentThread(vm, &env, 0);
|
|
||||||
|
|
||||||
jclass input_device_class = NULL;
|
|
||||||
FIND_CLASS(env, input_device_class, "android/view/InputDevice");
|
|
||||||
|
|
||||||
jmethodID method = NULL;
|
|
||||||
GET_STATIC_METHOD_ID(env, method, input_device_class, "getDevice", "(I)Landroid/view/InputDevice;");
|
|
||||||
|
|
||||||
jobject device = NULL;
|
|
||||||
CALL_OBJ_STATIC_METHOD_PARAM(env, device, input_device_class, method, (jint)id);
|
|
||||||
|
|
||||||
jmethodID getName = NULL;
|
|
||||||
GET_METHOD_ID(env, getName, input_device_class, "getName", "()Ljava/lang/String;");
|
|
||||||
|
|
||||||
jobject name = NULL;
|
|
||||||
CALL_OBJ_METHOD(env, name, device, getName);
|
|
||||||
|
|
||||||
const char *str = (*env)->GetStringUTFChars(env, name, 0);
|
|
||||||
strlcpy(buf, str, size);
|
|
||||||
(*env)->ReleaseStringUTFChars(env, name, str);
|
|
||||||
|
|
||||||
(*vm)->DetachCurrentThread(vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setup_keycode_lut(unsigned port, unsigned id, int source)
|
|
||||||
{
|
|
||||||
// Hack - we have to add '1' to the bit mask here because
|
|
||||||
// RETRO_DEVICE_ID_JOYPAD_B is 0
|
|
||||||
|
|
||||||
char msg[128];
|
|
||||||
char name_buf[256];
|
|
||||||
msg[0] = name_buf[0] = 0;
|
|
||||||
|
|
||||||
if (port > MAX_PADS)
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "Max number of pads reached.\n");
|
|
||||||
msg_queue_push(g_extern.msg_queue, msg, 0, 30);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* eight 8-bit values are packed into one uint64_t
|
|
||||||
* one for each of the 8 pads */
|
|
||||||
uint8_t shift = 8 + (port * 8);
|
|
||||||
|
|
||||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_LSTICK;
|
|
||||||
|
|
||||||
char *current_ime = g_android.current_ime;
|
|
||||||
|
|
||||||
if (strstr(current_ime, "com.ccpcreations.android.WiiUseAndroid"))
|
|
||||||
{
|
|
||||||
// Player 1
|
|
||||||
switch (port)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Wiimote (IME).\n", port);
|
|
||||||
snprintf(name_buf, sizeof(name_buf), "ccpcreations WiiUse");
|
|
||||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
|
||||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_RIGHT]|= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_1] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_3] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_4] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_5] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_6] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_M] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_P] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_E] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_B] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_F] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_G] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_C] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_LEFT_BRACKET] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_RIGHT_BRACKET] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_H] |= ((RARCH_RESET+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_W] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_S] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_A] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_D] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_C] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
shift = 8;
|
|
||||||
for(int i = 0; i < MAX_PADS; i++)
|
|
||||||
{
|
|
||||||
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
|
|
||||||
shift += 8;
|
|
||||||
}
|
|
||||||
goto do_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
get_device_name(name_buf, sizeof(name_buf), id);
|
|
||||||
|
|
||||||
if (strstr(name_buf, "Logitech"))
|
|
||||||
{
|
|
||||||
if(strstr(name_buf, "RumblePad 2"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: RumblePad 2.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "HuiJia USB GamePad"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: HuiJia USB Gamepad.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "Microsoft"))
|
|
||||||
{
|
|
||||||
if (strstr(name_buf, "Dual Strike"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder Dual Strike.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_L2) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "SideWinder"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "WiseGroup") && strstr(name_buf, "Dual USB Joypad"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: WiseGroup PS2 to USB.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "PLAYSTATION(R)3") || strstr(name_buf, "Dualshock3")
|
|
||||||
|| strstr(name_buf,"Sixaxis"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: DualShock3/Sixaxis.\n", port);
|
|
||||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
|
||||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_THUMBL] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_THUMBR] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "MOGA"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: MOGA.\n", port);
|
|
||||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
|
||||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "Sony Navigation Controller"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: PS Move Navi.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_15] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_14] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_UNKNOWN] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "CYPRESS USB"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Saturn USB.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "Mayflash Wii Classic"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mayflash Wii Classic.\n", port);
|
|
||||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_14] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_13] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_15] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
}
|
|
||||||
else if (strstr(name_buf, "Toodles 2008 ChImp"))
|
|
||||||
{
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Chimp Board.\n", port);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keyboard
|
|
||||||
// TODO: Map L2/R2/L3/R3
|
|
||||||
|
|
||||||
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_SHIFT_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_ENTER] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_X] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_S] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_Q] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_W] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
|
||||||
|
|
||||||
/* Misc control scheme */
|
|
||||||
keycode_lut[AKEYCODE_F2] |= ((RARCH_SAVE_STATE_KEY+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_F4] |= ((RARCH_LOAD_STATE_KEY+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_F7] |= ((RARCH_STATE_SLOT_PLUS+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_F6] |= ((RARCH_STATE_SLOT_MINUS+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_SPACE] |= ((RARCH_FAST_FORWARD_KEY+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_L] |= ((RARCH_FAST_FORWARD_HOLD_KEY+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BREAK] |= ((RARCH_PAUSE_TOGGLE+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_K] |= ((RARCH_FRAMEADVANCE+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_H] |= ((RARCH_RESET+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_R] |= ((RARCH_REWIND+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_F9] |= ((RARCH_MUTE+1) << shift);
|
|
||||||
|
|
||||||
keycode_lut[AKEYCODE_ESCAPE] |= ((RARCH_QUIT_KEY+1) << shift);
|
|
||||||
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
|
|
||||||
|
|
||||||
do_exit:
|
|
||||||
if (name_buf[0] != 0)
|
|
||||||
RARCH_LOG("Device %d: %s, port: %d.\n", id, name_buf, port);
|
|
||||||
|
|
||||||
unsigned timeout_val = 30;
|
|
||||||
|
|
||||||
if (msg[0] == 0)
|
|
||||||
{
|
|
||||||
if (source == AINPUT_SOURCE_TOUCHSCREEN)
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Touchscreen.\n", port);
|
|
||||||
else if (source == AINPUT_SOURCE_MOUSE)
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mouse.\n", port);
|
|
||||||
else if (source == AINPUT_SOURCE_KEYBOARD)
|
|
||||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Keyboard.\n", port);
|
|
||||||
else if (name_buf[0] != 0)
|
|
||||||
snprintf(msg, sizeof(msg), "HID [%s] unbound.\n", name_buf);
|
|
||||||
timeout_val = 120;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg[0] != 0)
|
|
||||||
msg_queue_push(g_extern.msg_queue, msg, 0, timeout_val);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *android_input_init(void)
|
static void *android_input_init(void)
|
||||||
{
|
{
|
||||||
pads_connected = 0;
|
pads_connected = 0;
|
||||||
@ -454,8 +78,7 @@ static void *android_input_init(void)
|
|||||||
for(int i = 0; i < MAX_DEVICE_IDS; i++)
|
for(int i = 0; i < MAX_DEVICE_IDS; i++)
|
||||||
state_device_ids[i] = -1;
|
state_device_ids[i] = -1;
|
||||||
|
|
||||||
for(int j = 0; j < LAST_KEYCODE; j++)
|
input_autodetect_init();
|
||||||
keycode_lut[j] = 0;
|
|
||||||
|
|
||||||
return (void*)-1;
|
return (void*)-1;
|
||||||
}
|
}
|
||||||
@ -493,7 +116,7 @@ static void android_input_poll(void *data)
|
|||||||
if(state_id == -1)
|
if(state_id == -1)
|
||||||
{
|
{
|
||||||
state_id = state_device_ids[id] = pads_connected++;
|
state_id = state_device_ids[id] = pads_connected++;
|
||||||
setup_keycode_lut(state_id, id, source);
|
input_autodetect_setup(state_id, id, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
int action = 0;
|
int action = 0;
|
||||||
@ -637,4 +260,3 @@ const input_driver_t input_android = {
|
|||||||
android_input_free_input,
|
android_input_free_input,
|
||||||
"android_input",
|
"android_input",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
368
android/native/jni/input_autodetect.c
Normal file
368
android/native/jni/input_autodetect.c
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch 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 Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch 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 RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "android_general.h"
|
||||||
|
#include "input_autodetect.h"
|
||||||
|
|
||||||
|
uint64_t keycode_lut[LAST_KEYCODE];
|
||||||
|
|
||||||
|
static void input_autodetect_get_device_name(char *buf, size_t size, int id)
|
||||||
|
{
|
||||||
|
JavaVM *vm = g_android.app->activity->vm;
|
||||||
|
JNIEnv *env = NULL;
|
||||||
|
(*vm)->AttachCurrentThread(vm, &env, 0);
|
||||||
|
|
||||||
|
jclass input_device_class = NULL;
|
||||||
|
FIND_CLASS(env, input_device_class, "android/view/InputDevice");
|
||||||
|
|
||||||
|
jmethodID method = NULL;
|
||||||
|
GET_STATIC_METHOD_ID(env, method, input_device_class, "getDevice", "(I)Landroid/view/InputDevice;");
|
||||||
|
|
||||||
|
jobject device = NULL;
|
||||||
|
CALL_OBJ_STATIC_METHOD_PARAM(env, device, input_device_class, method, (jint)id);
|
||||||
|
|
||||||
|
jmethodID getName = NULL;
|
||||||
|
GET_METHOD_ID(env, getName, input_device_class, "getName", "()Ljava/lang/String;");
|
||||||
|
|
||||||
|
jobject name = NULL;
|
||||||
|
CALL_OBJ_METHOD(env, name, device, getName);
|
||||||
|
|
||||||
|
const char *str = (*env)->GetStringUTFChars(env, name, 0);
|
||||||
|
strlcpy(buf, str, size);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, name, str);
|
||||||
|
|
||||||
|
(*vm)->DetachCurrentThread(vm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void input_autodetect_init (void)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < LAST_KEYCODE; j++)
|
||||||
|
keycode_lut[j] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void input_autodetect_setup(unsigned port, unsigned id, int source)
|
||||||
|
{
|
||||||
|
// Hack - we have to add '1' to the bit mask here because
|
||||||
|
// RETRO_DEVICE_ID_JOYPAD_B is 0
|
||||||
|
|
||||||
|
char msg[128];
|
||||||
|
char name_buf[256];
|
||||||
|
msg[0] = name_buf[0] = 0;
|
||||||
|
|
||||||
|
if (port > MAX_PADS)
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "Max number of pads reached.\n");
|
||||||
|
msg_queue_push(g_extern.msg_queue, msg, 0, 30);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* eight 8-bit values are packed into one uint64_t
|
||||||
|
* one for each of the 8 pads */
|
||||||
|
uint8_t shift = 8 + (port * 8);
|
||||||
|
|
||||||
|
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_LSTICK;
|
||||||
|
|
||||||
|
char *current_ime = g_android.current_ime;
|
||||||
|
|
||||||
|
if (strstr(current_ime, "com.ccpcreations.android.WiiUseAndroid"))
|
||||||
|
{
|
||||||
|
// Player 1
|
||||||
|
switch (port)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Wiimote (IME).\n", port);
|
||||||
|
snprintf(name_buf, sizeof(name_buf), "ccpcreations WiiUse");
|
||||||
|
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||||
|
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_RIGHT]|= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_1] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_3] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_4] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_5] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_6] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_M] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_P] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_E] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_B] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_F] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_G] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_C] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_LEFT_BRACKET] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_RIGHT_BRACKET] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_H] |= ((RARCH_RESET+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_W] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_S] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_A] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_D] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_C] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
shift = 8;
|
||||||
|
for(int i = 0; i < MAX_PADS; i++)
|
||||||
|
{
|
||||||
|
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
|
||||||
|
shift += 8;
|
||||||
|
}
|
||||||
|
goto do_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
input_autodetect_get_device_name(name_buf, sizeof(name_buf), id);
|
||||||
|
|
||||||
|
if (strstr(name_buf, "Logitech"))
|
||||||
|
{
|
||||||
|
if(strstr(name_buf, "RumblePad 2"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: RumblePad 2.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "HuiJia USB GamePad"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: HuiJia USB Gamepad.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "Microsoft"))
|
||||||
|
{
|
||||||
|
if (strstr(name_buf, "Dual Strike"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder Dual Strike.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_L2) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "SideWinder"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "WiseGroup") && strstr(name_buf, "Dual USB Joypad"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: WiseGroup PS2 to USB.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "PLAYSTATION(R)3") || strstr(name_buf, "Dualshock3")
|
||||||
|
|| strstr(name_buf,"Sixaxis"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: DualShock3/Sixaxis.\n", port);
|
||||||
|
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||||
|
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_THUMBL] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_THUMBR] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "MOGA"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: MOGA.\n", port);
|
||||||
|
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||||
|
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "Sony Navigation Controller"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: PS Move Navi.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_15] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_14] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_UNKNOWN] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "CYPRESS USB"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Saturn USB.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "Mayflash Wii Classic"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mayflash Wii Classic.\n", port);
|
||||||
|
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_14] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_13] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_15] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
}
|
||||||
|
else if (strstr(name_buf, "Toodles 2008 ChImp"))
|
||||||
|
{
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Chimp Board.\n", port);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keyboard
|
||||||
|
// TODO: Map L2/R2/L3/R3
|
||||||
|
|
||||||
|
keycode_lut[AKEYCODE_Z] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_SHIFT_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_ENTER] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_X] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_S] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_Q] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_W] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||||
|
|
||||||
|
/* Misc control scheme */
|
||||||
|
keycode_lut[AKEYCODE_F2] |= ((RARCH_SAVE_STATE_KEY+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_F4] |= ((RARCH_LOAD_STATE_KEY+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_F7] |= ((RARCH_STATE_SLOT_PLUS+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_F6] |= ((RARCH_STATE_SLOT_MINUS+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_SPACE] |= ((RARCH_FAST_FORWARD_KEY+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_L] |= ((RARCH_FAST_FORWARD_HOLD_KEY+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BREAK] |= ((RARCH_PAUSE_TOGGLE+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_K] |= ((RARCH_FRAMEADVANCE+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_H] |= ((RARCH_RESET+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_R] |= ((RARCH_REWIND+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_F9] |= ((RARCH_MUTE+1) << shift);
|
||||||
|
|
||||||
|
keycode_lut[AKEYCODE_ESCAPE] |= ((RARCH_QUIT_KEY+1) << shift);
|
||||||
|
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
|
||||||
|
|
||||||
|
do_exit:
|
||||||
|
if (name_buf[0] != 0)
|
||||||
|
RARCH_LOG("Device %d: %s, port: %d.\n", id, name_buf, port);
|
||||||
|
|
||||||
|
unsigned timeout_val = 30;
|
||||||
|
|
||||||
|
if (msg[0] == 0)
|
||||||
|
{
|
||||||
|
if (source == AINPUT_SOURCE_TOUCHSCREEN)
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Touchscreen.\n", port);
|
||||||
|
else if (source == AINPUT_SOURCE_MOUSE)
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mouse.\n", port);
|
||||||
|
else if (source == AINPUT_SOURCE_KEYBOARD)
|
||||||
|
snprintf(msg, sizeof(msg), "RetroPad #%d is: Keyboard.\n", port);
|
||||||
|
else if (name_buf[0] != 0)
|
||||||
|
snprintf(msg, sizeof(msg), "HID [%s] unbound.\n", name_buf);
|
||||||
|
timeout_val = 120;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg[0] != 0)
|
||||||
|
msg_queue_push(g_extern.msg_queue, msg, 0, timeout_val);
|
||||||
|
}
|
61
android/native/jni/input_autodetect.h
Normal file
61
android/native/jni/input_autodetect.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch 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 Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch 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 RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ANDROID_INPUT_AUTODETECT_H
|
||||||
|
#define _ANDROID_INPUT_AUTODETECT_H
|
||||||
|
|
||||||
|
#define MAX_PADS 8
|
||||||
|
|
||||||
|
#define AKEY_EVENT_NO_ACTION 255
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AKEYCODE_ESCAPE = 111,
|
||||||
|
AKEYCODE_BREAK = 121,
|
||||||
|
AKEYCODE_F2 = 132,
|
||||||
|
AKEYCODE_F3 = 133,
|
||||||
|
AKEYCODE_F4 = 134,
|
||||||
|
AKEYCODE_F5 = 135,
|
||||||
|
AKEYCODE_F6 = 136,
|
||||||
|
AKEYCODE_F7 = 137,
|
||||||
|
AKEYCODE_F8 = 138,
|
||||||
|
AKEYCODE_F9 = 139,
|
||||||
|
AKEYCODE_BUTTON_1 = 188,
|
||||||
|
AKEYCODE_BUTTON_2 = 189,
|
||||||
|
AKEYCODE_BUTTON_3 = 190,
|
||||||
|
AKEYCODE_BUTTON_4 = 191,
|
||||||
|
AKEYCODE_BUTTON_5 = 192,
|
||||||
|
AKEYCODE_BUTTON_6 = 193,
|
||||||
|
AKEYCODE_BUTTON_7 = 194,
|
||||||
|
AKEYCODE_BUTTON_8 = 195,
|
||||||
|
AKEYCODE_BUTTON_9 = 196,
|
||||||
|
AKEYCODE_BUTTON_10 = 197,
|
||||||
|
AKEYCODE_BUTTON_11 = 198,
|
||||||
|
AKEYCODE_BUTTON_12 = 199,
|
||||||
|
AKEYCODE_BUTTON_13 = 200,
|
||||||
|
AKEYCODE_BUTTON_14 = 201,
|
||||||
|
AKEYCODE_BUTTON_15 = 202,
|
||||||
|
AKEYCODE_BUTTON_16 = 203,
|
||||||
|
AKEYCODE_ASSIST = 219,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LAST_KEYCODE AKEYCODE_ASSIST
|
||||||
|
|
||||||
|
extern uint64_t keycode_lut[LAST_KEYCODE];
|
||||||
|
|
||||||
|
void input_autodetect_init (void);
|
||||||
|
void input_autodetect_setup(unsigned port, unsigned id, int source);
|
||||||
|
|
||||||
|
#endif
|
@ -248,6 +248,7 @@ INPUT
|
|||||||
#elif defined(XENON)
|
#elif defined(XENON)
|
||||||
#include "../../360/xenon360_input.c"
|
#include "../../360/xenon360_input.c"
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
|
#include "../../android/native/jni/input_autodetect.c"
|
||||||
#include "../../android/native/jni/input_android.c"
|
#include "../../android/native/jni/input_android.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user