engine: automatically turn-on touch emulation while editing touch from menu

This commit is contained in:
Alibek Omarov 2024-07-29 05:06:10 +03:00
parent f793413a79
commit eabed60e56
4 changed files with 11 additions and 6 deletions

View file

@ -163,8 +163,8 @@ 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_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_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_joy_texture, "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator");
static CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate touch with mouse" );
CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" ); CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" );
CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate touch with mouse" );
// code looks smaller with it // code looks smaller with it
#define B(x) (button->x) #define B(x) (button->x)
@ -2122,7 +2122,7 @@ void Touch_KeyEvent( int key, int down )
float x, y; float x, y;
int finger, xi, yi; int finger, xi, yi;
if( !touch_emulate.value ) if( !Touch_Emulated( ))
{ {
if( touch_enable.value ) if( touch_enable.value )
return; return;
@ -2176,6 +2176,11 @@ qboolean Touch_WantVisibleCursor( void )
return ( touch_enable.value && touch_emulate.value ) || touch.clientonly; return ( touch_enable.value && touch_emulate.value ) || touch.clientonly;
} }
qboolean Touch_Emulated( void )
{
return touch_emulate.value || touch_in_menu.value;
}
void Touch_Shutdown( void ) void Touch_Shutdown( void )
{ {
if( !touch.initialized ) if( !touch.initialized )

View file

@ -316,7 +316,7 @@ static void IN_MouseMove( void )
if( !in_mouseinitialized ) if( !in_mouseinitialized )
return; return;
if( touch_emulate.value ) if( Touch_Emulated( ))
{ {
// touch emulation overrides all input // touch emulation overrides all input
Touch_KeyEvent( 0, 0 ); Touch_KeyEvent( 0, 0 );
@ -347,7 +347,7 @@ void IN_MouseEvent( int key, int down )
else ClearBits( in_mstate, BIT( key )); else ClearBits( in_mstate, BIT( key ));
// touch emulation overrides all input // touch emulation overrides all input
if( touch_emulate.value ) if( Touch_Emulated( ))
{ {
Touch_KeyEvent( K_MOUSE1 + key, down ); Touch_KeyEvent( K_MOUSE1 + key, down );
} }

View file

@ -58,7 +58,6 @@ typedef enum
} touchEventType; } touchEventType;
extern convar_t touch_enable; extern convar_t touch_enable;
extern convar_t touch_emulate;
void Touch_Draw( void ); void Touch_Draw( void );
void Touch_SetClientOnly( byte state ); void Touch_SetClientOnly( byte state );
@ -74,6 +73,7 @@ void Touch_ResetDefaultButtons( void );
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ); int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
void Touch_KeyEvent( int key, int down ); void Touch_KeyEvent( int key, int down );
qboolean Touch_WantVisibleCursor( void ); qboolean Touch_WantVisibleCursor( void );
qboolean Touch_Emulated( void );
void Touch_NotifyResize( void ); void Touch_NotifyResize( void );
// //

View file

@ -350,7 +350,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type )
} }
// never disable cursor in touch emulation mode // never disable cursor in touch emulation mode
if( !visible && touch_emulate.value ) if( !visible && Touch_Emulated( ))
return; return;
host.mouse_visible = visible; host.mouse_visible = visible;