T3.6 USB Host - Joysticks

@KurtE
You really filled in a lot of the missing pieces. That XBOX controller seems to be a lot different than the PlayStation controllers. Think I read somewhere that XBOX BT is kind of unique to the xbox controllers and doesn't follow the norm. Think we are seeing that now.

xBox1 controller must be extreme given it only works on Windows 10 AFTER the Anniv Update - and no prior build or Win versions … well that and Teensy ? :)


"@defragster - I kind of remember your map function when I was playing around with the ili9341 for the GPS PPS "
I hoped to get to that again last night - but installed and tested Beta10, and this AM is going fast to lunch time, distracted trying to take pain from arms while watching a uTube about 'The First Conspiracy: The Secret Plot to Kill George Washington' … 71 minutes to the end … late again ...
 
@defragster and @mjs513, so far still not on T36... , and yes you have to wonder when Windows did not support it either until the anniversary edition.

At some point, I should also try their wireless adapter to see if it works OK. I did that earlier for XBox360 wireless...

Currently distracted by other project of seeing if I can get the Hexapod robot working with the XL servos on OpenCM... The XBee is finally working again. Think there may have been lose connection.
Probably should see how much of my "Phoenix" code base is working... Will be fun later to migrate to something else like T4 :D

But I am trying to understand some of the differences so hopefully will make progress
 
@defragster and @mjs513, so far still not on T36... , ….

Currently distracted by other project of seeing if I can get the Hexapod robot working with the XL servos on OpenCM... The XBee is finally working again. Think there may have been lose connection.
Probably should see how much of my "Phoenix" code base is working... Will be fun later to migrate to something else like T4 :D
Think I am going to have to get up to speed on bus servos. That swappy rover I was looking at uses 10 LewanSoul LX-16A Serial Bus Servo. Can't find them anywhere so may have to switch.
 
Hi,

Excuse my ignorance... I didn't follow this thread, and I'm a little confused.
How "plug'n play" is this solution? Can I connect any simple USB joystick, and it works "out of the box" - like in Windows? Or should a hypothetical program have some kind of setup?
Is there simple sample code I can try? A simple documentation?
Can someone help me out? I don't like to deal with USB internals... USB and me, we don't like each other. So pls. help a noob ;)
 
Morning Frank

Its pretty much plug and play. Only problem is, you have to eventually do is map the button values to the joystick buttons and the axes values as well - there really is no automatic way to do that.

As for instructions - that I will leave to Kurt :)
 
Ok, I'll need a "setup" - program, then. Is there an example for that ? I think it's not needed to invent new wheels here.. ;)
 
The basic joystick example in the examples folder should get you started. A lot of stuff but its a start. If you look at the JoystickBT example you can see how we mapped axes to the actual joystick for the PS4.

What kind of joystick are you planning on using?
 
Hi Frank:

Guess question would be, which type of joystick:
Currently there are three different types:

a) USB -> HID type joysticks. That is ones that you plug in, that work in similar ways as Mice or Keyboards, in that their USB descriptor data contains information about how many buttons, axis, ... And the code tries to properly map these to handle them. This for example includes the PS3 and PS4 when they are plugged into USB. I don't have any other real joysticks, but @mjs513 has one or two in this category.

b) XBox 360 and One - Plugged in USB? Actually 360 needs wireless adapter. But different code in place for these...

c) Bluetooth - Not in main branch yet - Currently only PS3 and PS4 working... Hopefully will figure out newer XBox one but ... With these:
PS4 (and likewise for BT mice and Keyboards) you need to compile in the code to do the pairing: where you have:
BluetoothController bluet(myusb, true, "0000")
And once paired you:
BluetoothController bluet(myusb)

This is similar to what the Host Shield 2 code was doing, but at some point, would be nice to rearrange the code to have a call to say start claim or pair...

But currently with PS4, you then have it running the pairing code with BT dongle plugged in, and then do the PS4 pairing (hold down share button and press PS)... And hopefully it pairs.

for PS3 they don't really support pairing over BT, so put in "Hack", that works like some of the linux apps like sixpair or the HS2 code, and put in API, that writes the pairing information over USB to the PS3... So to pair you need to have (or have had), the BT module plugged in, so we can remember the BT ADDR, and then have the PS3 plugged in (both can be plugged in HUB). Then in the JoystickBT scketch I have code in place, that if you are holding down the select button and press the PS button, it will call this API, which hopefully should program the PS3. Then you can unplug the PS3, and plug in BT and then when you press the PS button on joystick it should connect...
 
@KurtE

You know you bring up a good point with your explanation. The examples that we have are good, especially since we know what they are doing, but maybe we need to do a little reorganizing of the examples, i.e., like what HS2 does.
 
@mjs513, @defragster, @Paul, ...

I agree that we can/should do more to help document things more. Not just for joysticks, but also for the other USB devices as well. Probably should be a section/thread on MIDI, HUBS, MICE, KEYBOARDS, Serial Adapters, Bluetooth - Although this gets more complicated as should I mention that currently don't support Microsoft Arc Mouse in the bluetooth section and/or Mouse section...

What is unclear to me is, where/how best to do it.

That is, as step 1) probably should update posting #1, to have more up to data information, like member functions, how to use... Which hardware has been tried....

2) Maybe make a more global usbhost_t36 thread, which either a) we move all of this data into, or b) references all of the other threads.

3) Did I hear WIKI ;)

4) Some new page up on PJRC main area.
 
Maybe a wiki or new page in the main area. Think once XBOX one is done then it can all be finalized. Think that is the only open piece of the existing lib. Don't have a XBOX 360 controller to test with so can't be of much help there.

Working on the examples now and can make some notes as I go on the callable functions. Then you all can decide where to put it I guess :) Don't think going to get much done today - too tired and head is not clear enough to sit in front of the screen if you know what I mean. Just one of those days.

@KurtE - Question: do we need rawhid function in the examples? Also is there a good example on what I can use to test it with :)
 
Maybe a wiki or new page in the main area. Think once XBOX one is done then it can all be finalized. Think that is the only open piece of the existing lib. Don't have a XBOX 360 controller to test with so can't be of much help there.

Working on the examples now and can make some notes as I go on the callable functions. Then you all can decide where to put it I guess :) Don't think going to get much done today - too tired and head is not clear enough to sit in front of the screen if you know what I mean. Just one of those days.

Sounds like a great idea to have some more complete examples. :D

And yes I know what you mean! I am also distracted with other things. Busy with stuff trying to keep from needing doctors... Not something I would discuss on forum ;)

@KurtE - Question: do we need rawhid function in the examples? Also is there a good example on what I can use to test it with :)
I think when I did a quick test of it, I connected a teensy 3.x to it with it running the Example Program: teensy->USB_RawHid->Basic
 
For what it is worth, yesterday I received an RC Radio system I ordered, to try out on a robot... Nice thing about it is, that the receiver can be configured to receive the channels using Serial at 115200... But yesterday I noticed that it can hook up USB and work as a HID device, So I thought I would try it out...

It worked:
Code:
USB Host Joystick Testing
*** Device HID1 284e:7fff - connected ***
  manufacturer: Flysky
  product: FS-i6S emulator
  Serial: A78519D90FCA
*** HID Device joystick[0H] 284e:7fff - connected ***
  manufacturer: Flysky
  product: FS-i6S emulator
  Serial: A78519D90FCA
Joystick(0): buttons = 15 0:127 1:127 2:127 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:130 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:162 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:205 3:126 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:232 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:209 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:132 3:127 4:127 5:127
Joystick(0): buttons = 15 0:127 1:127 2:127 3:127 4:127 5:127
The two joysticks on it output on 0-3, not sure yet what outputs on 4 and 5
All of the buttons appear to register in the buttons field... The only thing that does not appear to output anything (yet) is two knobs vra and vrb... Which I thought might update 4 and 5 (but don't appear to)
 
@KurtE
Make sure you print the axes out to about 20 or so - the knobs may appear at a higher axes value or check the raw axes array. Found that might be the case with some of other strange joysticks (Logitech).

Mike
 
@mjs513 - Hopefully the Joystick code is printing out all of the values that the HID device specifies...

I was able to now get the additional values, by reconfiguring the "Aux Channel" outputs
So now Channel5 - is VRA and Channel 6 is VRB and 7 is SWA...
So now when plugged in to USB the 4: and 5: columns are the two variable rotating knobs on top of display...

More importantly I am able to get these values through Serial input... (Or could go back to PPM type stuff)... The nice thing is that the Receiver only can output 6 servo values, BUT in IBUS it can receive 10.
 
@KurtE

Nice. The reason I mentioned it was that at one point I didn't see some of the axes data - but we made so many changes it probably works now :).

Sounds like a cool RC radio system :)
 
Hello all,
I am New on teensy board.
I should like to build usb joystick to ppm signal. My goal is to use this interface with remote controller.
What board use and where can I found à code or a library that fo that ?
Thanks for your help.
Pierre
 
@mjs513 - I am also happy that it still works :D The Radio appears to be a reasonable and cheap starter radio for RC, and has the added plus of these serial communications. There is supposedly some bidirectional communications capability as well. But I think it is limited to maybe sending back (voltage, throttle and maybe altitude)? Documentation is a bit sketchy, but I might try experimenting to see if I can make some of this work for something...

@pierrottm777 - Sorry, I am not understanding your goals. This thread is about connecting up joysticks using the USB Host capabilities of the Teensy 3.6 and now the Beta 4.0, using the usbhost_t36 library. This includes joysticks such as the PS3 or PS4 and other USB joysticks that you might connect to a PC. I am not sure if you are wanting to plug in some such controller? Or do you have some controller that you wish for the Teensy to process PPM signal data? Again not sure of your project goals. You might want to start your own thread where you describe what you are trying to do.
 
Thanks KurtE for your answer.
My goal is to generate a ppm signal with a teensy. The teensy receive a usb joystick pc as input and each mouvement is converted to a compatible ppm signal for use with a remote controler.
 
Again sorry, not sure what hardware is available to generate a PPM signal... A long long time ago, back in the Lynxmotion days, we built an RC remote control. At that time we used some Spectrum RC controller hardware. Have no idea where he got them. They did have a specific digital inputs they expected... Been a long time since I have looked at it and it was written in basic (Atom Pro)... So my guess is, it may depend on what hardware you are trying to use to send out the PPM signals.
 
I'm also wondering the status of this library. Does it support DualShock4/X-Box One controllers? Is it fairly stable?

It sounds like I can use a USB Host shield, but it would be great to just use a Teensy 3.6. (my project is to build a usb-to-nes controller adapter to use modern controllers on old console systems)
 
I know there is support for DS4s. Mine appears to have a dead battery again so I can not test it right now.

Supported with both hard wired and Bluetooth.

More details about Bluetooth stuff in the thread: https://forum.pjrc.com/threads/49358-T3-6-USB-Host-Bluetooth?p=166305&viewfull=1#post166305

Note: it has been awhile since I played with this stuff. But I am now playing with a Robot (Hexapod) project and I will be using BT to probably PS3 controller to start for control.

XBox One. I know I had some of this working earlier, but it has been a long while since I tried it, so don't remember the state. If I remember correctly at least the earlier ones did not use Bluetooth, so I am not sure if parts of it got fully implemented. . But I see that the example test sketch does show XBox360 and XBoxOne as for options showing data... So I know at least some of it was working.

EDIT: PS4 controller looks like it is happier right now charghing to my USB external powered hub in it's charging port. At least now the controller is showing the pulsing colors.
 
Last edited:
I'm converting a Teensy 3.6 project with HS2 to use Teensy 4.1 native host. PS4 dualshock seems to be working well on this board with BT but I don't see support for the trackpad yet. I'd be incapable of doing anything without the work you have accomplished on this. So watching with great interest for any new developments!
 
Ah good the example JoystickBT.ino is super helpful and shows nearly everything working. Multi-touch is a bit of a mystery though. joystick1.getAxis(35) seems to show a finger counter but the value only updates after all fingers are lifted.

I also don't see the trackpad button in the example (pushing on the trackpad provides an extra button) so I'm hunting for a way to decode that too.
 
Back
Top