Keyboard input in Qt - linux

I am working on a Qt application running on embedded Linux. I am pretty new to this Qt business since I have just started it a month back, so understand that I'm not that object-oriented ... :P
I have the Qt applications running on my target running Linux. The Qt documentation http://doc.qt.io/archives/qt-4.7/qt-embedded-pointer.html says that we have to enable touchscreen, USB keyboard, keypad, etc. by exporting certain variables. Namely,
export QWS_MOUSE_PROTO=tslib:/dev/input/event1
export QWS_KEYBOARD="linuxinput:/dev/input/event0 usb:/dev/input/event2"
well, as you can guess, first line sets the mouse device in QT as touchscreen. "tslib" is the touchscreen library, and the "event1" is the node representing the touchscreen. Similarly, second line is for on-board keypad (event0), and USB keyboard (event2).
Now, the touchscreen work very well. But the problem is with either keyboard. If I do not export the second variable, namely QWS_KEYBOARD , then the application runs fine. But if I do export the second variable, the application goes into stopped state (SIGSTOP) as soon as it is launched. This is evident from ps output. I can not make it work with SIGCONT.
I am going to try and reconfigure Qt from source. Any thoughts are welcome.

Can not believe this but setting the QWS_KEYBOARD variable as null solved the problem.
Found it in the Qt developer FAQ http://developer.qt.nokia.com/faq/answer/why_doesnt_my_keyboard_work_after_i_have_done_an_export_qws_keyboard_dev_tt
export QWS_KEYBOARD=""
Well, it did not completely solve the problem since I still have to include the native keypad along with the USB keyboard.
Anyway, I am able to move to fields using the arrow/TAB keys. Text input works well. Although CAPS-LOCK and NUM-LOCK do not seem to work. SHIFT works. I am able to terminate the application by Ctrl+Alt+Bkspce. So, for the time being, I am able to input text at least.
Will post if any improvements.

Related

Developing a TV application

I have been trying to build a TV application, using an SD.
I have got features like image gallery, video player running,
However, I also wanted to add a virtual on-screen keyboard that works with up-down left-right arrow keys. Can somebody help me with how to get started?
When I wanted to do this with my Vestel (Polaroid Branded) smart TV, which uses "Opera for TV devices" as it's HbbTV browser, I found that I didn't need to.
I simply just used HTML text fields and input types where needed, and as soon as I clicked into them, the browser/OS kernel popped up an onscreen keyboard that was built in for me.
However, I did do some research to see if I needed it, and on some devices you do, whilst I never actually implemented it (My app was just for my own use) the "BBC Television Application Layer" (TAL for short) : https://github.com/bbc/tal had pretty good keyboard support.
Another one that might be worth looking at is "Mautilus SDK" : https://github.com/mautilus/sdk
Be aware though, both are horribly convoluted and use quite complex code where it's really not needed.

Embedded Qt Mouse Pointer Not Showing Up

I've got a bit of an interesting problem here. There are plenty of threads I've found where people are working to hide or get rid of a cursor on an embedded Qt GUI...but I'm trying to get a cursor to show up on an embedded Qt GUI.
I inherited a project that was 'finished' some time ago, and the person who did the most work on the project has moved on. Fast forward to today and there is a need to add a cursor to this functional touchscreen GUI. The system OS is Yocto Linux, and it is running a Qt 5.4 application on a framebuffer.
I've scoured the Qt code and there is nothing there that would hide a cursor. I've added in the appropriate QT_QPA_FB_HIDECURSOR=0 environment variable to my Qt startup script. I've experimented with adding a QCursor obejct to the GUI. Unfortunately none of these things are working. Using the QCusor I am sometimes able to get a cursor up on the screen, but isn't tied to the touch input (the cursor shows up at the position I programatically move it to, but it stays there when I interact with the GUI).
My touch input events are tied into Qt (via QT_QPA_GENERIC_PLUGINS=evdevtouch and QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event9:rotate=180), but for some reason that touch input cannot be tied to a cursor.
At this point I've spent a few days messing around with environment variables and startup script modifications, but nothing I've done has got the result I'm looking for.
Does anybody out there have some ideas on where to look for solutions to this problem?
Thanks!
Ian
So, now 3 months later I think my team and I just came up with a passable solution to this problem.
The path towards the solution started with the Qt Documentation on "Using libinput". The documentation boils down to a few important statements:
Parameters like the device node name can be set in the environment variables QT_QPA_EVDEV_MOUSE_PARAMETERS, QT_QPA_EVDEV_KEYBOARD_PARAMETERS and QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS
The mouse cursor shows up whenever QT_QPA_EGLFS_HIDECURSOR (for eglfs) or QT_QPA_FB_HIDECURSOR (for linuxfb) is not set and Qt's libudev-based device discovery reports that at least one mouse is available. When libudev support is not present, the mouse cursor always show up unless explicitly disabled via the environment variable.
The evdevtablet plugin provides basic support for Wacom and similar, pen-based tablets. It generates QTabletEvent events only. To enable it, pass QT_QPA_GENERIC_PLUGINS=evdevtablet in the environment or, alternatively, pass -plugin evdevtablet argument on the command-line. The plugin can take a device node parameter, for example QT_QPA_GENERIC_PLUGINS=evdevtablet:/dev/event1, in case the Qt's automatic device discovery (based either on libudev or a walkthrough of /dev/input/event*) is not functional or misbehaving.
So, in my system I have the device nodes: event0, event1, event2, event3, event4, event5, mice, and mouse0. Because I'm trying to get the mouse working, I made the assumption that I'd have to use the mouse0 node. This lead to me setting these environment variables:
QT_QPA_GENERIC_PLUGINS=evdevmouse
QT_QPA_EVDEV_MOUSE_PARAMETERS=/dev/input/mouse0
Much to my frustration these environment variables led to nothing. After some time my team and I figured out how to get debug output from Qt source on our system:
Modifying source code in the qtbase directory under our yocto build (roughly /yocto/poky/build/tmp/work/temp build directory/qtbase
Copying qtbase/plugins/generic/libqevdevmouseplugin.so to my hardware (roughly /usr/lib/qt5/plugins/generic)
Running Qt from the command line
We quickly discovered that the input events coming from mouse0 and mice were basically garbage data. On our system we did set up EVDEV in the kernel, so the mouse input was also tied to the device node event0. When we tried setting the Qt mouse parameter to event0 we started to see debug output that looked like real data.
QT_QPA_GENERIC_PLUGINS=evdevmouse
QT_QPA_EVDEV_MOUSE_PARAMETERS=/dev/input/event0
However, the problem of no-mouse-pointer still remained. After a while we looked back at the Qt Documentation, specifically at the 2nd paragraph listed above. As a last ditch attempt we tried adding in the QT_QPA_FB_HIDECURSOR environment variable...
QT_QPA_GENERIC_PLUGINS=evdevmouse
QT_QPA_EVDEV_MOUSE_PARAMETERS=/dev/input/event0
QT_QPA_FB_HIDECURSOR=0
And...voila! After countless hours of debugging and reading documentation, we finally got a mouse pointer.
I think the main crux of our issue was misinterpreting the Qt Documentation.
The mouse cursor shows up whenever ... QT_QPA_FB_HIDECURSOR (for linuxfb) is not set
By "not set", Qt means explicitly defined as FALSE...not simply "not set" at all.
This solution will work for us, but it does leave at least one thing to be desired. Along the way I stumbled across this thread answer on the Unix StackEx which points to the Kernel documentation of input/input.txt. In section "3.2.2 mousedev" you can see the line:
Each 'mouse' device is assigned to a single mouse or digitizer, except
the last one - 'mice'. This single character device is shared by all
mice and digitizers, and even if none are connected, the device is
present. This is useful for hotplugging USB mice, so that programs
can open the device even when no mice are present.
What this means for us is that while we can use event0 (which goes away when we unplug the mouse) for our mouse input event handling, we won't be able to support hot plugging without making some kernel/Qt-source modifications or figuring out how to get mice working as a Qt mouse input parameter.
So, the question of "why does event0 work and not mouse0/mice" still stands...but for now we've got a solution we can live with.
UPDATE: Now a little bit later we've figured out that udev was not working properly on our system. We added udev to the RDEPENDS in our package group for the Yocto build, and now we can set
QT_QPA_GENERIC_PLUGINS=evdevmouse
and we get a working mouse pointer with hotplug support.
I dont know if this applies to your problem (i dont use QT), but there is a
HAVE_TOUCHSCREEN=1 variable in the machconfig file. It is located normally in your BSP-layer in a recipes-bsp/formfactor/formfactor directory.
Setting this to 1 makes the cursor invisible.
Try setting it to 0

touch events in linux using Qt

I am trying to program touch events in linux using Qt. My touch screen works, however when I touch the screen I get mouse events rather than touch events. The mouse cursor moves to where I touch the screen. I don't know if it is a Qt problem or something that happens at the OS level.
I am using Qt 5.4.0 on Debian Jessie.
Since you did not share any source code, its hard to know what happens wrong on your side. Take a look at this documentation:
Detailed Description of QTouchEvent Class
Touch Input Examples
All that examples works well, and you need to test it on your side. If it will not work for you, it means that there are some problems on your side, otherwise, it mean that you forgot something in your application (like Qt::WA_AcceptTouchEvents attribute set, or not set to true the acceptTouchEvents attribute at graphics items...).

No keyboard input in Unity3D game builds

I'm using Unity3D and I'm having issues with the keyboard when I 'build' the project.
When I run the game within the Unity Editor, the input works fine. However, when I build the project and test it, I have no directional input whatsoever. The mouse works fine, the game registers keystrokes (the Esc key works), but the player won't move.
I'm using Input.GetAxisRaw("Vertical") and Input.GetAxisRaw("Horizontal")
I researched the issue on the web, but I'm still stucked. The only solution I found (in various links) mentions a problem with DirectInput and states that you should remove the key "Input" from [HKEY_CURRENT_USER\Software\Unity\Player], in the Windows registry, but that doesn't seem to work for me.
Has anybody else fought this problem? Any working solutions? Am I doing the registry trick wrong?
You should check out Input Manager in Edit->Project Settings-> Input. Have you tried using GetAxis instead of GetAxisRaw? I also suggest using, eg: Input.GetKey(KeyCode.A) and etc.
I've figured out what was troubling me.
Input.GetAxisRaw("Vertical") and Input.GetAxisRaw("Horizontal") were fine the whole time. Somehow, there was some code in the script that in the Editor worked just fine, but when running as standalone gave me a calculation equal to 0 (it depends on the Delta Time, so I assume that the Delta Time when running compiled is much smaller than when running in the Unity Editor) and thus the character didn't move at all.

Solaris 10 keyboard problem

Im runing Solaris 10 - but im having problems with the keyboard.
Instead of - i get /, and instead of y i get z, etc. I tried changing every option in the menu "Keyboard Behaviour". I also tried changing kmdconfig from xorg to xsun, but then the graphics goes all wild and ugly - although the keyboard works fine then. Also cant change resolution in xsun mode.
By the way, im runing Solaris from Vmware, but i doubt this has anything to do with this.
Leave the graphic environment to the console:
dtconfig -d
dtconfig -reset
Select the correct keyboard layout you use:
kbd -s
Load it:
loadkeys
Check the keys are working properly. If okay, enable the graphical environment again:
dtconfig -e
If that still works, make that choice persistent after a reboot by updating your eeprom. eg:
eeprom kbd-type=Spanish
This should be migrated to superuser.com
It seems that you are expecting a german keyboard layout but are getting a US layout - at least the differences you are seeing are differences between those layouts. I don't know where to change that in openSolaris, but maybe it helps you find the correct place to look. Whatever desktop environment that you are using, it should have a tool to change the keyboard layout, probably somewhere with the other internationalization settings.

Resources