mtouch
The mtouch service starts the resource managers for touch functionality and loads the configuration
Syntax:
mtouch [-c configfile] [-d] [-q queuebool] [-r] [-U user] [-v]
Runs on:
QNX OS
Options:
- -c configfile
-
Specify the location of the configuration file for
mtouch
resource manager (driver). If you don't specify the -c option,mtouch
uses /etc/system/config/mtouch.conf as the default. - -d
- Enable debug mode. This allows you run this driver without having the service running. Using this option is useful if you function in verbose mode and want to see the slog2info with the coordinate information from the touch driver.
- -q
- Disable event queue for touch. This means that you won't see any touch events when you touch the display. By default, this is set to 1(enabled). To disable the event queue, set it 0 (zero).
- -r
-
Enable resource managers so that you can access information associated with touch events without using the
Screen API. For example:
... mtouch -rd ls /dev/mtouch/ touch_display0
This information that's associated with the touch driver (e.g., touch_display0) is presented as a data structure of type mtouch_event_t. The information includes:
- event type
- timestamp
- sequence identifier
- contact identifier
- x coordinate
- y coordinate
- width
- height
- orientation
- pressure
- contact type
- selected buttons
To retrieve the touch event information, you can open resource manager and read the file descriptor. For example:
... int fd, nCount; mtouch_event_t touch_packet; ... fd = open("/dev/mtouch/touch_display0", O_RDWR | O_NONBLOCK); ... while(1) { nCount = read(fd, &touch_packet, sizeof(touch_packet)); if (0 >= nCount) { delay (100); } else { printf("Timestamp: %llu Sequence ID: %u Contact ID:%d X:%u, Y:%u Event: ", touch_packet.timestamp, touch_packet.seq_id, touch_packet.contact_id, touch_packet.x, touch_packet.y); switch (touch_packet.event_type) { case INPUT_EVENT_MTOUCH_TOUCH: printf("Touch event.\n"); break; case INPUT_EVENT_MTOUCH_MOVE: printf("Move event.\n"); break; case INPUT_EVENT_MTOUCH_RELEASE: printf("Release event.\n"); break; default: printf("Other...\n"); break; } } } return 0; ...
- -v
- Enable verbose mode. In this mode, per-event coordinates are printed that
include the x, y coordinates of the input region
and the coordinates that are mapped to the display. In addition, the width
and height relate to the size of the touched area, provided the hardware supports it.
For example, a 1 represents a small area (such as a pinkie finger) as opposed to a
larger area, such as a thumb.
Here's what an event looks like where the user provided touch input
at coordinates (around 20 (x-value) and 400 (y-value)) on the display:
Nov 09 15:38:16 5 9 200 touch_display[INFO]: x 21 y 400 width 1 height 1 Nov 09 15:38:16 5 9 200 touch_display[INFO]: x 22 y 410 width 1 height 1 Nov 09 15:38:16 5 9 200 touch_display[INFO]: x 19 y 413 width 1 height 1 Nov 09 15:38:16 5 9 200 touch_display[INFO]: x 23 y 402 width 1 height 1 Nov 09 15:38:16 5 9 200 touch_display[INFO]: x 20 y 401 width 1 height 1
Description:
The mtouch service starts the touch drivers that are specified in the mtouch.conf file. To run this service, you must first have Screen started. Other dependencies may vary based on your touch device.
Examples:
Use a Human Interface Device (HID) that uses a USB-based controller:
-
You need to ensure that the shared objects and configuration files that mtouch depends on are included in your system image. For example:
- libmtouch-hid.so.1
- scaling.conf
- mtouch.conf
See the
Shared libraries
section of the Building Embedded Systems guide for more information on how to determine which shared objects you need. -
On your target system, you typically require the USB drivers to be started before touch can be used. For example:
io-usb-otg -d hcd-dm816x-mg ioport=0x47401c00,irq=19
-
Start screen.
screen
-
Start mtouch.
mtouch