From 32aa9a9f546d80cafe4ddee63885875f931e7738 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 21 Apr 2018 00:13:20 +0300 Subject: [PATCH] Implement Mobility API support. Add missing IN_TouchShutdown and Joy_Shutdown calls. Don't save video and opengl configs if engine crashed. --- engine/client/cl_game.c | 2 + engine/client/cl_main.c | 12 ++- engine/client/cl_mobile.c | 149 ++++++++++++++++++++++++++++++++++++++ engine/client/client.h | 6 ++ 4 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 engine/client/cl_mobile.c diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 90fca13b..74cdeb73 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -4215,6 +4215,8 @@ qboolean CL_LoadProgs( const char *name ) if( !R_InitRenderAPI()) // Xash3D extension Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" ); + if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface + Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" ); CL_InitEdicts (); // initailize local player and world CL_InitClientMove(); // initialize pm_shared diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 6cc538e5..3e72a03c 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -2802,11 +2802,17 @@ void CL_Shutdown( void ) Con_Printf( "CL_Shutdown()\n" ); - Host_WriteOpenGLConfig (); - Host_WriteVideoConfig (); + if( !host.crashed ) + { + Host_WriteOpenGLConfig (); + Host_WriteVideoConfig (); + } - CL_CloseDemoHeader(); + IN_TouchShutdown (); + Joy_Shutdown (); + CL_CloseDemoHeader (); IN_Shutdown (); + Mobile_Shutdown (); SCR_Shutdown (); CL_UnloadProgs (); diff --git a/engine/client/cl_mobile.c b/engine/client/cl_mobile.c new file mode 100644 index 00000000..d3dd0286 --- /dev/null +++ b/engine/client/cl_mobile.c @@ -0,0 +1,149 @@ +/* +cl_mobile.c - common mobile interface +Copyright (C) 2015 a1batross + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +*/ + +#ifndef XASH_DEDICATED + +#include "common.h" +#include "client.h" +#include "mobility_int.h" +#include "library.h" +#include "gl_local.h" +#include "input.h" + +#if defined(__ANDROID__) +#include "platform/android/android-main.h" +#endif + +mobile_engfuncs_t *gMobileEngfuncs; + +convar_t *vibration_length; +convar_t *vibration_enable; + +static void pfnVibrate( float life, char flags ) +{ + if( !vibration_enable->value ) + return; + + if( life < 0.0f ) + { + MsgDev( D_WARN, "Negative vibrate time: %f\n", life ); + return; + } + + //MsgDev( D_NOTE, "Vibrate: %f %d\n", life, flags ); + + // here goes platform-specific backends +#ifdef __ANDROID__ + Android_Vibrate( life * vibration_length->value, flags ); +#endif +} + +static void Vibrate_f() +{ + if( Cmd_Argc() != 2 ) + { + Msg( "Usage: vibrate