diff --git a/engine/client/input.c b/engine/client/input.c index 3953911d..d549c3fe 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -51,6 +51,64 @@ convar_t *cl_sidespeed; convar_t *cl_backspeed; convar_t *look_filter; +/* +================ +IN_CollectInputDevices + +Returns a bit mask representing connected devices or, at least, enabled +================ +*/ +uint IN_CollectInputDevices( void ) +{ + uint ret = 0; + + if( !m_ignore->value ) // no way to check is mouse connected, so use cvar only + ret |= INPUT_DEVICE_MOUSE; + +#if 0 // TOUCHTODO + if( touch_enable->value ) + ret |= INPUT_DEVICE_TOUCH; +#endif + + if( Joy_IsActive() ) // connected or enabled + ret |= INPUT_DEVICE_JOYSTICK; + + Con_Reportf( "Connected devices: %s%s%s%s\n", + FBitSet( ret, INPUT_DEVICE_MOUSE ) ? "mouse " : "", + FBitSet( ret, INPUT_DEVICE_TOUCH ) ? "touch " : "", + FBitSet( ret, INPUT_DEVICE_JOYSTICK ) ? "joy " : "", + FBitSet( ret, INPUT_DEVICE_VR ) ? "vr " : ""); + + return ret; +} + +/* +================= +IN_LockInputDevices + +tries to lock any possibilty to connect another input device after +player is connected to the server +================= +*/ +void IN_LockInputDevices( qboolean lock ) +{ + extern convar_t *joy_enable; // private to input system + + if( lock ) + { + SetBits( m_ignore->flags, FCVAR_READ_ONLY ); + SetBits( joy_enable->flags, FCVAR_READ_ONLY ); + // TOUCHTODO + } + else + { + ClearBits( m_ignore->flags, FCVAR_READ_ONLY ); + ClearBits( joy_enable->flags, FCVAR_READ_ONLY ); + // TOUCHTODO + } +} + + /* =========== IN_StartupMouse diff --git a/engine/client/input.h b/engine/client/input.h index 72d8fd99..fefda78a 100644 --- a/engine/client/input.h +++ b/engine/client/input.h @@ -41,6 +41,9 @@ void IN_MouseRestorePos( void ); void IN_ToggleClientMouse( int newstate, int oldstate ); void IN_SetCursor( void *hCursor ); +uint IN_CollectInputDevices( void ); +void IN_LockInputDevices( qboolean lock ); + // // in_touch.c //