BsMacOSMouse.cpp 907 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Input/BsMouse.h"
  4. #include "Input/BsInput.h"
  5. #include "MacOS/BsMacOSInput.h"
  6. namespace bs
  7. {
  8. /** Contains private data for the MacOS Mouse implementation. */
  9. struct Mouse::Pimpl
  10. {
  11. explicit Pimpl(Input* owner)
  12. :hid(HIDType::Mouse, owner)
  13. { }
  14. HIDManager hid;
  15. bool hasInputFocus = true;
  16. };
  17. Mouse::Mouse(const String& name, Input* owner)
  18. : mName(name), mOwner(owner)
  19. {
  20. m = bs_new<Pimpl>(owner);
  21. }
  22. Mouse::~Mouse()
  23. {
  24. bs_delete(m);
  25. }
  26. void Mouse::capture()
  27. {
  28. m->hid.capture(nullptr, !m->hasInputFocus);
  29. }
  30. void Mouse::changeCaptureContext(UINT64 windowHandle)
  31. {
  32. m->hasInputFocus = windowHandle != (UINT64)-1;
  33. }
  34. }