geekhack Projects > Making Stuff Together!

Open source, DIY PMW3360 Gaming Mouse on Arduino

(1/4) > >>

inornate:
Hi, geeks.

This is yet another attempt to make a DIY mouse, but using Arduino.

# TL;DR

* Prepare a PMW-3360 module https://www.tindie.com/products/jkicklighter/pmw3360-motion-sensor/ and an ATMega32u4-based board (Arduino Leonardo, Micro, Pro Micro, etc.), and some wire and buttons.
* Scavenge some mouse shell you like.
* Go to my GitHub repo https://github.com/SunjunKim/PMW3360_Arduino and follow the instruction.
* Enjoy your DIY mouse.
# Introduction
I spotted an old thread "DIY PMW-3360 Gaming mouse", https://geekhack.org/index.php?topic=89837 and I hope to resurrect the project. I got a PMW3360 sensor module, which is still one of the best in mice market, from Tindie and attempted to get it to work.

The MrJohnK's original Arduino examples (https://github.com/mrjohnk/PMW3360DM-T2QU) doesn't work quite well with fast movement (e.g., https://github.com/mrjohnk/PMW3360DM-T2QU/issues/22)

In the other hand, the most successful attempts for interfacing PMW3360 family so far have been done by qsxcv et al. with a combination of Teensy 2.0 + PMW 3366 (or PMW 3360) sensor, as like in https://www.overclock.net/forum/375-mice/1561041-reverse-engineering-3366-a-35.html#post26314321 and  https://www.youtube.com/watch?v=nyb6M89QrWI&t=1s. They used a bulk transfer to minimize the communication cost between the module and MCU, which works better at high speed.

As Arduino is an easy and handy platform than a cumbersome AVR-GCC coding on Teensy, I feel like I need a complete set of examples which can drive the module on Arduino IDE.

# Implementation Example



# Download
Go https://github.com/SunjunKim/PMW3360_Arduino and hit the download link. Detailed instruction is provided on the README.

# What it does
- PMW3360DM-Burst: Minimal burst reading (Serial outputs x/y displacements)
- PMW3360DM-Mouse: A functional high-performance mouse implementation
- PMW3360DM-Camera: A raw sensor image capture

# Mouse firmware demo
## DIY mouse (PMW3360) vs. Logitech G502 (PMW3366)
Test method: Logged with MouseTester v1.5 https://www.overclock.net/forum/375-mice/1590569-mousetester-software-reloaded.html
In dual mouse mode. I shaked the two mice together, one in straight and one in reverse. The logged data will result in negative to each other. Both mice set to the same CPI, 1200.


Blue: G502 / Green: DIY
=> Almost equivalent performance.



 
## Playing Osu! with DIY mouse
=> Gamer-grade performance. No flaw in action (except my poor Osu! score...)

nevin:
Awesome! Thanks!
There's a couple of us working on one as well. Will definitely check it out!

inornate:
Some interesting example surfaces captured with the "Camera" firmware:
=> 36x36 images with SQUAL (=surface quality, higher is better) value.

Logitech G440 Mousepad


Anodized Aluminum (=Apple MacBook Retina 2013)


Fabric (a t-shirt)


A4 print paper


Printed character (by a laser printer) on A4 paper


Office desk (white)


Leather

nevin:
On your git page you mention the encoder. it should work, as long as it's mechanical and not optical (which it looks like it is).
Here's a link to buxtronix who's worked with the 3360 as well.
http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html
https://github.com/buxtronix/arduino/tree/master/libraries/Rotary (arduino rotary library & examples)

gipetto on overclock did a optical scroll wheel as well



Also, attached is what our group is running on Teensy 2.0s. I only made a small adjustment to the resolutions in the profiles.

--- Quote ---the edit/changes to this copy of the firmware:
uint8_t dpis[] = {7, 13, 19};
## representing 800, 1400, 2000 dpi
   - now, if the 800 & 2000 are in the wrong orientation to what you prefer we can switch it as it's saying that the first number "800" is profile 2, "1400" is profile 1/default, and "2000" is profile 3

// The first number is for Profile 2 (rear side button)
// The second number is for profile 1 (Default profile)
// The third number is for profile 3 (front side button)
--- End quote ---

(looks like this addresses the 16bit motion data too, look in usb_mouse.c). I'm waiting for parts to arrive to piece mine together. I've only been messing with the firmware & researching up to this point.

One thing i would like to do is add the ability to use keyboard key codes on a couple of the mouse buttons. I saw an example by gipetto but haven't had a chance to mess with it yet.

 bst3360_firmware.zip (183.65 kB - downloaded 268 times.)

inornate:

--- Quote from: nevin on Sat, 30 March 2019, 14:57:35 ---On your git page you mention the encoder. it should work, as long as it's mechanical and not optical (which it looks like it is).
Here's a link to buxtronix who's worked with the 3360 as well.
http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html
https://github.com/buxtronix/arduino/tree/master/libraries/Rotary (arduino rotary library & examples)

gipetto on overclock did a optical scroll wheel as well

--- End quote ---

Thanks for the references. I'm knowledgeable about how they work (both optical/rotary encoders) but it's a matter of free time I have for the project...



--- Quote from: nevin on Sat, 30 March 2019, 14:57:35 ---Also, attached is what our group is running on Teensy 2.0s. I only made a small adjustment to the resolutions in the profiles.

--- End quote ---
I'm also checking that firmware as well! A nicely implemented beauty.



--- Quote from: nevin on Sat, 30 March 2019, 14:57:35 ---(looks like this addresses the 16bit motion data too, look in usb_mouse.c).

--- End quote ---
The development branch of mine https://github.com/SunjunKim/PMW3360_Arduino/tree/development implemented the 16-bit motion report. I brought the HID report descriptor from the code you mentioned.



--- Quote from: nevin on Sat, 30 March 2019, 14:57:35 ---One thing i would like to do is add the ability to use keyboard key codes on a couple of the mouse buttons. I saw an example by gipetto but haven't had a chance to mess with it yet.

--- End quote ---

With Arduino it's fairly easy. Just add #include <Keyboard.h> on the top of a sketch, and send Keyboard.print(A_KEY_YOU_WANT). Check https://www.arduino.cc/reference/en/language/functions/usb/keyboard/.

Thanks for your interest!

Navigation

[0] Message Index

[#] Next page

Go to full version