mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(Android) custom input binding
This commit is contained in:
parent
ce32089623
commit
f65e64a638
@ -47,6 +47,8 @@ static void *android_input_init(void)
|
||||
{
|
||||
pads_connected = 0;
|
||||
|
||||
input_autodetect_init();
|
||||
|
||||
for(unsigned player = 0; player < 4; player++)
|
||||
for(unsigned i = 0; i < RARCH_FIRST_META_KEY; i++)
|
||||
{
|
||||
@ -73,8 +75,6 @@ static void *android_input_init(void)
|
||||
g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_L3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L3);
|
||||
g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_R3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R3);
|
||||
}
|
||||
|
||||
input_autodetect_init();
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,27 @@ end:
|
||||
|
||||
void input_autodetect_init (void)
|
||||
{
|
||||
for(int j = 0; j < LAST_KEYCODE; j++)
|
||||
int j, k;
|
||||
for(j = 0; j < LAST_KEYCODE; j++)
|
||||
keycode_lut[j] = 0;
|
||||
|
||||
volume_enable = true;
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
return;
|
||||
|
||||
for (j = 0; j < MAX_PADS; j++)
|
||||
{
|
||||
uint8_t shift = 8 + (j * 8);
|
||||
for (k = 0; k < RARCH_FIRST_CUSTOM_BIND; k++)
|
||||
{
|
||||
if (g_settings.input.binds[j][k].valid && g_settings.input.binds[j][k].joykey && g_settings.input.binds[j][k].joykey < LAST_KEYCODE)
|
||||
{
|
||||
RARCH_LOG("binding %llu to %d (p%d)\n", g_settings.input.binds[j][k].joykey, k, j);
|
||||
keycode_lut[g_settings.input.binds[j][k].joykey] |= ((k + 1) << shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source)
|
||||
|
@ -165,7 +165,8 @@
|
||||
android:defaultValue="true"
|
||||
android:key="input_autodetect_enable"
|
||||
android:summary="This will attempt to preconfigure various gamepads and/or IME apps that you connect."
|
||||
android:title="Enable" />
|
||||
android:title="Enable"
|
||||
android:disableDependentsState="true" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="Debug input reporting" >
|
||||
<CheckBoxPreference
|
||||
@ -188,11 +189,215 @@
|
||||
android:targetPackage="org.retroarch" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
<!--<PreferenceCategory android:title="Button Binds" >
|
||||
<PreferenceCategory android:title="Custom Binds">
|
||||
<PreferenceScreen
|
||||
android:title="Player 1 Custom Binds"
|
||||
android:dependency="input_autodetect_enable" >
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="testKey"
|
||||
android:key="input_player1_up_btn"
|
||||
android:title="Up Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_down_btn"
|
||||
android:title="Down Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_left_btn"
|
||||
android:title="Left Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_right_btn"
|
||||
android:title="Right Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_a_btn"
|
||||
android:title="A Button" />
|
||||
</PreferenceCategory>-->
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_b_btn"
|
||||
android:title="B Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_x_btn"
|
||||
android:title="X Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_y_btn"
|
||||
android:title="Y Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_start_btn"
|
||||
android:title="Start Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_select_btn"
|
||||
android:title="Select Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_l_btn"
|
||||
android:title="L1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_r_btn"
|
||||
android:title="R1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_l2_btn"
|
||||
android:title="L2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_r2_btn"
|
||||
android:title="R2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_l3_btn"
|
||||
android:title="L3 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player1_r3_btn"
|
||||
android:title="R3 Button" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:title="Player 2 Custom Binds"
|
||||
android:dependency="input_autodetect_enable" >
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_up_btn"
|
||||
android:title="Up Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_down_btn"
|
||||
android:title="Down Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_left_btn"
|
||||
android:title="Left Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_right_btn"
|
||||
android:title="Right Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_a_btn"
|
||||
android:title="A Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_b_btn"
|
||||
android:title="B Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_x_btn"
|
||||
android:title="X Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_y_btn"
|
||||
android:title="Y Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_start_btn"
|
||||
android:title="Start Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_select_btn"
|
||||
android:title="Select Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_l_btn"
|
||||
android:title="L1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_r_btn"
|
||||
android:title="R1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_l2_btn"
|
||||
android:title="L2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_r2_btn"
|
||||
android:title="R2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_l3_btn"
|
||||
android:title="L3 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player2_r3_btn"
|
||||
android:title="R3 Button" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:title="Player 3 Custom Binds"
|
||||
android:dependency="input_autodetect_enable" >
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_up_btn"
|
||||
android:title="Up Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_down_btn"
|
||||
android:title="Down Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_left_btn"
|
||||
android:title="Left Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_right_btn"
|
||||
android:title="Right Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_a_btn"
|
||||
android:title="A Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_b_btn"
|
||||
android:title="B Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_x_btn"
|
||||
android:title="X Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_y_btn"
|
||||
android:title="Y Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_start_btn"
|
||||
android:title="Start Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_select_btn"
|
||||
android:title="Select Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_l_btn"
|
||||
android:title="L1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_r_btn"
|
||||
android:title="R1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_l2_btn"
|
||||
android:title="L2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_r2_btn"
|
||||
android:title="R2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_l3_btn"
|
||||
android:title="L3 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player3_r3_btn"
|
||||
android:title="R3 Button" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:title="Player 4 Custom Binds"
|
||||
android:dependency="input_autodetect_enable" >
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_up_btn"
|
||||
android:title="Up Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_down_btn"
|
||||
android:title="Down Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_left_btn"
|
||||
android:title="Left Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_right_btn"
|
||||
android:title="Right Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_a_btn"
|
||||
android:title="A Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_b_btn"
|
||||
android:title="B Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_x_btn"
|
||||
android:title="X Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_y_btn"
|
||||
android:title="Y Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_start_btn"
|
||||
android:title="Start Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_select_btn"
|
||||
android:title="Select Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_l_btn"
|
||||
android:title="L1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_r_btn"
|
||||
android:title="R1 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_l2_btn"
|
||||
android:title="L2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_r2_btn"
|
||||
android:title="R2 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_l3_btn"
|
||||
android:title="L3 Button" />
|
||||
<org.retroarch.browser.KeyBindPreference
|
||||
android:key="input_player4_r3_btn"
|
||||
android:title="R3 Button" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -343,6 +343,16 @@ public class RetroArch extends Activity implements
|
||||
|
||||
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
|
||||
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
final String btns[] = {"up", "down", "left", "right", "a", "b", "x", "y", "start", "select", "l", "r", "l2", "r2", "l3", "r3" };
|
||||
for (String b : btns)
|
||||
{
|
||||
String p = "input_player" + String.valueOf(i) + "_" + b + "_btn";
|
||||
config.setInt(p, prefs.getInt(p, 0));
|
||||
}
|
||||
}
|
||||
|
||||
String confPath = getDefaultConfigPath();
|
||||
try {
|
||||
config.write(new File(confPath));
|
||||
|
Loading…
x
Reference in New Issue
Block a user