Teensy 3.1: Adding mouse scrolling support for Linux

Logitech wireless keyboard + Teensy 3.1 + USB Host chip

Logitech wireless keyboard + Teensy 3.1 + USB Host chip

I recently started a project with a Teensy 3.1 and USB Host Shield, I dub it my Keyboard/Mouse Macroizer.  The objective was pretty simple: Record and Playback all of the actions one typically does with a keyboard and mouse.  This is fairly unique since it can record not only keyboard actions, but mouse actions too.  Currently I have two of them and they are my default keyboard and mouse both at home and at work.

LCD + 3d printed case

LCD + 3d printed case

Today I’ll just be talking about some modifications needed to the default Teensyduino 1.18 to add the necessary support for mice.  Apparently there is a bug in the linux driver for mice support, that causes the scrolling action on an absolute mouse, to not be processed by linux.  One day I may track it down, but for now, my work a round is to add a second mouse to the USB descriptors that the Teensy passes the OS when it begins the enumeration process.

Just so everyone knows, I’m using Eclipse as my IDE for this project since the Arduino IDE is designed for beginners.  I would have given up in frustration if I had to use the Arduino IDE to develop these project.

A quick summary of the changes I made:

  • Added support for 5 mouse buttons
  • Added an absolute mouse HID
  • Increased the power that the Teensy requests from the USB host (aka computer)
  • Removed support for the joystick (not necessary in my application)

I just went and updated Paul’s latest repo with my changes, which are reflected in the following git diff.  My recommended method of adding these features, if desired, is to use the application provided by Paul to get the base environment, then add the changes from there.

Continue reading