dolphin/Source/Core/Common/Keyboard.h
Sepalani 49a7dce956 IOS/KBD: Move keyboard logic to Common/Keyboard
The keypress loop was simplified and its keyboard state buffer removed.

KeyboardContext helper class added.
2026-02-05 12:26:38 +04:00

52 lines
904 B
C++

// Copyright 2026 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <memory>
#include "Common/CommonTypes.h"
namespace Common
{
enum
{
KBD_LAYOUT_QWERTY = 0,
KBD_LAYOUT_AZERTY = 1
};
using HIDPressedKeys = std::array<u8, 6>;
struct HIDPressedState
{
u8 modifiers = 0;
HIDPressedKeys pressed_keys{};
auto operator<=>(const HIDPressedState&) const = default;
};
class KeyboardContext
{
public:
~KeyboardContext();
static std::shared_ptr<KeyboardContext> GetInstance();
HIDPressedState GetPressedState() const;
private:
KeyboardContext();
void Init();
void Quit();
bool IsVirtualKeyPressed(int virtual_key) const;
u8 PollHIDModifiers() const;
HIDPressedKeys PollHIDPressedKeys() const;
void UpdateLayout();
bool m_is_ready = false;
int m_keyboard_layout = KBD_LAYOUT_QWERTY;
};
} // namespace Common