Closed a-sable closed 6 years ago
I am not sure if you have seen this problem or not: https://github.com/pelya/android-keyboard-gadget/issues/109 but it manages to get the mouse to work on windows although it isn't as nice
Thank you for answer. I try, but cant do this correctly =(
when I try do this (left click)
adb shell "echo '0x10 0x00 0x00 0x00' | /dev/hidg1"
I get the response
/system/bin/sh: ./dev/higd1: can't execute: Permission denied
(commands for keyboard still worked)
what am I doing wrong? '0x10 0x00 0x00 0x00' is correct format for left click? I use command panel windows 8.1
thank u one more time)
Your command is not in the correct format, it should look like this:
adb shell "echo -e -n '\x0\x0\x0\x0' > /dev/hidg1"
this is different because you were using the format of 0x00
instead of \x0
You were also missing the>
which you had input as a|
which is not right for this case for the mouse.
You also have not entered the value for the left click properly either so I thought I would share with you what I have found the various values need to be.
The format for the mouse data is as follows:
\x(Button)\x(X Pos)\x(Y Pos)\x(Scroll Wheel)
The button values follow this:
typedef enum {
BUTTON_LEFT = 0x1,
BUTTON_RIGHT = 0x2,
BUTTON_MIDDLE = 0x4,
} MouseButtons_t;
(So a value of 0 is no click, 1 is left, 2 is right and 4 is middle/scroll click)
The X Position and Y Position can be any value between -127 and 127. This represents pixels and is relative to where the mouse currently is. e,g if you are at the point 150, 150 then you can move the mouse anywhere that is within 127 pixels of this point (23, 23) and (277, 277) would be the maximums. Therefore, if the mouse is at 0,0 (top left corner) and you want to move to 1920, 1080 (bottom right corner) Then you would need to move the mouse a few times 127 pixels at a time (or less) in either direction.
The scroll wheel value can either be 1 for scrolling up, or 255 for scrolling down. This will then move 3 lines by default in windows each time this is run.
IMPORTANT: All of these values need to be input as hex using the format above so you can use a hex converter to get the values you need.
Examples:
(Left click) adb shell "echo -e -n '\x01\x0\x0\x0' > /dev/hidg1"
which is followed by adb shell "echo -e -n '\x0\x0\x0\x0' > /dev/hidg1"
This is because a click is a click and then release (left click then no click)
(Move Mouse) adb shell "echo -e -n '\x0\x7f\x7f\x0' > /dev/hidg1"
This moves the mouse 127 pixels to the right and 127 pixels down (7f is hex for 127)
(Mouse Move 2) adb shell "echo -e -n '\x0\x81\x81\x0' > /dev/hidg1"
This moves the mouse 127 pixels to the left and 127 pixels up (81 is hex for -127)
Do not enter x80 as I think this is effectively negative 0 or whatever. So to get other negative numbers you keep going e.g 82 is -126, 83 is -125 etc
Another note: you do not have to move in both the x and y direction at the same time you can just do one at time.
(Mouse Scroll Up) adb shell "echo -e -n '\x00\x0\x0\x01' > /dev/hidg1"
(Mouse Scroll Down) adb shell "echo -e -n '\x00\x0\x0\xff' > /dev/hidg1"
it works
Thank you very mach, for u best explanations!
Hey.
.
What and how I do:
Windows 8.1, from the command line I execute the connection:
The commands for the keyboard are working (returns "recv report: 01", and pressing the key):
adb shell "echo a ./data/local/tmp/hid-gadget-test / dev / hidg0 keyboard"
For example, mouse command (returns nothing, do not press mouse:
adb shell "echo -b2 | ./data/local/tmp/hid-gadget-test / dev / hidg1 mouse"
p.s. issue, not critical for me: Lineage OS 15.1 with the kernel FireKernel 2.4: another problem (similar to this https://github.com/pelya/android-keyboard-gadget/issues/117) - freezes the command panel, from those commands that work on other firmware. Does the oreo work?