Fix another crash on Android 2.2. Handle evdev input.

This commit is contained in:
a1batross 2016-12-09 23:40:09 +03:00
parent f89aa8b3d7
commit d0ce1778a0
5 changed files with 29 additions and 7 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.celest.xash3d.cs16client" package="in.celest.xash3d.cs16client"
android:versionCode="384" android:versionCode="406"
android:versionName="1.3"> android:versionName="1.31">
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="23"/> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="23"/>
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:debuggable="false" android:debuggable="false"

View File

@ -147,7 +147,6 @@ public class LauncherActivity extends Activity {
editor.putBoolean("zbots", mEnableZBot.isChecked()); editor.putBoolean("zbots", mEnableZBot.isChecked());
editor.putBoolean("yapbs", mEnableYaPB.isChecked()); editor.putBoolean("yapbs", mEnableYaPB.isChecked());
editor.commit(); editor.commit();
editor.apply();
extractPAK(this, false); extractPAK(this, false);
@ -277,7 +276,6 @@ public class LauncherActivity extends Activity {
SharedPreferences.Editor editor = mPref.edit(); SharedPreferences.Editor editor = mPref.edit();
editor.putBoolean("dev", true); editor.putBoolean("dev", true);
editor.commit(); editor.commit();
editor.apply();
mDev = true; mDev = true;

View File

@ -136,12 +136,22 @@ int __MsgFunc_ServerName( const char *name, int size, void *buf )
return 1; return 1;
} }
#ifdef __ANDROID__
void __CmdFunc_MouseSucks( void ) { }
#endif
// This is called every time the DLL is loaded // This is called every time the DLL is loaded
void CHud :: Init( void ) void CHud :: Init( void )
{ {
HOOK_COMMAND( "special", InputCommandSpecial ); HOOK_COMMAND( "special", InputCommandSpecial );
//HOOK_COMMAND( "gunsmoke", GunSmoke ); //HOOK_COMMAND( "gunsmoke", GunSmoke );
#ifdef __ANDROID__
HOOK_COMMAND( "evdev_mouseopen", MouseSucks );
HOOK_COMMAND( "evdev_mouseclose", MouseSucks );
#endif
HOOK_MESSAGE( Logo ); HOOK_MESSAGE( Logo );
HOOK_MESSAGE( ResetHUD ); HOOK_MESSAGE( ResetHUD );
HOOK_MESSAGE( GameMode ); HOOK_MESSAGE( GameMode );
@ -302,10 +312,14 @@ void CHud :: VidInit( void )
// REMOVE LATER // REMOVE LATER
float currentScale = CVAR_GET_FLOAT("hud_scale"); float currentScale = CVAR_GET_FLOAT("hud_scale");
float invalidScale = (float)min( TrueWidth, TrueHeight) / 640.0f; float invalidScale = (float)min( TrueWidth, TrueHeight ) / 640.0f;
// REMOVE LATER // REMOVE LATER
if( currentScale > maxScale || currentScale == invalidScale ) if( currentScale > maxScale ||
( currentScale == invalidScale &&
currentScale != 1.0f &&
currentScale != 0.0f &&
invalidScale < 1.0f ) )
{ {
gEngfuncs.Cvar_SetValue( "hud_scale", maxScale ); gEngfuncs.Cvar_SetValue( "hud_scale", maxScale );
gEngfuncs.Con_Printf("^3Maximum scale factor reached. Reset: %f\n", maxScale ); gEngfuncs.Con_Printf("^3Maximum scale factor reached. Reset: %f\n", maxScale );

View File

@ -12,6 +12,7 @@
cvar_t *cl_laddermode; cvar_t *cl_laddermode;
cvar_t *sensitivity; cvar_t *sensitivity;
cvar_t *in_joystick; cvar_t *in_joystick;
cvar_t *evdev_grab;
float ac_forwardmove; float ac_forwardmove;
@ -126,9 +127,12 @@ void IN_ClientMoveEvent( float forwardmove, float sidemove )
void IN_ClientLookEvent( float relyaw, float relpitch ) void IN_ClientLookEvent( float relyaw, float relpitch )
{ {
if( ( evdev_grab && evdev_grab->value != 0.0f ) || bMouseInUse ) return;
rel_yaw += relyaw; rel_yaw += relyaw;
rel_pitch += relpitch; rel_pitch += relpitch;
} }
// Rotate camera and add move values to usercmd // Rotate camera and add move values to usercmd
void IN_Move( float frametime, usercmd_t *cmd ) void IN_Move( float frametime, usercmd_t *cmd )
{ {
@ -278,6 +282,8 @@ void IN_Init( void )
sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity", "3", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity", "3", FCVAR_ARCHIVE );
in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick", "0", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick", "0", FCVAR_ARCHIVE );
cl_laddermode = gEngfuncs.pfnRegisterVariable ( "cl_laddermode", "2", FCVAR_ARCHIVE ); cl_laddermode = gEngfuncs.pfnRegisterVariable ( "cl_laddermode", "2", FCVAR_ARCHIVE );
evdev_grab = gEngfuncs.pfnGetCvarPointer("evdev_grab");
#ifdef __ANDROID__ #ifdef __ANDROID__
gEngfuncs.Cvar_SetValue("m_yaw", -1); gEngfuncs.Cvar_SetValue("m_yaw", -1);

View File

@ -1717,6 +1717,10 @@ void UI_Init( void )
Cmd_AddCommand( "menu_playdemo", UI_PlayDemo_Menu ); Cmd_AddCommand( "menu_playdemo", UI_PlayDemo_Menu );
Cmd_AddCommand( "menu_recdemo", UI_RecDemo_Menu ); Cmd_AddCommand( "menu_recdemo", UI_RecDemo_Menu );
#ifdef __ANDROID__
Cmd_RemoveCommand( "evdev_mouseopen" );
Cmd_RemoveCommand( "evdev_mouseclose" );
#endif
CHECK_MAP_LIST( TRUE ); CHECK_MAP_LIST( TRUE );