You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

inputhandler.h 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: inputhandler.h
  5. *
  6. * Description: Passes input to an inputbridge
  7. *
  8. * Version: 1.0
  9. * Created: 03/28/2014 06:19:01 PM
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: YOUR NAME (),
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #pragma once
  19. #include <SDL2/SDL.h>
  20. #include <map>
  21. #include "nano_signal_slot.hpp"
  22. namespace vtk {
  23. struct ActionIdentifier {
  24. SDL_Keycode keyCode; //Key code
  25. unsigned mouseCode; //Mouse button code
  26. bool mouse; //Is mouse button?
  27. };
  28. class InputHandler {
  29. public:
  30. void update();
  31. bool isActionDown(const std::string& action);
  32. bool setAction(const std::string& actionName, const std::string& actionButton);
  33. Nano::signal<void()>& getEventSignal(const Uint32& type);
  34. protected:
  35. std::map<std::string, ActionIdentifier> actions;
  36. std::map<Uint32, Nano::signal<void()> > events; //SDL Event type handling
  37. Uint32 mouseButtons;
  38. const Uint8* keys;
  39. SDL_Event event;
  40. Sint32 mMouseXRel;
  41. Sint32 mMouseYRel;
  42. };
  43. }