UiProcess and InputProcess events
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
UiProcess and InputProcess events
This two event on wiki page warn me that if I return true with one of this event, player will be locked from moving, event with lower order stop processing, all be bad.
But there are a way to bypass this using network event. And in this point I lost thread of thought. I must override two events one of which send all input and ui events in network? Write input event inside network event? Write network event inside input?
But there are a way to bypass this using network event. And in this point I lost thread of thought. I must override two events one of which send all input and ui events in network? Write input event inside network event? Write network event inside input?
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
UiProcess and InputProcess are events to get direct access to keyboard events. Normally you don't have to return true in the events; also with InputProcess the game and the player just keeps moving. UIProcess is more meant for a kind of modal screens, at least that is where I use it for. In UIProcess you can also catch system keys like ESC and PrtScr and such, and provides also direct access to mouseX/Y coordinates and left/right/wheel button clicks.
Both events are UI bound, so you can't modify game data there; that's why the NetworkProcess event exists; when you use SendNetworkEvent in InputProcess or UiProcess, you can receive and process the information in NetworkProcess.
Very simple example for Input:
Both events are UI bound, so you can't modify game data there; that's why the NetworkProcess event exists; when you use SendNetworkEvent in InputProcess or UiProcess, you can receive and process the information in NetworkProcess.
Very simple example for Input:
Code: Select all
override bool InputProcess (InputEvent e)
{
if (e.Type == InputEvent.Type_KeyDown && automapactive == false) // not when automap is active
SendNetworkEvent("keypress", e.KeyScan);
return false;
}
override void NetworkProcess(ConsoleEvent e)
{
if (e.Name == "keypress")
console.printf("%d", e.Args[0]);
}
Re: UiProcess and InputProcess events
Ooooo, send RESULT of event.
I think about sending ENTIRE event...
Also, how check buttons in input process? I mean, what name I must use for key, say "L"?
I think about sending ENTIRE event...
Also, how check buttons in input process? I mean, what name I must use for key, say "L"?
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
See the console.printf in my example for the exact value; otherwise see in gzdoom.pk3 the events.txt , struct InputEvent.Apeirogon wrote: Also, how check buttons in input process? I mean, what name I must use for key, say "L"?
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
Btw, in my example I used e.KeyScan which is an internal code for the engine, but you can also use the ascii code, which is represented by e.KeyChar.
Re: UiProcess and InputProcess events
Okay, now I know what button player press, release and how long it was pressed.
How check is this button do something inside game? Like, I want check how much time player press "use" button.
How check is this button do something inside game? Like, I want check how much time player press "use" button.
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
Using the same keypress command as in the previous example, it would be something like this:Apeirogon wrote: Like, I want check how much time player press "use" button.
Code: Select all
int used; //<== local variable in your eventhandler class
override void OnRegister()
{
used=0;
}
override bool InputProcess (InputEvent e)
{
if (e.Type == InputEvent.Type_KeyDown && automapactive == false) // not when automap is active
SendNetworkEvent("keypress", e.KeyScan);
return false;
}
override void NetworkProcess(ConsoleEvent e)
{
if (e.Name == "keypress")
{
int key1, key2;
[key1, key2] = Bindings.GetKeysForCommand("+use");
if ((key1 && key1 == e.Args[0]) || (key2 && key2 == e.Args[0]))
{
used++;
}
}
}
Re: UiProcess and InputProcess events
Why you check two time value of argument from input event? This important?
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
You mean this: if ((key1 && key1 == e.Args[0]).. ?Apeirogon wrote:Why you check two time value of argument from input event? This important?
Re: UiProcess and InputProcess events
More specific, why
instead
Code: Select all
[key1, key2] = Bindings.GetKeysForCommand("+use");
if ((key1 && key1 == e.Args[0]) || (key2 && key2 == e.Args[0]))
Code: Select all
key = Bindings.GetKeysForCommand("+use");
if (key && key == e.Args[0])
- gwHero
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: UiProcess and InputProcess events
Because Bindings.GetKeysForCommand returns 2 values; you can have 2 keys assigned to an action.