Merge pull request #300 from Sonicadvance1/Fix-AndroidInput

[Android] Fixes a bunch of input bugs.
This commit is contained in:
shuffle2
2014-05-30 15:32:08 -07:00
9 changed files with 138 additions and 132 deletions

View File

@ -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`
@ -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`
@ -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`
@ -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`

View File

@ -84,7 +84,6 @@ public final class DolphinEmulator extends Activity
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");
@ -93,6 +92,10 @@ public final class DolphinEmulator extends Activity
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);

View File

@ -54,23 +54,9 @@ public final class NativeLibrary
}
/**
* 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.
* Default touchscreen device
*/
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).
*/
public static native void onTouchAxisEvent(int padID, int Axis, float force);
public static final String TouchScreenDevice = "Touchscreen";
/**
* Handles button press events for a gamepad.

View File

@ -290,10 +290,10 @@ public final class EmulationActivity extends Activity
}
// Normal key events.
action = 0;
action = NativeLibrary.ButtonState.PRESSED;
break;
case KeyEvent.ACTION_UP:
action = 1;
action = NativeLibrary.ButtonState.RELEASED;
break;
default:
return false;

View File

@ -123,14 +123,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{
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);
}
}
@ -142,7 +142,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
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;