(Android) Add ICade profile option

This commit is contained in:
twinaphex 2013-02-09 11:44:32 +01:00
parent 6a6ad5d606
commit fa582bf15e
7 changed files with 95 additions and 30 deletions

View File

@ -601,36 +601,46 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
}
else if (strstr(name_buf, "Broadcom Bluetooth HID"))
{
/* TODO: unsure about Select button here */
/* TODO: hookup right stick
* RStick Up: 37
* RStick Down: 39
* RStick Left:38
* RStick Right: 40 */
if ((g_settings.input.icade_count +1) < 4)
{
g_settings.input.icade_count++;
/* Red Samurai */
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_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_BACK] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_ENTER] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
keycode_lut[AKEYCODE_9] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
keycode_lut[AKEYCODE_0] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
keycode_lut[AKEYCODE_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
keycode_lut[AKEYCODE_6] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
keycode_lut[AKEYCODE_7] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
keycode_lut[AKEYCODE_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
switch(g_settings.input.icade_profile[g_settings.input.icade_count])
{
case ICADE_PROFILE_RED_SAMURAI:
/* TODO: unsure about Select button here */
/* TODO: hookup right stick
* RStick Up: 37
* RStick Down: 39
* RStick Left:38
* RStick Right: 40 */
/* unsure if the person meant the SNES-mapping here or whether it's the pad */
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_Y+1) << shift);
keycode_lut[AKEYCODE_4] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
/* Red Samurai */
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_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_BACK] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_ENTER] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
keycode_lut[AKEYCODE_9] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
keycode_lut[AKEYCODE_0] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
keycode_lut[AKEYCODE_5] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
keycode_lut[AKEYCODE_6] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
keycode_lut[AKEYCODE_7] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
keycode_lut[AKEYCODE_8] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
/* unsure if the person meant the SNES-mapping here or whether it's the pad */
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_Y+1) << shift);
keycode_lut[AKEYCODE_4] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
break;
}
}
}
else if (strstr(name_buf, "USB Gamepad") || strstr(name_buf, "DragonRise"))
{

View File

@ -21,6 +21,10 @@
#define AKEY_EVENT_NO_ACTION 255
enum {
ICADE_PROFILE_RED_SAMURAI = 0,
} icade_profile_enums;
enum {
AKEYCODE_META_FUNCTION_ON = 8,
AKEYCODE_ESCAPE = 111,

View File

@ -19,6 +19,14 @@
<item>1.60000</item>
<item>1.14286</item>
</string-array>
<string-array name="icade_profiles">
<item>Red Samurai</item>
</string-array>
<string-array name="icade_profiles_values">
<item>0</item>
</string-array>
<string-array name="fbo_scales">
<item>1.0x</item>
@ -249,4 +257,4 @@
<item>MUSIC</item>
<item>CALCULATOR</item>
</string-array>
</resources>
</resources>

View File

@ -168,6 +168,30 @@
android:summary="This will attempt to preconfigure various gamepads and/or IME apps that you connect."
android:title="Enable"
android:disableDependentsState="true" />
<ListPreference
android:entries="@array/icade_profiles"
android:entryValues="@array/icade_profiles_values"
android:key="input_autodetect_icade_profile_pad0"
android:summary="Select the iCade profile to use for controller 1."
android:title="iCade profile Pad 1" />
<ListPreference
android:entries="@array/icade_profiles"
android:entryValues="@array/icade_profiles_values"
android:key="input_autodetect_icade_profile_pad1"
android:summary="Select the iCade profile to use for controller 2."
android:title="iCade profile Pad 2" />
<ListPreference
android:entries="@array/icade_profiles"
android:entryValues="@array/icade_profiles_values"
android:key="input_autodetect_icade_profile_pad2"
android:summary="Select the iCade profile to use for controller 3."
android:title="iCade profile Pad 3" />
<ListPreference
android:entries="@array/icade_profiles"
android:entryValues="@array/icade_profiles_values"
android:key="input_autodetect_icade_profile_pad3"
android:summary="Select the iCade profile to use for controller 4."
android:title="iCade profile Pad 4" />
</PreferenceCategory>
<PreferenceCategory android:title="Debug input reporting" >
<CheckBoxPreference

View File

@ -324,6 +324,10 @@ public class RetroArch extends Activity implements
config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true));
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
config.setInt("input_autodetect_icade_profile_pad1", prefs.getInt("input_autodetect_icade_profile_pad1", 0));
config.setInt("input_autodetect_icade_profile_pad2", prefs.getInt("input_autodetect_icade_profile_pad2", 0));
config.setInt("input_autodetect_icade_profile_pad3", prefs.getInt("input_autodetect_icade_profile_pad3", 0));
config.setInt("input_autodetect_icade_profile_pad4", prefs.getInt("input_autodetect_icade_profile_pad4", 0));
if (prefs.getBoolean("video_sync_refreshrate_to_screen", true)
&& (getRefreshRate() < 59.95)) {

View File

@ -235,6 +235,8 @@ struct settings
bool debug_enable;
#ifdef ANDROID
bool autodetect_enable;
unsigned icade_profile[MAX_PLAYERS];
unsigned icade_count;
#endif
#ifdef RARCH_CONSOLE
uint64_t default_binds[RARCH_CUSTOM_BIND_LIST_END];

View File

@ -468,7 +468,7 @@ bool config_load_file(const char *path)
CONFIG_GET_INT(video.aspect_ratio_idx, "aspect_ratio_index");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
for (unsigned i = 0; i < 8; i++)
for (unsigned i = 0; i < MAX_PLAYERS; i++)
{
char cfg[64];
snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
@ -477,6 +477,12 @@ bool config_load_file(const char *path)
CONFIG_GET_INT(input.device[i], cfg);
}
#ifdef ANDROID
CONFIG_GET_INT(input.icade_profile[0], "input_autodetect_icade_profile_pad1");
CONFIG_GET_INT(input.icade_profile[1], "input_autodetect_icade_profile_pad2");
CONFIG_GET_INT(input.icade_profile[2], "input_autodetect_icade_profile_pad3");
CONFIG_GET_INT(input.icade_profile[3], "input_autodetect_icade_profile_pad4");
#endif
CONFIG_GET_BOOL_EXTERN(console.screen.gamma_correction, "gamma_correction");
@ -1181,6 +1187,13 @@ bool config_save_file(const char *path)
config_set_string(conf, "system_directory", g_settings.system_directory);
config_set_string(conf, "audio_resampler", g_settings.audio.resampler);
#ifdef ANDROID
config_set_int(conf, "input_autodetect_icade_profile_pad1", input.icade_profile[0]);
config_set_int(conf, "input_autodetect_icade_profile_pad2", input.icade_profile[1]);
config_set_int(conf, "input_autodetect_icade_profile_pad3", input.icade_profile[2]);
config_set_int(conf, "input_autodetect_icade_profile_pad4", input.icade_profile[3]);
#endif
if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_OVERSCAN_ENABLE))
config_set_bool(conf, "overscan_enable", true);
else