keyboard.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "common/common_types.h"
  5. #include "core/hle/service/hid/controllers/controller_base.h"
  6. #include "core/hle/service/hid/ring_lifo.h"
  7. namespace Core::HID {
  8. class EmulatedDevices;
  9. struct KeyboardModifier;
  10. struct KeyboardKey;
  11. } // namespace Core::HID
  12. namespace Service::HID {
  13. class Controller_Keyboard final : public ControllerBase {
  14. public:
  15. explicit Controller_Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_);
  16. ~Controller_Keyboard() override;
  17. // Called when the controller is initialized
  18. void OnInit() override;
  19. // When the controller is released
  20. void OnRelease() override;
  21. // When the controller is requesting an update for the shared memory
  22. void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
  23. private:
  24. // This is nn::hid::detail::KeyboardState
  25. struct KeyboardState {
  26. s64 sampling_number{};
  27. Core::HID::KeyboardModifier modifier{};
  28. Core::HID::KeyboardAttribute attribute{};
  29. Core::HID::KeyboardKey key{};
  30. };
  31. static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size");
  32. struct KeyboardSharedMemory {
  33. // This is nn::hid::detail::KeyboardLifo
  34. Lifo<KeyboardState, hid_entry_count> keyboard_lifo{};
  35. static_assert(sizeof(keyboard_lifo) == 0x3D8, "keyboard_lifo is an invalid size");
  36. INSERT_PADDING_WORDS(0xA);
  37. };
  38. static_assert(sizeof(KeyboardSharedMemory) == 0x400, "KeyboardSharedMemory is an invalid size");
  39. KeyboardState next_state{};
  40. KeyboardSharedMemory* shared_memory = nullptr;
  41. Core::HID::EmulatedDevices* emulated_devices = nullptr;
  42. };
  43. } // namespace Service::HID