Code Monkey home page Code Monkey logo

mouse's Introduction

Mouse Library for Arduino

Check Arduino status Compile Examples status Spell Check status

This library allows an Arduino board with USB capabilities to act as a Mouse.

For more information about this library please visit us at https://www.arduino.cc/reference/en/language/functions/usb/mouse/

License

Copyright (c) Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

mouse's People

Contributors

aentinger avatar canchebagur avatar cmaglie avatar dependabot[bot] avatar facchinm avatar karlsoderby avatar per1234 avatar pnndra avatar tigoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mouse's Issues

Platform IO, Teensy, HID.h

Hi there,

long time ago I've wrote a small program to emulate a mouse button click for clicker games. This was done for a Teensy 2.0 using the Arduino IDE - see here for more details.

Now I've got a new computer and tried to get this program compiling again. I'm using Platform IO in VS Code as extension. An empty default program without any logic compiles well. When I add the mouse library, the compile fails because the header file HID.h used in Mouse.h is not found.

So I tried this also in the Arduino IDE - same happens there, the header file HID.h is missing.

Seems that there is something missing, but I cannot remember on what this lib depends. Same also for Keyboard, there is also HID.h used. Also can't find any hint on the pages of Arduino for keyboard or mouse.

What have i missed?

Add example sketches

Currently the library does not include any bundled example sketches.

Due to the library's origin as part of the core, the examples were instead included in the "built-in" examples bundled with Arduino IDE:

https://github.com/arduino/arduino-examples/tree/main/examples/09.USB

This poses two problems:

  • Users are accustomed to finding library examples via the File > Examples > <library name> menu path in the IDE
  • The "built-in" examples are not be available for users of other development tools which provide the Mouse library (e.g., Arduino CLI, PlatformIO)

The problem with Mouse.cpp.

Hi.
I'm doing a mouse on arduino and I ran into a problem:
How to use 16-bit data for XY axes? The fact is that the 8-bit data type is not enough for the optical sensor and when I put large DPI values then the mouse cursor makes a jerk. This happens when the value on the axis exceeds 127 and the cursor goes to 0.

How much I understood it is necessary to modify file Mouse.cpp.

Read mouse sensitivity from OS

Add a way to read the OS's set mouse sensitivity so the sensitivity of mice using this library can be set from the OS.

See here for example code for windows using SystemParametersInfo(SPI_GETMOUSESPEED, 0, &mouseSpeed, 0);

Support for horizontal scroll

Hello!

Have you considered adding a support for emulating horizontal scroll, or this is not needed for vast majority of this library's users?

It seems that this is possible to add such functionality in a painless way: https://arduino.stackexchange.com/questions/46055/can-the-mouse-library-scroll-horizontally

I had made a fork of this lib with the aforementioned adjustments (https://github.com/nikita-tomilov/HMouse), and it actually works as expected, but I had to rename the class because of conflict with another library. I will be more than happy to create a proper pull request to this repository (without such renaming), if there is any need in this.

Mouse.move() - update documentation / limit input range

Originally opened by @125401qwerty here.

@125401qwerty
Hi.
I'm doing a mouse on arduino and I ran into a problem:
How to use 16-bit data for XY axes? The fact is that the 8-bit data type is not enough for the optical sensor and when I put large DPI values then the mouse cursor makes a jerk. This happens when the value on the axis exceeds 127 (-127) and the cursor goes to 0.
Apparently it's in the file Mouse.cpp. It is necessary to change the descriptor.
In general, how to increase the limit on the XY axes in the -127 to +127, At least up to 255 -255 or -1024 +1024?
Maybe someone already solved this problem.

I found a simpler solution:

if (x > 126) {x = 127;}
if (x < -126) {x = -127;}
if (y > 126) {y = 127;}
if (y < -126) {y = -127;}
Mouse.move(x, y, 0);

@PaulStoffregen
I believe this issue should be moved to the Mouse library repository.

https://github.com/arduino-libraries/Mouse

As I understand this, the issue seems to be a misunderstanding about integer truncation. It's pretty easy to see how this sort of misunderstanding could happen by looking at the Mouse.move() documentation.

https://www.arduino.cc/reference/en/language/functions/usb/mouse/mousemove/

While it does say "Allowed data types: signed char", nowhere on that page is the actual numerical range explained to be -128 to +127. Neither does this page link to any other reference that explains the significance of what "Allowed data types: signed char" really means.

Even if the page did explain that, the HID report descriptor says the numerical range is -127 to +127. Using -128 should not be allowed.

The Mouse.move() reference does have an example program, but the example is overly complicated and pretty far from the simple novice-friendly style Arduino normally uses for examples. It also limits the range to only 12, without any explanation I can see.

At the very least, the reference page should be updated to explicitly state the allowed numerical range is -127 to +127.

A better, much more Arduino-style approach might change Mouse.move() to take int inputs instead of signed char, and explicitly clamp the range to -127 to +127. Then if a user unwittingly tries to call Mouse.move() with values outside the legal -127 to +127 range, they would be nicely limited to the maximum rather than giving the confusing result of the compiler passing only the low 8 bits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.