Show game actions before showing all keycodes for HW key remap dialog
This commit is contained in:
@@ -525,6 +525,16 @@ class SDL_Keys
|
|||||||
|
|
||||||
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
||||||
|
|
||||||
|
static String getName(int v)
|
||||||
|
{
|
||||||
|
for( int f = 0; f < values.length; f++ )
|
||||||
|
{
|
||||||
|
if( values[f] == v )
|
||||||
|
return names[f];
|
||||||
|
}
|
||||||
|
return names[0];
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
ArrayList<String> Names = new ArrayList<String> ();
|
ArrayList<String> Names = new ArrayList<String> ();
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
{
|
{
|
||||||
return p.getResources().getString(R.string.remap_hwkeys);
|
return p.getResources().getString(R.string.remap_hwkeys);
|
||||||
}
|
}
|
||||||
//boolean enabled() { return true; };
|
|
||||||
void run (final MainActivity p)
|
void run (final MainActivity p)
|
||||||
{
|
{
|
||||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||||
@@ -290,13 +289,55 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
|
|
||||||
final int KeyIndexFinal = keyIndex;
|
final int KeyIndexFinal = keyIndex;
|
||||||
|
CharSequence[] items = {
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[0]],
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[1]],
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[2]],
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[3]],
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[4]],
|
||||||
|
SDL_Keys.names[Globals.RemapScreenKbKeycode[5]],
|
||||||
|
p.getResources().getString(R.string.remap_hwkeys_select_more_keys),
|
||||||
|
};
|
||||||
|
|
||||||
|
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||||
|
items[i] = Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.remap_hwkeys_select);
|
builder.setTitle(R.string.remap_hwkeys_select_simple);
|
||||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[keyIndex]], new DialogInterface.OnClickListener()
|
builder.setItems(items, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick(DialogInterface dialog, int item)
|
public void onClick(DialogInterface dialog, int item)
|
||||||
{
|
{
|
||||||
Globals.RemapHwKeycode[KeyIndexFinal] = SDL_Keys.namesSortedIdx[item];
|
dialog.dismiss();
|
||||||
|
if( item >= 6 )
|
||||||
|
ShowAllKeys(KeyIndexFinal);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
|
||||||
|
goBack(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||||
|
{
|
||||||
|
public void onCancel(DialogInterface dialog)
|
||||||
|
{
|
||||||
|
goBack(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.setOwnerActivity(p);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
public void ShowAllKeys(final int KeyIndex)
|
||||||
|
{
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
|
builder.setTitle(R.string.remap_hwkeys_select);
|
||||||
|
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
public void onClick(DialogInterface dialog, int item)
|
||||||
|
{
|
||||||
|
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
@@ -346,7 +387,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||||
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i];
|
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
||||||
@@ -389,7 +430,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
};
|
};
|
||||||
|
|
||||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||||
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i];
|
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
||||||
{
|
{
|
||||||
@@ -707,14 +748,14 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
if( i >= 2 && i <= 7 )
|
if( i >= 2 && i <= 7 )
|
||||||
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
|
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
|
||||||
if( i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length )
|
if( i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length )
|
||||||
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2];
|
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2].replace("_", " ");
|
||||||
if( i == 0 )
|
if( i == 0 )
|
||||||
buttonText = "Joystick";
|
buttonText = "Joystick";
|
||||||
if( i == 1 )
|
if( i == 1 )
|
||||||
buttonText = "Text input";
|
buttonText = "Text input";
|
||||||
if( i == 8 )
|
if( i == 8 )
|
||||||
buttonText = "Joystick 2";
|
buttonText = "Joystick 2";
|
||||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText.replace("_", " "));
|
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTouchEvent(final MotionEvent ev)
|
public void onTouchEvent(final MotionEvent ev)
|
||||||
|
|||||||
@@ -124,6 +124,8 @@
|
|||||||
<string name="remap_hwkeys">Remap physical keys</string>
|
<string name="remap_hwkeys">Remap physical keys</string>
|
||||||
<string name="remap_hwkeys_press">Press any key except HOME and POWER, you may use volume keys</string>
|
<string name="remap_hwkeys_press">Press any key except HOME and POWER, you may use volume keys</string>
|
||||||
<string name="remap_hwkeys_select">Select SDL keycode</string>
|
<string name="remap_hwkeys_select">Select SDL keycode</string>
|
||||||
|
<string name="remap_hwkeys_select_simple">Select action</string>
|
||||||
|
<string name="remap_hwkeys_select_more_keys">Show all keycodes</string>
|
||||||
|
|
||||||
<string name="remap_screenkb">Remap on-screen controls</string>
|
<string name="remap_screenkb">Remap on-screen controls</string>
|
||||||
<string name="remap_screenkb_joystick">Joystick</string>
|
<string name="remap_screenkb_joystick">Joystick</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user