您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

88 行
2.0 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2017—2019 Sam Hocevar <sam@hocevar.net>
  5. // © 2010—2015 Benjamin Litzelmann
  6. //
  7. // Lol Engine is free software. It comes without any warranty, to
  8. // the extent permitted by applicable law. You can redistribute it
  9. // and/or modify it under the terms of the Do What the Fuck You Want
  10. // to Public License, Version 2, as published by the WTFPL Task Force.
  11. // See http://www.wtfpl.net/ for more details.
  12. //
  13. #pragma once
  14. #include <string>
  15. namespace lol
  16. {
  17. /** Internal class (not public) that allows to construct an InputDevice
  18. * dynamically, when the keys, axis and cursors are not known at
  19. * compile time. */
  20. class InputDeviceInternal : public InputDevice
  21. {
  22. public:
  23. inline InputDeviceInternal(std::string const& name) : InputDevice(name) { }
  24. void AddKey(int id, char const * name);
  25. inline void AddKey(char const * name)
  26. {
  27. AddKey(-1, name);
  28. }
  29. void AddAxis(int id, char const * name, float sensitivity = 1.0f);
  30. inline void AddAxis(char const * name, float sensitivity = 1.0f)
  31. {
  32. AddAxis(-1, name, sensitivity);
  33. }
  34. void AddCursor(int id, char const * name);
  35. inline void AddCursor(char const * name)
  36. {
  37. AddCursor(-1, name);
  38. }
  39. void SetCursor(int id, vec2 const & position, ivec2 const & pixel)
  40. {
  41. m_cursors[id].m1 = position;
  42. m_cursors[id].m2 = pixel;
  43. }
  44. ivec2 GetCursorPixelPos(int id)
  45. {
  46. return m_cursors[id].m2;
  47. }
  48. /* Internal functions for the platform-specific drivers. */
  49. void internal_set_key(int id, bool state)
  50. {
  51. m_keys[id] = state;
  52. }
  53. void internal_add_text(std::string const &text)
  54. {
  55. m_text += text;
  56. }
  57. void internal_set_axis(int id, float value)
  58. {
  59. m_axis[id].m1 = value;
  60. }
  61. static bool GetMouseCapture()
  62. {
  63. return m_capturemouse;
  64. }
  65. static InputDeviceInternal* CreateStandardKeyboard();
  66. static InputDeviceInternal* CreateStandardMouse();
  67. };
  68. } /* namespace lol */