Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #300 from Sonicadvance1/Fix-AndroidInput
[Android] Fixes a bunch of input bugs.
  • Loading branch information
shuffle2 committed May 30, 2014
2 parents 8fc83d8 + e1bbda1 commit d020133
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 131 deletions.
48 changes: 24 additions & 24 deletions Source/Android/assets/GCPadNew.ini
Expand Up @@ -12,14 +12,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15`
C-Stick/Down = `Axis 16`
C-Stick/Left = `Axis 17`
C-Stick/Right = `Axis 18`
C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000
Triggers/L = `Button 18`
Triggers/R = `Button 19`
Triggers/L = `Axis 20`
Triggers/R = `Axis 21`
D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8`
Expand All @@ -38,14 +38,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15`
C-Stick/Down = `Axis 16`
C-Stick/Left = `Axis 17`
C-Stick/Right = `Axis 18`
C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18`
Triggers/R = `Axis 19`
Triggers/L = `Axis 20`
Triggers/R = `Axis 21`
D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8`
Expand All @@ -64,14 +64,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15`
C-Stick/Down = `Axis 16`
C-Stick/Left = `Axis 17`
C-Stick/Right = `Axis 18`
C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18`
Triggers/R = `Axis 19`
Triggers/L = `Axis 20`
Triggers/R = `Axis 21`
D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8`
Expand All @@ -90,14 +90,14 @@ Main Stick/Left = `Axis 13`
Main Stick/Right = `Axis 14`
Main Stick/Modifier = Shift_L
Main Stick/Modifier/Range = 50.000000
C-Stick/Up = `Axis 15`
C-Stick/Down = `Axis 16`
C-Stick/Left = `Axis 17`
C-Stick/Right = `Axis 18`
C-Stick/Up = `Axis 16`
C-Stick/Down = `Axis 17`
C-Stick/Left = `Axis 18`
C-Stick/Right = `Axis 19`
C-Stick/Modifier = Control_L
C-Stick/Modifier/Range = 50.000000
Triggers/L = `Axis 18`
Triggers/R = `Axis 19`
Triggers/L = `Axis 20`
Triggers/R = `Axis 21`
D-Pad/Up = `Button 6`
D-Pad/Down = `Button 7`
D-Pad/Left = `Button 8`
Expand Down
Expand Up @@ -84,7 +84,6 @@ public void onCreate(Bundle savedInstanceState)
if(!file.exists())
{
NativeLibrary.CreateUserFolders();
CopyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini");
CopyAsset("Dolphin.ini", ConfigDir + File.separator + "Dolphin.ini");
CopyAsset("dsp_coef.bin", GCDir + File.separator + "dsp_coef.bin");
CopyAsset("dsp_rom.bin", GCDir + File.separator + "dsp_rom.bin");
Expand All @@ -93,6 +92,10 @@ public void onCreate(Bundle savedInstanceState)
CopyAssetFolder("Shaders", BaseDir + File.separator + "Shaders");
}

// Always copy over the GCPad config in case of change or corruption.
// Not a user configurable file.
CopyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini");

// Load the configuration keys set in the Dolphin ini and gfx ini files
// into the application's shared preferences.
UserPreferences.LoadIniToPrefs(this);
Expand Down
18 changes: 2 additions & 16 deletions Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java
Expand Up @@ -54,23 +54,9 @@
}

/**
* Handles touch events.
*
* @param padID Identifier for which GCpad 0-3,
* @param Button Key code identifying which button was pressed,
* @param Action Mask for the action being performed.
*/
public static native void onTouchEvent(int padID, int Button, int Action);

/**
* Handles axis-related touch events.
*
* @param padID Identifier for which GCpad 0-3,
* @param Axis Axis ID for the type of axis being altered. (Example: Main stick up, down, left, right, etc),
* @param force How 'far down' the joystick is pushed down. 0.0f indicates center (or no force),
* 1.0f indicates max force (or joystick pushed all the way down in any arbitrary direction).
* Default touchscreen device
*/
public static native void onTouchAxisEvent(int padID, int Axis, float force);
public static final String TouchScreenDevice = "Touchscreen";

/**
* Handles button press events for a gamepad.
Expand Down
Expand Up @@ -290,10 +290,10 @@ public boolean dispatchKeyEvent(KeyEvent event)
}

// Normal key events.
action = 0;
action = NativeLibrary.ButtonState.PRESSED;
break;
case KeyEvent.ACTION_UP:
action = 1;
action = NativeLibrary.ButtonState.RELEASED;
break;
default:
return false;
Expand Down
Expand Up @@ -123,14 +123,14 @@ public boolean onTouch(View v, MotionEvent event)
{
if (button.getBounds().contains((int)event.getX(), (int)event.getY()))
{
NativeLibrary.onTouchEvent(0, button.getId(), buttonState);
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), buttonState);
}
else
{
// Because the above code only changes the state for the button that is being touched, sliding off the
// button does not allow for it to be released. Release the button as soon as the touch coordinates leave
// the button bounds.
NativeLibrary.onTouchEvent(0, button.getId(), ButtonState.RELEASED);
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED);
}
}

Expand All @@ -142,7 +142,7 @@ public boolean onTouch(View v, MotionEvent event)
float[] axises = joystick.getAxisValues();

for (int i = 0; i < 4; i++)
NativeLibrary.onTouchAxisEvent(0, axisIDs[i], axises[i]);
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice, axisIDs[i], axises[i]);
}

return true;
Expand Down

0 comments on commit d020133

Please sign in to comment.