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.

82 lines
1.7 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Benjamin Litzelmann
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #pragma once
  11. namespace lol
  12. {
  13. /** Internal class (not public) that allows to construct an InputDevice
  14. * dynamically, when the keys, axis and cursors are not known at
  15. * compile time. */
  16. class InputDeviceInternal : InputDevice
  17. {
  18. public:
  19. inline InputDeviceInternal(char const * name) : InputDevice(name) { }
  20. void AddKey(int id, char const * name);
  21. inline void AddKey(char const * name)
  22. {
  23. AddKey(-1, name);
  24. }
  25. void AddAxis(int id, char const * name, float sensitivity = 1.0f);
  26. inline void AddAxis(char const * name, float sensitivity = 1.0f)
  27. {
  28. AddAxis(-1, name, sensitivity);
  29. }
  30. void AddCursor(int id, char const * name);
  31. inline void AddCursor(char const * name)
  32. {
  33. AddCursor(-1, name);
  34. }
  35. void SetKey(int id, bool state)
  36. {
  37. m_keys[id] = state;
  38. }
  39. void AddText(String const &text)
  40. {
  41. m_text += text;
  42. }
  43. void SetAxis(int id, float value)
  44. {
  45. m_axis[id].m1 = value;
  46. }
  47. void SetCursor(int id, vec2 const & position, ivec2 const & pixel)
  48. {
  49. m_cursors[id].m1 = position;
  50. m_cursors[id].m2 = pixel;
  51. }
  52. ivec2 GetCursorPixelPos(int id)
  53. {
  54. return m_cursors[id].m2;
  55. }
  56. static bool GetMouseCapture()
  57. {
  58. return m_capturemouse;
  59. }
  60. static InputDeviceInternal* CreateStandardKeyboard();
  61. static InputDeviceInternal* CreateStandardMouse();
  62. };
  63. } /* namespace lol */