mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +00:00
(Android) work on IME key detection
works with wiimote IME, but not with standard keyboard IME. hopefully most gamepad IMEs work
This commit is contained in:
parent
c838b1359c
commit
cffc556fd0
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/key_bind_dialog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
@ -14,13 +15,17 @@
|
|||||||
android:text="@string/key_bind_title"
|
android:text="@string/key_bind_title"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
android:id="@+id/key_bind_value"
|
android:id="@+id/key_bind_value"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignLeft="@+id/key_bind_title"
|
android:layout_alignLeft="@+id/key_bind_title"
|
||||||
android:layout_below="@+id/key_bind_title"
|
android:layout_below="@+id/key_bind_title"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:ems="10"
|
||||||
|
android:inputType="text" >
|
||||||
|
|
||||||
|
<requestFocus />
|
||||||
|
</EditText>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/key_bind_list"
|
android:id="@+id/key_bind_list"
|
||||||
@ -28,7 +33,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_above="@+id/key_bind_clear"
|
android:layout_above="@+id/key_bind_clear"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_below="@+id/key_bind_value"
|
android:layout_below="@+id/key_bind_value"
|
||||||
android:entries="@array/key_bind_values" >
|
android:entries="@array/key_bind_values" >
|
||||||
|
|
||||||
|
@ -9,14 +9,42 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.retroarch.R;
|
import org.retroarch.R;
|
||||||
|
|
||||||
class KeyBindPreference extends DialogPreference implements View.OnKeyListener, AdapterView.OnItemClickListener, View.OnClickListener {
|
class KeyBindEditText extends EditText
|
||||||
|
{
|
||||||
|
KeyBindPreference pref;
|
||||||
|
public KeyBindEditText(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoundPreference(KeyBindPreference pref)
|
||||||
|
{
|
||||||
|
this.pref = pref;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyPreIme(int keyCode, KeyEvent event)
|
||||||
|
{
|
||||||
|
Log.i("RetroArch", "key! " + String.valueOf(event.getKeyCode()));
|
||||||
|
pref.onKey(null, event.getKeyCode(), event);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||||
|
{
|
||||||
|
Log.i("RetroArch", "key! " + String.valueOf(event.getKeyCode()));
|
||||||
|
pref.onKey(null, event.getKeyCode(), event);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KeyBindPreference extends DialogPreference implements View.OnKeyListener, AdapterView.OnItemClickListener, View.OnClickListener, LayoutInflater.Factory {
|
||||||
private int key_bind_code;
|
private int key_bind_code;
|
||||||
TextView keyText;
|
KeyBindEditText keyText;
|
||||||
private String[] key_labels;
|
private String[] key_labels;
|
||||||
private final int DEFAULT_KEYCODE = 0;
|
private final int DEFAULT_KEYCODE = 0;
|
||||||
|
|
||||||
@ -39,9 +67,11 @@ class KeyBindPreference extends DialogPreference implements View.OnKeyListener,
|
|||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView()
|
protected View onCreateDialogView()
|
||||||
{
|
{
|
||||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).cloneInContext(getContext());
|
||||||
|
inflater.setFactory(this);
|
||||||
View view = inflater.inflate(R.layout.key_bind_dialog, null);
|
View view = inflater.inflate(R.layout.key_bind_dialog, null);
|
||||||
keyText = (TextView) view.findViewById(R.id.key_bind_value);
|
keyText = (KeyBindEditText) view.findViewById(R.id.key_bind_value);
|
||||||
|
keyText.setBoundPreference(this);
|
||||||
view.setOnKeyListener(this);
|
view.setOnKeyListener(this);
|
||||||
((ListView) view.findViewById(R.id.key_bind_list)).setOnItemClickListener(this);
|
((ListView) view.findViewById(R.id.key_bind_list)).setOnItemClickListener(this);
|
||||||
((Button) view.findViewById(R.id.key_bind_clear)).setOnClickListener(this);
|
((Button) view.findViewById(R.id.key_bind_clear)).setOnClickListener(this);
|
||||||
@ -87,4 +117,13 @@ class KeyBindPreference extends DialogPreference implements View.OnKeyListener,
|
|||||||
else
|
else
|
||||||
return key_labels[code];
|
return key_labels[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(String name, Context context, AttributeSet attrs) {
|
||||||
|
Log.i("RetroArch", "view name: " + name);
|
||||||
|
if (name.equals("EditText"))
|
||||||
|
return new KeyBindEditText(context, attrs);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user