Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved Unsupported keys in Qt on Android

    Mobile and Embedded
    android game buttons game keys keys
    3
    3
    1131
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bundickt last edited by

      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

      1 Reply Last reply Reply Quote 1
      • L
        Leonardo last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • First post
            Last post