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

67 行
1.4 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #pragma once
  13. //
  14. // The SdlInput class
  15. // ------------------
  16. //
  17. #include "engine/entity.h"
  18. #if LOL_USE_SDL
  19. # if HAVE_SDL2_SDL_H
  20. # include <SDL2/SDL.h>
  21. # elif HAVE_SDL_H
  22. # include <SDL.h>
  23. # endif
  24. #endif
  25. #include <memory>
  26. #include <vector>
  27. #include <tuple>
  28. namespace lol
  29. {
  30. class SdlInput : public entity
  31. {
  32. public:
  33. /** passing the screen resolution (note: not the windowed app resolution!) allows to make the mouse axis resolution-independent */
  34. SdlInput(int screen_w, int screen_h);
  35. virtual ~SdlInput();
  36. void SetScreenResolution();
  37. protected:
  38. virtual void tick_game(float seconds);
  39. virtual void tick_draw(float seconds, Scene &scene);
  40. private:
  41. void tick(float seconds);
  42. #if LOL_USE_SDL
  43. std::vector<std::tuple<SDL_Joystick *, std::shared_ptr<class input::device::joystick>>> m_joysticks;
  44. #endif
  45. vec2 m_app;
  46. vec2 m_screen;
  47. ivec2 m_prev_mouse_pos = ivec2::zero;
  48. bool m_mousecapture = false;
  49. bool m_tick_in_draw_thread = false;
  50. };
  51. } /* namespace lol */