IOS/USB_KBD: Make the message type enum an enum class
Avoids polluting the surrounding scope with enum values. We can also make use of it in MessageData's constructor to enforce proper type passing.
This commit is contained in:
parent
d89ea8bf41
commit
7f5ca64c4d
|
@ -176,8 +176,9 @@ constexpr std::array<u8, 256> s_key_codes_azerty{};
|
|||
#endif
|
||||
} // Anonymous namespace
|
||||
|
||||
USB_KBD::MessageData::MessageData(u32 type, u8 modifiers, PressedKeyData pressed_keys)
|
||||
: MsgType{Common::swap32(type)}, Modifiers{modifiers}, PressedKeys{pressed_keys}
|
||||
USB_KBD::MessageData::MessageData(MessageType type, u8 modifiers, PressedKeyData pressed_keys)
|
||||
: MsgType{Common::swap32(static_cast<u32>(type))}, Modifiers{modifiers}, PressedKeys{
|
||||
pressed_keys}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -198,7 +199,7 @@ IPCCommandResult USB_KBD::Open(const OpenRequest& request)
|
|||
m_OldKeyBuffer.fill(false);
|
||||
m_OldModifiers = 0x00;
|
||||
|
||||
// m_MessageQueue.emplace(MSG_KBD_CONNECT, 0, PressedKeyData{});
|
||||
// m_MessageQueue.emplace(MessageType::KeyboardConnect, 0, PressedKeyData{});
|
||||
return Device::Open(request);
|
||||
}
|
||||
|
||||
|
@ -304,6 +305,6 @@ void USB_KBD::Update()
|
|||
}
|
||||
|
||||
if (GotEvent)
|
||||
m_MessageQueue.emplace(MSG_EVENT, Modifiers, PressedKeys);
|
||||
m_MessageQueue.emplace(MessageType::Event, Modifiers, PressedKeys);
|
||||
}
|
||||
} // namespace IOS::HLE::Device
|
||||
|
|
|
@ -26,11 +26,11 @@ public:
|
|||
void Update() override;
|
||||
|
||||
private:
|
||||
enum
|
||||
enum class MessageType : u32
|
||||
{
|
||||
MSG_KBD_CONNECT = 0,
|
||||
MSG_KBD_DISCONNECT = 1,
|
||||
MSG_EVENT = 2
|
||||
KeyboardConnect = 0,
|
||||
KeyboardDisconnect = 1,
|
||||
Event = 2
|
||||
};
|
||||
|
||||
using PressedKeyData = std::array<u8, 6>;
|
||||
|
@ -38,13 +38,13 @@ private:
|
|||
#pragma pack(push, 1)
|
||||
struct MessageData
|
||||
{
|
||||
u32 MsgType = 0;
|
||||
MessageType MsgType{};
|
||||
u32 Unk1 = 0;
|
||||
u8 Modifiers = 0;
|
||||
u8 Unk2 = 0;
|
||||
PressedKeyData PressedKeys{};
|
||||
|
||||
MessageData(u32 msg_type, u8 modifiers, PressedKeyData pressed_keys);
|
||||
MessageData(MessageType msg_type, u8 modifiers, PressedKeyData pressed_keys);
|
||||
};
|
||||
static_assert(std::is_trivially_copyable_v<MessageData>,
|
||||
"MessageData must be trivially copyable, as it's copied into emulated memory.");
|
||||
|
|
Loading…
Reference in New Issue