jkuhlmann / gainput

Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch
http://gainput.johanneskuhlmann.de/
MIT License
858 stars 103 forks source link

integrate with SFML #57

Open Arthapz opened 6 years ago

Arthapz commented 6 years ago

Hi, how can i integrate Gainput with SFML, SFML expose only the Window ID, and how to integrate gainput event handling with sfml event Handling ?

RicoP commented 6 years ago

I guess you can just get the native window handle with GetActiveWindow

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646292(v=vs.85).aspx

Arthapz commented 6 years ago

Sorry, i forgot to specifying that i'm on Linux environnement (and SFML expose Window handle but not Display handle), i managed this issue by writting my own library that expose directly the natives event (on WinAPI / X11)

window::Event event;
#ifdef STORM_OS_LINUX
XEvent xevent;
while(m_window->pollEvent(event, &xevent)) {
    m_input_manager.HandleEvent(xevent);
#else
while(m_window->pollEvent(event)) {
#endif

but i think a solution to this issue can be useful for other peoples

(sorry for my english, this is not my primary language)