keyboard.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/common_types.h"
  5. #include "common/swap.h"
  6. #include "core/core_timing.h"
  7. #include "core/hle/service/hid/controllers/keyboard.h"
  8. namespace Service::HID {
  9. constexpr size_t SHARED_MEMORY_OFFSET = 0x3800;
  10. void Controller_Keyboard::OnInit() {}
  11. void Controller_Keyboard::OnRelease() {}
  12. void Controller_Keyboard::OnUpdate(u8* data, size_t size) {
  13. shared_memory.header.timestamp = CoreTiming::GetTicks();
  14. shared_memory.header.total_entry_count = 17;
  15. if (!IsControllerActivated()) {
  16. shared_memory.header.entry_count = 0;
  17. shared_memory.header.last_entry_index = 0;
  18. return;
  19. }
  20. shared_memory.header.entry_count = 16;
  21. auto& last_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
  22. shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
  23. auto& cur_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
  24. cur_entry.sampling_number = last_entry.sampling_number + 1;
  25. cur_entry.sampling_number2 = cur_entry.sampling_number;
  26. // TODO(ogniK): Update keyboard states
  27. std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
  28. }
  29. void Controller_Keyboard::OnLoadInputDevices() {}
  30. }; // namespace Service::HID