(Android) Autoconfigures IME app ccpcreations Wiimote pad 1 now

This commit is contained in:
twinaphex 2012-12-31 17:39:04 +01:00
parent 7855a25502
commit 9f361de651
3 changed files with 71 additions and 53 deletions

View File

@ -23,11 +23,9 @@
struct droid
{
struct android_app* app;
unsigned width;
unsigned height;
bool window_ready;
float disp_refresh_rate;
jobject class_loader_obj;
char current_ime[PATH_MAX];
};
extern struct droid g_android;

View File

@ -116,8 +116,12 @@ static void get_device_name(char *buf, size_t size, int id)
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];
msg[0] = 0;
char name_buf[256];
msg[0] = name_buf[0] = 0;
if (port > MAX_PADS)
{
@ -126,18 +130,68 @@ static void setup_keycode_lut(unsigned port, unsigned id, int source)
return;
}
char name_buf[256];
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_LSTICK;
get_device_name(name_buf, sizeof(name_buf), id);
/* eight 8-bit values are packed into one uint64_t
* one for each of the 8 pads */
uint8_t shift = 8 + (port * 8);
// Hack - we have to add '1' to the bit mask here because
// RETRO_DEVICE_ID_JOYPAD_B is 0
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"))
{
@ -158,41 +212,6 @@ static void setup_keycode_lut(unsigned port, unsigned id, int source)
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
}
}
#if 0
// com.ccpcreations.android.WiiUseAndroid IME driver
// Player 1
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);
#endif
else if (strstr(name_buf, "HuiJia USB GamePad"))
{
snprintf(msg, sizeof(msg), "RetroPad #%d is: HuiJia USB Gamepad.\n", port);
@ -386,7 +405,9 @@ static void setup_keycode_lut(unsigned port, unsigned id, int source)
keycode_lut[AKEYCODE_ESCAPE] |= ((RARCH_QUIT_KEY+1) << shift);
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
RARCH_LOG("Device %d: %s, port: %d.\n", id, name_buf, port);
do_exit:
if (name_buf[0] != 0)
RARCH_LOG("Device %d: %s, port: %d.\n", id, name_buf, port);
unsigned timeout_val = 30;
@ -398,7 +419,7 @@ static void setup_keycode_lut(unsigned port, unsigned id, int source)
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
else if (name_buf[0] != 0)
snprintf(msg, sizeof(msg), "HID [%s] unbound.\n", name_buf);
timeout_val = 120;
}

View File

@ -249,7 +249,6 @@ static int android_app_set_argv(char** argv)
char rom_path[PATH_MAX];
char libretro_path[PATH_MAX];
char config_file[PATH_MAX];
char current_ime[PATH_MAX];
struct jni_params in_params;
struct jni_out_params_char out_args;
@ -291,8 +290,8 @@ static int android_app_set_argv(char** argv)
jni_get(&in_params, &out_args);
// Current IME
out_args.out = current_ime;
out_args.out_sizeof = sizeof(current_ime);
out_args.out = g_android.current_ime;
out_args.out_sizeof = sizeof(g_android.current_ime);
strlcpy(out_args.in, "IME", sizeof(out_args.in));
jni_get(&in_params, &out_args);
@ -304,7 +303,7 @@ static int android_app_set_argv(char** argv)
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
RARCH_LOG("Display Refresh rate: %.2f Hz.\n", refreshrate);
RARCH_LOG("Config file: [%s].\n", config_file);
RARCH_LOG("Current IME: [%s].\n", current_ime);
RARCH_LOG("Current IME: [%s].\n", g_android.current_ime);
int argc = 0;