Open andreafeletto opened 1 year ago
Thanks a lot for implementing this! I just added button events: https://github.com/David96/xdg-desktop-portal-wlr/tree/remotedesktop Feel free to use however you want, I basically just copied your code, so I don't care about authorship or anything here.
Thanks a lot for implementing this! I just added button events: https://github.com/David96/xdg-desktop-portal-wlr/tree/remotedesktop Feel free to use however you want, I basically just copied your code, so I don't care about authorship or anything here.
Thanks. Give me another 4/5 days and I'll get back to this.
I've successfully tested pointer movement and buttons with kdeconnect (23.04) and wayfire (on Raspberry Pi OS v5). Scrolling does seem to have some code already, but it wasn't working here. I could see dbus messages in dbus-monitor, but no scrolling happened.
I started working on keyboard support, but I'm not sure if my approach is suitable as I have no experience with xkbcommon, evdev or wayland. You can find my implementation in https://github.com/DefaultUser/xdg-desktop-portal-wlr/commit/b092b2a8fdcbc6c12dbf96c21a69752fbcd37c36
(Edit: fixed the link to the commit)
I've fixed the scrolling issues I mentioned in my previous comment. This also fixed some smaller issues I was experiencing (see commit message for details). I am not sure if my approach is the best, but KDEConnect's remote input feature now works fine with wayfire. The fix is here: https://github.com/DefaultUser/xdg-desktop-portal-wlr/commit/b2cacc910e560a097b2e43b5a683809e5a94bb68
but KDEConnect's remote input feature now works fine with wayfire.
Worked fine with my sway too (sway master/020a572
, wlroots master/26eac25
, portal-wlr remotedesktop/b2cacc9
but rebased over master/84a9cf4
). Tested mouse movement, mouse buttons, scrolling, dragging ~(cursed over WAN latency)~, and keyboard (on multiple apps).
I have been using @DefaultUser's fork for the past few weeks and works almost perfectly. Mouse input is perfect, but there's some keyboard functions that are wonky. The X key seems to send a Mute volume command instead of the actual letter.
It is nearly there tho. I don't expect there to be much more work required.
@tralph3 : I assume that you're using Wayfire. Wayfire uses the underlying keycodes instead of the key symbols for binds and ignores the keymap this. I think that is was planned to add an option to change this in Wayfire, but I don't know if it is already implemented. I have to admit that my branch only covers exactly what I need from it (ASCII input), but it offers a starting point for someone with more time to fix this. I currently use a build where I simply remap the buttons in the keymap that have binds in Wayfire's default config and add some special cases for them in code. This is quite an ugly workaround. The proper way to handle this is by adding more keymap definitions and switching between them dynamically. That way, non-ASCII characters could be handled.
I use Hyprland, actually.
I have also been using this a bit now on Hyprland and its amazing to be able to use the pointer and type something!! Things that map the wrong way for me: z -> increase volume y -> decrease volume x -> toggle mute j -> print capital latters are mapped as lower case letters special symbols do not work (some math symbols, currencies, degree symbol, shapes, ...)
I just took a crack at implementing a more "proper" solution using libxkbcommon and had some success, all the basic keys are working as expected, though symbols are still not working. This is my first time coding in C so I would definitely want it to be checked over by someone before going forward but to get the ball rolling even more, here's what I have:
Enovale@11817f90de8903a32b9ea0add3bb3a478c6635e5
EDIT: Capital letters aren't working currently either.
Cool that you are trying to work on it :) Unfortunately I also do not know any C so can't help you with the code (but I guess it will be reviewed anyway before getting merged). But I can test some. Can confirm that the letters are now mapped correctly (except capital as you pointed out already) Regarding the other characters some are now not working anymore that were working previously: + -> = _ -> - !@#$%^&*() -> 1234567890 " -> ' : -> ; ? -> / ~ -> ` | -> \ < -> , > -> . {} -> [] from currencies "€" does work. the others not the rest remains
Also Im getting this warning which is treated as error by default. I had to change the compile options before being able to build.
xdg-desktop-portal-wlr> [31/33] Compiling C object xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o
xdg-desktop-portal-wlr> FAILED: xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o
xdg-desktop-portal-wlr> gcc -Ixdg-desktop-portal-wlr.p -I. -I.. -I../include -Iprotocols -I/nix/store/di7vbvn478r2gx1wlfvxvv0ani8fy4qh-wayland-1.22.0-dev/include -I/nix/store/8jwrkvi3r40a2fh56qk6bippnhzxcv03-systemd-255.6-dev/include -I/nix/store/k986n2g13n6hjlmr913hcv3c44jj29nk-pipewire-1.0.6-dev/include/pipewire-0.3 -I/nix/store/k986n2g13n6hjlmr913hcv3c44jj29nk-pipewire-1.0.6-dev/include/spa-0.2 -I/nix/store/9qisjifkjmb1z14vsd9vdw2r44i3z883-inih-58/include -I/nix/store/wsayddhkdwh7a37d9k9kz02pn0r9d469-mesa-24.0.7-dev/include -I/nix/store/xjvnswjz32dw12ld8nb29lhwp92275aj-libdrm-2.4.120-dev/include -I/nix/store/xjvnswjz32dw12ld8nb29lhwp92275aj-libdrm-2.4.120-dev/include/libdrm -I/nix/store/alcgjc7smx41sh1xn1xi07pqpwv2sdi2-libxkbcommon-1.7.0-dev/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter -D_POSIX_C_SOURCE=200809L '-DSYSCONFDIR="/nix/store/62fg5fzqvama4c1w2jy6d2ry7dv499as-xdg-desktop-portal-wlr-0.7.1/etc"' -DHAVE_LIBSYSTEMD=1 -D_REENTRANT -MD -MQ xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o -MF xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o.d -o xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o -c ../src/remotedesktop/remotedesktop.c
xdg-desktop-portal-wlr> ../src/remotedesktop/remotedesktop.c: In function 'init_keymap':
xdg-desktop-portal-wlr> ../src/remotedesktop/remotedesktop.c:252:9: error: ignoring return value of 'ftruncate' declared with attribute 'warn_unused_result' [-Werror=unused-result]
xdg-desktop-portal-wlr> 252 | ftruncate(keymap_fd, keymap_size);
xdg-desktop-portal-wlr> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xdg-desktop-portal-wlr> cc1: all warnings being treated as errors
xdg-desktop-portal-wlr> [32/33] Compiling C object xdg-desktop-portal-wlr.p/src_screencast_pipewire_screencast.c.o
xdg-desktop-portal-wlr> ninja: build stopped: subcommand failed.
It's also worth noting that the portal with my changes segfaults and crashes my compositor whenever I run it with -r or otherwise kill it and re-run it. It works fine when systemd boots it up after a reboot, though. I have no idea what's going on with that
Implements https://github.com/emersion/xdg-desktop-portal-wlr/issues/2
ToDo: