An Open-Source Gaming Mouse

It’s a shame, that peripherals sold as of higher performance for gaming so often deliver little but aggressive styling. [Wareya] became frustrated with the fragile switches on his choice of gaming mouse, so decided to design his own. In the video that he’s placed below the break, he takes us through all the many choices and pitfalls inherent to these devices

After quite a few iterations he arrived upon a design featuring an RP2040 and an optical sensor easily found in relatively inexpensive mice. The whole design is open source and can be found in a GitHub repository, but for us perhaps the most interesting part of the explanation lies in the use of a three-contact switch, and how the third contact is used to aid in debouncing. In an application in which latency is of paramount importance this is a key design feature of a gaming mouse.

Perhaps it’s a mark of how good computer mice are in general that we see so relatively few projects building them from scratch rather than modifying exiting ones, but despite that a few have made it to these pages.

12 thoughts on “An Open-Source Gaming Mouse

  1. “Perhaps it’s a mark of how good computer mice are in general that we see so relatively few projects building them from scratch rather than modifying exiting (sic!) ones…” – with all due respect, no.

    I’ll let this project’s README save me the time on wording: “None of the companies that make gaming mouse sensors sell them to consumers, including Pixart, so the sensor needs to be salvaged (or bought from a scalper, or a small business that specializes in reselling them).”

    Last time I checked, there was a single entity selling PixArt sensor boards on Tindie, and they were more expensive than a mouse housing the same thing before you added on international shipping and taxes.

    1. codico.com sells the pmw3360dm sample kit of 5 sensors and lenses in europe. they are the dealer for pixart. I don’t think there’s any restriction on buying them, it’s more that they don’t show up on search engines and you have to research on your own.

      yes you have to pay more for components but they are running a business, they should not be expected to subsidize hobbiests. bastardkb sells a sensor board. There are also several open source sensor board designs around that you can get pcb assembled cheaper than you would buy it complete.

      1. The point in question is attractiveness of constructing a mouse from scratch as opposed to modifying an existing one. You can get a mouse with one of those sensors for ~20€ around here at a semi-normal tech shop. If that’s where you start, there is a major skill/time advantage to skipping desoldering and soldering the sensor.

        However, I do appreciate the pointers at alternate suppliers.

  2. I appreciated the rabbit hole that the 3-terminal switch comment in the writeup sent me down. Tom’s hardware have a good article on this topic:
    https://www.tomshardware.com/reviews/hack-mouse-click-do-it-yourself,4458-4.html

    The gist seems to be one can make much better use of a standard 3-terminal NO/NC switch than I typically have (such as for 3d printer and CNC router limit switches). Instead of just looking for continuity or polarity on the middle pin, using it with a 2-wire sensing approach plus software, or using the middle terminal with some minor extra circuitry really does produce a more reliable ling-term output.

  3. @2:45 rofl. Sensor wont desolder because of garbage TS-I tip used for comedic effect :) What is this, a tip for Ants? Jevelry? Fixing headphone wires? My heart sank a little @7:00 when he mentioned contemplating respinning whole board because one SMD resistor needed replacement :o. Dude really needs a set of good tips, BC2 K D24 JL02, maybe C1 + good liquid flux.

    I dont agree with couple design choices:
    You dont like Chinese disposable Omrons regularly dying (Personally I think its a conspiracy to make Mice a recurring revenue for the likes of Logitech), yet you use those anyway? Perfect solution does exist! Optical switches where Button part just moves a slit breaking light barrier. No debouncing, no mechanical aging. Afair Asus and Benq? mice use those.
    Case. In my personal hacked mice I just reused whole Steelseries mouse because its super comfy and looks great. 3D printed case is ugly :( and looks like it would irritate the hand with all those edges and gaps. It absolutely looks like a potato mouse :-)

    Seriously cool project! Especially total control over the firmware.

  4. RP2040 is a poor choice, it has no general purpose timers- which you need for real-time anything such as debounce. Too bad he went to oddball switches to cover for this.

  5. Silly Idea: If each mouse button clicks when pressed, you could have a handful of non-collinear microphones in or near the mouse listening to these clicks.

    Buttons should be distinguishable from one another because the click sounds arrive at different mics at different times.

  6. Before looking at switches debouncing to optimize speed, he should have looked at his code. DigitalRead and DigitalWrite used to take 400 instruction cycles instead of 1 or 2 with a register access. Also, he’s reading the wheel in poll mode while a PIO driver exists.

    Good job anyway but there are tons of optimizations to do

    1. Hi, thanks for the feedback. I timed each section of code before releasing it. The call to update_buttons only takes about 19 microseconds total. Dummying out the digital writes makes it take about 16 microseconds, so they’re not the bottleneck. This is somewhat slower than it needs to be, but it wasn’t slow enough for me to hold back the release to change it over to output register access. The rp2040 runs at 125~133mhz, so things that would be silly and extremely slow to do on an 8mhz or 16mhz arduino are totally fine here.

      As for the scroll wheel, I want to leave the PIO units unused in case someone wants to do something interesting with them in a mod. Polling at roughly 4khz is enough to avoid glitches without interfering with the rest of the processor.

  7. A flaw common to all modern mice that I’ve seen is that controls are not isolated from each other. The middle “button” is part of the scroll wheel, so that pressing it risks scrolling before the click activates. That’s defective design. Another problems is buttons on the side that are activated by pressing horizontally, risking moving the mouse when the intention is to press the button without moving the mouse. Bad design.

    1. This isn’t a mouse thing. Most gamepads nowadays have clickable analog sticks and 3D motion control in spite of all the buttons not being, uh, perpendicular to 3D. It may bother you – the stick clicking bother a lot of people, myself included, though I’m not a fan of analog sticks at all – but clearly there’s enough popularity of the features to push for them to be included.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.