Listening to mouse message and controlling it

Hi,

I’m trying to make a small project that’ll benefit me at my work. I have an Arduino Leonardo.

What I’m trying to do is if mouse left is held, I want it to consistently click until it’s letten go.

How would I go about doing this or is it possible at all? Thanks.

Need to see code and hardware setup.

cruisey:
Hi,

I’m trying to make a small project that’ll benefit me at my work. I have an Arduino Leonardo.

What I’m trying to do is if mouse left is held, I want it to consistently click until it’s letten go.

How would I go about doing this or is it possible at all? Thanks.

What mouse?

Hi,

Is the computer mouse Bluetooth, Wireless, Wired?

Thanks

Zeb

ZebH:
Hi,

Is the computer mouse Bluetooth, Wireless, Wired?

Thanks

Zeb

GoForSmoke:
What mouse?

It's a wired, steelseries rival 100 mouse.

Wired to the Leonardo? I have seen projects where mice were Arduino-hacked and I know that PS2 mouse can be wired direct to Arduino pins.

"What I'm trying to do is if mouse left is held, I want it to consistently click until it's letten go."

Yes you can do that if you mean sending mouse and clicks as HID to the PC.

You have to use time calculations to know when the mouse button is held down and to make nice even clicks but what your sketch reads from the mouse does not control what the Leonardo sends to the PC.

GoForSmoke:
Wired to the Leonardo? I have seen projects where mice were Arduino-hacked and I know that PS2 mouse can be wired direct to Arduino pins.

"What I'm trying to do is if mouse left is held, I want it to consistently click until it's letten go."

Yes you can do that if you mean sending mouse and clicks as HID to the PC.

You have to use time calculations to know when the mouse button is held down and to make nice even clicks but what your sketch reads from the mouse does not control what the Leonardo sends to the PC.

Thank you for the reply, I'd like to re-phrase what I said.

Is there a specific function I could use to know if MOUSE_LEFT button is held?
The Arduino itself is connected to the PC directly through the micro-usb cable.
The mouse is connected to the PC, the mouse itself does not connect to the Arduino in any sort of way.

I've also accomplished the PS/2 mouse event, where I had to open inside the mouse and connect the wires to the according Arduino pins although those mouses are really old and I don't want to switch mouses.

Thanks.

Is there a specific function I could use to know if MOUSE_LEFT button is held?

There is an isPressed() function in the library

bool Mouse_::isPressed(uint8_t b)
{
 if ((b & _buttons) > 0) 
 return true;
 return false;
}

It takes one of these #defined values to determine which button or buttons to test

#define MOUSE_LEFT 1
#define MOUSE_RIGHT 2
#define MOUSE_MIDDLE 4
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)

cruisey:
The Arduino itself is connected to the PC directly through the micro-usb cable.
The mouse is connected to the PC, the mouse itself does not connect to the Arduino in any sort of way.

Your Arduino acts as a HID, your mouse acts as a HID. I doubt very much that what you want to achieve is possible without extreme effort (including writing new drivers for the mouse on the PC).

cruisey:
Thank you for the reply, I'd like to re-phrase what I said.

Is there a specific function I could use to know if MOUSE_LEFT button is held?
The Arduino itself is connected to the PC directly through the micro-usb cable.
The mouse is connected to the PC, the mouse itself does not connect to the Arduino in any sort of way.

I've also accomplished the PS/2 mouse event, where I had to open inside the mouse and connect the wires to the according Arduino pins although those mouses are really old and I don't want to switch mouses.

Thanks.

You can wire directly to the PS2 jack and interface PS2 keyboard and/or mouse without opening either device.

There's more than tutorial article in the Playground on doing just that.

I for one never tried to read the PC when using Arduino in HID mode. That doesn't mean it can't be done.