Author Topic: Open source, DIY PMW3360 Gaming Mouse on Arduino  (Read 43966 times)

0 Members and 1 Guest are viewing this topic.

Offline inornate

  • Thread Starter
  • Posts: 25
Open source, DIY PMW3360 Gaming Mouse on Arduino
« on: Thu, 28 March 2019, 16:10:39 »
Hi, geeks.

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

# TL;DR

# 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
216215-0
216217-1

# 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.
216209-2
216211-3
216213-4
 
## Playing Osu! with DIY mouse
=> Gamer-grade performance. No flaw in action (except my poor Osu! score...)
« Last Edit: Sun, 31 March 2019, 11:19:12 by inornate »

Offline nevin

  • Posts: 1646
  • Location: US
Re: Open source, DIY PMW3360 Gaming Mouse with Arduino
« Reply #1 on: Thu, 28 March 2019, 17:06:34 »
Awesome! Thanks!
There's a couple of us working on one as well. Will definitely check it out!
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline inornate

  • Thread Starter
  • Posts: 25
Re: Open source, DIY PMW3360 Gaming Mouse with Arduino
« Reply #2 on: Sat, 30 March 2019, 13:52:31 »
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
« Last Edit: Sat, 30 March 2019, 16:24:01 by inornate »

Offline nevin

  • Posts: 1646
  • Location: US
Re: Open source, DIY PMW3360 Gaming Mouse with Arduino
« Reply #3 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



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)

(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 256 times.)
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline inornate

  • Thread Starter
  • Posts: 25
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #4 on: Sat, 30 March 2019, 16:44:46 »
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

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...


Also, attached is what our group is running on Teensy 2.0s. I only made a small adjustment to the resolutions in the profiles.
I'm also checking that firmware as well! A nicely implemented beauty.


(looks like this addresses the 16bit motion data too, look in usb_mouse.c).
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.


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.

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!

Offline nevin

  • Posts: 1646
  • Location: US
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #5 on: Sat, 30 March 2019, 21:17:05 »
The "public" is probably better than what we're running
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline inornate

  • Thread Starter
  • Posts: 25
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #6 on: Sun, 31 March 2019, 15:45:27 »
The "public" is probably better than what we're running

I see buxtronix's implementation is clear and concise. I'll start from that in my project. :)

Offline nevin

  • Posts: 1646
  • Location: US
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #7 on: Sun, 31 March 2019, 16:45:52 »
Yeah, after a a little more digging... public is good, 5 button.

Buxtronix is public with cleaned up wheel code.

So as far as what I can tell the Buxtronix is the latest/most complete? version

Some parts came in today, see if I have time tonight to try some stuff out.
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline xealous

  • Posts: 1
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #8 on: Mon, 01 July 2019, 21:53:52 »
Thinking of building my own one:

What does the MrJohnK pcb actually do? I notice a bunch of smd components.
AFAICT the only thing these smd components provide is voltage regulation? But the Arduino Pro micro is 5v already, so no regulation is necessary?

Can we just solder from the atmega32u4 to the sensor (it's only $10.50usd with lens on aliexpress, vs $30 usd with the pcb).

Offline inornate

  • Thread Starter
  • Posts: 25
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #9 on: Mon, 11 November 2019, 00:58:07 »
Thinking of building my own one:

What does the MrJohnK pcb actually do? I notice a bunch of smd components.
AFAICT the only thing these smd components provide is voltage regulation? But the Arduino Pro micro is 5v already, so no regulation is necessary?

Can we just solder from the atmega32u4 to the sensor (it's only $10.50usd with lens on aliexpress, vs $30 usd with the pcb).


PMW3360 sensor runs on 1.8V – 2.1V, a level converter is needed to communicate with any of Arduino boards runs on 3.3v or 5v. The SMDs on the MrJohnK PCB are for that.

Offline gipetto

  • Posts: 91
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #10 on: Thu, 02 January 2020, 17:48:46 »
I should clarify, I created a repo of mouse firmware based on bst and qsxcv's work. Then i ported buxtronix's rotary encoder code to the mouse firmware to take advantage of the better performance. ben buxton never worked on mouses afaik. just today i finished the assembly of this diy mouse pcb pictured. although you might think the pmw3360 is old hat and been surpassed, there has been a release of the srom_0x05 which removes smoothing at higher dpi, like the pmw3366. So it's still quite competitive.

Offline mips

  • Posts: 1
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #11 on: Mon, 06 July 2020, 09:12:52 »
I should clarify, I created a repo of mouse firmware based on bst and qsxcv's work. Then i ported buxtronix's rotary encoder code to the mouse firmware to take advantage of the better performance. ben buxton never worked on mouses afaik. just today i finished the assembly of this diy mouse pcb pictured. although you might think the pmw3360 is old hat and been surpassed, there has been a release of the srom_0x05 which removes smoothing at higher dpi, like the pmw3366. So it's still quite competitive.

Is there firmware out there that will work with a CoolerMaster MM530 mouse by any chance?

Some MM530 mice seem to develop an issue where the mouse freezes followed by usb disconnect. It's a known issue with no fix, not sure if it's hardware or firmware related.

Offline nevin

  • Posts: 1646
  • Location: US
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #12 on: Mon, 06 July 2020, 09:20:18 »
Quote
Is there firmware out there that will work with a CoolerMaster MM530 mouse by any chance?

Probably not, without replacing the controller. And at that point, it's probably easier to replace all the guts than to try & figure out how their pcb is designed/wired.

I haven't messed with one, but most off the shelf mice are locked into whatever programming utility they come with (if they have one).
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline gipetto

  • Posts: 91
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #13 on: Tue, 07 July 2020, 03:24:38 »
Is there firmware out there that will work with a CoolerMaster MM530 mouse by any chance?

Some MM530 mice seem to develop an issue where the mouse freezes followed by usb disconnect. It's a known issue with no fix, not sure if it's hardware or firmware related.

I have little experience with arm but there's stm32 firmware here https://www.overclock.net/forum/375-mice/1724838-progress-fully-custom-mouse-16.html#post28500436
you would have to port the code to a slightly different arm architecture, probably not a huge job, just change registers following the datasheets and map the pinout the mouse uses.

Offline Dont_Panic_101

  • Posts: 1
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #14 on: Thu, 18 February 2021, 16:09:07 »
So I am currently building this and I noticed that you have to files that say you have support for forward and back buttons. Which pins are they on? Or do I have to program them in myself?

Thanks!

Offline abraam

  • Posts: 1
Re: Open source, DIY PMW3360 Gaming Mouse on Arduino
« Reply #15 on: Thu, 21 October 2021, 14:55:09 »
Hello,

I know this was made a long time ago but I am planning on using this for the basics of something else. The thing is we are using an arduino uno. What pin would mt go to on the arduino uno?

Thank you in advance for the help to anyone that is still here