Forum Rule: Always post complete source code & details to reproduce any issue!
Page 7 of 7 FirstFirst ... 5 6 7
Results 151 to 153 of 153

Thread: Many axis joystick

  1. #151
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quote Originally Posted by obzai View Post
    Can anyone see any problems with trying to use a rotary encoder to act as a Mouse.scroll() wheel in a Teensy build of a hybrid mouse-keyboard-gamepad-mega-joystick with more than 8 axes?
    This should be possible. Certainly Teensy gives you the way to implement these HID interfaces and precisely control what actually gets sent to your PC.

    To specifically answer your question, here are some challenges you might face.

    If using Microsoft Windows, the default joystick driver might not recognize more than 8 axes, even though it's properly implemented on the Teensy side (assuming you've edited the code to enable the bigger HID joystick report - or otherwise edited the USB code).

    In designing your code on the Teensy side, you'll want to avoid delays, so you're always being responsive to all the input signals. Simple as this sounds, real-world signals often aren't as nice as you might like and require "debouncing" or other techniques. Many people have gone down a path of adding delays in their code, which tends to work for only 1 signal, but then becomes really difficult when the delays to clean up 1 signal cause everything to be unresponsive to all the others. Teensyduino has features like elapsedMillis to make this easier, so if you need to do this sort of work I recommend using those and avoid delay().

    HID provides fixed bandwidth. At best you can send 1000 events per second. That's usually plenty, but it can quickly become a limitation if you do things inefficiently. The joystick functions have a way to freeze, so you can change multiple settings and have it all go out the USB cable to your PC as a single packet.

    If you do approach the bandwidth limits, those functions to send will end up waiting. If using the Encoder library, you may see the result of several changes at once. Likewise for other inputs, if those functions have to wait, your code may be "blind" to changes. Teensy's USB stack does buffer several outgoing packets, which gives you some flexibility. But as a general rule, if you try to sustain close to or more than 1000 updates per second, you will run into HID bandwidth limits and ultimately your code will suffer waits in the transmit functions.

  2. #152
    Junior Member
    Join Date
    Aug 2018
    Fantastic, thanks for the detailed reply Paul.

    Sounds like I could reasonably expect to build something that will work using this approach. I'll see how I go.
    Thanks for your work on the Teensy boards Paul, they're my favourite "do anything" solution. I always keep a couple on hand.

  3. #153
    Junior Member
    Join Date
    Sep 2018
    I tried to code a 8 axis joystick. I took the many axis joystick disabling all sliders beyond 2. Only data from the 6 axis are transmitted, sliders remain at zero
    Click image for larger version. 

Name:	Joystick.JPG 
Views:	35 
Size:	49.9 KB 
ID:	14715

Posting Permissions

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