mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 05:29:51 +01:00
platform: add GetMousePos, SetMousePos calls, fix typo
This commit is contained in:
parent
68ed732928
commit
96e0167e47
@ -29,9 +29,7 @@ GNU General Public License for more details.
|
||||
#include "library.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "sound.h" // SND_STOP_LOOPING
|
||||
#ifdef XASH_SDL
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define MAX_LINELENGTH 80
|
||||
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
|
||||
@ -2021,22 +2019,6 @@ static float pfnGetClientMaxspeed( void )
|
||||
return cl.local.maxspeed;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_GetMousePosition
|
||||
|
||||
=============
|
||||
*/
|
||||
void CL_GetMousePosition( int *mx, int *my )
|
||||
{
|
||||
#ifdef XASH_SDL
|
||||
SDL_GetMouseState( mx, my );
|
||||
#else
|
||||
if( mx ) *mx = 0;
|
||||
if( my ) *my = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnIsNoClipping
|
||||
@ -2747,20 +2729,7 @@ void pfnGetMousePos( struct tagPOINT *ppt )
|
||||
if( !ppt )
|
||||
return;
|
||||
|
||||
CL_GetMousePosition( &ppt->x, &ppt->y );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnSetMousePos
|
||||
|
||||
=============
|
||||
*/
|
||||
void pfnSetMousePos( int mx, int my )
|
||||
{
|
||||
#ifdef XASH_SDL
|
||||
SDL_WarpMouseInWindow( host.hWnd, mx, my );
|
||||
#endif
|
||||
Platform_GetMousePos( &ppt->x, &ppt->y );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4002,7 +3971,7 @@ static cl_enginefunc_t gEngfuncs =
|
||||
pfnGetClientMaxspeed,
|
||||
COM_CheckParm,
|
||||
Key_Event,
|
||||
CL_GetMousePosition,
|
||||
Platform_GetMousePos,
|
||||
pfnIsNoClipping,
|
||||
CL_GetLocalPlayer,
|
||||
pfnGetViewModel,
|
||||
@ -4052,7 +4021,7 @@ static cl_enginefunc_t gEngfuncs =
|
||||
pfnGetPlayerForTrackerID,
|
||||
pfnServerCmdUnreliable,
|
||||
pfnGetMousePos,
|
||||
pfnSetMousePos,
|
||||
Platform_SetMousePos,
|
||||
pfnSetMouseEnable,
|
||||
Cvar_GetList,
|
||||
(void*)Cmd_GetFirstFunctionHandle,
|
||||
|
@ -1728,7 +1728,7 @@ void IN_TouchKeyEvent( int key, int down )
|
||||
if( !touch.clientonly )
|
||||
return;
|
||||
|
||||
CL_GetMousePosition( &xi, &yi );
|
||||
Platform_GetMousePos( &xi, &yi );
|
||||
|
||||
x = xi/SCR_W;
|
||||
y = yi/SCR_H;
|
||||
|
@ -101,10 +101,8 @@ void IN_MouseSavePos( void )
|
||||
if( !in_mouseactive )
|
||||
return;
|
||||
|
||||
#ifdef XASH_SDL
|
||||
SDL_GetMouseState( &in_lastvalidpos.x, &in_lastvalidpos.y );
|
||||
Platform_GetMousePos( &in_lastvalidpos.x, &in_lastvalidpos.y );
|
||||
in_mouse_savedpos = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -119,9 +117,7 @@ void IN_MouseRestorePos( void )
|
||||
if( !in_mouse_savedpos )
|
||||
return;
|
||||
|
||||
#ifdef XASH_SDL
|
||||
SDL_WarpMouseInWindow( host.hWnd, in_lastvalidpos.x, in_lastvalidpos.y );
|
||||
#endif
|
||||
Platform_SetMousePos( in_lastvalidpos.x, in_lastvalidpos.y );
|
||||
|
||||
in_mouse_savedpos = false;
|
||||
}
|
||||
@ -152,7 +148,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_WarpMouseInWindow( host.hWnd, host.window_center_x, host.window_center_y );
|
||||
Platform_SetMousePos( host.window_center_x, host.window_center_y );
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
|
||||
if( clgame.dllFuncs.pfnLookEvent )
|
||||
SDL_SetRelativeMouseMode( SDL_TRUE );
|
||||
@ -282,9 +278,7 @@ void IN_MouseMove( void )
|
||||
return;
|
||||
|
||||
// find mouse movement
|
||||
#ifdef XASH_SDL
|
||||
SDL_GetMouseState( ¤t_pos.x, ¤t_pos.y );
|
||||
#endif
|
||||
Platform_GetMousePos( ¤t_pos.x, ¤t_pos.y );
|
||||
|
||||
VGui_MouseMove( current_pos.x, current_pos.y );
|
||||
|
||||
@ -321,7 +315,7 @@ void IN_MouseEvent( void )
|
||||
#if defined( XASH_SDL )
|
||||
static qboolean ignore; // igonre mouse warp event
|
||||
int x, y;
|
||||
SDL_GetMouseState(&x, &y);
|
||||
Platform_GetMousePos(&x, &y);
|
||||
if( host.mouse_visible )
|
||||
SDL_ShowCursor( SDL_TRUE );
|
||||
else
|
||||
@ -332,7 +326,7 @@ void IN_MouseEvent( void )
|
||||
x > host.window_center_x + host.window_center_x / 2 ||
|
||||
y > host.window_center_y + host.window_center_y / 2 )
|
||||
{
|
||||
SDL_WarpMouseInWindow(host.hWnd, host.window_center_x, host.window_center_y);
|
||||
Platform_SetMousePos( host.window_center_x, host.window_center_y );
|
||||
ignore = 1; // next mouse event will be mouse warp
|
||||
return;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
|
||||
float yscale = (float)glState.height / (float)clgame.scrInfo.iHeight;
|
||||
int x, y;
|
||||
|
||||
CL_GetMousePosition( &x, &y );
|
||||
Platform_GetMousePos( &x, &y );
|
||||
*_x = x / xscale, *_y = y / yscale;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,9 @@ int Platform_JoyInit( int numjoy ); // returns number of connected gamepads, neg
|
||||
void Platform_EnableTextInput( qboolean enable );
|
||||
// System events
|
||||
void Platform_RunEvents( void );
|
||||
// Mouse
|
||||
void Platform_GetMousePos( int *x, int *y );
|
||||
void Platform_SetMousePos( int x, int y );
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
@ -470,7 +470,7 @@ void Platform_RunEvents( void )
|
||||
SDLash_EventFilter( &event );
|
||||
}
|
||||
|
||||
void* Platform_GetNativeObject( void )
|
||||
void* Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
return NULL; // SDL don't have it
|
||||
}
|
||||
|
@ -28,6 +28,28 @@ GNU General Public License for more details.
|
||||
static SDL_Joystick *joy;
|
||||
static SDL_GameController *gamecontroller;
|
||||
|
||||
/*
|
||||
=============
|
||||
Platform_GetMousePos
|
||||
|
||||
=============
|
||||
*/
|
||||
void Platform_GetMousePos( int *x, int *y )
|
||||
{
|
||||
SDL_GetMouseState( x, y );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Platform_SetMousePos
|
||||
|
||||
============
|
||||
*/
|
||||
void Platform_SetMousePos( int x, int y )
|
||||
{
|
||||
SDL_WarpMouseInWindow( host.hWnd, x, y );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Platform_Vibrate
|
||||
|
Loading…
Reference in New Issue
Block a user