GHOST: remove redundant ascii argument to GHOST_EventKey
Now only the utf8 buffer is used there is no reason to pass both.
This commit is contained in:
parent
eb3e56a36e
commit
cdd8b96e3b
|
@ -22,6 +22,7 @@ class GHOST_EventKey : public GHOST_Event {
|
|||
* \param msec: The time this event was generated.
|
||||
* \param type: The type of key event.
|
||||
* \param key: The key code of the key.
|
||||
* \param is_repeat: Enabled for key repeat events (only for press events).
|
||||
*/
|
||||
GHOST_EventKey(
|
||||
uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window, GHOST_TKey key, bool is_repeat)
|
||||
|
@ -38,15 +39,15 @@ class GHOST_EventKey : public GHOST_Event {
|
|||
* \param msec: The time this event was generated.
|
||||
* \param type: The type of key event.
|
||||
* \param key: The key code of the key.
|
||||
* \param ascii: The ascii code for the key event.
|
||||
* \param is_repeat: Enabled for key repeat events (only for press events).
|
||||
* \param utf8_buf: The text associated with this key event (only for press events).
|
||||
*/
|
||||
GHOST_EventKey(uint64_t msec,
|
||||
GHOST_TEventType type,
|
||||
GHOST_IWindow *window,
|
||||
GHOST_TKey key,
|
||||
char ascii,
|
||||
const char utf8_buf[6],
|
||||
bool is_repeat)
|
||||
bool is_repeat,
|
||||
const char utf8_buf[6])
|
||||
: GHOST_Event(msec, type, window)
|
||||
{
|
||||
m_keyEventData.key = key;
|
||||
|
@ -56,11 +57,6 @@ class GHOST_EventKey : public GHOST_Event {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1779,7 +1779,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||
NSString *characters;
|
||||
NSData *convertedCharacters;
|
||||
GHOST_TKey keyCode;
|
||||
unsigned char ascii;
|
||||
NSString *charsIgnoringModifiers;
|
||||
|
||||
window = m_windowManager->getWindowAssociatedWithOSWindow((void *)[event window]);
|
||||
|
@ -1789,7 +1788,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||
}
|
||||
|
||||
char utf8_buf[6] = {'\0'};
|
||||
ascii = 0;
|
||||
|
||||
switch ([event type]) {
|
||||
|
||||
|
@ -1809,7 +1807,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||
kUCKeyActionUp);
|
||||
}
|
||||
|
||||
/* handling both unicode or ascii */
|
||||
characters = [event characters];
|
||||
if ([characters length] > 0) {
|
||||
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
@ -1835,41 +1832,31 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
|||
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSEventModifierFlagCommand))
|
||||
break; // Cmd-Q is directly handled by Cocoa
|
||||
|
||||
/* ascii is a subset of unicode */
|
||||
if (utf8_buf[0] && !utf8_buf[1]) {
|
||||
ascii = utf8_buf[0];
|
||||
}
|
||||
|
||||
if ([event type] == NSEventTypeKeyDown) {
|
||||
pushEvent(new GHOST_EventKey([event timestamp] * 1000,
|
||||
GHOST_kEventKeyDown,
|
||||
window,
|
||||
keyCode,
|
||||
ascii,
|
||||
utf8_buf,
|
||||
[event isARepeat]));
|
||||
[event isARepeat],
|
||||
utf8_buf));
|
||||
#if 0
|
||||
printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
|
||||
printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
|
||||
[event keyCode],
|
||||
[charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
|
||||
' ',
|
||||
keyCode,
|
||||
ascii,
|
||||
ascii,
|
||||
utf8_buf);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
pushEvent(new GHOST_EventKey(
|
||||
[event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL, false));
|
||||
[event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, false, NULL));
|
||||
#if 0
|
||||
printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
|
||||
printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
|
||||
[event keyCode],
|
||||
[charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
|
||||
' ',
|
||||
keyCode,
|
||||
ascii,
|
||||
ascii,
|
||||
utf8_buf);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -608,8 +608,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
|
|||
utf8_buf[0] = convert_keyboard_event_to_ascii(sdl_sub_evt);
|
||||
}
|
||||
|
||||
g_event = new GHOST_EventKey(
|
||||
getMilliSeconds(), type, window, gkey, '\0', utf8_buf, is_repeat);
|
||||
g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, is_repeat, utf8_buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2257,8 +2257,8 @@ static void keyboard_handle_key(void *data,
|
|||
|
||||
if (wl_surface *focus_surface = input->keyboard.wl_surface) {
|
||||
GHOST_IWindow *win = ghost_wl_surface_user_data(focus_surface);
|
||||
input->system->pushEvent(new GHOST_EventKey(
|
||||
input->system->getMilliSeconds(), etype, win, gkey, '\0', utf8_buf, false));
|
||||
input->system->pushEvent(
|
||||
new GHOST_EventKey(input->system->getMilliSeconds(), etype, win, gkey, false, utf8_buf));
|
||||
}
|
||||
|
||||
/* An existing payload means the key repeat timer is reset and will be added again. */
|
||||
|
@ -2290,9 +2290,8 @@ static void keyboard_handle_key(void *data,
|
|||
GHOST_kEventKeyDown,
|
||||
win,
|
||||
payload->key_data.gkey,
|
||||
'\0',
|
||||
utf8_buf,
|
||||
true));
|
||||
true,
|
||||
utf8_buf));
|
||||
}
|
||||
};
|
||||
input->key_repeat.timer = input->system->installTimer(
|
||||
|
|
|
@ -1256,9 +1256,8 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
|
|||
keyDown ? GHOST_kEventKeyDown : GHOST_kEventKeyUp,
|
||||
window,
|
||||
key,
|
||||
ascii,
|
||||
utf8_char,
|
||||
is_repeat);
|
||||
is_repeat,
|
||||
utf8_char);
|
||||
|
||||
// GHOST_PRINTF("%c\n", ascii); // we already get this info via EventPrinter
|
||||
}
|
||||
|
|
|
@ -745,9 +745,8 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
|
|||
GHOST_kEventKeyDown,
|
||||
window,
|
||||
ghost_key_from_keysym(modifiers[i]),
|
||||
'\0',
|
||||
nullptr,
|
||||
false));
|
||||
false,
|
||||
nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1206,8 +1205,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
}
|
||||
}
|
||||
|
||||
g_event = new GHOST_EventKey(
|
||||
getMilliSeconds(), type, window, gkey, '\0', utf8_buf, is_repeat);
|
||||
g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, is_repeat, utf8_buf);
|
||||
|
||||
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
|
||||
/* when using IM for some languages such as Japanese,
|
||||
|
@ -1232,7 +1230,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
|
|||
pushEvent(g_event);
|
||||
|
||||
g_event = new GHOST_EventKey(
|
||||
getMilliSeconds(), type, window, gkey, '\0', &utf8_buf[i], is_repeat);
|
||||
getMilliSeconds(), type, window, gkey, is_repeat, &utf8_buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue