Creating Your Own Keyboard From Scratch – Thumbstick and Mouse Buttons

Summary Page

wpid-dsc05512-e1351603196266-2012-10-30-23-05.jpg Relatively at the beginning of this project, with my second or third parts-order, I bought a thumb slide joystick and a beginners kit including some micro switches. I hadn’t any concrete plans to use them, though. While further reading about keyboards, mice and input devices in general as well as the ergonomic aspect of them, the idea settled to further minimize the length of the ways I had to move my hands on a normal workday. Since I’m habitually using the mouse a lot and with the parts already there, I decided to integrate the thumb joystick in the left keyboard part (a while ago I switched my mouse-hand) and mouse buttons in the right side. wpid-dsc05522-e1351604357995-2012-10-30-23-05.jpg So after getting the keyboard to work smoothly I decided to add basic mouse behavior. The goal was to integrate the mouse in such a way, that I could do basic navigation and clicking with my thumbs. Nothing really fancy. Luckily there was enough space and I didn’t had to modify the case much. Basically I just made holes for the buttons and the thumb joystick. In the latter case I had to grind off a little bit from the top of the case, so that the stick could freely move. I hadn’t really the time and energy to varnish the case and the buttons afterwards. So it still looks a little unfinished if you look closely. The thumb stick essentially behaves like two potentiometers, e.g. the resistance changes when you move it. You supply VCC and GND to the corresponding pins and connect each output to an analog pin of the Arduino. The device has a quite broad resting area. For example when you move it to the right and let it move back to the middle the measured value is 585 or less and when you move it to the left and release it the value is around 455 or above. The same is true for the Y-axis (top and down). I remember a tutorial using this thumb stick, unfortunately I can’t find it anymore, the values there were quite different compared to mine and the author stated, that you have to experiment to find the actual resting values. The next gist shows the code to read the thumb stick: [gist 3981451/] The code to send the mouse move to the right side of the keyboard will get explained in a later post. For now I come to the second part that constitutes a mouse, the mouse buttons. They are simply connected to pins of the Arduino of the right hand side and polled and debounced similar to the keys of the keyboard matrix. The following gist shows that: [gist 3983213/] After reading the thumb stick and the mouse buttons their combined state has to be send to the computer. To be able to do this – sending mouse reports in addition to keyboard reports – I had to change the device class (COD) to “COMBO”. You can achieve this by configuring the RN-42 HID module (see the documentation for details). Afterwards you can send raw mouse reports and the computer acts accordingly. Finally here is the code that does exactly that: [gist 3983329/] I had to experiment a lot with the actual values for the report interval as well as the strength of the mouse move. Again the test gui of the hidapi helped a lot to find out how real mice behave. Nevertheless I’m not really satisfied with the outcome. As fully wireless-nes would have been nice. Another aspect with tweaking potential.

Summary Page


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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