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

Question(/possible Feature?): Sending "Power off" keyboard button signal #1863

Open
aetonsi opened this issue Dec 26, 2024 · 3 comments
Open
Labels
question Further information is requested

Comments

@aetonsi
Copy link

aetonsi commented Dec 26, 2024

hi,
i was reading up here: https://github.com/tiny-pilot/tinypilot/wiki/Add-an-RF-controlled-power-socket-to-TinyPilot (😦)
and here: https://forum.tinypilotkvm.com/-29/no-usb-input

... and i was wondering if it would be possible to send the "Power off" keyboard button signal many multimedia keyboards have (not talking about laptops).
I am talking about KBs like these:


So i stumbled upon this: https://wiki.osdev.org/PS/2_Keyboard
and especially this: https://aeb.win.tue.nl/linux/kbd/scancodes-1.html#power

... but not being a linux expert... i just wasted many hours trying to find the right device, how to send codes, how to read(?) available codes, and even just how to print "Hi" as in the example code from the thread above:
echo -ne "\x20\0\xb\0\0\0\0\0" > /dev/hidg0 && \
echo -ne "\0\0\xc\0\0\0\0\0" > /dev/hidg0 && \
echo -ne "\0\0\0\0\0\0\0\0" > /dev/hidg0

This example just prints "H" for me, for some reason.... After many hours i figured out how to print "Hi":

echo -ne "\x20\x00\x0B\x00\x00\x00\x00\x00" "\x8B\x00\x00\x00\x00\x00\x00\x00" > /dev/hidg0 && \
echo -ne "\x00\x00\x0C\x00\x00\x00\x00\x00" "\x8C\x00\x00\x00\x00\x00\x00\x00" > /dev/hidg0

# or simply

echo -ne "\x20\0\x0B\0\0\0\0\0" "\x8B\0\0\0\0\0\0\0" "\0\0\x0C\0\0\0\0\0" "\x8C\0\0\0\0\0\0\0" > /dev/hidg0

is this something that could be done? I think it might even be useful to add it to the "visual" keyboard?

image

@aetonsi aetonsi added the question Further information is requested label Dec 26, 2024
@cghague
Copy link
Contributor

cghague commented Dec 30, 2024

Hi @aetonsi, thanks for your great question about adding the Power, Sleep, and Wake keys to TinyPilot.

TinyPilot emulates a USB keyboard and can generate key codes for any key listed in the "Keyboard/Keypad Page" section of the USB HID Usage Tables. Unfortunately, that doesn't include the Power, Sleep, and Wake keys. The scan codes you found are from older, non-USB keyboards.

USB keyboards that do feature these keys are comparatively rare. As a result, they tend to add the functionality by requiring the user to install custom software or by presenting themselves to the computer as multiple USB devices (likely using the "Generic Desktop Page," although that's speculation on my behalf). We don't have any plans to add this ability to TinyPilot at the moment.

I appreciate that this isn't the answer you wanted, but I hope this context helps and answers your questions.

@aetonsi
Copy link
Author

aetonsi commented Dec 31, 2024

I appreciate that this isn't the answer you wanted, but I hope this context helps and answers your questions.

thank you very much, i learned something new anyway!

so if i might also ask, then, the mouse/pointing device is just done by the javascript webpage?

@cghague
Copy link
Contributor

cghague commented Jan 8, 2025

I'm happy my answer was helpful! Regarding the mouse, TinyPilot calculates the position of the local mouse cursor relative to the video stream of the target computer's screen and sends those coordinates to the target computer as an emulated USB mouse using absolute positioning (akin to how a graphics tablet or touchscreen works). The target computer, the local computer, or both may display a cursor. On the local computer, you can change the appearance of the mouse cursor in TinyPilot for convenience, but the setting has no impact on the target computer. Please let me know if you have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants