0
\$\begingroup\$

I'm using CH9329, a uart to USB keyboard/mouse simulator chip, to simulate mouse movement, with a moveable signal sender and an esp32-based signal receiver connected to it.

[sender] -> signal

signal -> [receiver->ch9329(simulate mouse)->computer]

Now I can see while I am moving my sender, the simulated cursor correctly moves and it also responses to mouse click (by clicking some desktop buttons). But, the weird thing is, if I open a whiteboard program, and want to draw a line, the cursor clicks at the first point, showing a visiable dot, but then failed to draw other points (moved correctly). However, I'm sure I am sending the right packet to indicate the mouse button is down (through uart tools).

In one sentence, it seems in all my "left-button-down" data packets, only the first packet really clicked, while other packets just let the mouse move.

How can this be possible? Any ideas? I think real mouses also report positions in the form of discrete points to the host, and the host knows how to draw a line. But my case failed.

--Edit--

I assume when using a real mouse to draw a line in a general painting program, you press the left button and then holding the button to keep it down, when you finish drawing you let the button up, right? That's what I did.

The chip protocol uses a byte to indicate the mouse state in every mouse-host communication packet. A 0x01 means the left button is down and a 0x00 means the left button is up. And when I detected a esp32 button is pressed, I begin sending 0x01 down packet, when I detected that esp32 button is up, I then changed to send 0x00 up packet.

My logs showing the button and packets I send:

.[0;32mI (95069) uart-mouse: sending to host : mouse state: 0
.[0m
.[0;32mI (95089) uart-mouse: sending to host : mouse state: 0
.[0m
.[0;32mI (95089) server-main: btn clicked
.[0m
.[0;32mI (95089) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95109) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95129) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95149) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95169) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95189) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95209) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95229) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95249) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95269) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95289) uart-mouse: sending to host : mouse state: 1
.[0m
.[0;32mI (95299) server-main: btn released
.[0m
.[0;32mI (95299) uart-mouse: sending to host : mouse state: 0
.[0m
.[0;32mI (95309) uart-mouse: sending to host : mouse state: 0
.[0m
.[0;32mI (95329) uart-mouse: sending to host : mouse state: 0
.[0m
\$\endgroup\$
4
  • 1
    \$\begingroup\$ To draw a line on most OSs and programs, the mouse must first give left button DOWN signal, not left button CLICKED signal. a click is a button DOWN immediately followed by button UP. Are you sending button down followed by multiple mouse moved followed by a button UP packets ? \$\endgroup\$ – AJN Aug 27 '20 at 15:15
  • \$\begingroup\$ Link 1 Linux link 2 Windows Link 3 Windows read last sentence "*I'm sure I am sending the right packet to indicate the mouse button is clicked *" Can you show a sample output set ? \$\endgroup\$ – AJN Aug 27 '20 at 15:21
  • \$\begingroup\$ @AJN I misused the world 'click' someway and I actually let the mouse button down by pressing a button on esp32 when begin drawing, keep the buttons down then, and finally let the mouse up by releasing the esp32 button. So it's a 'down - holding down - up' process. \$\endgroup\$ – lincr Aug 28 '20 at 1:47
  • \$\begingroup\$ Besides I'm using macOS and drawing using an online whiteboard: https//w-xuefeng.github.io/drawing/ \$\endgroup\$ – lincr Aug 28 '20 at 1:49
1
\$\begingroup\$

Finally I found the reason, I made a phone call to the chip FAE, and found that I should send packets of relative mouse location if I want to draw a line. And I previously used absolute mouse location all the time. Though absolute location method works in general scenarios, drawing may be a case that it cannot work.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.