Search code examples
c++boostevent-handlingsignalsboost-signals2

Boost Signals2: How do I register events such as mouse clicks and key presses?


I'm working on a game at the moment, and I'm planning on using the signals2 library for event handling in C++.

However, I don't understand how it all fits together, as I'm wanting to have events such as "on key press" and "on mouse click", as well as things like incoming connections on sockets. How do I register these events? It seems that this library is used for this type of thing, but nothing online seems to give any hint on how to do these types of event handling.


Solution

  • This sounds like a job for a global hook. See Hooks Overview. or Check this out: https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx

    You are looking, in particular for the WM_KEYBOARD hook.