Wednesday, February 11, 2015

SFML & 3DMouse support with 3DConnexionSDK

How to make 3DMouse support in a SFML project?

The problem with SFML is that the windows event layer is wrapped for multi-platform issues.
The problem with the 3DConnexion SDK is that it uses internal windows event messages, that should be processed by GetMessage() or PollMEssage()

So you can't have access to SFML internal poll event without changing the source code, and you can't use GetMessage or PollMessage as shown in the 3DConnexion SDK sample codes.

I've found a solution with Windows Callback.

First set the callback with SetWindowsHookEx

SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)&SpaceNavigatorCB, GetModuleHandle(NULL), GetCurrentThreadId()) == NULL
The callback should be prototyped like this :

LRESULT CALLBACK SpaceNavigatorCB(int code, WPARAM wParam, LPARAM lParam)

Complete code for the callback :


Hope it helps !

Follow the project on Facebook : https://www.facebook.com/immersionengine
Follow me on twitter : twitter.com/lefebv_l

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.