[vlc-devel] [PATCH] Small change to let other keyboard layouts have hotkeys

Militaru Cristian cristipiticul at gmail.com
Wed Jan 11 18:54:01 CET 2012


Hello!

You asked why my patch (replacing "uint32_t i_vlck = 0;" with "uint32_t
i_vlck = qtk;") would do as expected. Here's my answer :D:

okay, here's the whole function:

int qtEventToVLCKey( QKeyEvent *e )
{
    int qtk = e->key();
    uint32_t i_vlck = qtk;

    if( qtk <= 0xff )
    {
        /* VLC and X11 use lowercase whereas Qt uses uppercase, this
         * method should be equal to towlower in case of latin1 */
        if( qtk >= 'A' && qtk <= 'Z' ) i_vlck = qtk+32;
        else if( qtk >= 0xC0 && qtk <= 0xDE && qtk != 0xD7) i_vlck = qtk+32;
        else i_vlck = qtk;
    }
    else
    {
        const vlc_qt_key_t *map;

        map = (const vlc_qt_key_t *)
              bsearch( &qtk, (const void *)keys,
sizeof(keys)/sizeof(keys[0]),
                       sizeof(*keys), keycmp );
        if( map != NULL )
            i_vlck = map->vlc;
    }

    /* Handle modifiers */
    i_vlck |= qtKeyModifiersToVLC( e );
    return i_vlck;
}

okay, if it's about other keyboard layouts, I've seen a key code equal to
1065 ( key "A" in Uzbek or Russian keyboard layout - found it using gdb
./vlc and other debugging stuff). If you look there, if a key has a bigger
code than 0xff and it can't be found in the vlc map of keys, it wouldn't
change at all. So if it's initialized with 0 and the key is in another
encoding, the function will say that I pressed no key, so it would put
"Unset" in the hotkey table. If I initialize it with the key I actually
pressed, it would return the key code which I pressed and the shortcut
would be set correctly. As far as I've tested, it works correctly.

Thank you for your response.

Cristian Militaru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120111/4685ee74/attachment.html>


More information about the vlc-devel mailing list