gesture.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <cstring>
  5. #include "common/common_types.h"
  6. #include "core/core_timing.h"
  7. #include "core/hle/service/hid/controllers/gesture.h"
  8. namespace Service::HID {
  9. constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
  10. Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {}
  11. Controller_Gesture::~Controller_Gesture() = default;
  12. void Controller_Gesture::OnInit() {}
  13. void Controller_Gesture::OnRelease() {}
  14. void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
  15. std::size_t size) {
  16. shared_memory.header.timestamp = static_cast<s64>(core_timing.GetCPUTicks());
  17. shared_memory.header.total_entry_count = 17;
  18. if (!IsControllerActivated()) {
  19. shared_memory.header.entry_count = 0;
  20. shared_memory.header.last_entry_index = 0;
  21. return;
  22. }
  23. shared_memory.header.entry_count = 16;
  24. const auto& last_entry =
  25. shared_memory.gesture_states[static_cast<u64>(shared_memory.header.last_entry_index)];
  26. shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
  27. auto& cur_entry =
  28. shared_memory.gesture_states[static_cast<u64>(shared_memory.header.last_entry_index)];
  29. cur_entry.sampling_number = last_entry.sampling_number + 1;
  30. cur_entry.sampling_number2 = cur_entry.sampling_number;
  31. // TODO(ogniK): Update gesture states
  32. std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
  33. }
  34. void Controller_Gesture::OnLoadInputDevices() {}
  35. } // namespace Service::HID