Is anyone able to map usb touch input to specific displays with the weston/wayland container using udev rules or any other method.
I have two displays connected to imx8mp via HDMIs(J15 and J16) on yavia board running torizon os 6.x.x. On my host OS I have weston vivante container running where I want to receive touch inputs for my application from two usb input.
Now, what’s happening is the touch from both the input devices is getting mapped to primary display in the weston extend mode. So even if I’m touching on secondary screen the input is received on primary display which should have been received on secondary display. Is there any solution for this issue?
Greetings @Sudharshan,
I’ve been doing some research on this topic. From what I’ve seen it appears that Weston/Wayland does not have any touch device to display mapping features: Touchscreen - ArchWiki
The general suggestion online seems to be to use an alternative Wayland compositor like Sway, which does support touch-display mapping. That said we haven’t done much experimentation with Sway in our containers since we use Weston as our default compositor. So I can’t comment too much on how well it will work.
That said I’ve also asked internally on this topic to see if there are any other things I’m missing. Though at least for the time-being this does seem to be a limitation of Weston.
Best Regards,
Jeremias
Hi @jeremias.tx ,
Thanks for the response. Indeed, as of now weston/wayland doesn’t have the functionality to map touch to display like we have in x11 with xinput.
JFYI I’m not much aware of yocto build environment, If I had to use sway compositor where should I start from, do I need a full fledge yocto build or I can have a new container on the existing torizon os, where I have installed sway. Just like there’s a weston-wayland container, can I have my custom sway-wayland container?
I tried installing sway with apt on the base debian container provided by toradex, the libraries got installed but there was some display error.
OR,
Is it possible to run a container/os with X11 on imx8mp, with xinput, I believe it can easily fulfil my requirement of having dual-display and having respective usb touch input mapping for them.
Regards
JFYI I’m not much aware of yocto build environment, If I had to use sway compositor where should I start from, do I need a full fledge yocto build or I can have a new container on the existing torizon os, where I have installed sway. Just like there’s a weston-wayland container, can I have my custom sway-wayland container?
Well there’s a lot of unknowns here and potential problems. First of all I don’t believe there has been any extensive testing with Sway on our systems, so I can’t even gurantee how well this would work.
Next, the Weston we use is not just the common Weston. We use the forked weston-imx
from NXP that has been modified to support NXP hardware. I don’t believe there is a Sway equivalent for this. Even if we do get Sway installed, there’s a high chance there will still be issues with getting proper graphics output.
Is it possible to run a container/os with X11 on imx8mp, with xinput, I believe it can easily fulfil my requirement of having dual-display and having respective usb touch input mapping for them.
It might be possible, but NXP does not support direct X11 on their i.MX8* chips and have no plans to. So we run into the issue again of going into unsupported territory where things are likely to break or not work.
A colleague of mine had an idea. It is possible to create a udev rule for touchscreens for the purpose of calibrating them: Static device configuration via udev — libinput 1.25.0 documentation
Maybe it’s possible to “incorrectly” calibrate a device by creating a calibration value that shifts the touch input of the 2nd touch device to the 2nd display. This is just a theory at best and not something anyone’s tried. But I’m not seeing much other options unless you want to venture into testing unsupported software.
Best Regards,
Jeremias
Just wanted to share something I found recently. It seems it might be possible to map touch devices to screens with the right udev rule as seen here: https://web.archive.org/web/20201112030845/https://wiki.tizen.org/IVI/Mapping_multiple_touchscreen_Wayland
Best Regards,
Jeremias
So my udev rules directory looks something like this
torizon@verdin-imx8mp-14753765:/etc/udev/rules.d$ ls
10-imx.rules 90-toradex-gpio.rules 92-toradex-spidev.rules 94-toradex-pwm.rules bootpart-automount.rules touchscreen.rules
10-toradex-net-rename.rules 91-toradex-i2cdev.rules 93-toradex-backlight.rules 99-toradex.rules multi-touch.rules
By default, touchscreen.rules was a pre-existing file I thought with which I can enforce the WL_OUTPUT rules
So I’ve added the rules as below
ENV{ID_VENDOR_ID}=="222A",ENV{ID_MODEL_ID}=="0001",DEVPATH=="/devices/platform/soc@0/32f10108.usb/38200000.usb/xhci-hcd.1.auto/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0/0003:222A:0001.0005",ENV{WL_OUTPUT}="HDMI-A-1"
ENV{ID_VENDOR_ID}=="222A",ENV{ID_MODEL_ID}=="0001",DEVPATH=="/devices/platform/soc@0/32f10108.usb/38200000.usb/xhci-hcd.1.auto/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0/0003:222A:0001.0004",ENV{WL_OUTPUT}="HDMI-A-2"
Expecting USB input to be mapped to displays named HDMI-A-1 HDMI-A-2 respectively. But its not working, I wonder how I can verify if the weston compositor is reading my rules correctly, or how exactly does the weston compositor will read various files under udev. What should I name my rule file? I created a new file named multi-touch-rules mentioned on that article as well but that’s not working.
Switching VT tty1 to text mode if currently in graphics mode
Switching to VT 7
SoC is: 'i.MX8MP'
SoC has GPU: true
SoC has DPU: false
g2d implementation: viv
Removing previously created '.X*-lock' entries under /tmp before starting Weston. Pass 'IGNORE_X_LOCKS=1' environment variable to Weston container to disable this behavior.
dos2unix: converting file /etc/xdg/weston/weston.ini to Unix format...
dos2unix: converting file /etc/xdg/weston-dev/weston.ini to Unix format...
00:00:00.000 [INFO] [seatd/seat.c:39] Created VT-bound seat seat0
00:00:00.000 [INFO] [seatd/seatd.c:194] seatd started
Date: 2024-02-23 UTC
[12:30:53.244] weston 10.0.1
https://wayland.freedesktop.org
Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Build: lf-5.15.52-2.1.0-10-g9452feba
[12:30:53.244] Command line: weston -Bdrm-backend.so --current-mode -Swayland-0
[12:30:53.244] OS: Linux, 5.15.129-6.4.0+git.67c3153d20ff, #1-TorizonCore SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023, aarch64
[12:30:53.244] Flight recorder: enabled
[12:30:53.247] Using config file '/etc/xdg/weston/weston.ini'
[12:30:53.248] Output repaint window is 7 ms maximum.
[12:30:53.250] Loading module '/usr/lib/aarch64-linux-gnu/libweston-10/drm-backend.so'
[12:30:53.289] initializing drm backend
[12:30:53.289] Trying libseat launcher...
00:00:00.121 [INFO] [seatd/server.c:145] New client connected (pid: 30, uid: 1000, gid: 1000)
00:00:00.121 [INFO] [seatd/seat.c:170] Added client 7 to seat0
00:00:00.121 [INFO] [seatd/seat.c:480] Opened client 7 on seat0
[12:30:53.290] libseat: session control granted
[12:30:53.295] using /dev/dri/card0
[12:30:53.295] DRM: supports atomic modesetting
[12:30:53.295] DRM: does not support GBM modifiers
[12:30:53.295] DRM: supports picture aspect ratio
[12:30:53.296] Loading module '/usr/lib/aarch64-linux-gnu/libweston-10/gl-renderer.so'
[12:30:53.341] EGL client extensions: EGL_EXT_client_extensions
EGL_EXT_platform_base EGL_KHR_platform_wayland
EGL_EXT_platform_wayland EGL_EXT_device_query
EGL_EXT_device_drm EGL_EXT_device_drm_render_node
EGL_KHR_platform_gbm
[12:30:53.347] EGL device extensions: EGL_EXT_client_extensions
EGL_EXT_platform_base EGL_KHR_platform_wayland
EGL_EXT_platform_wayland EGL_EXT_device_query
EGL_EXT_device_drm EGL_EXT_device_drm_render_node
EGL_KHR_platform_gbm
[12:30:53.347] EGL version: 1.5
[12:30:53.347] EGL vendor: Vivante Corporation
[12:30:53.347] EGL client APIs: OpenGL_ES OpenGL OpenVG
[12:30:53.347] EGL extensions: EGL_KHR_fence_sync EGL_KHR_reusable_sync
EGL_KHR_wait_sync EGL_KHR_image EGL_KHR_image_base
EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image
EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image
EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_lock_surface
EGL_KHR_create_context EGL_KHR_no_config_context
EGL_KHR_surfaceless_context EGL_KHR_get_all_proc_addresses
EGL_EXT_create_context_robustness EGL_EXT_protected_surface
EGL_EXT_protected_content EGL_EXT_buffer_age
EGL_ANDROID_native_fence_sync EGL_WL_bind_wayland_display
EGL_WL_create_wayland_buffer_from_image EGL_KHR_partial_update
EGL_EXT_swap_buffers_with_damage
EGL_KHR_swap_buffers_with_damage EGL_EXT_pixel_format_float
[12:30:53.347] EGL_KHR_surfaceless_context available
[12:30:53.367] GL version: OpenGL ES 3.1 V6.4.3.p4.398061
[12:30:53.367] GLSL version: OpenGL ES GLSL ES 3.10
[12:30:53.367] GL vendor: Vivante Corporation
[12:30:53.367] GL renderer: Vivante GC7000UL
[12:30:53.368] GL extensions: GL_OES_vertex_type_10_10_10_2
GL_OES_vertex_half_float GL_OES_element_index_uint
GL_OES_mapbuffer GL_OES_vertex_array_object
GL_OES_compressed_ETC1_RGB8_texture
GL_OES_compressed_paletted_texture GL_OES_texture_npot
GL_OES_rgb8_rgba8 GL_OES_depth_texture
GL_OES_depth_texture_cube_map GL_OES_depth24 GL_OES_depth32
GL_OES_packed_depth_stencil GL_OES_fbo_render_mipmap
GL_OES_get_program_binary GL_OES_fragment_precision_high
GL_OES_standard_derivatives GL_OES_EGL_image
GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3
GL_OES_EGL_sync GL_OES_texture_stencil8
GL_OES_shader_image_atomic
GL_OES_texture_storage_multisample_2d_array
GL_OES_required_internalformat GL_OES_surfaceless_context
GL_OES_draw_buffers_indexed GL_OES_texture_border_clamp
GL_OES_texture_buffer GL_OES_texture_cube_map_array
GL_OES_draw_elements_base_vertex GL_OES_texture_half_float
GL_OES_texture_float GL_KHR_blend_equation_advanced
GL_KHR_debug GL_KHR_robustness
GL_KHR_robust_buffer_access_behavior
GL_EXT_texture_type_2_10_10_10_REV
GL_EXT_texture_compression_dxt1 GL_EXT_texture_format_BGRA8888
GL_EXT_texture_compression_s3tc GL_EXT_read_format_bgra
GL_EXT_multi_draw_arrays GL_EXT_frag_depth
GL_EXT_discard_framebuffer GL_EXT_blend_minmax
GL_EXT_multisampled_render_to_texture
GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float
GL_EXT_robustness GL_EXT_texture_sRGB_decode
GL_EXT_draw_buffers_indexed GL_EXT_texture_border_clamp
GL_EXT_texture_buffer GL_EXT_texture_cube_map_array
GL_EXT_multi_draw_indirect GL_EXT_draw_elements_base_vertex
GL_EXT_texture_rg GL_EXT_protected_textures GL_EXT_sRGB
GL_EXT_unpack_subimage GL_VIV_direct_texture
[12:30:53.438] GL ES 3.1 - renderer features:
read-back format: BGRA
EGL Wayland extension: yes
[12:30:53.472] event1 - gpio-keys: is tagged by udev as: Keyboard
[12:30:53.472] event1 - gpio-keys: device is a keyboard
[12:30:53.476] event0 - 30370000.snvs:snvs-powerkey: is tagged by udev as: Keyboard
[12:30:53.476] event0 - 30370000.snvs:snvs-powerkey: device is a keyboard
[12:30:53.482] event2 - PixArt USB Optical Mouse: is tagged by udev as: Mouse
[12:30:53.483] event2 - PixArt USB Optical Mouse: device is a pointer
[12:30:53.560] event3 - ILITEK ILITEK-TP: is tagged by udev as: Touchscreen
[12:30:53.560] event3 - ILITEK ILITEK-TP: device is a touch device
[12:30:53.568] event4 - ILITEK ILITEK-TP Mouse: is tagged by udev as: Mouse
[12:30:53.569] event4 - ILITEK ILITEK-TP Mouse: device is a pointer
[12:30:53.650] event5 - ILITEK ILITEK-TP: is tagged by udev as: Touchscreen
[12:30:53.650] event5 - ILITEK ILITEK-TP: device is a touch device
[12:30:53.658] event6 - ILITEK ILITEK-TP Mouse: is tagged by udev as: Mouse
[12:30:53.659] event6 - ILITEK ILITEK-TP Mouse: device is a pointer
[12:30:53.663] event7 - audio-hdmi HDMI Jack: is tagged by udev as: Switch
[12:30:53.743] event7 - not using input device '/dev/input/event7'
[12:30:53.788] libinput: configuring device "gpio-keys".
[12:30:53.788] libinput: configuring device "30370000.snvs:snvs-powerkey".
[12:30:53.788] libinput: configuring device "PixArt USB Optical Mouse".
[12:30:53.788] Touchscreen - ILITEK ILITEK-TP - /sys/devices/platform/soc@0/32f10108.usb/38200000.usb/xhci-hcd.1.auto/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.0/0003:222A:0001.0002/input/input10/event3
[12:30:53.788] libinput: configuring device "ILITEK ILITEK-TP".
[12:30:53.788] input device event3 has no enabled output associated (none named), skipping calibration for now.
[12:30:53.788] libinput: configuring device "ILITEK ILITEK-TP Mouse".
[12:30:53.788] input device event4 has no enabled output associated (none named), skipping calibration for now.
[12:30:53.788] Touchscreen - ILITEK ILITEK-TP - /sys/devices/platform/soc@0/32f10108.usb/38200000.usb/xhci-hcd.1.auto/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0/0003:222A:0001.0003/input/input13/event5
[12:30:53.788] libinput: configuring device "ILITEK ILITEK-TP".
[12:30:53.788] input device event5 has no enabled output associated (none named), skipping calibration for now.
[12:30:53.788] libinput: configuring device "ILITEK ILITEK-TP Mouse".
[12:30:53.788] input device event6 has no enabled output associated (none named), skipping calibration for now.
[12:30:54.128] DRM: head 'HDMI-A-1' updated, connector 38 is connected, EDID make 'LEN', model 'LEN L1950wD', serial 'B3432845'
[12:30:54.128] DRM: head 'HDMI-A-1' found, connector 38 is connected, EDID make 'LEN', model 'LEN L1950wD', serial 'B3432845'
[12:30:54.262] DRM: head 'HDMI-A-2' updated, connector 40 is connected, EDID make 'LEN', model 'LEN L1950wD', serial 'B3432845'
[12:30:54.263] DRM: head 'HDMI-A-2' found, connector 40 is connected, EDID make 'LEN', model 'LEN L1950wD', serial 'B3432845'
[12:30:54.263] Registered plugin API 'weston_drm_output_api_v1' of size 24
[12:30:54.263] Registered plugin API 'weston_drm_virtual_output_api_v1' of size 48
[12:30:54.263] Color manager: no-op
[12:30:54.264] Module '/usr/lib/libgbm.so' already loaded
[12:30:54.264] Output 'HDMI-A-1' using color profile: built-in default sRGB SDR profile
[12:30:54.265] Chosen EGL config details: id: 21 rgba: 8 8 8 0 buf: 24 dep: 0 stcl: 0 int: 1-60 type: win|pix|pbf|swap_preserved vis_id: XRGB8888 (0x34325258)
[12:30:54.265] Output HDMI-A-1 (crtc 33) video modes:
1024x768@60.0, preferred, current, 65.0 MHz
1920x1080@60.0 16:9, 148.5 MHz
1920x1080@59.9 16:9, 148.4 MHz
1920x1080@50.0, 148.5 MHz
1920x1080@50.0 16:9, 148.5 MHz
1280x1024@75.0, 135.0 MHz
1280x1024@60.0, 108.0 MHz
1440x900@75.0, 136.8 MHz
1440x900@59.9, 88.8 MHz
1280x720@60.0, 74.2 MHz
1280x720@60.0 16:9, 74.2 MHz
1280x720@59.9 16:9, 74.2 MHz
1280x720@50.0, 74.2 MHz
1280x720@50.0 16:9, 74.2 MHz
1024x768@75.0, 78.8 MHz
1024x768@70.1, 75.0 MHz
832x624@74.6, 57.3 MHz
800x600@75.0, 49.5 MHz
800x600@72.2, 50.0 MHz
800x600@60.3, 40.0 MHz
800x600@56.2, 36.0 MHz
720x576@50.0, 27.0 MHz
720x576@50.0 4:3, 27.0 MHz
720x576@50.0 16:9, 27.0 MHz
720x480@60.0 4:3, 27.0 MHz
720x480@60.0 16:9, 27.0 MHz
720x480@59.9 4:3, 27.0 MHz
720x480@59.9 16:9, 27.0 MHz
640x480@75.0, 31.5 MHz
640x480@72.8, 31.5 MHz
640x480@60.0 4:3, 25.2 MHz
640x480@59.9, 25.2 MHz
720x400@70.1, 28.3 MHz
[12:30:54.266] associating input device event1 with output HDMI-A-1 (none by udev)
[12:30:54.266] associating input device event0 with output HDMI-A-1 (none by udev)
[12:30:54.266] associating input device event2 with output HDMI-A-1 (none by udev)
[12:30:54.266] associating input device event3 with output HDMI-A-1 (none by udev)
[12:30:54.267] associating input device event4 with output HDMI-A-1 (none by udev)
[12:30:54.268] associating input device event5 with output HDMI-A-1 (none by udev)
[12:30:54.269] associating input device event6 with output HDMI-A-1 (none by udev)
[12:30:54.270] Output 'HDMI-A-1' enabled with head(s) HDMI-A-1
[12:30:54.270] Module '/usr/lib/libgbm.so' already loaded
[12:30:54.270] Output 'HDMI-A-2' using color profile: built-in default sRGB SDR profile
[12:30:54.271] Chosen EGL config details: id: 21 rgba: 8 8 8 0 buf: 24 dep: 0 stcl: 0 int: 1-60 type: win|pix|pbf|swap_preserved vis_id: XRGB8888 (0x34325258)
[12:30:54.271] Output HDMI-A-2 (crtc 36) video modes:
1024x768@60.0, preferred, current, 65.0 MHz
1920x1080@60.0 16:9, 148.5 MHz
1920x1080@59.9 16:9, 148.4 MHz
1920x1080@50.0, 148.5 MHz
1920x1080@50.0 16:9, 148.5 MHz
1280x1024@75.0, 135.0 MHz
1280x1024@60.0, 108.0 MHz
1440x900@75.0, 136.8 MHz
1440x900@59.9, 88.8 MHz
1280x720@60.0, 74.2 MHz
1280x720@60.0 16:9, 74.2 MHz
1280x720@59.9 16:9, 74.2 MHz
1280x720@50.0, 74.2 MHz
1280x720@50.0 16:9, 74.2 MHz
1024x768@75.0, 78.8 MHz
1024x768@70.1, 75.0 MHz
832x624@74.6, 57.3 MHz
800x600@75.0, 49.5 MHz
800x600@72.2, 50.0 MHz
800x600@60.3, 40.0 MHz
800x600@56.2, 36.0 MHz
720x576@50.0, 27.0 MHz
720x576@50.0 4:3, 27.0 MHz
720x576@50.0 16:9, 27.0 MHz
720x480@60.0 4:3, 27.0 MHz
720x480@60.0 16:9, 27.0 MHz
720x480@59.9 4:3, 27.0 MHz
720x480@59.9 16:9, 27.0 MHz
640x480@75.0, 31.5 MHz
640x480@72.8, 31.5 MHz
640x480@60.0 4:3, 25.2 MHz
640x480@59.9, 25.2 MHz
720x400@70.1, 28.3 MHz
[12:30:54.272] Output 'HDMI-A-2' enabled with head(s) HDMI-A-2
[12:30:54.272] Compositor capabilities:
arbitrary surface rotation: yes
screen capture uses y-flip: yes
cursor planes: yes
arbitrary resolutions: no
view mask clipping: yes
explicit sync: yes
color operations: no
presentation clock: CLOCK_MONOTONIC, id 1
presentation clock resolution: 0.000000001 s
[12:30:54.275] Loading module '/usr/lib/aarch64-linux-gnu/weston/desktop-shell.so'
[12:30:54.279] launching '/usr/lib/aarch64-linux-gnu/weston-keyboard'
[12:30:54.284] Note: support for the deprecated wl_shell interface is disabled. If a legacy client still needs it, it can be re-enabled by passing -Ddeprecated-wl-shell=true to Meson when building Weston.
[12:30:54.285] Loading module '/usr/lib/aarch64-linux-gnu/weston/screen-share.so'
[12:30:54.288] Loading module '/usr/lib/aarch64-linux-gnu/libweston-10/xwayland.so'
[12:30:54.373] Registered plugin API 'weston_xwayland_v1' of size 32
[12:30:54.373] Registered plugin API 'weston_xwayland_surface_v1' of size 16
[12:30:54.374] xserver listening on display :0
[12:30:54.374] launching '/usr/lib/aarch64-linux-gnu/weston-desktop-shell'
My USB inputs are as event3 and event5.
From the logs I can see
All the input events are associated to HDMI-A-1 only. (none from udev)
event3 should be mapped to HDMI-A-1
event5 should be mapped to HDMI-A-2
Strange this method worked for my colleagues previously. Did you reboot the device and/or reload the udev rules after you created your new rules? Also when you run your container are you bind-mounting /run/udev
from the host?
Best Regards,
Jeremias
I did bind mount it.
-v /dev:/dev -v /tmp:/tmp -v /run/udev/:/run/udev/
Did a reboot as well.
Can you verify and let me know if I’m writing the rules in correct format, or using the right file?
Regards
Can you verify and let me know if I’m writing the rules in correct format, or using the right file?
Your rules look okay to me, assuming you got the USB device information correct. As for the “right file”. I’m not sure what you mean. As long as the udev rule file is located in the correct directory it should be okay.
Best Regards,
Jeremias