guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#34978] Enable support for veyron chrombooks


From: Danny Milosavljevic
Subject: [bug#34978] Enable support for veyron chrombooks
Date: Wed, 3 Apr 2019 18:59:57 +0200

> BTW, if U-Boot and Depthcharge are able to install custom keymaps, it’d
> be nice to implement that support like commit
> 8d058e7b1b1a409d3d9cc29c5650a98db4e78783 does for GRUB.

Heh, I wish U-Boot did that, but it really doesn't:

/* Translate the scancode in ASCII */
static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
                                unsigned char modifier, int pressed)
{
        uint8_t keycode = 0;

        /* Key released */
        if (pressed == 0) {
                data->repeat_delay = 0;
                return 0;
        }

        if (pressed == 2) {
                data->repeat_delay++;
                if (data->repeat_delay < REPEAT_DELAY)
                        return 0;

                data->repeat_delay = REPEAT_DELAY;
        }

        /* Alphanumeric values */
        if ((scancode > 3) && (scancode <= 0x1d)) {
                keycode = scancode - 4 + 'a';

                if (data->flags & USB_KBD_CAPSLOCK)
                        keycode &= ~CAPITAL_MASK;

                if (modifier & (LEFT_SHIFT | RIGHT_SHIFT)) {
                        /* Handle CAPSLock + Shift pressed simultaneously */
                        if (keycode & CAPITAL_MASK)
                                keycode &= ~CAPITAL_MASK;
                        else
                                keycode |= CAPITAL_MASK;
                }
        }

        if ((scancode > 0x1d) && (scancode < 0x39)) {
                /* Shift pressed */
                if (modifier & (LEFT_SHIFT | RIGHT_SHIFT))
                        keycode = usb_kbd_numkey_shifted[scancode - 0x1e];
                else
                        keycode = usb_kbd_numkey[scancode - 0x1e];
        }

        /* Arrow keys */
        if ((scancode >= 0x4f) && (scancode <= 0x52))
                keycode = usb_kbd_arrow[scancode - 0x4f];

        /* Numeric keypad */
        if ((scancode >= 0x54) && (scancode <= 0x67))
                keycode = usb_kbd_num_keypad[scancode - 0x54];

        if (data->flags & USB_KBD_CTRL)
                keycode = scancode - 0x3;

        if (pressed == 1) {
                if (scancode == NUM_LOCK) {
                        data->flags ^= USB_KBD_NUMLOCK;
                        return 1;
                }

                if (scancode == CAPS_LOCK) {
                        data->flags ^= USB_KBD_CAPSLOCK;
                        return 1;
                }
                if (scancode == SCROLL_LOCK) {
                        data->flags ^= USB_KBD_SCROLLLOCK;
                        return 1;
                }
        }

        /* Report keycode if any */
        if (keycode) {
                debug("%c", keycode);
                usb_kbd_put_queue(data, keycode);
        }

        return 0;
}

Attachment: pgpIZLe2bpbYU.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]