Fix compatibility again

This commit is contained in:
mittorn 2017-03-30 23:32:27 +00:00
parent 58cd129055
commit 8fcb6ca128

View file

@ -403,10 +403,12 @@ public class XashActivity extends Activity {
SurfaceHolder holder = mSurface.getHolder(); SurfaceHolder holder = mSurface.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
if( sdk < 12 ) if( sdk >= 14 )
handler = new JoystickHandler(); handler = new JoystickHandler_v14();
else else if( sdk >= 12 )
handler = new JoystickHandler_v12(); handler = new JoystickHandler_v12();
else
handler = new JoystickHandler();
handler.init(); handler.init();
mPixelFormat = mPref.getInt("pixelformat", 0); mPixelFormat = mPref.getInt("pixelformat", 0);
@ -1272,13 +1274,14 @@ class EngineTouchListener_v5 implements View.OnTouchListener{
lx = event.getX(); lx = event.getX();
ly = event.getY(); ly = event.getY();
boolean down = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN; boolean down = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN;
if( down && (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0 ) int buttonState = XashActivity.handler.getButtonState( event );
if( down && (buttonState & MotionEvent.BUTTON_SECONDARY) != 0 )
{ {
XashActivity.nativeKey( 1,-243 ); XashActivity.nativeKey( 1,-243 );
secondarypressed = true; secondarypressed = true;
return true; return true;
} }
else if( !down && secondarypressed && (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) == 0 ) else if( !down && secondarypressed && (buttonState & MotionEvent.BUTTON_SECONDARY) == 0 )
{ {
secondarypressed = false; secondarypressed = false;
XashActivity.nativeKey( 0,-243 ); XashActivity.nativeKey( 0,-243 );
@ -1433,6 +1436,10 @@ class JoystickHandler
public void showMouse( boolean show ) public void showMouse( boolean show )
{ {
} }
public int getButtonState( MotionEvent event)
{
return 0;
}
} }
class Wrap_NVMouseExtensions{ class Wrap_NVMouseExtensions{
@ -1628,3 +1635,11 @@ class JoystickHandler_v12 extends JoystickHandler
Wrap_NVMouseExtensions.setCursorVisibility( show ); Wrap_NVMouseExtensions.setCursorVisibility( show );
} }
} }
class JoystickHandler_v14 extends JoystickHandler_v12
{
public int getButtonState( MotionEvent event )
{
return event.getButtonState();
}
};