Enigma 3.2.2
A Simple, Reliable and Efficient Encryption Tool
Loading...
Searching...
No Matches
KeyEvent.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef ENIGMA_KEY_EVENT_H
3#define ENIGMA_KEY_EVENT_H
4
5#include "Event.hpp"
6#include <Core/Core.hpp>
7#include <Core/Types.hpp>
9#include <sstream>
10
12
14class KeyEvent : public Event {
15 public:
16 KeyCode GetKeyCode() const noexcept { return m_key_code; }
17
19
20 protected:
21 explicit KeyEvent(const KeyCode keyCode)
22 : m_key_code(keyCode) {}
23
25};
26
28class KeyPressedEvent : public KeyEvent {
29 public:
30 KeyPressedEvent(const KeyCode keycode, const std::uint16_t repeat_count)
31 : KeyEvent(keycode),
32 m_repeat_count(repeat_count) {}
33
34 std::uint16_t GetRepeatCount() const noexcept { return m_repeat_count; }
35
36 std::string ToString() const override {
37 std::ostringstream ss;
38 ss << "KeyPressedEvent: " << m_key_code << " (" << m_repeat_count << " repeats)";
39 return ss.str();
40 }
41
43
44 private:
45 std::uint16_t m_repeat_count;
46};
47
49class KeyReleasedEvent : public KeyEvent {
50 public:
51 explicit KeyReleasedEvent(const KeyCode keyCode)
52 : KeyEvent(keyCode) {}
53
54 std::string ToString() const override {
55 std::ostringstream ss;
56 ss << "KeyReleasedEvent: " << m_key_code;
57 return ss.str();
58 }
59
61};
62
64class KeyTypedEvent : public KeyEvent {
65 public:
66 explicit KeyTypedEvent(const KeyCode keyCode)
67 : KeyEvent(keyCode) {}
68
69 std::string ToString() const override {
70 std::ostringstream ss;
71 ss << "KeyTypedEvent: " << m_key_code;
72 return ss.str();
73 }
74
76};
77
78
80
81#endif // !ENIGMA_KEY_EVENT_H
#define EVENT_CLASS_TYPE(type)
Definition Event.hpp:59
#define EVENT_CLASS_CATEGORY(category)
Definition Event.hpp:63
KeyCode
Definition KeyCodes.hpp:11
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition Macros.hpp:13
#define NS_ENIGMA_END
Definition Macros.hpp:14
KeyCode m_key_code
Definition KeyEvent.hpp:24
KeyCode GetKeyCode() const noexcept
Definition KeyEvent.hpp:16
KeyEvent(const KeyCode keyCode)
Definition KeyEvent.hpp:21
std::uint16_t GetRepeatCount() const noexcept
Definition KeyEvent.hpp:34
KeyPressedEvent(const KeyCode keycode, const std::uint16_t repeat_count)
Definition KeyEvent.hpp:30
std::string ToString() const override
Definition KeyEvent.hpp:36
KeyReleasedEvent(const KeyCode keyCode)
Definition KeyEvent.hpp:51
std::string ToString() const override
Definition KeyEvent.hpp:54
KeyTypedEvent(const KeyCode keyCode)
Definition KeyEvent.hpp:66
std::string ToString() const override
Definition KeyEvent.hpp:69