Changed accelerometer/multitouch/joystick input once again, removed touch event ratelimiting for Froyo and newer.
This commit is contained in:
@@ -44,7 +44,6 @@ class AccelerometerReader implements SensorEventListener
|
||||
|
||||
public AccelerometerReader(Activity context)
|
||||
{
|
||||
System.out.println("libSDL: accelerometer start required: " + String.valueOf(Globals.UseAccelerometerAsArrowKeys));
|
||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
start();
|
||||
}
|
||||
@@ -53,14 +52,13 @@ class AccelerometerReader implements SensorEventListener
|
||||
{
|
||||
if( _manager != null )
|
||||
{
|
||||
System.out.println("libSDL: stopping accelerometer");
|
||||
_manager.unregisterListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start()
|
||||
{
|
||||
if( Globals.UseAccelerometerAsArrowKeys )
|
||||
if( Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer )
|
||||
{
|
||||
if( _manager != null )
|
||||
{
|
||||
@@ -97,5 +95,3 @@ class AccelerometerReader implements SensorEventListener
|
||||
private native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||
private native void nativeOrientation(float accX, float accY, float accZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class Globals
|
||||
public static boolean AppNeedsArrowKeys = true;
|
||||
public static boolean AppNeedsTextInput = true;
|
||||
public static boolean AppUsesJoystick = false;
|
||||
public static boolean AppHandlesJoystickSensitivity = false;
|
||||
public static boolean AppUsesAccelerometer = false;
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
public static boolean NonBlockingSwapBuffers = false;
|
||||
public static boolean ResetSdlConfigForThisVersion = false;
|
||||
|
||||
@@ -240,7 +240,7 @@ public class MainActivity extends Activity
|
||||
return;
|
||||
System.out.println("libSDL: Initializing video and SDL application");
|
||||
sdlInited = true;
|
||||
if(Globals.UseAccelerometerAsArrowKeys)
|
||||
if(Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer)
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
_videoLayout.removeView(_layout);
|
||||
|
||||
@@ -845,17 +845,10 @@ class Settings
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.UseAccelerometerAsArrowKeys || ! Globals.AppHandlesJoystickSensitivity;
|
||||
return Globals.UseAccelerometerAsArrowKeys;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
|
||||
{
|
||||
Globals.AccelerometerSensitivity = 2; // Slow, full range
|
||||
showAccelerometerCenterConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_slow) };
|
||||
@@ -885,13 +878,6 @@ class Settings
|
||||
}
|
||||
static void showAccelerometerCenterConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
|
||||
{
|
||||
Globals.AccelerometerCenterPos = 2; // Fixed horizontal center position
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_floating),
|
||||
p.getResources().getString(R.string.accel_fixed_start),
|
||||
p.getResources().getString(R.string.accel_fixed_horiz) };
|
||||
@@ -2436,6 +2422,8 @@ class Settings
|
||||
Globals.ShowMouseCursor ? 1 : 0 );
|
||||
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
|
||||
nativeSetJoystickUsed();
|
||||
if( Globals.AppUsesAccelerometer )
|
||||
nativeSetAccelerometerUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
nativeSetAccelerometerSettings(Globals.AccelerometerSensitivity, Globals.AccelerometerCenterPos);
|
||||
@@ -2592,6 +2580,7 @@ class Settings
|
||||
int relativeMovement, int relativeMovementSpeed,
|
||||
int relativeMovementAccel, int showMouseCursor);
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetAccelerometerUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetSmoothVideo();
|
||||
|
||||
@@ -502,9 +502,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
{
|
||||
if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers )
|
||||
{
|
||||
synchronized(this)
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
this.notify();
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -517,9 +520,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
}
|
||||
|
||||
// Unblock event processing thread only after we've finished rendering
|
||||
synchronized(this)
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
this.notify();
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -662,10 +668,11 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
private boolean mGlContextLost = false;
|
||||
public boolean mGlSurfaceCreated = false;
|
||||
public boolean mPaused = false;
|
||||
//public boolean mPutToBackground = false;
|
||||
private boolean mFirstTimeStart = true;
|
||||
public int mWidth = 0;
|
||||
public int mHeight = 0;
|
||||
|
||||
public static final boolean mRatelimitTouchEvents = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
@@ -682,7 +689,10 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
touchInput.process(event);
|
||||
limitEventRate(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -690,7 +700,10 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public boolean onGenericMotionEvent (final MotionEvent event)
|
||||
{
|
||||
touchInput.processGenericEvent(event);
|
||||
limitEventRate(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user