diff --git a/3rdparty/mainui b/3rdparty/mainui index 7ba2010e..0f31c646 160000 --- a/3rdparty/mainui +++ b/3rdparty/mainui @@ -1 +1 @@ -Subproject commit 7ba2010e8dffa60ca1bc166db005c13c7b75aeb9 +Subproject commit 0f31c646d623d75b46a9b16f887ac29a167319a3 diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index de8f46f3..21c70337 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -914,11 +914,7 @@ void CL_ParseServerData( sizebuf_t *msg ) // set the background state if( cls.demoplayback && ( cls.demonum != -1 )) - { - // re-init mouse - host.mouse_visible = false; cl.background = true; - } else cl.background = background; if( cl.background ) // tell the game parts about background state @@ -2502,11 +2498,7 @@ void CL_ParseLegacyServerData( sizebuf_t *msg ) // set the background state if( cls.demoplayback && ( cls.demonum != -1 )) - { - // re-init mouse - host.mouse_visible = false; cl.background = true; - } else cl.background = background; if( cl.background ) // tell the game parts about background state diff --git a/engine/client/cl_qparse.c b/engine/client/cl_qparse.c index 76865362..be6752a0 100644 --- a/engine/client/cl_qparse.c +++ b/engine/client/cl_qparse.c @@ -237,10 +237,6 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) } else Cvar_Reset( "r_decals" ); - // re-init mouse - if( cl.background ) - host.mouse_visible = false; - if( cl.background ) // tell the game parts about background state Cvar_FullSet( "cl_background", "1", FCVAR_READ_ONLY ); else Cvar_FullSet( "cl_background", "0", FCVAR_READ_ONLY ); diff --git a/engine/client/in_touch.c b/engine/client/in_touch.c index 81d58e9a..f8136e6d 100644 --- a/engine/client/in_touch.c +++ b/engine/client/in_touch.c @@ -469,8 +469,8 @@ static touch_button_t *Touch_FindFirst( touchbuttonlist_t *list, const char *nam void Touch_SetClientOnly( byte state ) { + // TODO: fix clash with vgui cursors touch.clientonly = state; - host.mouse_visible = state; touch.move_finger = touch.look_finger = -1; touch.forward = touch.side = 0; @@ -2070,6 +2070,11 @@ void Touch_KeyEvent( int key, int down ) ly = y; } +qboolean Touch_WantVisibleCursor( void ) +{ + return ( touch_enable.value && touch_emulate.value ) || touch.clientonly; +} + void Touch_Shutdown( void ) { if( !touch.initialized ) diff --git a/engine/client/input.c b/engine/client/input.c index 43647e57..68d6e2aa 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -47,8 +47,6 @@ convar_t *cl_backspeed; convar_t *look_filter; convar_t *m_rawinput; -static qboolean s_bRawInput, s_bMouseGrab; - /* ================ IN_CollectInputDevices @@ -173,19 +171,16 @@ Called when key_dest is changed */ void IN_ToggleClientMouse( int newstate, int oldstate ) { - if( newstate == oldstate ) return; + if( newstate == oldstate ) + return; - if( oldstate == key_game ) - { - IN_DeactivateMouse(); - } - else if( newstate == key_game ) + // since SetCursorType controls cursor visibility + // execute it first, and then check mouse grab state + if(( newstate == key_menu || newstate == key_console || newstate == key_message ) && + ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( ))) { - IN_ActivateMouse(); - } + Platform_SetCursorType( dc_arrow ); - if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( ))) - { #if XASH_ANDROID Android_ShowMouse( true ); #endif @@ -195,6 +190,8 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) } else { + Platform_SetCursorType( dc_none ); + #if XASH_ANDROID Android_ShowMouse( false ); #endif @@ -202,10 +199,21 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) Evdev_SetGrab( true ); #endif } + + if( oldstate == key_game ) + { + IN_DeactivateMouse(); + } + else if( newstate == key_game ) + { + IN_ActivateMouse(); + } } void IN_CheckMouseState( qboolean active ) { + static qboolean s_bRawInput, s_bMouseGrab; + #if XASH_WIN32 qboolean useRawInput = CVAR_TO_BOOL( m_rawinput ) && clgame.client_dll_uses_sdl || clgame.dllFuncs.pfnLookEvent; #else @@ -313,15 +321,6 @@ void IN_MouseMove( void ) if( !in_mouseinitialized ) return; - if( FBitSet( touch_emulate.flags, FCVAR_CHANGED )) - { - // FIXME: do not hide cursor if it was requested by GUI - if( !touch_emulate.value ) - Platform_SetCursorType( dc_none ); - - ClearBits( touch_emulate.flags, FCVAR_CHANGED ); - } - if( touch_emulate.value ) { // touch emulation overrides all input @@ -334,11 +333,6 @@ void IN_MouseMove( void ) VGui_MouseMove( x, y ); - // HACKHACK: show cursor in UI, as mainui doesn't call - // platform-dependent SetCursor anymore - if( UI_IsVisible( )) - Platform_SetCursorType( dc_arrow ); - // if the menu is visible, move the menu cursor UI_MouseMove( x, y ); } diff --git a/engine/client/input.h b/engine/client/input.h index 25e2df49..6b992490 100644 --- a/engine/client/input.h +++ b/engine/client/input.h @@ -74,6 +74,7 @@ void Touch_GetMove( float * forward, float *side, float *yaw, float *pitch ); void Touch_ResetDefaultButtons( void ); int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ); void Touch_KeyEvent( int key, int down ); +qboolean Touch_WantVisibleCursor( void ); // // in_joy.c diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index 67449772..cd134e24 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -24,7 +24,7 @@ GNU General Public License for more details. #include "platform/platform.h" static enum VGUI_KeyCode s_pVirtualKeyTrans[256]; -static VGUI_DefaultCursor s_currentCursor; +static VGUI_DefaultCursor s_currentCursor = -1; static HINSTANCE s_pVGuiSupport; // vgui_support library static convar_t *vgui_utf8 = NULL; @@ -50,8 +50,12 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) void GAME_EXPORT VGUI_CursorSelect( VGUI_DefaultCursor cursor ) { - Platform_SetCursorType( cursor ); - s_currentCursor = cursor; + if( s_currentCursor != cursor ) + { + Platform_SetCursorType( cursor ); + + s_currentCursor = cursor; + } } byte GAME_EXPORT VGUI_GetColor( int i, int j) @@ -250,7 +254,6 @@ void VGui_Startup( const char *clientlib, int width, int height ) if( vgui.initialized ) { - //host.mouse_visible = true; vgui.Startup( width, height ); } else if ( COM_CheckString( clientlib ) ) diff --git a/engine/common/common.h b/engine/common/common.h index 3099e436..b08432e5 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -358,7 +358,7 @@ typedef struct host_parm_s qboolean allow_cheats; // this host will allow cheating qboolean con_showalways; // show console always (developer and dedicated) qboolean change_game; // initialize when game is changed - qboolean mouse_visible; // vgui override cursor control + qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!) qboolean shutdown_issued; // engine is shutting down qboolean force_draw_version; // used when fraps is loaded float force_draw_version_time; diff --git a/engine/common/host.c b/engine/common/host.c index 97fdb923..9dc606e3 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -703,15 +703,6 @@ void GAME_EXPORT Host_Error( const char *error, ... ) static qboolean recursive = false; va_list argptr; - if( host.mouse_visible && !CL_IsInMenu( )) - { - // hide VGUI mouse -#ifdef XASH_SDL - SDL_ShowCursor( 0 ); -#endif - host.mouse_visible = false; - } - va_start( argptr, error ); Q_vsprintf( hosterror1, error, argptr ); va_end( argptr ); diff --git a/engine/common/system.c b/engine/common/system.c index 18ba734f..ed7493a4 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -400,12 +400,16 @@ void Sys_Error( const char *error, ... ) va_list argptr; char text[MAX_PRINT_MSG]; + // enable cursor before debugger call + if( !Host_IsDedicated( )) + Platform_SetCursorType( dc_arrow ); + DEBUG_BREAK; if( host.status == HOST_ERR_FATAL ) return; // don't multiple executes - // make sure what console received last message + // make sure that console received last message if( host.change_game ) Sys_Sleep( 200 ); error_on_exit = true; diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 2a1a217c..515739dd 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -668,7 +668,7 @@ TODO: kill mouse in win32 clients too */ void Platform_PreCreateMove( void ) { - if( CVAR_TO_BOOL( m_ignore ) ) + if( CVAR_TO_BOOL( m_ignore )) { SDL_GetRelativeMouseState( NULL, NULL ); SDL_ShowCursor( SDL_TRUE );