mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-25 20:25:42 +00:00
(Android) improve key bind preference handler, allow manual selection for IMEs
This commit is contained in:
parent
a5cdd29f4a
commit
2ac69233e5
@ -20,14 +20,25 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/key_bind_title"
|
||||
android:layout_below="@+id/key_bind_title"
|
||||
android:text="_"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/key_bind_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/key_bind_clear"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/key_bind_value"
|
||||
android:entries="@array/key_bind_values" >
|
||||
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/key_bind_clear"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/key_bind_value"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/key_bind_clear" />
|
||||
|
||||
|
@ -35,4 +35,218 @@
|
||||
<item>4.0</item>
|
||||
<item>5.0</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="key_bind_values">
|
||||
<item>UNBOUND</item>
|
||||
<item>SOFT LEFT</item>
|
||||
<item>SOFT RIGHT</item>
|
||||
<item>HOME</item>
|
||||
<item>BACK</item>
|
||||
<item>CALL</item>
|
||||
<item>ENDCALL</item>
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>STAR</item>
|
||||
<item>POUND</item>
|
||||
<item>DPAD UP</item>
|
||||
<item>DPAD DOWN</item>
|
||||
<item>DPAD LEFT</item>
|
||||
<item>DPAD RIGHT</item>
|
||||
<item>DPAD CENTER</item>
|
||||
<item>VOLUME UP</item>
|
||||
<item>VOLUME DOWN</item>
|
||||
<item>POWER</item>
|
||||
<item>CAMERA</item>
|
||||
<item>CLEAR</item>
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>C</item>
|
||||
<item>D</item>
|
||||
<item>E</item>
|
||||
<item>F</item>
|
||||
<item>G</item>
|
||||
<item>H</item>
|
||||
<item>I</item>
|
||||
<item>J</item>
|
||||
<item>K</item>
|
||||
<item>L</item>
|
||||
<item>M</item>
|
||||
<item>N</item>
|
||||
<item>O</item>
|
||||
<item>P</item>
|
||||
<item>Q</item>
|
||||
<item>R</item>
|
||||
<item>S</item>
|
||||
<item>T</item>
|
||||
<item>U</item>
|
||||
<item>V</item>
|
||||
<item>W</item>
|
||||
<item>X</item>
|
||||
<item>Y</item>
|
||||
<item>Z</item>
|
||||
<item>COMMA</item>
|
||||
<item>PERIOD</item>
|
||||
<item>ALT LEFT</item>
|
||||
<item>ALT RIGHT</item>
|
||||
<item>SHIFT LEFT</item>
|
||||
<item>SHIFT RIGHT</item>
|
||||
<item>TAB</item>
|
||||
<item>SPACE</item>
|
||||
<item>SYM</item>
|
||||
<item>EXPLORER</item>
|
||||
<item>ENVELOPE</item>
|
||||
<item>ENTER</item>
|
||||
<item>DEL</item>
|
||||
<item>GRAVE</item>
|
||||
<item>MINUS</item>
|
||||
<item>EQUALS</item>
|
||||
<item>LEFT BRACKET</item>
|
||||
<item>RIGHT BRACKET</item>
|
||||
<item>BACKSLASH</item>
|
||||
<item>SEMICOLON</item>
|
||||
<item>APOSTROPHE</item>
|
||||
<item>SLASH</item>
|
||||
<item>AT</item>
|
||||
<item>NUM</item>
|
||||
<item>HEADSETHOOK</item>
|
||||
<item>FOCUS</item>
|
||||
<item>PLUS</item>
|
||||
<item>MENU</item>
|
||||
<item>NOTIFICATION</item>
|
||||
<item>SEARCH</item>
|
||||
<item>MEDIA PLAY PAUSE=</item>
|
||||
<item>MEDIA STOP</item>
|
||||
<item>MEDIA NEXT</item>
|
||||
<item>MEDIA PREVIOUS</item>
|
||||
<item>MEDIA REWIND</item>
|
||||
<item>MEDIA FAST FORWARD</item>
|
||||
<item>MUTE</item>
|
||||
<item>PAGE UP</item>
|
||||
<item>PAGE DOWN</item>
|
||||
<item>PICTSYMBOLS</item>
|
||||
<item>SWITCH CHARSET</item>
|
||||
<item>BUTTON A</item>
|
||||
<item>BUTTON B</item>
|
||||
<item>BUTTON C</item>
|
||||
<item>BUTTON X</item>
|
||||
<item>BUTTON Y</item>
|
||||
<item>BUTTON Z</item>
|
||||
<item>BUTTON L1</item>
|
||||
<item>BUTTON R1</item>
|
||||
<item>BUTTON L2</item>
|
||||
<item>BUTTON R2</item>
|
||||
<item>BUTTON THUMBL</item>
|
||||
<item>BUTTON THUMBR</item>
|
||||
<item>BUTTON START</item>
|
||||
<item>BUTTON SELECT</item>
|
||||
<item>BUTTON MODE</item>
|
||||
<item>ESCAPE</item>
|
||||
<item>FORWARD DEL</item>
|
||||
<item>CTRL LEFT</item>
|
||||
<item>CTRL RIGHT</item>
|
||||
<item>CAPS LOCK</item>
|
||||
<item>SCROLL LOCK</item>
|
||||
<item>META LEFT</item>
|
||||
<item>META RIGHT</item>
|
||||
<item>FUNCTION</item>
|
||||
<item>SYSRQ</item>
|
||||
<item>BREAK</item>
|
||||
<item>MOVE HOME</item>
|
||||
<item>MOVE END</item>
|
||||
<item>INSERT</item>
|
||||
<item>FORWARD</item>
|
||||
<item>MEDIA PLAY</item>
|
||||
<item>MEDIA PAUSE</item>
|
||||
<item>MEDIA CLOSE</item>
|
||||
<item>MEDIA EJECT</item>
|
||||
<item>MEDIA RECORD</item>
|
||||
<item>F1</item>
|
||||
<item>F2</item>
|
||||
<item>F3</item>
|
||||
<item>F4</item>
|
||||
<item>F5</item>
|
||||
<item>F6</item>
|
||||
<item>F7</item>
|
||||
<item>F8</item>
|
||||
<item>F9</item>
|
||||
<item>F10</item>
|
||||
<item>F11</item>
|
||||
<item>F12</item>
|
||||
<item>NUM LOCK</item>
|
||||
<item>NUMPAD 0</item>
|
||||
<item>NUMPAD 1</item>
|
||||
<item>NUMPAD 2</item>
|
||||
<item>NUMPAD 3</item>
|
||||
<item>NUMPAD 4</item>
|
||||
<item>NUMPAD 5</item>
|
||||
<item>NUMPAD 6</item>
|
||||
<item>NUMPAD 7</item>
|
||||
<item>NUMPAD 8</item>
|
||||
<item>NUMPAD 9</item>
|
||||
<item>NUMPAD DIVIDE</item>
|
||||
<item>NUMPAD MULTIPLY</item>
|
||||
<item>NUMPAD SUBTRACT</item>
|
||||
<item>NUMPAD ADD</item>
|
||||
<item>NUMPAD DOT</item>
|
||||
<item>NUMPAD COMMA</item>
|
||||
<item>NUMPAD ENTER</item>
|
||||
<item>NUMPAD EQUALS</item>
|
||||
<item>NUMPAD LEFT PAREN</item>
|
||||
<item>NUMPAD RIGHT PAREN</item>
|
||||
<item>VOLUME MUTE</item>
|
||||
<item>INFO</item>
|
||||
<item>CHANNEL UP</item>
|
||||
<item>CHANNEL DOWN</item>
|
||||
<item>ZOOM IN</item>
|
||||
<item>ZOOM OUT</item>
|
||||
<item>TV</item>
|
||||
<item>WINDOW</item>
|
||||
<item>GUIDE</item>
|
||||
<item>DVR</item>
|
||||
<item>BOOKMARK</item>
|
||||
<item>CAPTIONS</item>
|
||||
<item>SETTINGS</item>
|
||||
<item>TV POWER</item>
|
||||
<item>TV INPUT</item>
|
||||
<item>STB POWER</item>
|
||||
<item>STB INPUT</item>
|
||||
<item>AVR POWER</item>
|
||||
<item>AVR INPUT</item>
|
||||
<item>PROG RED</item>
|
||||
<item>PROG GREEN</item>
|
||||
<item>PROG YELLOW</item>
|
||||
<item>PROG BLUE</item>
|
||||
<item>APP SWITCH</item>
|
||||
<item>BUTTON 1</item>
|
||||
<item>BUTTON 2</item>
|
||||
<item>BUTTON 3</item>
|
||||
<item>BUTTON 4</item>
|
||||
<item>BUTTON 5</item>
|
||||
<item>BUTTON 6</item>
|
||||
<item>BUTTON 7</item>
|
||||
<item>BUTTON 8</item>
|
||||
<item>BUTTON 9</item>
|
||||
<item>BUTTON 10</item>
|
||||
<item>BUTTON 11</item>
|
||||
<item>BUTTON 12</item>
|
||||
<item>BUTTON 13</item>
|
||||
<item>BUTTON 14</item>
|
||||
<item>BUTTON 15</item>
|
||||
<item>BUTTON 16</item>
|
||||
<item>LANGUAGE SWITCH</item>
|
||||
<item>MANNER MODE</item>
|
||||
<item>3D MODE</item>
|
||||
<item>CONTACTS</item>
|
||||
<item>CALENDAR</item>
|
||||
<item>MUSIC</item>
|
||||
<item>CALCULATOR</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -13,7 +13,7 @@
|
||||
<string name="cores_guide">Cores Guide</string>
|
||||
<string name="overlay_guide">Overlay How-to Guide</string>
|
||||
<string name="shader_pack">Shader Pack</string>
|
||||
<string name="key_bind_title">Press the button to use</string>
|
||||
<string name="key_bind_clear">Clear</string>
|
||||
<string name="key_bind_title">Press the button to use, or select it from the list</string>
|
||||
<string name="key_bind_clear">Unbind</string>
|
||||
|
||||
</resources>
|
||||
|
@ -7,15 +7,28 @@ import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.retroarch.R;
|
||||
|
||||
class KeyBindPreference extends DialogPreference implements View.OnKeyListener {
|
||||
class KeyBindPreference extends DialogPreference implements View.OnKeyListener, AdapterView.OnItemClickListener, View.OnClickListener {
|
||||
private int key_bind_code;
|
||||
TextView keyText;
|
||||
private String[] key_labels;
|
||||
private final int DEFAULT_KEYCODE = 0;
|
||||
|
||||
public KeyBindPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
key_labels = getContext().getResources().getStringArray(R.array.key_bind_values);
|
||||
}
|
||||
|
||||
private void setKey(int keyCode)
|
||||
{
|
||||
key_bind_code = keyCode;
|
||||
keyText.setText("Current: " + key_labels[key_bind_code]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,6 +43,9 @@ class KeyBindPreference extends DialogPreference implements View.OnKeyListener {
|
||||
View view = inflater.inflate(R.layout.key_bind_dialog, null);
|
||||
keyText = (TextView) view.findViewById(R.id.key_bind_value);
|
||||
view.setOnKeyListener(this);
|
||||
((ListView) view.findViewById(R.id.key_bind_list)).setOnItemClickListener(this);
|
||||
((Button) view.findViewById(R.id.key_bind_clear)).setOnClickListener(this);
|
||||
setKey(getPersistedInt(DEFAULT_KEYCODE));
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -38,18 +54,37 @@ class KeyBindPreference extends DialogPreference implements View.OnKeyListener {
|
||||
super.onDialogClosed(positiveResult);
|
||||
|
||||
if (positiveResult) {
|
||||
// deal with persisting your values here
|
||||
persistInt(key_bind_code);
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
Log.i("RetroArch", "Key event!");
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN)
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode != 0 && keyCode < key_labels.length)
|
||||
{
|
||||
key_bind_code = keyCode;
|
||||
keyText.setText(String.valueOf(key_bind_code));
|
||||
setKey(keyCode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
setKey((int)id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setKey(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
int code = getPersistedInt(DEFAULT_KEYCODE);
|
||||
if (code >= key_labels.length)
|
||||
return "";
|
||||
else
|
||||
return key_labels[code];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user