BsMacOSGamepad.cpp 967 B

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