MouseLinux.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2024 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Input/Mouse.h>
  6. /// Mouse interface class, keeps track of the mouse button state and of the absolute and relative movements of the mouse.
  7. class MouseLinux : public Mouse
  8. {
  9. public:
  10. /// Constructor
  11. MouseLinux();
  12. virtual ~MouseLinux() override;
  13. /// Initialization / shutdown
  14. virtual bool Initialize(ApplicationWindow *inWindow) override;
  15. virtual void Shutdown() override;
  16. /// Update the mouse state
  17. virtual void Poll() override;
  18. virtual int GetX() const override { return mX; }
  19. virtual int GetY() const override { return mY; }
  20. virtual int GetDX() const override { return mDX; }
  21. virtual int GetDY() const override { return mDY; }
  22. virtual bool IsLeftPressed() const override { return mLeftPressed; }
  23. virtual bool IsRightPressed() const override { return mRightPressed; }
  24. virtual bool IsMiddlePressed() const override { return mMiddlePressed; }
  25. virtual void HideCursor() override;
  26. virtual void ShowCursor() override;
  27. private:
  28. void Reset();
  29. Display * mDisplay;
  30. Window mWindow;
  31. int mX;
  32. int mY;
  33. int mDX;
  34. int mDY;
  35. bool mLeftPressed;
  36. bool mRightPressed;
  37. bool mMiddlePressed;
  38. };