Code Monkey home page Code Monkey logo

logitech-mouse's Introduction

logitech-mouse

Use an arduino as a logitech wireless ๐Ÿญ

We managed to make an Arduino act like a Logitech wireless mouse using a NRF24. This work is based on our retroengineering work done in December 2016 and January 2017 during our school project @Supelec.

Example

This code makes the mouse move in circle on the screen.

#include "logitech-mouse.h"

logiMouse myMouse;

float mouseSpeed = 10.0f;
float degreesToRadians = 2.0f*3.14f/360.0f;

void setup() {
  Serial.begin(115200);

  Serial.println("Starting");

  myMouse.begin();

  Serial.println("Trying to reconnect");

  if(myMouse.reconnect())
      Serial.println("Reconnected using previous configuration !");
  else
  {
      Serial.println("Unable to reconnect to dongle... Pairing with any dongle...");
      myMouse.pair();
  }
    
  Serial.println("Ready :)");
}

void loop() {
  int x, y = 0;

  for(x = 0; x < 360; x+=5) {
    myMouse.move( (uint16_t)(mouseSpeed * cos( ((float)x) * degreesToRadians ) ),  
      (uint16_t)(mouseSpeed * sin( ((float)x) * degreesToRadians ) ));
      
    delay(10);
  }
}

Quick doc

The class we created is called logiMouse.

Methods

General methods

  • bool begin() : inits NRF24 module for wireless communication
  • bool pair() : pairs Arduino with Logitech dongle (don't forget to put the dongle into pairing mode using the unifying desktop app), returns false if pairing failed
  • bool pair(uint8_t) : pairs with timeout (exits if pairing takes too much time)
  • bool reconnect() : reconnects to previously connected dongle (exits if dongle is not found), returns true if success

Move methods

  • void move(uint16_t x_move, uint16_t y_move) : moves the mouse on the screen according to specified velocity (x,y)
  • void move(uint16_t x_move, uint16_t y_move, bool leftClick, bool rightClick) : moves the mouse on the screen according to specified velocity (x,y), and click according to booleans
  • void move(uint16_t x_move, uint16_t y_move, uint8_t scroll_v, uint8_t scroll_h) : moves and scrolls (see scrolls methods for more info)
  • void move(uint16_t x_move, uint16_t y_move, uint8_t scroll_v, uint8_t scroll_h, bool leftClick, bool rightClick) : moves, scrolls and clicks (see related methods for more info)

Scroll methods

  • void scroll(uint8_t scroll_v, uint8_t scroll_h) : scrolls horizontally and vertically (scroll_v and scroll_h can be negative)
  • void scroll(uint8_t scroll_v) : scrolls vertically (scroll_v can be negative)

Click methods

  • void click(bool leftClick, bool rightClick) : clicks according to booleans

Copyright

The NRF24 lib included in this repo was written by Coliz [email protected], all rights reserved to him.

We are the author of both files : logitech-mouse.cpp and logitech-mouse.h

logitech-mouse's People

Contributors

ronangaillard avatar guicodron avatar

Watchers

James Cloos avatar

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.