Unsupported keys in Qt on Android

  • Is there a way to add unsupported keys in Qt on Android. I have a game pad that generates android button events "a b x y", but in Qt the key value ends up being 0 (also the native scan code for all keys is 0 on Android). There is already an issues for this (https://bugreports.qt.io/browse/QTBUG-38190), but it doesn't look like it's going to get fixed anytime soon.

    Possible Solutions:

    1. If possible I would like to be able to add an unsupported key without touching the Qt's source code, but I don't believe Qt has a way to add unsupported keys without changing Qt's source code.

    2. Remap the keys in the QtActivit.java to KEYCODE_PROG_RED, KEYCODE_PROG_GREEN, KEYCODE_PROG_YELLOW and KEYCODE_PROG_BLUE. This will result in Qt::Key_Red, Qt::Key_Green, Qt::Key_Yellow, Qt::Key_Blue. I don't like this because the buttons are a b x y and not red, green, yellow, blue, but this will get me by.

    3. Do the same remapping, but in the androidjniinput.cpp and create a patch file. I like this even less because this will only work for the exact version of Qt. I will have to create new patch files for each version of Qt I use and it's still a work-around.

    4. Add the new keys to the Qt framework and update androidjniinput.cpp to use the new keys I added. This seems like the best approach, but I don't know the coding standards and guidelines for adding new keys to the Qt framework. If I did this I would want to do it the Qt way and submit a patch. Can someone post a link to documentation on how to add new keys to the Qt framework.

    Missing Keys:
    0x00000060: // KEYCODE_BUTTON_A
    0x00000061: // KEYCODE_BUTTON_B
    0x00000063: // KEYCODE_BUTTON_X
    0x00000064: // KEYCODE_BUTTON_Y

  • Hi. Instead of relying on Qt's key handling, maybe you could override the onKeyDown method from QtActivity and then implement your own handler for these special keys, calling your own native method. That way you would neither need to patch Qt nor remap the keys to misleading codes.

  • Lifetime Qt Champion


    Gerrit Introduction is the starting point for Qt Contribution. You can also check the videos of the Qt World Summit 2015. There was a talk about "your first contribution to Qt"

    Coding Style Guide for how to write the code.

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.