summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2021-06-20 13:12:33 -0400
committerAaron Franke <arnfranke@yahoo.com>2021-08-10 16:26:55 -0500
commitfa3a32a2d6b054543645b0d4752514c90732b935 (patch)
treef3ba2c2543431c356ba0eca13d5be9a3e42daedd /platform/osx
parent18bd0fee5a8aa360177cbe14a16d6be69f088d8f (diff)
Use Key enum instead of plain integers
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/display_server_osx.h2
-rw-r--r--platform/osx/display_server_osx.mm18
2 files changed, 10 insertions, 10 deletions
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 6b1b777224..06b14f1c14 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -85,7 +85,7 @@ public:
bool pressed = false;
bool echo = false;
bool raw = false;
- uint32_t keycode = 0;
+ Key keycode = KEY_NONE;
uint32_t physical_keycode = 0;
uint32_t unicode = 0;
};
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 974f4d3018..cc8400980a 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -585,7 +585,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
ke.pressed = true;
ke.echo = false;
ke.raw = false; // IME input event
- ke.keycode = 0;
+ ke.keycode = KEY_NONE;
ke.physical_keycode = 0;
ke.unicode = codepoint;
@@ -928,9 +928,9 @@ static bool isNumpadKey(unsigned int key) {
// Translates a OS X keycode to a Godot keycode
//
-static int translateKey(unsigned int key) {
+static Key translateKey(unsigned int key) {
// Keyboard symbol translation table
- static const unsigned int table[128] = {
+ static const Key table[128] = {
/* 00 */ KEY_A,
/* 01 */ KEY_S,
/* 02 */ KEY_D,
@@ -1070,7 +1070,7 @@ static int translateKey(unsigned int key) {
struct _KeyCodeMap {
UniChar kchar;
- int kcode;
+ Key kcode;
};
static const _KeyCodeMap _keycodes[55] = {
@@ -1131,7 +1131,7 @@ static const _KeyCodeMap _keycodes[55] = {
{ '/', KEY_SLASH }
};
-static int remapKey(unsigned int key, unsigned int state) {
+static Key remapKey(unsigned int key, unsigned int state) {
if (isNumpadKey(key)) {
return translateKey(key);
}
@@ -3271,7 +3271,7 @@ void DisplayServerOSX::_process_key_events() {
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
+ k->set_physical_keycode((Key)ke.physical_keycode);
k->set_unicode(ke.unicode);
_push_input(k);
@@ -3284,8 +3284,8 @@ void DisplayServerOSX::_process_key_events() {
_get_key_modifier_state(ke.osx_state, k);
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
- k->set_keycode(0);
- k->set_physical_keycode(0);
+ k->set_keycode(KEY_NONE);
+ k->set_physical_keycode(KEY_NONE);
k->set_unicode(ke.unicode);
_push_input(k);
@@ -3298,7 +3298,7 @@ void DisplayServerOSX::_process_key_events() {
k->set_pressed(ke.pressed);
k->set_echo(ke.echo);
k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
+ k->set_physical_keycode((Key)ke.physical_keycode);
if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) {
k->set_unicode(key_event_buffer[i + 1].unicode);