mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-31 04:50:48 +00:00
Added E_Responder call for direct mouse input interception
This commit is contained in:
parent
e5a3d2244e
commit
883048b538
3 changed files with 23 additions and 15 deletions
|
@ -288,7 +288,7 @@ void D_ProcessEvents (void)
|
||||||
if (M_Responder (ev))
|
if (M_Responder (ev))
|
||||||
continue; // menu ate the event
|
continue; // menu ate the event
|
||||||
// check events
|
// check events
|
||||||
if (E_Responder(ev)) // [ZZ] ZScript ate the event
|
if (E_Responder(ev)) // [ZZ] ZScript ate the event // update 07.03.17: mouse events are handled directly
|
||||||
continue;
|
continue;
|
||||||
G_Responder (ev);
|
G_Responder (ev);
|
||||||
}
|
}
|
||||||
|
@ -310,7 +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 && !E_CheckUiProcessors())
|
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_Responder(ev))
|
||||||
{
|
{
|
||||||
if (Button_Mlook.bDown || freelook)
|
if (Button_Mlook.bDown || freelook)
|
||||||
{
|
{
|
||||||
|
|
|
@ -410,28 +410,36 @@ void E_PlayerDisconnected(int num)
|
||||||
handler->PlayerDisconnected(num);
|
handler->PlayerDisconnected(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool E_Responder(event_t* ev)
|
bool E_Responder(const event_t* ev)
|
||||||
{
|
{
|
||||||
|
bool uiProcessorsFound = false;
|
||||||
|
|
||||||
if (ev->type == EV_GUI_Event)
|
if (ev->type == EV_GUI_Event)
|
||||||
{
|
{
|
||||||
// iterate handlers back to front by order, and give them this event.
|
// iterate handlers back to front by order, and give them this event.
|
||||||
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
||||||
{
|
{
|
||||||
if (handler->IsUiProcessor && handler->UiProcess(ev))
|
if (handler->IsUiProcessor)
|
||||||
|
{
|
||||||
|
uiProcessorsFound = true;
|
||||||
|
if (handler->UiProcess(ev))
|
||||||
return true; // event was processed
|
return true; // event was processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 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)
|
||||||
|
uiProcessorsFound = true;
|
||||||
if (handler->InputProcess(ev))
|
if (handler->InputProcess(ev))
|
||||||
return true; // event was processed
|
return true; // event was processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return (uiProcessorsFound && (ev->type == EV_Mouse)); // mouse events are eaten by the event system if there are any uiprocessors.
|
||||||
}
|
}
|
||||||
|
|
||||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||||
|
@ -939,7 +947,7 @@ void DStaticEventHandler::PlayerDisconnected(int num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FUiEvent::FUiEvent(event_t *ev)
|
FUiEvent::FUiEvent(const event_t *ev)
|
||||||
{
|
{
|
||||||
Type = (EGUIEvent)ev->subtype;
|
Type = (EGUIEvent)ev->subtype;
|
||||||
KeyChar = 0;
|
KeyChar = 0;
|
||||||
|
@ -979,7 +987,7 @@ FUiEvent::FUiEvent(event_t *ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DStaticEventHandler::UiProcess(event_t* ev)
|
bool DStaticEventHandler::UiProcess(const event_t* ev)
|
||||||
{
|
{
|
||||||
IFVIRTUAL(DStaticEventHandler, UiProcess)
|
IFVIRTUAL(DStaticEventHandler, UiProcess)
|
||||||
{
|
{
|
||||||
|
@ -998,7 +1006,7 @@ bool DStaticEventHandler::UiProcess(event_t* ev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FInputEvent::FInputEvent(event_t *ev)
|
FInputEvent::FInputEvent(const event_t *ev)
|
||||||
{
|
{
|
||||||
Type = (EGenericEvent)ev->type;
|
Type = (EGenericEvent)ev->type;
|
||||||
// we don't want the modders to remember what weird fields mean what for what events.
|
// we don't want the modders to remember what weird fields mean what for what events.
|
||||||
|
@ -1025,7 +1033,7 @@ FInputEvent::FInputEvent(event_t *ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DStaticEventHandler::InputProcess(event_t* ev)
|
bool DStaticEventHandler::InputProcess(const event_t* ev)
|
||||||
{
|
{
|
||||||
IFVIRTUAL(DStaticEventHandler, InputProcess)
|
IFVIRTUAL(DStaticEventHandler, InputProcess)
|
||||||
{
|
{
|
||||||
|
|
10
src/events.h
10
src/events.h
|
@ -56,7 +56,7 @@ void E_PlayerDied(int num);
|
||||||
// this executes when a player leaves the game
|
// this executes when a player leaves the game
|
||||||
void E_PlayerDisconnected(int num);
|
void E_PlayerDisconnected(int num);
|
||||||
// this executes on events.
|
// this executes on events.
|
||||||
bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess
|
bool E_Responder(const event_t* ev); // splits events into InputProcess and UiProcess
|
||||||
// this executes on console/net events.
|
// this executes on console/net events.
|
||||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ public:
|
||||||
void PlayerDisconnected(int num);
|
void PlayerDisconnected(int num);
|
||||||
|
|
||||||
// return true if handled.
|
// return true if handled.
|
||||||
bool InputProcess(event_t* ev);
|
bool InputProcess(const event_t* ev);
|
||||||
bool UiProcess(event_t* ev);
|
bool UiProcess(const event_t* ev);
|
||||||
|
|
||||||
//
|
//
|
||||||
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||||
|
@ -215,7 +215,7 @@ struct FUiEvent
|
||||||
bool IsCtrl;
|
bool IsCtrl;
|
||||||
bool IsAlt;
|
bool IsAlt;
|
||||||
|
|
||||||
FUiEvent(event_t *ev);
|
FUiEvent(const event_t *ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FInputEvent
|
struct FInputEvent
|
||||||
|
@ -230,7 +230,7 @@ struct FInputEvent
|
||||||
int MouseX;
|
int MouseX;
|
||||||
int MouseY;
|
int MouseY;
|
||||||
|
|
||||||
FInputEvent(event_t *ev);
|
FInputEvent(const event_t *ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FConsoleEvent
|
struct FConsoleEvent
|
||||||
|
|
Loading…
Reference in a new issue