mouse.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/mouse.h"
  8. namespace Service::HID {
  9. constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
  10. Controller_Mouse::Controller_Mouse() = default;
  11. Controller_Mouse::~Controller_Mouse() = default;
  12. void Controller_Mouse::OnInit() {}
  13. void Controller_Mouse::OnRelease() {}
  14. void Controller_Mouse::OnUpdate(u8* data, std::size_t size) {
  15. shared_memory.header.timestamp = CoreTiming::GetTicks();
  16. shared_memory.header.total_entry_count = 17;
  17. if (!IsControllerActivated()) {
  18. shared_memory.header.entry_count = 0;
  19. shared_memory.header.last_entry_index = 0;
  20. return;
  21. }
  22. shared_memory.header.entry_count = 16;
  23. auto& last_entry = shared_memory.mouse_states[shared_memory.header.last_entry_index];
  24. shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
  25. auto& cur_entry = shared_memory.mouse_states[shared_memory.header.last_entry_index];
  26. cur_entry.sampling_number = last_entry.sampling_number + 1;
  27. cur_entry.sampling_number2 = cur_entry.sampling_number;
  28. // TODO(ogniK): Update mouse states
  29. std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
  30. }
  31. void Controller_Mouse::OnLoadInputDevices() {}
  32. } // namespace Service::HID