Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: LUFA Mouse - Scroll wheel?

  1. #1

    LUFA Mouse - Scroll wheel?

    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.

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,025
    why not use the keyboard up/down arrow as a temporary fix

  3. #3
    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.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,323
    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.

  5. #5
    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!

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,323
    Quote Originally Posted by lufamousescrollwheel View Post
    Seems like they only have vertical scroll, not horizontal, so I will still probably have to read up on some USB standards.
    Oh, horizontal scroll. Maybe I should add that??

  7. #7

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,323
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •