marnold's picture

Windows Touch Events in the GameWindow?

My efforts to integrate the Windows Multitouch events into the OpenTK gameWindow seem to be stalled out:

I was (finally) able to obtain the handle of the GameWindow so it could be and registered for touch events, but these WM_ events are then typically received in a WindowsProcedure override function in most Windows Form apps. This WndProc call associated with the GameWindow is not currently available for override, so the events are never received.

Has anyone succeeded in getting a windows touch event listener to work with the OpenTK GameWindow? Is there a simple workaround that I am missing?

This would be a nice feature to add to future OpenTK releases (i.e. available inputs = Mouse, Keyboard, Joystick AND Touch)

thanks,
-


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
glopes's picture

Sorry for the two year hiatus, but for reference, here's how to wrap a native IntPtr into a class that you can override WndProc with:
http://msdn.microsoft.com/en-us/library/system.windows.forms.nativewindow(v=vs.110).aspx

the Fiddler's picture

OpenTK.GameWindow does not use Windows.Forms. That is its raison d'être: WinForms are not suitable for real-time games because they perform memory allocations for every event they send. Move your mouse? You allocate memory. Touch a key? The same.

Touch events are planned for the next version (OpenTK 1.2). If you wish to help, please post an issue at https://github.com/opentk/opentk/issues, thanks!

glopes's picture

Great to hear about touch events on OpenTK 1.2!

About the OP's question: I may be wrong, but I was under the impression that the NativeWindow class worked for any Win32 window, not just Windows.Forms.

Since the OP mentioned that he was able to obtain the Win32 window handle for GameWindow, I think it's possible to override its WndProc that way... at least I was able to do this with other native windows, but to be fair I've never tried with OpenTK's GameWindow, so I have no idea whether it will work. It should in principle, though.

the Fiddler's picture

You can obtain the window handle via the GameWindow.WindowInfo.Handle property. If it's just a matter of overriding the wndproc, then this will work. This is obviously a windows-specific solution.

OpenTK already does this internally in WinRawInput.cs for WM_INPUT events, so it's simply a matter of adding a new case for WM_TOUCH in there. The advantage of doing this inside OpenTK is that you already have WinAPI bindings for pretty much everything you might need (no need to hunt down for DllImports), plus it would benefit everyone using the library.