Repository: libsdl-org/SDL
File: src/joystick/hidapi/SDL_hidapi_gip.c (C)

Code before:
                    SDL_UCS4ToUTF8(0x0161, utf8);
                    break;
                case 156:
                    SDL_UCS4ToUTF8(0x0153, utf8);
                    break;
                default:
                    SDL_UCS4ToUTF8(attachment->altcode, utf8);
                    break;
                }
                SDL_SendKeyboardText(utf8);
            }
            attachment->altcode_digit = -1;
            SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, SDL_SCANCODE_NUMLOCKCLEAR, true);
            SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, SDL_SCANCODE_NUMLOCKCLEAR, false);
        }
    }

    if (!bytes[2] && attachment->last_key) {
        if (attachment->last_key == SDL_SCANCODE_CAPSLOCK) {
            attachment->capslock = !attachment->capslock;
        }
        SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, attachment->last_key, false);
        if (!(attachment->last_modifiers & 0xfd)) {
            SDL_Keycode keycode = SDL_GetKeymapKeycode(NULL,
                attachment->last_key,
                (attachment->last_modifiers & 0x02) || attachment->capslock ? SDL_KMOD_SHIFT : 0);
            if (keycode && keycode < 0x80) {
                char text[2] = { keycode };
                SDL_SendKeyboardText(text);
            }
        }
        attachment->last_key = 0;
    } else {
        SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, bytes[2], true);
        attachment->last_key = bytes[2];

        if ((modifiers & 0x04) && attachment->altcode_digit >= 0) {
            int digit = bytes[2] - SDL_SCANCODE_KP_1 + 1;
            if (digit < 1 || digit > 10) {
                attachment->altcode_digit = -1;
            } else {
                attachment->altcode_digit++;
                attachment->altcode *= 10;
                if (digit < 10) {
                    attachment->altcode += digit;
                }
            }
        }
    }

    attachment->last_modifiers = modifiers;

Review comment (suggestion):
Parens for clarity?
```suggestion
                ((attachment->last_modifiers & 0x02) || attachment->capslock) ? SDL_KMOD_SHIFT : 0);
```

Code after:
                case 154:
                    SDL_UCS4ToUTF8(0x0161, utf8);
                    break;
                case 156:
                    SDL_UCS4ToUTF8(0x0153, utf8);
                    break;
                default:
                    SDL_UCS4ToUTF8(attachment->altcode, utf8);
                    break;
                }
                SDL_SendKeyboardText(utf8);
            }
            attachment->altcode_digit = -1;
            SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, SDL_SCANCODE_NUMLOCKCLEAR, true);
            SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, SDL_SCANCODE_NUMLOCKCLEAR, false);
        }
    }

    if (!bytes[2] && attachment->last_key) {
        if (attachment->last_key == SDL_SCANCODE_CAPSLOCK) {
            attachment->capslock = !attachment->capslock;
        }
        SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, attachment->last_key, false);
        if (!(attachment->last_modifiers & 0xfd)) {
            SDL_Keycode keycode = SDL_GetKeymapKeycode(NULL,
                attachment->last_key,
                ((attachment->last_modifiers & 0x02) || attachment->capslock) ? SDL_KMOD_SHIFT : 0);
            if (keycode && keycode < 0x80) {
                char text[2] = { (char)keycode };
                SDL_SendKeyboardText(text);
            }
        }
        attachment->last_key = 0;
    } else {
        SDL_SendKeyboardKey(timestamp, attachment->keyboard, 0, bytes[2], true);
        attachment->last_key = bytes[2];

        if ((modifiers & 0x04) && attachment->altcode_digit >= 0) {
            int digit = bytes[2] - SDL_SCANCODE_KP_1 + 1;
            if (digit < 1 || digit > 10) {
                attachment->altcode_digit = -1;
            } else {
                attachment->altcode_digit++;
                attachment->altcode *= 10;
                if (digit < 10) {
                    attachment->altcode += digit;
                }
            }
        }
    }