- cleanup of mouse input code and removal of all magic factors.
Sensitivity scaling of both axes is now exposed as a raw factor to the user instead of obscuring it behind an unclear 'prescale' boolean. This also consolidates the coordinate processing code to prevent such discrepancies as were present here from happening again. Migration code for old config settings is present so that this change does not affect existing configurations.
This commit is contained in:
parent
cd6ef67209
commit
51518d63a4
13 changed files with 139 additions and 187 deletions
|
|
@ -42,6 +42,7 @@
|
|||
#include "m_joy.h"
|
||||
#include "vm.h"
|
||||
#include "gamestate.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
bool G_Responder(event_t* ev);
|
||||
|
||||
|
|
@ -49,6 +50,11 @@ int eventhead;
|
|||
int eventtail;
|
||||
event_t events[MAXEVENTS];
|
||||
|
||||
CVAR(Float, m_sensitivity_x, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, m_sensitivity_y, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D_ProcessEvents
|
||||
|
|
@ -116,6 +122,57 @@ void D_RemoveNextCharEvent()
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D_PostEvent
|
||||
//
|
||||
// Called by the I/O functions when input is detected.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D_PostEvent(event_t* ev)
|
||||
{
|
||||
// Do not post duplicate consecutive EV_DeviceChange events.
|
||||
if (ev->type == EV_DeviceChange && events[eventhead].type == EV_DeviceChange)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (sysCallbacks && sysCallbacks->DispatchEvent && sysCallbacks->DispatchEvent(ev))
|
||||
return;
|
||||
|
||||
events[eventhead] = *ev;
|
||||
eventhead = (eventhead + 1) & (MAXEVENTS - 1);
|
||||
}
|
||||
|
||||
|
||||
void PostMouseMove(int xx, int yy)
|
||||
{
|
||||
static float lastx = 0, lasty = 0;
|
||||
event_t ev{};
|
||||
|
||||
float x = float(xx) * m_sensitivity_x;
|
||||
float y = -float(yy) * m_sensitivity_y;
|
||||
|
||||
if (m_filter)
|
||||
{
|
||||
ev.x = xs_CRoundToInt((x + lastx) / 2);
|
||||
ev.y = xs_CRoundToInt((y + lasty) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ev.x = xs_CRoundToInt(x);
|
||||
ev.y = xs_CRoundToInt(y);
|
||||
}
|
||||
lastx = x;
|
||||
lasty = y;
|
||||
if (ev.x | ev.y)
|
||||
{
|
||||
ev.type = EV_Mouse;
|
||||
D_PostEvent(&ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FInputEvent::FInputEvent(const event_t *ev)
|
||||
{
|
||||
Type = (EGenericEvent)ev->type;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue