LUFA Mouse - Scroll wheel?

Status
Not open for further replies.
I am using a Teensy 2.0 for an HID project using LUFA's Mouse class drivers. I've been successful at moving the cursor on the screen and clicking. However, I am stuck trying to get scrolling to work. I've done a bit of searching on Google and looked through both the sample code and the documentation but I couldn't find any information on it. Have I missed it somewhere, or is mouse wheel scrolling not implemented in LUFA? Ultimately I would like my device to have both vertical and horizontal scrolling.
 
I have indeed done that, and I've been using it for about a week or so... Unfortunately there are a few applications which interpret the arrow keys and scrolling in pretty different ways. For example in text editors -- the arrow keys change the position of the text cursor but sometimes I just want to view something that's currently off the screen while keeping the text entry point the same.
 
You probably never wish to use Arduino if you're programming with LUFA, but maybe it wouldn't hurt too much to at least give Arduino quick try for comparison?

After installing Teensyduino, run Arduino and click File > Examples > Teensy > USB_Mouse > Buttons. Use a pushbutton or just tap a wire between GND and pins 14-17 to get the example to send scroll wheel communication. Yeah, I know some people don't like the idea of Arduino, but really to try this all you do is run a couple installers, run Arduino, click Tools > Boards to select your Teensy, then click the menu to open that example. Click Upload to program it onto your Teensy. So very quick and easy!

If you'd like to dig into the USB code, it can be found inside Arduino, in hardware/teensy/avr/cores/usb_mouse. If using a Mac, control-click Ardiuno and select "Show Package Contents". Then the hardware folder can be found inside Context/Java. But before digging into so much code, please do the very easy thing to try the ready-to-use Buttons example, so you can see it working first. :)
 
I guess it's not implemented in LUFA then, just as I feared...
Good idea with looking into Arduino though. Seems like they only have vertical scroll, not horizontal, so I will still probably have to read up on some USB standards.
Thanks for the reply, hopefully something useful will come out of this!
 
Since this old thread was written in 2017, I did indeed add horizontal scrolling support in Teensyduino's USB mouse feature.

From Arduino code, use it like this:

Code:
  Mouse.scroll(vertical, horizontal);

To scroll only horizontal, just use 0 for the vertical input.
 
Status
Not open for further replies.
Back
Top