diff --git a/engine/client/in_touch.c b/engine/client/in_touch.c index 58f0d7b7f..d5648ada0 100644 --- a/engine/client/in_touch.c +++ b/engine/client/in_touch.c @@ -161,7 +161,7 @@ static CVAR_DEFINE_AUTO( touch_dpad_radius, "1.0", FCVAR_FILTERABLE, "dpad radiu static CVAR_DEFINE_AUTO( touch_joy_radius, "1.0", FCVAR_FILTERABLE, "joy radius multiplier" ); static CVAR_DEFINE_AUTO( touch_move_indicator, "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" ); static CVAR_DEFINE_AUTO( touch_joy_texture, "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator"); -static CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_PRIVILEGED, "emulate touch with mouse" ); +static CVAR_DEFINE( touch_emulate, "_touch_emulate", "0", FCVAR_PRIVILEGED, "emulate touch with mouse" ); CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" ); // code looks smaller with it @@ -536,9 +536,15 @@ void Touch_SetClientOnly( byte state ) touch.forward = touch.side = 0; if( state ) + { + Platform_SetCursorType( dc_arrow ); IN_DeactivateMouse(); + } else + { + Platform_SetCursorType( dc_none ); IN_ActivateMouse(); + } } static void Touch_SetClientOnly_f( void ) @@ -2182,14 +2188,8 @@ void Touch_KeyEvent( int key, int down ) float x, y; int finger, xi, yi; - if( !Touch_Emulated( )) - { - if( touch_enable.value ) - return; - - if( !touch.clientonly ) - return; - } + if( !Touch_WantVisibleCursor( )) + return; if( !key ) { @@ -2214,10 +2214,6 @@ void Touch_KeyEvent( int key, int down ) } } - // don't deactivate mouse in game - // checking a case when mouse and touchscreen - // can be used simultaneously - Platform_SetCursorType( dc_arrow ); Platform_GetMousePos( &xi, &yi ); x = xi / (float)refState.width; @@ -2233,12 +2229,7 @@ void Touch_KeyEvent( int key, int down ) qboolean Touch_WantVisibleCursor( void ) { - return ( touch_enable.value && touch_emulate.value ) || touch.clientonly; -} - -qboolean Touch_Emulated( void ) -{ - return touch_emulate.value || touch_in_menu.value; + return ( touch_enable.value && touch_emulate.value ) || touch.clientonly || touch_in_menu.value; } void Touch_Shutdown( void ) diff --git a/engine/client/input.c b/engine/client/input.c index 8a506b0e1..be4abc369 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -332,7 +332,7 @@ static void IN_MouseMove( void ) if( !in_mouseinitialized ) return; - if( Touch_Emulated( )) + if( Touch_WantVisibleCursor( )) { // touch emulation overrides all input Touch_KeyEvent( 0, 0 ); @@ -363,7 +363,7 @@ void IN_MouseEvent( int key, int down ) else ClearBits( in_mstate, BIT( key )); // touch emulation overrides all input - if( Touch_Emulated( )) + if( Touch_WantVisibleCursor( )) { Touch_KeyEvent( K_MOUSE1 + key, down ); } diff --git a/engine/client/input.h b/engine/client/input.h index 30a4d2646..4fb4fe7dc 100644 --- a/engine/client/input.h +++ b/engine/client/input.h @@ -74,7 +74,6 @@ 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 ); -qboolean Touch_Emulated( void ); void Touch_NotifyResize( void ); // diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 01991d10b..1e94b5824 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -221,7 +221,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) } // never disable cursor in touch emulation mode - if( !visible && Touch_Emulated( )) + if( !visible && Touch_WantVisibleCursor( )) return; host.mouse_visible = visible;