InputProcess Type Enum work around

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
peewee_RotA
Posts: 407
Joined: Fri Feb 07, 2014 6:45 am

InputProcess Type Enum work around

Post by peewee_RotA »

The InputProcess event does not have information about the e.Type variable. So here's what I found out to help anyone else in the future.

The EventHandler override for InputProcess takes in an InputEvent. This has a property named "type" which is of type EGenericEvent

There is no documentation on EGenericEvent, so diving into the code, it is an enum defined inside of the InputEvent struct.

It appears that the child definitions of this struct are not accessible outside of this file, so you cannot get to the Enum directly. However enums convert natively to int so you can access it by number. So here is a guide to the input types if you ever need to check them.

From https://github.com/ZDoom/gzdoom/blob/ca ... nts.zs#L85

Code: Select all

    enum EGenericEvent
    {
        Type_None,          	0
        Type_KeyDown,		1
        Type_KeyUp,		2
        Type_Mouse,		3
        Type_GUI, 		4  (unused, kept for completeness)
        Type_DeviceChange	5
    }
If you're doing investigation, you can't print e.Type directly, but you can string format them into numbers like so:

Code: Select all

        console.printf(String.Format("type %d", e.Type));
Edit: Here's a set of const you can copy if you want them handy

Code: Select all

    const EGenericEvent_Type_None = 0;
    const EGenericEvent_Type_KeyDown = 1;
    const EGenericEvent_Type_KeyUp = 2;
    const EGenericEvent_Type_Mouse = 3;
    const EGenericEvent_Type_GUI = 4;
    const EGenericEvent_Type_DeviceChange = 5;
Last edited by peewee_RotA on Thu Mar 14, 2024 6:24 am, edited 3 times in total.
peewee_RotA
Posts: 407
Joined: Fri Feb 07, 2014 6:45 am

Re: InputProcess Type Enum work around

Post by peewee_RotA »

I got curious and checked out UiProcess. It has a similar enum named EGUIEvent, but different enough to change how it works.

Here are the values:

Code: Select all

    enum EGUIEvent
    {
        Type_None,					0
        Type_KeyDown,					1
        Type_KeyRepeat,					2
        Type_KeyUp,					3
        Type_Char,					4
        Type_FirstMouseEvent, // ? 			5
            Type_MouseMove,				6
            Type_LButtonDown,				7	
            Type_LButtonUp,				8
            Type_LButtonClick,				9
            Type_MButtonDown,				10
            Type_MButtonUp,				11
            Type_MButtonClick,				12
            Type_RButtonDown,				13
            Type_RButtonUp,				14
            Type_RButtonClick,				15
            Type_WheelUp,				16
            Type_WheelDown,				17
            Type_WheelRight, // ???			18
            Type_WheelLeft, // ???			19
            Type_BackButtonDown, // ???			20
            Type_BackButtonUp, // ???			21
            Type_FwdButtonDown, // ???			22
            Type_FwdButtonUp, // ???			23
        Type_LastMouseEvent				24
    }


I do want to note that these are by far the most appropriate code comments I have ever seen. LOL

Code: Select all

           Type_WheelRight, // ???	
           Type_WheelLeft, // ???
User avatar
phantombeta
Posts: 2182
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: InputProcess Type Enum work around

Post by phantombeta »

Don't copy the enums. The actual enums can be used just fine like so:
InputEvent.Type_KeyDown
UiEvent.Type_LButtonDown
peewee_RotA
Posts: 407
Joined: Fri Feb 07, 2014 6:45 am

Re: InputProcess Type Enum work around

Post by peewee_RotA »

I'll give that a shot.

I tried every version of those enums that I could find in the sourcecode with every combination of qualified classnames I could think of and all of them threw errors.

If there is an official list somewhere that is accessible it would be really cool to have it documented.
Post Reply

Return to “Scripting”