I’m happy to share with you my new project.
It’s a Trackpad in a Keycap!
I was thinking for a while about a trackpad solution that could be built into a keyboard. And finally decided to build it for the Corne keyboard based on the BlackBarry 8520 optical sensor.
Check this out! And don’t forget to turn subtitles on! 😉
Trackpad.c that reads the trackpad data and sends it to QMK.
Schematics and PCBs
This add-on consists of two main parts:
- an adapter PCB that goes between Elite-C and the main keyboard
- a connector PCB that links trackpad with the adapter
Schematics and PCB designs are opensourced and could be found on my GitHub in KiCad format.
Also, I would like to thank the Grey Cat Co. for the amazing LoRa Text Dev Kit they have designed! It has the same BB 8520 trackpad. I analyzed their solution before starting my own design. In fact, I bought one LoRa Kit, connected my ProMicro to their SPI bus and did a quick working prototype with QMK! Check out this demo!
I had to create the adapter PCB due to several reasons. Firstly, I had to rewire Elite-C because I need hardware SPI pins for the BlackBarry trackpad. In the original Corne schematics, some of the SPI pins were used to perform the matrix scan.
And the second reason – the trackpad operates with 2.85V so I had to find a place for the 2.85V voltage regulator and 5V <-> 2.85V level shifter.
That’s how the adapter PCB looks in KiCad:
Sockets for Elite-C are soldered on the top side of adapter PCB.
All components such as voltage regulator, the level shifter, capacitors, and resistors are mounted on the bottom side.
The PCB bottom connector footprint is the same as ProMicro’s. It was designed to be easily connected to the Corne sockets.
Photo from the top:
And from the bottom with flex cable and connector soldered:
The keycap with the sensor
I used some 2-sided adhesive material to attach the trackpad to the keycap.
The only concern is the flexible circuit board that goes with the BB sensor. I’m not sure if it was designed to bend that much on every key click. Will figure this out on practice, I’ve been using the keyboard for about a week and it still works 🙂
Reading the trackpad data.
Here is my trackpad.c file that I included in my keymap’s rules.mk file. Pin definitions could be found in the trackpad.h.
I use the QMK Pointing Device feature to translate X and Y offset data into the mouse movements.
The Pointing Device feature should be explicitly enabled in the rules.mk:
POINTING_DEVICE_ENABLE = yes
The BB 8520 trackpad controller protocol is similar to the ADNS-3060 optical mouse sensor. Here is the related discussion on the Arduino forum.
The trackpad uses SPI so it has to be connected to the hardware Elite-C SPI pins. They’re PB1(SCK), PB3(MISO) and PB2(MOSI). These pins don’t have to be configured explicitly (that’s why you won’t find them in the trackpad.h). SPI pins are configured automatically as soon as SPI module is initialized on Elite-C (mega32U4).
The current implementation uses the polling technique. Every pointing_device_task() cycle reads data from 0x02 register. If the most significant bit is set then motion has occurred and we have to read X and Y offsets.
Then the data is sent to QMK core using pointing_device_send();
I wired the trackpad INT_MOTION line to the PD3 Elite-C pin (AtMega32U4’s INT line). Haven’t a chance to test this feature yet but I hope to avoid polling and use the interrupt line to detect the motion.
- PCBs – produced them with pcbway.com
- BlackBerry 8520 trackpad – could be found on eBay, like this.
- Bidirectional level shifter TXB0106PWR 5V <-> 2.85V
- SMD connector for BB8520 – 20POS 0.4MM
- 2.85V DC Regulator
- Mill-Max sockets
- Mill-Max pins
- 10 Position Cable Assembly Rectangular Socket – to connect two PCBs
- Connector header 10POS 2.54MM
- Capacitor 10uF
- Capacitor 100pF
- Capacitor 0.1uF
- Resistor 2.5k
- Resistor 3.3k
- Resistor 220k
Assembling the module.
Firstly, the adapter has to be inserted into the sockets on the Corne board.
Then Elite-C connects through the sockets to the adapter PCB.
The next step is to attach the second PCB using flex connector.
And lastly, the BB Trackpad connects to the small connector on the bottom of the second PCB.
I’ve been using this keyboard for about a week, still adjusting settings for mouse speed/acceleration 🙂
I use Logitech Trackman Marble as a trackball device, and I tried to get similar experience here. I believe now I can use my solution as a complete trackball replacement! It works great for me. Let me use it for another month and I’ll share more feedback:)
Also, I’m not an expert in PCB design. If you see some big issues with it please let me know or make a pull request 🙂
I hope this could be interesting to the keyboard community. Probably it’s possible to make a more generic solution for some other keyboards.
Please let me know what you think about this in the comments!
Bravo! This is just the kind of thing I have been searching for, thank you for sharing. I for one am interested in a few for my Corne/Crkbd/Helidox keyboards – and perhaps more if another variation of this could be generalized for other keyboard designs.
Thanks! Sure, I’d be happy to share any information if needed! It’s completely open-source, I have a few extra PCBs that I can send. It would be cool if someone else could build this mod too 🙂
Hi Volodymyr, thanks for sharing your solution, do you still have those extra PCBs you mentioned? I am interested in the solution 🙂
Adding a link to the post on Reddit.
This is really great. I was looking into adding a trackpad to a qmk powered keyboard, but this solution might be even more elegant than what I was looking for. Also, the level of documentation of the project stands out – thanks so much for sharing this in such detail.
I was mostly inspired and triggered by the ‘holding down to select’ action, that’s such a logical interaction when you see it … and is usually something people struggle with using regular trackpads.
I’m happy to hear you liked the trackpad idea! It integrates pretty well with QMK.
Hope this could help you to integrate a trackpad with your keyboard!
Hey ! Thank you for this nice and detailed project !
Do you still use it regularly ?
This is an amazing work. Some time ago I tried to integrate a thinkpad track point in an atomic keyboard , the software part and the track pad worked but was unusable ergonomically ( the trackpoint had too much lever). You solution is really good!
Hello, can you mail me please, I have some questions about this great project
Hello, can I ask you some questions about your project with trackpad?