# Custom made trackball

**URL:** https://community.keyboard.io/t/custom-made-trackball/900
**Category:** Kaleidoscope Internals
**Created:** [December 27, 2017, 4:04am UTC](https://community.keyboard.io/t/custom-made-trackball/900 "2017-12-27T04:04:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![acasajus](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/acasajus/32/744_2.png) [@acasajus](https://community.keyboard.io/u/acasajus)
#### Post date: [December 27, 2017, 4:04am UTC](https://community.keyboard.io/t/custom-made-trackball/900/1 "2017-12-27T04:04:30Z")

</div>

Hello,

I’m thiinkikg of buiding a custom trackball. Well, not really a trackball… Instead if a ball i want to use an analog thumbstick. In any case i wouid like to use kaleidoscope and an atmega32u4. To read the thumbstick I can use the adcsin the micro, but trying to pry apart kaleidoscope it seems to need an attiny to do the matrix scan. Can sombody give me some pointers on hiw to do the matrix scan in the 32u4 directiy?

Cheers

---

<div class="post-metadata">

### Author: ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)
#### Post date: [December 27, 2017, 6:18am UTC](https://community.keyboard.io/t/custom-made-trackball/900/2 "2017-12-27T06:18:00Z")

</div>

Something like [AtmegaScanner](https://github.com/keyboardio/AtmegaScanner) should be close enough. It was made for the Shortcut, but should be reasonably easy to copy and adapt to reading thumbsticks, or anything else, directly with the 32u4.

---

<div class="post-metadata">

### Author: ![acasajus](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/acasajus/32/744_2.png) [@acasajus](https://community.keyboard.io/u/acasajus)
#### Post date: [December 27, 2017, 8:44pm UTC](https://community.keyboard.io/t/custom-made-trackball/900/3 "2017-12-27T20:44:16Z")

</div>

I know im asking a lot but how can i plug it into kaleidoscope?

---

<div class="post-metadata">

### Author: ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)
#### Post date: [December 27, 2017, 9:34pm UTC](https://community.keyboard.io/t/custom-made-trackball/900/4 "2017-12-27T21:34:35Z")

</div>

Something [along these lines](https://github.com/Dygmalab/Kaleidoscope-Hardware-Shortcut/tree/master/src). The core idea is that there are Hardware plugins, which implement most of the hardware-specific pieces of the puzzle, such as key scanning. These are pulled in by Kaleidoscope via the `KALEIDOSCOPE_HARDWARE_H` macro, defined in [boards.txt](https://github.com/keyboardio/Arduino-Boards/blob/master/boards.txt).

If you want to create a new device, you’ll need a new hardware plugin (which can either use other libraries, or reimplement things, whichever is more convenient/practical), and a new entry in `boards.txt` to pull them together.

Then, select the new board in the Arduino IDE, or if using the command line tools, set `BOARD` to the name of the board you used in `boards.txt`.

---

<div class="post-metadata">

### Author: ![acasajus](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/acasajus/32/744_2.png) [@acasajus](https://community.keyboard.io/u/acasajus)
#### Post date: [December 28, 2017, 9:46pm UTC](https://community.keyboard.io/t/custom-made-trackball/900/5 "2017-12-28T21:46:37Z")

</div>

thanks! I’ll look into that

---

<div class="post-metadata">

### Author: ![acasajus](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/acasajus/32/744_2.png) [@acasajus](https://community.keyboard.io/u/acasajus)
#### Post date: [January 4, 2018, 12:36am UTC](https://community.keyboard.io/t/custom-made-trackball/900/6 "2018-01-04T00:36:32Z")

</div>

hello again,

I’ve been looking at the shortcut code and I’ve got mire ir less figured out the matrix scan. But in order to properly emulate a mouse with a thumbstick i need to read two ADCs (0-1023) for the two axis. How should I return that to kaleidoscope? It has to be used to calculate the movement speed of the mouse. Should i do something special?

---

<div class="post-metadata">

### Author: ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)
#### Post date: [January 4, 2018, 9:49am UTC](https://community.keyboard.io/t/custom-made-trackball/900/7 "2018-01-04T09:49:36Z")

</div>

There are a number of ways to do this, I think. What I would do, is read the ADCs in the hardware plugins `scanMatrix` function, store the values in two variables, and in your sketch, have a macro that uses these to move the mouse (via MouseKeys).

This is definitely not the most elegant solution, but it is fairly simple.
