4

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.

asked Jan 30, 2012 at 13:08

3 Answers 3

5

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.

answered Jan 30, 2012 at 13:13
Sign up to request clarification or add additional context in comments.

2 Comments

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. SDL unfortunately need both of them to be in a same thread.
I don't know about such a restriction under SDL. Why do you think it exists? Try googling for 'sdl multithreading', there are tons of example programs that do just what you claim is impossible.
3

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.

answered Jan 30, 2012 at 22:43

Comments

0

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.

answered Jan 30, 2012 at 19:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.