Fix gamepads, move gamepad motion event source check before mouse
This commit is contained in:
parent
08d2309986
commit
b48d965111
1 changed files with 20 additions and 12 deletions
|
@ -27,7 +27,7 @@ import android.view.inputmethod.*;
|
||||||
|
|
||||||
import java.lang.*;
|
import java.lang.*;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
import in.celest.xash3d.hl.R;
|
import in.celest.xash3d.hl.R;
|
||||||
|
@ -219,7 +219,9 @@ public class XashActivity extends Activity {
|
||||||
Log.v( TAG, "onResume()" );
|
Log.v( TAG, "onResume()" );
|
||||||
|
|
||||||
if( mEngineReady )
|
if( mEngineReady )
|
||||||
|
{
|
||||||
nativeOnResume();
|
nativeOnResume();
|
||||||
|
}
|
||||||
|
|
||||||
mEnginePaused = false;
|
mEnginePaused = false;
|
||||||
|
|
||||||
|
@ -667,9 +669,9 @@ public class XashActivity extends Activity {
|
||||||
|
|
||||||
final int source = XashActivity.handler.getSource( event );
|
final int source = XashActivity.handler.getSource( event );
|
||||||
final int action = event.getAction();
|
final int action = event.getAction();
|
||||||
final boolean isGamePad = ( source & InputDevice.SOURCE_GAMEPAD ) == InputDevice.SOURCE_GAMEPAD;
|
final boolean isGamePad = FWGSLib.FExactBitSet( source, InputDevice.SOURCE_GAMEPAD );
|
||||||
final boolean isJoystick = ( source & InputDevice.SOURCE_CLASS_JOYSTICK ) == InputDevice.SOURCE_CLASS_JOYSTICK;
|
final boolean isJoystick = FWGSLib.FExactBitSet( source, InputDevice.SOURCE_CLASS_JOYSTICK );
|
||||||
final boolean isDPad = ( source & InputDevice.SOURCE_DPAD ) == InputDevice.SOURCE_DPAD;
|
final boolean isDPad = FWGSLib.FExactBitSet( source, InputDevice.SOURCE_DPAD );
|
||||||
|
|
||||||
if( isDPad )
|
if( isDPad )
|
||||||
{
|
{
|
||||||
|
@ -744,7 +746,8 @@ public class XashActivity extends Activity {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// must be never reached too
|
// must be never reached too, but sometimes happens(for DPad, for example)
|
||||||
|
Log.d( TAG, "Unhandled GamePad button: " + XashActivity.handler.keyCodeToString( keyCode ) + ". Passed as simple key.");
|
||||||
return performEngineKeyEvent( action, keyCode, event );
|
return performEngineKeyEvent( action, keyCode, event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1992,14 +1995,18 @@ class JoystickHandler_v12 extends JoystickHandler
|
||||||
public boolean onGenericMotion( View view, MotionEvent event )
|
public boolean onGenericMotion( View view, MotionEvent event )
|
||||||
{
|
{
|
||||||
final int source = XashActivity.handler.getSource( event );
|
final int source = XashActivity.handler.getSource( event );
|
||||||
final int axisDevices = InputDevice.SOURCE_CLASS_JOYSTICK | InputDevice.SOURCE_GAMEPAD;
|
|
||||||
|
if( FWGSLib.FExactBitSet( source, InputDevice.SOURCE_GAMEPAD ) ||
|
||||||
|
FWGSLib.FExactBitSet( source, InputDevice.SOURCE_CLASS_JOYSTICK ) )
|
||||||
|
return XashActivity.handler.handleAxis( event );
|
||||||
|
|
||||||
if( mNVMouseExtensions )
|
if( mNVMouseExtensions )
|
||||||
{
|
{
|
||||||
float x = event.getAxisValue( Wrap_NVMouseExtensions.getAxisRelativeX(), 0 );
|
float x = event.getAxisValue( Wrap_NVMouseExtensions.getAxisRelativeX(), 0 );
|
||||||
float y = event.getAxisValue( Wrap_NVMouseExtensions.getAxisRelativeY(), 0 );
|
float y = event.getAxisValue( Wrap_NVMouseExtensions.getAxisRelativeY(), 0 );
|
||||||
if( ( source & InputDevice.SOURCE_MOUSE) != InputDevice.SOURCE_MOUSE && (x != 0 || y != 0 ))
|
if( !FWGSLib.FExactBitSet( source, InputDevice.SOURCE_MOUSE) && (x != 0 || y != 0 ))
|
||||||
mouseId = event.getDeviceId();
|
mouseId = event.getDeviceId();
|
||||||
|
|
||||||
switch( event.getAction() )
|
switch( event.getAction() )
|
||||||
{
|
{
|
||||||
case MotionEvent.ACTION_SCROLL:
|
case MotionEvent.ACTION_SCROLL:
|
||||||
|
@ -2022,9 +2029,6 @@ class JoystickHandler_v12 extends JoystickHandler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( source & axisDevices ) != 0 )
|
|
||||||
return XashActivity.handler.handleAxis( event );
|
|
||||||
|
|
||||||
// TODO: Add it someday
|
// TODO: Add it someday
|
||||||
// else if( (event.getSource() & InputDevice.SOURCE_CLASS_TRACKBALL) == InputDevice.SOURCE_CLASS_TRACKBALL )
|
// else if( (event.getSource() & InputDevice.SOURCE_CLASS_TRACKBALL) == InputDevice.SOURCE_CLASS_TRACKBALL )
|
||||||
// return XashActivity.handleBall( event );
|
// return XashActivity.handleBall( event );
|
||||||
|
@ -2032,11 +2036,14 @@ class JoystickHandler_v12 extends JoystickHandler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasVibrator()
|
public boolean hasVibrator()
|
||||||
{
|
{
|
||||||
return XashActivity.mVibrator.hasVibrator();
|
return XashActivity.mVibrator.hasVibrator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showMouse( boolean show )
|
public void showMouse( boolean show )
|
||||||
{
|
{
|
||||||
if( mNVMouseExtensions )
|
if( mNVMouseExtensions )
|
||||||
|
@ -2046,6 +2053,7 @@ class JoystickHandler_v12 extends JoystickHandler
|
||||||
|
|
||||||
class JoystickHandler_v14 extends JoystickHandler_v12
|
class JoystickHandler_v14 extends JoystickHandler_v12
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public int getButtonState( MotionEvent event )
|
public int getButtonState( MotionEvent event )
|
||||||
{
|
{
|
||||||
return event.getButtonState();
|
return event.getButtonState();
|
||||||
|
|
Loading…
Add table
Reference in a new issue