mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
(Android) start of a custom key config panel
This commit is contained in:
parent
9372e26cf3
commit
e517dd96da
34
android/phoenix/res/layout/key_bind_dialog.xml
Normal file
34
android/phoenix/res/layout/key_bind_dialog.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/key_bind_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="@string/key_bind_title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/key_bind_value"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
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" />
|
||||||
|
|
||||||
|
<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_centerHorizontal="true"
|
||||||
|
android:text="@string/key_bind_clear" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -13,5 +13,7 @@
|
|||||||
<string name="cores_guide">Cores Guide</string>
|
<string name="cores_guide">Cores Guide</string>
|
||||||
<string name="overlay_guide">Overlay How-to Guide</string>
|
<string name="overlay_guide">Overlay How-to Guide</string>
|
||||||
<string name="shader_pack">Shader Pack</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>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -188,6 +188,11 @@
|
|||||||
android:targetPackage="org.retroarch" />
|
android:targetPackage="org.retroarch" />
|
||||||
</Preference>
|
</Preference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory android:title="Button Binds" >
|
||||||
|
<org.retroarch.browser.KeyBindPreference
|
||||||
|
android:key="testKey"
|
||||||
|
android:title="A Button" />
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package org.retroarch.browser;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.DialogPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.retroarch.R;
|
||||||
|
|
||||||
|
class KeyBindPreference extends DialogPreference implements View.OnKeyListener {
|
||||||
|
private int key_bind_code;
|
||||||
|
TextView keyText;
|
||||||
|
public KeyBindPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindDialogView(View view) {
|
||||||
|
super.onBindDialogView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View onCreateDialogView()
|
||||||
|
{
|
||||||
|
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View view = inflater.inflate(R.layout.key_bind_dialog, null);
|
||||||
|
keyText = (TextView) view.findViewById(R.id.key_bind_value);
|
||||||
|
view.setOnKeyListener(this);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDialogClosed(boolean positiveResult) {
|
||||||
|
super.onDialogClosed(positiveResult);
|
||||||
|
|
||||||
|
if (positiveResult) {
|
||||||
|
// deal with persisting your values here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
Log.i("RetroArch", "Key event!");
|
||||||
|
if (event.getAction() == KeyEvent.ACTION_DOWN)
|
||||||
|
{
|
||||||
|
key_bind_code = keyCode;
|
||||||
|
keyText.setText(String.valueOf(key_bind_code));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user