mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Fixed mouse input in event handlers. Added RequireMouse field in event handler to signify that native mouse should be turned on for certain handlers.
This commit is contained in:
parent
08f1731ded
commit
03f7c39ea7
6 changed files with 25 additions and 9 deletions
|
@ -310,8 +310,7 @@ void D_PostEvent (const event_t *ev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
events[eventhead] = *ev;
|
events[eventhead] = *ev;
|
||||||
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling
|
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_CheckUiProcessors())
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Button_Mlook.bDown || freelook)
|
if (Button_Mlook.bDown || freelook)
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,7 +386,7 @@ bool E_Responder(event_t* ev)
|
||||||
// not sure if we want to handle device changes, but whatevs.
|
// not sure if we want to handle device changes, but whatevs.
|
||||||
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
||||||
{
|
{
|
||||||
if (!handler->IsUiProcessor && handler->InputProcess(ev))
|
if (handler->InputProcess(ev))
|
||||||
return true; // event was processed
|
return true; // event was processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,15 +397,18 @@ bool E_Responder(event_t* ev)
|
||||||
bool E_CheckUiProcessors()
|
bool E_CheckUiProcessors()
|
||||||
{
|
{
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||||
{
|
|
||||||
if (handler->IsUiProcessor)
|
if (handler->IsUiProcessor)
|
||||||
{
|
|
||||||
//Printf("E_CheckUiProcessors = true\n");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Printf("E_CheckUiProcessors = false\n");
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool E_CheckRequireMouse()
|
||||||
|
{
|
||||||
|
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||||
|
if (handler->IsUiProcessor && handler->RequireMouse)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +430,7 @@ IMPLEMENT_CLASS(DInputEvent, false, false)
|
||||||
|
|
||||||
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, Order);
|
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, Order);
|
||||||
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, IsUiProcessor);
|
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, IsUiProcessor);
|
||||||
|
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, RequireMouse);
|
||||||
|
|
||||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewPos);
|
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewPos);
|
||||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewAngle);
|
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewAngle);
|
||||||
|
|
|
@ -60,6 +60,8 @@ bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess
|
||||||
|
|
||||||
// check if there is anything that should receive GUI events
|
// check if there is anything that should receive GUI events
|
||||||
bool E_CheckUiProcessors();
|
bool E_CheckUiProcessors();
|
||||||
|
// check if we need native mouse due to UiProcessors
|
||||||
|
bool E_CheckRequireMouse();
|
||||||
|
|
||||||
// serialization stuff
|
// serialization stuff
|
||||||
void E_SerializeEvents(FSerializer& arc);
|
void E_SerializeEvents(FSerializer& arc);
|
||||||
|
@ -89,6 +91,7 @@ public:
|
||||||
//
|
//
|
||||||
int Order;
|
int Order;
|
||||||
bool IsUiProcessor;
|
bool IsUiProcessor;
|
||||||
|
bool RequireMouse;
|
||||||
|
|
||||||
// serialization handler. let's keep it here so that I don't get lost in serialized/not serialized fields
|
// serialization handler. let's keep it here so that I don't get lost in serialized/not serialized fields
|
||||||
void Serialize(FSerializer& arc) override
|
void Serialize(FSerializer& arc) override
|
||||||
|
@ -105,6 +108,7 @@ public:
|
||||||
|
|
||||||
arc("Order", Order);
|
arc("Order", Order);
|
||||||
arc("IsUiProcessor", IsUiProcessor);
|
arc("IsUiProcessor", IsUiProcessor);
|
||||||
|
arc("RequireMouse", RequireMouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// destroy handler. this unlinks EventHandler from the list automatically.
|
// destroy handler. this unlinks EventHandler from the list automatically.
|
||||||
|
|
|
@ -186,6 +186,9 @@ void CheckNativeMouse()
|
||||||
&& (MENU_On == menuactive || MENU_OnNoPause == menuactive);
|
&& (MENU_On == menuactive || MENU_OnNoPause == menuactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wantNative && E_CheckRequireMouse())
|
||||||
|
wantNative = true;
|
||||||
|
|
||||||
I_SetNativeMouse(wantNative);
|
I_SetNativeMouse(wantNative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "win32iface.h"
|
#include "win32iface.h"
|
||||||
#include "rawinput.h"
|
#include "rawinput.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -282,6 +283,9 @@ void I_CheckNativeMouse(bool preferNative)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!want_native && E_CheckRequireMouse())
|
||||||
|
want_native = true;
|
||||||
|
|
||||||
//Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse);
|
//Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse);
|
||||||
|
|
||||||
if (want_native != NativeMouse)
|
if (want_native != NativeMouse)
|
||||||
|
|
|
@ -317,6 +317,8 @@ class StaticEventHandler : Object native
|
||||||
native int Order;
|
native int Order;
|
||||||
// this value will be queried on user input to decide whether to send UiProcess to this handler.
|
// this value will be queried on user input to decide whether to send UiProcess to this handler.
|
||||||
native bool IsUiProcessor;
|
native bool IsUiProcessor;
|
||||||
|
// this value determines whether mouse input is required.
|
||||||
|
native bool RequireMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EventHandler : StaticEventHandler native
|
class EventHandler : StaticEventHandler native
|
||||||
|
|
Loading…
Reference in a new issue