Use Key enum instead of plain integers

This commit is contained in:
Aaron Franke
2021-06-20 13:12:33 -04:00
parent 18bd0fee5a
commit fa3a32a2d6
43 changed files with 173 additions and 102 deletions

View File

@@ -34,6 +34,7 @@
#include "core/input/input_enums.h"
#include "core/io/resource.h"
#include "core/math/transform_2d.h"
#include "core/os/keyboard.h"
#include "core/string/ustring.h"
#include "core/typedefs.h"
@@ -163,8 +164,8 @@ class InputEventKey : public InputEventWithModifiers {
bool pressed = false; /// otherwise release
uint32_t keycode = 0; ///< check keyboard.h , KeyCode enum, without modifier masks
uint32_t physical_keycode = 0;
Key keycode = KEY_NONE; // Key enum, without modifier masks.
Key physical_keycode = KEY_NONE;
uint32_t unicode = 0; ///unicode
bool echo = false; /// true if this is an echo key
@@ -176,11 +177,11 @@ public:
void set_pressed(bool p_pressed);
virtual bool is_pressed() const override;
void set_keycode(uint32_t p_keycode);
uint32_t get_keycode() const;
void set_keycode(Key p_keycode);
Key get_keycode() const;
void set_physical_keycode(uint32_t p_keycode);
uint32_t get_physical_keycode() const;
void set_physical_keycode(Key p_keycode);
Key get_physical_keycode() const;
void set_unicode(uint32_t p_unicode);
uint32_t get_unicode() const;
@@ -199,7 +200,7 @@ public:
virtual String as_text() const override;
virtual String to_string() override;
static Ref<InputEventKey> create_reference(uint32_t p_keycode_with_modifier_masks);
static Ref<InputEventKey> create_reference(Key p_keycode_with_modifier_masks);
InputEventKey() {}
};