Page 1 of 1

InputProcess Type Enum work around

Posted: Thu Mar 14, 2024 6:05 am
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;

Re: InputProcess Type Enum work around

Posted: Thu Mar 14, 2024 6:10 am
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, // ???

Re: InputProcess Type Enum work around

Posted: Thu Mar 14, 2024 7:14 pm
by phantombeta
Don't copy the enums. The actual enums can be used just fine like so:
InputEvent.Type_KeyDown
UiEvent.Type_LButtonDown

Re: InputProcess Type Enum work around

Posted: Thu Mar 14, 2024 8:44 pm
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.