pi-as-keyboard icon indicating copy to clipboard operation
pi-as-keyboard copied to clipboard

Set the mouse to a position

Open burpy opened this issue 7 years ago • 7 comments

Is it possible to set the mouse to a defined x,y position on the display?

burpy avatar Oct 05 '18 21:10 burpy

Hi,

Sorry for the delay. It should be possible ! I will test it and update the project / issue.

c4software avatar Oct 09 '18 21:10 c4software

I have added a c program to this repo « to play » with HID code. I will try some combination this week-end.

c4software avatar Oct 11 '18 22:10 c4software

With the test script I was able to click, but not moving the cursor on OSX.

I will try on another computer this weekend

c4software avatar Oct 17 '18 20:10 c4software

Thanks so far. A click on a defined position would be great. I use it on linux at the moment and I move cursor with the number keypad (for example the 8 to move the cursor to the north). I make a click with the enter key on the keypad. This workes but it would be better to set the cursor to position x,y. It would be faster and much more exakt.

burpy avatar Oct 18 '18 07:10 burpy

According the documentation the position should be in percentage since the HID device didn't have any clue of the resolution of your monitor.

Example :

  • 0,0 is the top left
  • 100,100 is the bottom right

c4software avatar Oct 19 '18 07:10 c4software

My python script looks like this at the moment.

#!/usr/bin/python
import time

def write_report(report):
    with open('/dev/hidg0', 'rb+') as fd:
        fd.write(report.encode())

NULL_CHAR = chr(0)
write_report(NULL_CHAR*2+chr(0x5F)+NULL_CHAR*5) # go to north west with KEYPAD_7
time.sleep(2.2)
write_report(NULL_CHAR*8)

I go from the current mouse position to the left top corner. What do I have to change to make the mouse position for example in the middle (50,50)?

burpy avatar Oct 19 '18 17:10 burpy

You find the solution here: https://github.com/pelya/android-keyboard-gadget/issues/135#issuecomment-386842277

Worked for me!

burpy avatar Jan 24 '19 09:01 burpy