diff options
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_Types.h | 11 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventKey.h | 13 | ||||
-rw-r--r-- | intern/ghost/test/multitest/EventToBuf.c | 6 |
3 files changed, 13 insertions, 17 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 2fc84349eb9..fa74bfde866 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -547,17 +547,6 @@ typedef struct { /** The key code. */ GHOST_TKey key; - /* ascii / utf8: both should always be set when possible, - * - ascii may be '\0' however if the user presses a non ascii key - * - unicode may not be set if the system has no unicode support - * - * These values are intended to be used as follows. - * For text input use unicode when available, fallback to ascii. - * For areas where unicode is not needed, number input for example, always - * use ascii, unicode is ignored - campbell. - */ - /** The ascii code for the key event ('\0' if none). */ - char ascii; /** The unicode character. if the length is 6, not NULL terminated if all 6 are set. */ char utf8_buf[6]; diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h index 1c3156c27d2..d3cfbbeddd7 100644 --- a/intern/ghost/intern/GHOST_EventKey.h +++ b/intern/ghost/intern/GHOST_EventKey.h @@ -28,7 +28,6 @@ class GHOST_EventKey : public GHOST_Event { : GHOST_Event(msec, type, window) { m_keyEventData.key = key; - m_keyEventData.ascii = '\0'; m_keyEventData.utf8_buf[0] = '\0'; m_keyEventData.is_repeat = is_repeat; m_data = &m_keyEventData; @@ -51,11 +50,17 @@ class GHOST_EventKey : public GHOST_Event { : GHOST_Event(msec, type, window) { m_keyEventData.key = key; - m_keyEventData.ascii = ascii; - if (utf8_buf) + if (utf8_buf) { memcpy(m_keyEventData.utf8_buf, utf8_buf, sizeof(m_keyEventData.utf8_buf)); - else + } + else { m_keyEventData.utf8_buf[0] = '\0'; + } + /* TODO(@campbellbarton): phase out `ascii` and always use `utf8_buf`, this needs to be done + * on all platforms though, so for now write the ascii into the utf8_buf. */ + if (m_keyEventData.utf8_buf[0] == '\0' && ascii) { + m_keyEventData.utf8_buf[0] = ascii; + } m_keyEventData.is_repeat = is_repeat; m_data = &m_keyEventData; } diff --git a/intern/ghost/test/multitest/EventToBuf.c b/intern/ghost/test/multitest/EventToBuf.c index baab32328c3..846a867a371 100644 --- a/intern/ghost/test/multitest/EventToBuf.c +++ b/intern/ghost/test/multitest/EventToBuf.c @@ -218,8 +218,10 @@ void event_to_buf(GHOST_EventHandle evt, char buf[128]) case GHOST_kEventKeyUp: { GHOST_TEventKeyData *kd = data; pos += sprintf(pos, " - key: %s (%d)", keytype_to_string(kd->key), kd->key); - if (kd->ascii) - pos += sprintf(pos, " ascii: '%c' (%d)", kd->ascii, kd->ascii); + /* TODO: ideally this would print the unicode character. */ + if (kd->utf8_buf[0]) { + pos += sprintf(pos, " ascii: '%c' (%d)", kd->utf8_buf[0], kd->utf8_buf[0]); + } break; } } |