Download

Returning out of ProcessMessage manually (without Engine Source)

We are developing for Windows touch devices and as such are registering two clicks/events from every touch, as from what we’ve read Unreal doesn’t officially support Windows touch (funnily enough even the Epic Launcher itself has this problem).
So we looked into blocking the second mouse event and tried doing that with a plugin:


virtual bool ProcessMessage(HWND Hwnd, uint32 Message, WPARAM WParam,
                         LPARAM LParam, int32& OutResult) override
    {
        if (Message == WM_LBUTTONUP || Message == WM_LBUTTONDOWN)
        {
            if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) {
                // Click was generated by wisptis / Windows Touch
                GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5.0f, FColor::Red,
                                                        TEXT("Input was Touch"));
                return true;
            }
            else {
                GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5.0f, FColor::Red,
                                                       TEXT("Input was Non-Touch"));
                // Click was generated by the mouse.
            }
        }
        return false;
    }

The problem is this only sets bMessageExternallyHandled in WindowsApplication.cpp to true:


    for (IWindowsMessageHandler* Handler : MessageHandlers)
        {
            int32 HandlerResult = 0;
            if (Handler->ProcessMessage(hwnd, msg, wParam, lParam, HandlerResult))
            {
                if (!bMessageExternallyHandled)
                {
                    bMessageExternallyHandled = true;
                    ExternalMessageHandlerResult = HandlerResult;
                }
            }
        }

But this bool is only used way in the end of a switch that checks the msg, so it’s only used if the msg doesn’t fit any other type (which being a touch event, it will).
What we would need it to do is to return out of the ProcessMessage function entirely.
And this used to be the case as we realized:


#if WINVER >= 0x0601
        // ORION - REMOVED FOR WACOM SUPPORT!
        /*
        if (IsFakeMouseInputMessage(msg))
        {
            return 0;
        }
        */
#endif

This IsFakeMouseInputMessage function basically does the same as our function, but as a result just returns 0 instead of just changing the bool.
Apparently Unreal broke Windows Touch support in favor of Wacom?

So really, we could now build the engine from source and just change this with one line and it would work for us…
but doing that for a one line change seems a bit of a hassle, does anyone know/have an idea of how to achieve this otherwise?