mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-11 10:11:47 +00:00
in_sdl.c: made total_dx, total_dy and FilterMouseEvents() static. added
a boolean no_mouse. added check for '-nomouse' command line switch which disables all mouse events. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@46 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
053735ef0f
commit
5ddd5a30cb
1 changed files with 17 additions and 2 deletions
|
@ -22,14 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
|
|
||||||
|
static qboolean no_mouse = false;
|
||||||
|
|
||||||
// mouse variables
|
// mouse variables
|
||||||
cvar_t m_filter = {"m_filter","0"};
|
cvar_t m_filter = {"m_filter","0"};
|
||||||
|
|
||||||
// total accumulated mouse movement since last frame
|
// total accumulated mouse movement since last frame
|
||||||
// this gets updated from the main game loop via IN_MouseMove
|
// this gets updated from the main game loop via IN_MouseMove
|
||||||
int total_dx, total_dy = 0;
|
static int total_dx, total_dy = 0;
|
||||||
|
|
||||||
int FilterMouseEvents (const SDL_Event *event)
|
static int FilterMouseEvents (const SDL_Event *event)
|
||||||
{
|
{
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +46,9 @@ int FilterMouseEvents (const SDL_Event *event)
|
||||||
|
|
||||||
void IN_Activate (void)
|
void IN_Activate (void)
|
||||||
{
|
{
|
||||||
|
if (no_mouse)
|
||||||
|
return;
|
||||||
|
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
||||||
{
|
{
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
|
@ -67,6 +72,9 @@ void IN_Activate (void)
|
||||||
|
|
||||||
void IN_Deactivate (qboolean free_cursor)
|
void IN_Deactivate (qboolean free_cursor)
|
||||||
{
|
{
|
||||||
|
if (no_mouse)
|
||||||
|
return;
|
||||||
|
|
||||||
if (free_cursor)
|
if (free_cursor)
|
||||||
{
|
{
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
||||||
|
@ -96,6 +104,13 @@ void IN_Init (void)
|
||||||
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
|
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
|
||||||
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
|
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
|
||||||
|
|
||||||
|
if (COM_CheckParm("-nomouse"))
|
||||||
|
{
|
||||||
|
no_mouse = true;
|
||||||
|
// discard all mouse events when input is deactivated
|
||||||
|
SDL_SetEventFilter(FilterMouseEvents);
|
||||||
|
}
|
||||||
|
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue