BsMacOSKeyboard.cpp 937 B

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