mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 21:50:59 +01:00
engine: input: fix incorrect client notifying about mouse button states
This commit is contained in:
parent
f9d0fba05f
commit
abbd0f92a4
@ -30,8 +30,7 @@ qboolean in_mouseinitialized;
|
||||
qboolean in_mouse_suspended;
|
||||
POINT in_lastvalidpos;
|
||||
qboolean in_mouse_savedpos;
|
||||
static uint in_mouse_oldbuttonstate;
|
||||
static int in_mouse_buttons = 5; // SDL maximum
|
||||
static int in_mstate = 0;
|
||||
static struct inputstate_s
|
||||
{
|
||||
float lastpitch, lastyaw;
|
||||
@ -337,50 +336,33 @@ void IN_MouseMove( void )
|
||||
IN_MouseEvent
|
||||
===========
|
||||
*/
|
||||
void IN_MouseEvent( uint mstate )
|
||||
void IN_MouseEvent( int key, int down )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !in_mouseinitialized )
|
||||
return;
|
||||
|
||||
if( down )
|
||||
SetBits( in_mstate, BIT( key ));
|
||||
else ClearBits( in_mstate, BIT( key ));
|
||||
|
||||
if( cls.key_dest == key_game )
|
||||
{
|
||||
// perform button actions
|
||||
for( i = 0; i < in_mouse_buttons; i++ )
|
||||
{
|
||||
if( FBitSet( mstate, BIT( i )) && !FBitSet( in_mouse_oldbuttonstate, BIT( i )))
|
||||
{
|
||||
VGui_KeyEvent( K_MOUSE1 + i, true );
|
||||
}
|
||||
|
||||
if( !FBitSet( mstate, BIT( i )) && FBitSet( in_mouse_oldbuttonstate, BIT( i )))
|
||||
{
|
||||
VGui_KeyEvent( K_MOUSE1 + i, false );
|
||||
}
|
||||
}
|
||||
VGui_KeyEvent( K_MOUSE1 + key, down );
|
||||
|
||||
// don't do Key_Event here
|
||||
// client may override IN_MouseEvent
|
||||
// but by default it calls back to Key_Event anyway
|
||||
if( in_mouseactive )
|
||||
clgame.dllFuncs.IN_MouseEvent( mstate );
|
||||
|
||||
in_mouse_oldbuttonstate = mstate;
|
||||
return;
|
||||
clgame.dllFuncs.IN_MouseEvent( in_mstate );
|
||||
}
|
||||
|
||||
// perform button actions
|
||||
for( i = 0; i < in_mouse_buttons; i++ )
|
||||
else
|
||||
{
|
||||
if( FBitSet( mstate, BIT( i )) && !FBitSet( in_mouse_oldbuttonstate, BIT( i )))
|
||||
{
|
||||
Key_Event( K_MOUSE1 + i, true );
|
||||
}
|
||||
|
||||
if( !FBitSet( mstate, BIT( i )) && FBitSet( in_mouse_oldbuttonstate, BIT( i )))
|
||||
{
|
||||
Key_Event( K_MOUSE1 + i, false );
|
||||
}
|
||||
// perform button actions
|
||||
Key_Event( K_MOUSE1 + key, down );
|
||||
}
|
||||
in_mouse_oldbuttonstate = mstate;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -33,7 +33,7 @@ extern qboolean in_mouseinitialized;
|
||||
void IN_Init( void );
|
||||
void Host_InputFrame( void );
|
||||
void IN_Shutdown( void );
|
||||
void IN_MouseEvent( uint mstate );
|
||||
void IN_MouseEvent( int key, int down );
|
||||
void IN_ActivateMouse( void );
|
||||
void IN_DeactivateMouse( void );
|
||||
void IN_MouseSavePos( void );
|
||||
|
@ -281,19 +281,19 @@ static void SDLash_MouseEvent( SDL_MouseButtonEvent button )
|
||||
switch( button.button )
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
if( down ) SetBits( mstate, BIT( 0 ));
|
||||
IN_MouseEvent( 0, down );
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
if( down ) SetBits( mstate, BIT( 1 ));
|
||||
IN_MouseEvent( 1, down );
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
if( down ) SetBits( mstate, BIT( 2 ));
|
||||
IN_MouseEvent( 2, down );
|
||||
break;
|
||||
case SDL_BUTTON_X1:
|
||||
if( down ) SetBits( mstate, BIT( 3 ));
|
||||
IN_MouseEvent( 3, down );
|
||||
break;
|
||||
case SDL_BUTTON_X2:
|
||||
if( down ) SetBits( mstate, BIT( 4 ));
|
||||
IN_MouseEvent( 4, down );
|
||||
break;
|
||||
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
@ -306,8 +306,6 @@ static void SDLash_MouseEvent( SDL_MouseButtonEvent button )
|
||||
default:
|
||||
Con_Printf( "Unknown mouse button ID: %d\n", button.button );
|
||||
}
|
||||
|
||||
IN_MouseEvent( mstate );
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user