Update to SDL 2.0.5
This commit is contained in:
@@ -61,7 +61,7 @@ This product bundles pixman 0.32.8, which is available under an
|
|||||||
This product bundles libpng 1.6.12, which is available under a
|
This product bundles libpng 1.6.12, which is available under a
|
||||||
"zlib" (BSD-style) license. For details, see [project/lib/png/](project/lib).
|
"zlib" (BSD-style) license. For details, see [project/lib/png/](project/lib).
|
||||||
|
|
||||||
This product bundles SDL 2.0.4, which is available under a
|
This product bundles SDL 2.0.5, which is available under a
|
||||||
"zlib" (BSD-style) license. For details, see [project/lib/sdl/](project/lib).
|
"zlib" (BSD-style) license. For details, see [project/lib/sdl/](project/lib).
|
||||||
|
|
||||||
This product bundles libvorbis 1.3.3, which is available under a
|
This product bundles libvorbis 1.3.3, which is available under a
|
||||||
|
|||||||
Submodule project/lib/sdl updated: 50975d3425...fa8fd53e14
@@ -17,7 +17,7 @@ import android.view.inputmethod.BaseInputConnection;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AbsoluteLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -61,6 +61,7 @@ public class SDLActivity extends Activity {
|
|||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
protected static AudioTrack mAudioTrack;
|
protected static AudioTrack mAudioTrack;
|
||||||
|
protected static AudioRecord mAudioRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL before loading the native shared libraries.
|
* This method is called by SDL before loading the native shared libraries.
|
||||||
@@ -110,6 +111,7 @@ public class SDLActivity extends Activity {
|
|||||||
mJoystickHandler = null;
|
mJoystickHandler = null;
|
||||||
mSDLThread = null;
|
mSDLThread = null;
|
||||||
mAudioTrack = null;
|
mAudioTrack = null;
|
||||||
|
mAudioRecord = null;
|
||||||
mExitCalledFromJava = false;
|
mExitCalledFromJava = false;
|
||||||
mBrokenLibraries = false;
|
mBrokenLibraries = false;
|
||||||
mIsPaused = false;
|
mIsPaused = false;
|
||||||
@@ -175,7 +177,7 @@ public class SDLActivity extends Activity {
|
|||||||
mJoystickHandler = new SDLJoystickHandler();
|
mJoystickHandler = new SDLJoystickHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
mLayout = new AbsoluteLayout(this);
|
mLayout = new RelativeLayout(this);
|
||||||
mLayout.addView(mSurface);
|
mLayout.addView(mSurface);
|
||||||
|
|
||||||
setContentView(mLayout);
|
setContentView(mLayout);
|
||||||
@@ -371,7 +373,10 @@ public class SDLActivity extends Activity {
|
|||||||
break;
|
break;
|
||||||
case COMMAND_TEXTEDIT_HIDE:
|
case COMMAND_TEXTEDIT_HIDE:
|
||||||
if (mTextEdit != null) {
|
if (mTextEdit != null) {
|
||||||
mTextEdit.setVisibility(View.GONE);
|
// Note: On some devices setting view to GONE creates a flicker in landscape.
|
||||||
|
// Setting the View's sizes to 0 is similar to GONE but without the flicker.
|
||||||
|
// The sizes will be set to useful values when the keyboard is shown again.
|
||||||
|
mTextEdit.setLayoutParams(new RelativeLayout.LayoutParams(0, 0));
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
|
||||||
@@ -508,8 +513,9 @@ public class SDLActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING);
|
||||||
w, h + HEIGHT_PADDING, x, y);
|
params.leftMargin = x;
|
||||||
|
params.topMargin = y;
|
||||||
|
|
||||||
if (mTextEdit == null) {
|
if (mTextEdit == null) {
|
||||||
mTextEdit = new DummyEdit(getContext());
|
mTextEdit = new DummyEdit(getContext());
|
||||||
@@ -547,7 +553,7 @@ public class SDLActivity extends Activity {
|
|||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static int audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
|
public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
|
||||||
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
|
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
|
||||||
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
|
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
|
||||||
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
|
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
|
||||||
@@ -626,13 +632,72 @@ public class SDLActivity extends Activity {
|
|||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static void audioQuit() {
|
public static int captureOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
|
||||||
|
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
|
||||||
|
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
|
||||||
|
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
|
||||||
|
|
||||||
|
Log.v(TAG, "SDL capture: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||||
|
|
||||||
|
// Let the user pick a larger buffer if they really want -- but ye
|
||||||
|
// gods they probably shouldn't, the minimums are horrifyingly high
|
||||||
|
// latency already
|
||||||
|
desiredFrames = Math.max(desiredFrames, (AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
|
||||||
|
|
||||||
|
if (mAudioRecord == null) {
|
||||||
|
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
|
||||||
|
channelConfig, audioFormat, desiredFrames * frameSize);
|
||||||
|
|
||||||
|
// see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
|
||||||
|
if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
|
||||||
|
Log.e(TAG, "Failed during initialization of AudioRecord");
|
||||||
|
mAudioRecord.release();
|
||||||
|
mAudioRecord = null;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAudioRecord.startRecording();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.v(TAG, "SDL capture: got " + ((mAudioRecord.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioRecord.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called by SDL using JNI. */
|
||||||
|
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
|
||||||
|
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
|
||||||
|
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||||
|
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called by SDL using JNI. */
|
||||||
|
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
|
||||||
|
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
|
||||||
|
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||||
|
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** This method is called by SDL using JNI. */
|
||||||
|
public static void audioClose() {
|
||||||
if (mAudioTrack != null) {
|
if (mAudioTrack != null) {
|
||||||
mAudioTrack.stop();
|
mAudioTrack.stop();
|
||||||
|
mAudioTrack.release();
|
||||||
mAudioTrack = null;
|
mAudioTrack = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This method is called by SDL using JNI. */
|
||||||
|
public static void captureClose() {
|
||||||
|
if (mAudioRecord != null) {
|
||||||
|
mAudioRecord.stop();
|
||||||
|
mAudioRecord.release();
|
||||||
|
mAudioRecord = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -666,6 +731,21 @@ public class SDLActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a given device is considered a possible SDL joystick
|
||||||
|
public static boolean isDeviceSDLJoystick(int deviceId) {
|
||||||
|
InputDevice device = InputDevice.getDevice(deviceId);
|
||||||
|
// We cannot use InputDevice.isVirtual before API 16, so let's accept
|
||||||
|
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
|
||||||
|
if ((device == null) || (deviceId < 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int sources = device.getSources();
|
||||||
|
return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) ||
|
||||||
|
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
|
||||||
|
((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// APK expansion files support
|
// APK expansion files support
|
||||||
|
|
||||||
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
|
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
|
||||||
@@ -674,15 +754,6 @@ public class SDLActivity extends Activity {
|
|||||||
/** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */
|
/** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */
|
||||||
private Method expansionFileMethod;
|
private Method expansionFileMethod;
|
||||||
|
|
||||||
/**
|
|
||||||
* This method was called by SDL using JNI.
|
|
||||||
* @deprecated because of an incorrect name
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public InputStream openAPKExtensionInputStream(String fileName) throws IOException {
|
|
||||||
return openAPKExpansionInputStream(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
* @return an InputStream on success or null if no expansion file was used.
|
* @return an InputStream on success or null if no expansion file was used.
|
||||||
@@ -1172,11 +1243,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
// Dispatch the different events depending on where they come from
|
// Dispatch the different events depending on where they come from
|
||||||
// Some SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
|
// Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
|
||||||
// So, we try to process them as DPAD or GAMEPAD events first, if that fails we try them as KEYBOARD
|
// So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD
|
||||||
|
//
|
||||||
if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
|
// Furthermore, it's possible a game controller has SOURCE_KEYBOARD and
|
||||||
(event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {
|
// SOURCE_JOYSTICK, while its key events arrive from the keyboard source
|
||||||
|
// So, retrieve the device itself and check all of its sources
|
||||||
|
if (SDLActivity.isDeviceSDLJoystick(event.getDeviceId())) {
|
||||||
|
// Note that we process events with specific key codes here
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
if (SDLActivity.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
|
if (SDLActivity.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
|
||||||
return true;
|
return true;
|
||||||
@@ -1188,7 +1262,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
|
if ((event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
//Log.v("SDL", "key down: " + keyCode);
|
//Log.v("SDL", "key down: " + keyCode);
|
||||||
SDLActivity.onNativeKeyDown(keyCode);
|
SDLActivity.onNativeKeyDown(keyCode);
|
||||||
@@ -1201,6 +1275,20 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) {
|
||||||
|
// on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
|
||||||
|
// they are ignored here because sending them as mouse input to SDL is messy
|
||||||
|
if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case KeyEvent.ACTION_DOWN:
|
||||||
|
case KeyEvent.ACTION_UP:
|
||||||
|
// mark the event as handled or it will be handled by system
|
||||||
|
// handling KEYCODE_BACK by system will call onBackPressed()
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,7 +1307,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
// !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
|
// !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
|
||||||
if (event.getSource() == InputDevice.SOURCE_MOUSE && SDLActivity.mSeparateMouseAndTouch) {
|
if (event.getSource() == InputDevice.SOURCE_MOUSE && SDLActivity.mSeparateMouseAndTouch) {
|
||||||
if (Build.VERSION.SDK_INT < 14) {
|
if (Build.VERSION.SDK_INT < 14) {
|
||||||
mouseButton = 1; // For Android==12 all mouse buttons are the left button
|
mouseButton = 1; // all mouse buttons are the left button
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
|
mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
|
||||||
@@ -1338,7 +1426,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
|
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
|
||||||
y / SensorManager.GRAVITY_EARTH,
|
y / SensorManager.GRAVITY_EARTH,
|
||||||
event.values[2] / SensorManager.GRAVITY_EARTH - 1);
|
event.values[2] / SensorManager.GRAVITY_EARTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1365,7 +1453,7 @@ class DummyEdit extends View implements View.OnKeyListener {
|
|||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
|
||||||
// This handles the hardware keyboard input
|
// This handles the hardware keyboard input
|
||||||
if (event.isPrintingKey()) {
|
if (event.isPrintingKey() || keyCode == KeyEvent.KEYCODE_SPACE) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1);
|
ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1);
|
||||||
}
|
}
|
||||||
@@ -1389,7 +1477,7 @@ class DummyEdit extends View implements View.OnKeyListener {
|
|||||||
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
|
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
|
||||||
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
|
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
|
||||||
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
|
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
|
||||||
// FIXME: A more effective solution would be to change our Layout from AbsoluteLayout to Relative or Linear
|
// FIXME: A more effective solution would be to assume our Layout to be RelativeLayout or LinearLayout
|
||||||
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
||||||
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
|
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
|
||||||
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
@@ -1428,7 +1516,7 @@ class SDLInputConnection extends BaseInputConnection {
|
|||||||
*/
|
*/
|
||||||
int keyCode = event.getKeyCode();
|
int keyCode = event.getKeyCode();
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
if (event.isPrintingKey()) {
|
if (event.isPrintingKey() || keyCode == KeyEvent.KEYCODE_SPACE) {
|
||||||
commitText(String.valueOf((char) event.getUnicodeChar()), 1);
|
commitText(String.valueOf((char) event.getUnicodeChar()), 1);
|
||||||
}
|
}
|
||||||
SDLActivity.onNativeKeyDown(keyCode);
|
SDLActivity.onNativeKeyDown(keyCode);
|
||||||
@@ -1529,13 +1617,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
|
|||||||
if (joystick == null) {
|
if (joystick == null) {
|
||||||
joystick = new SDLJoystick();
|
joystick = new SDLJoystick();
|
||||||
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
|
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
|
||||||
|
if (SDLActivity.isDeviceSDLJoystick(deviceIds[i])) {
|
||||||
if (
|
|
||||||
(joystickDevice.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0
|
|
||||||
||
|
|
||||||
(joystickDevice.getSources() & InputDevice.SOURCE_CLASS_BUTTON) != 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
joystick.device_id = deviceIds[i];
|
joystick.device_id = deviceIds[i];
|
||||||
joystick.name = joystickDevice.getName();
|
joystick.name = joystickDevice.getName();
|
||||||
joystick.axes = new ArrayList<InputDevice.MotionRange>();
|
joystick.axes = new ArrayList<InputDevice.MotionRange>();
|
||||||
@@ -1544,7 +1626,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
|
|||||||
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
|
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
|
||||||
Collections.sort(ranges, new RangeComparator());
|
Collections.sort(ranges, new RangeComparator());
|
||||||
for (InputDevice.MotionRange range : ranges ) {
|
for (InputDevice.MotionRange range : ranges ) {
|
||||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ) {
|
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||||
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
|
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
|
||||||
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
||||||
joystick.hats.add(range);
|
joystick.hats.add(range);
|
||||||
@@ -1598,7 +1680,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMotionEvent(MotionEvent event) {
|
public boolean handleMotionEvent(MotionEvent event) {
|
||||||
if ( (event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
||||||
int actionPointerIndex = event.getActionIndex();
|
int actionPointerIndex = event.getActionIndex();
|
||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
switch(action) {
|
switch(action) {
|
||||||
@@ -1637,8 +1719,7 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
|||||||
case InputDevice.SOURCE_JOYSTICK:
|
case InputDevice.SOURCE_JOYSTICK:
|
||||||
case InputDevice.SOURCE_GAMEPAD:
|
case InputDevice.SOURCE_GAMEPAD:
|
||||||
case InputDevice.SOURCE_DPAD:
|
case InputDevice.SOURCE_DPAD:
|
||||||
SDLActivity.handleJoystickMotionEvent(event);
|
return SDLActivity.handleJoystickMotionEvent(event);
|
||||||
return true;
|
|
||||||
|
|
||||||
case InputDevice.SOURCE_MOUSE:
|
case InputDevice.SOURCE_MOUSE:
|
||||||
action = event.getActionMasked();
|
action = event.getActionMasked();
|
||||||
|
|||||||
Reference in New Issue
Block a user