Reputation: 7824
I am building cross-platform game engine and now I am focused on Input system.
I have written an abstract Input system which passes the messages up and is beeing fed by platform dependent modules, running in separate thread.
In windows I have created "Message-only" window, which feed Input system with messages (translated to platform independent) from RAWINPUT.
Now I am having troubles to figure out how to do similar thing on unix based system. Is there any convenient way to get input (keyup, keydown, mousemove...) from kernel? Or any other way without need showing any window?
EDIT
I do not want to my Input System be dependent on my Renderer. Renderer should just notify input when app focus changed... So I want Input system to run on different thread than renderer.
Upvotes: 4
Views: 5666
Reputation: 52085
Assuming you're using X11:
Peter Hutterer has a series of XInput2 articles. Supports raw events apparently.
ManyMouse claims to use XInput2 without a window:
- On Unix systems, we try to use the XInput2 extension if possible. ManyMouse will try to fallback to other approaches if there is no X server available or the X server doesn't support XInput2. If you want to use the XInput2 target, make sure you link with "-ldl", since we use dlopen() to find the X11/XInput2 libraries. You do not have to link against Xlib directly, and ManyMouse will fail gracefully (reporting no mice in the ManyMouse XInput2 driver) if the libraries don't exist on the end user's system. Naturally, you'll need the X11 headers on your system (on Ubuntu, you would want to apt-get install libxi-dev). You can build with SUPPORT_XINPUT2 defined to zero to disable XInput2 support completely. Please note that the XInput2 target does not need your app to supply an X11 window. The test_manymouse_stdio app works with this target, so long as the X server is running. Please note that the X11 DGA extension conflicts with XInput2 (specifically: SDL might use it). This is a good way to deal with this in SDL 1.2:
Might be worth looking through the source.
Upvotes: 3
Reputation: 119847
Under X Window system there is a concept of input-only windows, which is more or less parallel to that of message-only window under Windows.
Upvotes: 0
Reputation: 57545
Usually cross-platform input is achieved by using a wrapper library -- SDL is one that is pretty good at that, and the current version is even BSD licenced.
The advantages of using a wrapper are so big, that even Windows games that use their own solution on Windows tend to use SDL as a wrapper when running on Linux (that was the original reason SDL was created).
So in the worst case, you may keep your libraries on Windows, and use SDL for implementation specifically on *nix systems.
Upvotes: 5