Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse translation support for USB HID Gadget #838

Open
deliciouslytyped opened this issue Sep 15, 2024 · 2 comments
Open

Add mouse translation support for USB HID Gadget #838

deliciouslytyped opened this issue Sep 15, 2024 · 2 comments
Labels
enhancement New feature or request usb-gadget

Comments

@deliciouslytyped
Copy link

Background

I'm currently using keyd with the usb-gadget support to translate uinput events (/dev/input/event*) to usb gadget hid keyboards (/dev/hidg*) for my own glued together KVM setup. I haven't found any other tools that can do this.

I'm using tools like https://github.com/viandoxdev/jsfw to forward the events over the network from a source machine to an SBC, and then using keyd to translate to usb hid reports for the usb gadget, which is then used to control a target machine.

I am open to any better recommendations.

I'm running into usb-gadget: mouse support is not implemented from

keyd/src/vkbd/usb-gadget.c

Lines 137 to 150 in 393d341

void vkbd_mouse_move(const struct vkbd *vkbd, int x, int y)
{
fprintf(stderr, "usb-gadget: mouse support is not implemented\n");
}
void vkbd_mouse_move_abs(const struct vkbd *vkbd, int x, int y)
{
fprintf(stderr, "usb-gadget: mouse support is not implemented\n");
}
void vkbd_mouse_scroll(const struct vkbd *vkbd, int x, int y)
{
fprintf(stderr, "usb-gadget: mouse support is not implemented\n");
}
, because I would now also like to send mouse events.

Can this be implemented?

@rvaiya
Copy link
Owner

rvaiya commented Dec 30, 2024

I'm using tools like https://github.com/viandoxdev/jsfw to forward the events over the network from a source machine to an SBC, and then using keyd to translate to usb hid reports for the usb gadget, which is then used to control a target machine.

This sounds utterly perverse. I love it :P.

Can this be implemented?

This should be relatively straightforward to implement, but I don't have the means to test it. @gkbd submitted the patch which adds support for this, perhaps he can have a go at it. It has been on my todo list to acquire an SBC board and give this a go myself, but I haven't had the chance to do so yet.

@deliciouslytyped
Copy link
Author

deliciouslytyped commented Jan 4, 2025

I think I hacked small POC patches together, that I didn't submit here, but I don't know where I put it right now. I think it kind of worked, but then I had to get back to other things before I could finish the project.

I think it mainly consisted of creating another device like whatever the keyd code currently does, and implementing the minimal translation I needed to do to get a given device to work (I probably had to hard-code the device sensor valuehandling), accompanies by something about the usb device configuration bytestring, but that may have just been a configfs thing I needed to do?

This sounds utterly perverse. I love it :P

Yeah, it feels more complicated than it should be, it would be best if device busses could "magically" be forwarded across nodes with the kernel, but of course you can't just handwave that. I was inspired by USB over IP existing.
"UNIX philosophy" as well.

Another interesting thing is that x11vnc has support for writing to uinput devices, and video from v4l devices, so I actually want to use it to tie together video capture and input handling for some kind of hacked together KVM tool, but I haven't been able to finish. Maybe if x11vnc is patched to support MJPEG from v4l devices, it could be directly hooked up to some cheap HDMI USB capture dongles that exist. This is what I was doing but needed an intermediate tool to reencode the frames to a format x11vnc would take as input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request usb-gadget
Projects
None yet
Development

No branches or pull requests

2 participants