Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting device input (mouse, keyboard ...) on LINUX

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.

like image 784
relaxxx Avatar asked Feb 21 '23 16:02

relaxxx


1 Answers

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.

like image 117
Kornel Kisielewicz Avatar answered Mar 02 '23 18:03

Kornel Kisielewicz