xpad.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_funcs.h"
  6. #include "common/common_types.h"
  7. #include "common/swap.h"
  8. #include "core/hle/service/hid/controllers/controller_base.h"
  9. namespace Service::HID {
  10. class Controller_XPad final : public ControllerBase {
  11. public:
  12. explicit Controller_XPad(Core::System& system);
  13. ~Controller_XPad() override;
  14. // Called when the controller is initialized
  15. void OnInit() override;
  16. // When the controller is released
  17. void OnRelease() override;
  18. // When the controller is requesting an update for the shared memory
  19. void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, std::size_t size) override;
  20. // Called when input devices should be loaded
  21. void OnLoadInputDevices() override;
  22. private:
  23. struct AnalogStick {
  24. s32_le x;
  25. s32_le y;
  26. };
  27. static_assert(sizeof(AnalogStick) == 0x8, "AnalogStick is an invalid size");
  28. struct XPadState {
  29. s64_le sampling_number;
  30. s64_le sampling_number2;
  31. s32_le attributes;
  32. u32_le pad_states;
  33. AnalogStick x_stick;
  34. AnalogStick y_stick;
  35. };
  36. static_assert(sizeof(XPadState) == 0x28, "XPadState is an invalid size");
  37. struct XPadEntry {
  38. CommonHeader header;
  39. std::array<XPadState, 17> pad_states{};
  40. INSERT_PADDING_BYTES(0x138);
  41. };
  42. static_assert(sizeof(XPadEntry) == 0x400, "XPadEntry is an invalid size");
  43. struct SharedMemory {
  44. std::array<XPadEntry, 4> shared_memory_entries{};
  45. };
  46. static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
  47. SharedMemory shared_memory{};
  48. Core::System& system;
  49. };
  50. } // namespace Service::HID