C
Handling keyboard input
If the system has a keyboard, you can send key events to the application using PlatformInterface::handleKeyEvent() with Qul::EventQueue. The Qt Quick Ultralite engine passes key events to the application for further prosessing, without interpreting them. Any visual QML item in the application can receive key events, see Keys QML Type for more information.
Here is an example that sends key press event:
struct KeyboardEvent { uint64_t timestamp; Qul::PlatformInterface::KeyEventType type; int key; unsigned int nativeScanCode; unsigned int modifiers; uint32_t ucs4; bool autorepeat; }; class PlatformKeyboardEventQueue : public Qul::EventQueue<KeyboardEvent> { void onEvent(const KeyboardEvent &event) QUL_DECL_OVERRIDE { // Use the information stored in the custom struct shown above // to transfer the information into the Qul engine Qul::PlatformInterface::handleKeyEvent(event.timestamp, event.type, event.key, event.nativeScanCode, event.modifiers, NULL, event.autorepeat, event.ucs4); } }; static PlatformKeyboardEventQueue keyboardEventQueue; void keyboardISR() { // Here would be platform specific code to fetch data from the keyboard. static KeyboardEvent event; event.timestamp = Qul::Platform::getPlatformInstance()->currentTimestamp(); event.type = Qul::PlatformInterface::KeyPressEvent; event.key = Qul::PlatformInterface::Key_A; event.nativeScanCode = 0; event.modifiers = Qul::PlatformInterface::NoKeyboardModifier; event.ucs4 = 0x61; event.autorepeat = false; keyboardEventQueue.postEventFromInterrupt(event); }
Note: Qt Quick Ultralite forwards only the key event type, key code, and native scan code to the application. The additional arguments shown in this example are not forwarded.
Available under certain Qt licenses.
Find out more.