224 changes: 110 additions & 114 deletions Source/Android/.idea/workspace.xml
Expand Up @@ -204,7 +204,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
return false;
}
InputDevice input = event.getDevice();
NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action);
NativeLibrary.onGamePadEvent(InputConfigActivity.getInputDesc(input), event.getKeyCode(), action);
return true;
}
return false;
Expand All @@ -222,7 +222,7 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
{
InputDevice.MotionRange range;
range = motions.get(a);
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), range.getAxis(), event.getAxisValue(range.getAxis()));
NativeLibrary.onGamePadMoveEvent(InputConfigActivity.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis()));
}

return true;
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.InputDevice;
Expand All @@ -26,6 +27,19 @@ public class InputConfigActivity extends ListActivity {
boolean Configuring = false;
boolean firstEvent = true;

static public String getInputDesc(InputDevice input)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
return input.getDescriptor();
else
{
List<InputDevice.MotionRange> motions = input.getMotionRanges();
String fakeid = "";
for (InputDevice.MotionRange range : motions)
fakeid += range.getAxis();
return fakeid;
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
Expand Down Expand Up @@ -124,12 +138,12 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
range = motions.get(a);
if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f))
{
AssignBind("Device '" + input.getDescriptor() + "'-Axis " + range.getAxis() + "-");
AssignBind("Device '" + InputConfigActivity.getInputDesc(input) + "'-Axis " + range.getAxis() + "-");
Configuring = false;
}
else if (m_values.get(a) < (event.getAxisValue(range.getAxis()) - 0.5f))
{
AssignBind("Device '" + input.getDescriptor() + "'-Axis " + range.getAxis() + "+");
AssignBind("Device '" + InputConfigActivity.getInputDesc(input) + "'-Axis " + range.getAxis() + "+");
Configuring = false;
}
}
Expand All @@ -148,7 +162,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
if (Configuring)
{
InputDevice input = event.getDevice();
AssignBind("Device '" + input.getDescriptor() + "'-Button " + event.getKeyCode());
AssignBind("Device '" + InputConfigActivity.getInputDesc(input) + "'-Button " + event.getKeyCode());
Configuring = false;
return true;
}
Expand Down