BsInputHandlerOIS.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include "BsOISPrerequisites.h"
  3. #include "BsRawInputHandler.h"
  4. #include <OIS/OISEvents.h>
  5. #include <OIS/OISInputManager.h>
  6. #include <OIS/OISKeyboard.h>
  7. #include <OIS/OISMouse.h>
  8. namespace BansheeEngine
  9. {
  10. /**
  11. * @brief Raw input handler using OIS library for acquiring input.
  12. */
  13. class BS_OIS_EXPORT InputHandlerOIS : public RawInputHandler, public OIS::KeyListener, public OIS::MouseListener
  14. {
  15. public:
  16. InputHandlerOIS(unsigned int hWnd);
  17. virtual ~InputHandlerOIS();
  18. private:
  19. /**
  20. * @brief Called by OIS whenever a keyboard button is pressed.
  21. */
  22. virtual bool keyPressed(const OIS::KeyEvent& arg);
  23. /**
  24. * @brief Called by OIS whenever a keyboard button is released.
  25. */
  26. virtual bool keyReleased(const OIS::KeyEvent& arg);
  27. /**
  28. * @brief Called by OIS whenever mouse is moved.
  29. */
  30. virtual bool mouseMoved(const OIS::MouseEvent& arg);
  31. /**
  32. * @brief Called by OIS whenever is a mouse button pressed.
  33. */
  34. virtual bool mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id);
  35. /**
  36. * @brief Called by OIS whenever is a mouse button released
  37. */
  38. virtual bool mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id);
  39. /**
  40. * @brief Called once per frame.
  41. *
  42. * @note Internal method.
  43. */
  44. virtual void _update();
  45. /**
  46. * @brief Called whenever the currently focused window changes.
  47. *
  48. * @note Internal method.
  49. */
  50. virtual void _inputWindowChanged(const RenderWindow& win);
  51. /**
  52. * @brief Converts an OIS key code into engine button code.
  53. */
  54. ButtonCode keyCodeToButtonCode(OIS::KeyCode keyCode) const;
  55. /**
  56. * @brief Converts an OIS mouse button code into engine button code.
  57. */
  58. ButtonCode mouseButtonToButtonCode(OIS::MouseButtonID mouseBtn) const;
  59. private:
  60. OIS::InputManager* mInputManager;
  61. OIS::Mouse* mMouse;
  62. OIS::Keyboard* mKeyboard;
  63. UINT64 mTimestampClockOffset;
  64. };
  65. }