T3.6 USB Host - Joysticks

@defragster - I guess I should see why my computer is still on 1803?

@mjs513 - yep the FF00-FFF is vendor specific... Which is always fun.

And Yes it is fun when even things like Sony is for example even Sony is not consistent between their own products... Example PS3...
The Hat: shows up as 4 buttons (0x10 up, 20 right, 40 down 80 left)... But also shows up in axis for pressure values in 14, 15, 16, 17

But then PS4: They don't show up as buttons at all, it does update the HAT axis 0x39 with values like 0x08 nothing pressed, 0x0 if up press, 2 right, 4 down, 6 left

But then look at its description and you see:
Code:
Usage (Hat Switch),             ; Hat switch (39h, dynamic value)
    Logical Minimum (0),
    Logical Maximum (7),
    Physical Minimum (0),
    Physical Maximum (315),
    Unit (Degrees),
    Report Size (4),
    Report Count (1),
    Input (Variable, Null State),
    Unit,
Which I am not really processing correctly... As we really should be processing this like:
So UP button is 0/7*315 = 0 degrees,
Right2/7*315 = 90 degrees.
Down 4/7*315 = 180
left = 6/7*315 = 270
...
 
@KurtE and @defragster

As an aside I saw the Windows play store lets you download and install Linux versions per that link that Tim posted :)

Now you realize of course that is all for wired controllers and not for Bluetooth. For BT they don't present themselves as HID devices as far as I can tell unless its not just printing. And of course I don't get those nice prints you get from Linux. :)

EDIT: Any chance we can try and get XBOX working BT for comparison with the sony controllers?
 
Hi Mike,

Hopefully will get the XBox joystick later today... But may take awhile to figure out how it is working...

As a side note: I have a hacked up version of the BT hid input, to play with the PS3, so that buttons and axis work the same... But again just playing around:
Code:
bool JoystickController::process_bluetooth_HID_data(const uint8_t *data, uint16_t length) 
{
	// Example data from PS4 controller
	//01 7e 7f 82 84 08 00 00 00 00
	//   LX LY RX RY BT BT PS LT RT
	//DBGPrintf("JoystickController::process_bluetooth_HID_data\n");
	// May have to look at this one with other controllers...
	if (data[0] == 1) {
		//print("  Joystick Data: ");
		//print_hexbytes(data, length);
//		DBGPrintf("  Joystick Data: ");
		if (length > TOTAL_AXIS_COUNT) length = TOTAL_AXIS_COUNT;	// don't overflow arrays...
		if (joystickType == PS3) {
			// Quick and dirty hack to match PS3 HID data
			uint32_t cur_buttons = data[2] | ((uint16_t)data[3] << 8) | ((uint32_t)data[4] << 16); 
			if (cur_buttons != buttons) {
				buttons = cur_buttons;
				joystickEvent = true;	// something changed.
			}

			uint64_t mask = 0x1;
			axis_mask_ = 0x27;	// assume bits 0, 1, 2, 5
			for (uint16_t i = 0; i < 3; i++) {
				if (axis[i] != data[i+6]) {
					axis_changed_mask_ |= mask;
					axis[i] = data[i+6];
				}
				mask <<= 1;	// shift down the mask.
			}
			if (axis[5] != data[9]) {
				axis_changed_mask_ |= (1<<5);
				axis[5] = data[9];
			}

			// Then rest of data
			mask = 0x1 << 10;	// setup for other bits
			for (uint16_t i = 10; i < length; i++ ) {
				axis_mask_ |= mask;
				if(data[i] != axis[i]) { 
					axis_changed_mask_ |= mask;
					axis[i] = data[i];
				} 
				mask <<= 1;	// shift down the mask.
			}

		} else {
			uint64_t mask = 0x1;
			axis_mask_ = 0;

			for (uint16_t i = 0; i < length; i++ ) {
				axis_mask_ |= mask;
				if(data[i] != axis[i]) { 
					axis_changed_mask_ |= mask;
					axis[i] = data[i];
				} 
				mask <<= 1;	// shift down the mask.
//				DBGPrintf("%02x ", axis[i]);
			}

		}

		if (axis_changed_mask_ & axis_change_notify_mask_)
			joystickEvent = true;
		connected_ = true;
		return true;
 
Hey Kurt

Just started playing around with your PS3 code. You do have to make 1 change to start:
Code:
for (uint16_t i = 0; i < 3; i++)    s/b for (uint16_t i = 0; i < 4; i++)

EDIT:
assume bits 0, 1, 2, 5 -> should add in 3,4 for L1/L2 triggers - that seems to be HID id putting those values. Which is 18 and 19. So, axis 4 and 5 would equate to the rumble triggers.

EDIT2:
As a test I use psAxis[18], psAxis[19] for the trigger values but the way its set up with the change mask it you neve see a smooth transition from 0-255 it goes in fits or stops.
 
Last edited:
Hi @mjs513 and @defragster.

New toys arrived today starting to play :D

I have not done much yet with the XBox one controller, I did plug it in USB and get some data, but not a lot of information and maybe not button information... Will soon

But also one of the PS3 controllers that have a bluetooth type of Keyboard and did not return any data...

And noticed when we completed the connectionComplete callback it showed as unknown joystick type, even though earlier was set to PS3???
Figured out my name copy function had an off by one error which turns out this controller has a name > size of buffer and so I overwrote the joystick type with trailing NULL character... Fixed,
Now that cheap joystick is outputting data...

Also have function in place, that if you have a PS3 plugged into USB and have the BDADDR of the Bluetooth controller, and can do the stuff like sixpair and write out data to the joytick for binding.

I updated the sketch that if you are holding down the select button and press the PS button, it will call this function. I have the test app modified that it remember the last Bluetooth device BDADDR that was plugged in during this boot, and if there is one it uses it... So should work if you plug both into HUB or if you first plug in Bluetooth adapter, unplug, plus in PS3, do this operation plug the BT adapter back in and hit the PS button... At least it appeared to work with this new controller.

The code has the PS3 mapping I mentioned earlier.

Also have some code I was experimenting with trying to get the device name in the PS4 pair mode, which is still not working properly, It looks like I get part of the data interspersed with joystick data returned...

So the question is, would it hurt anyone if I push up these changes to github, even though it is all still WIP?
 
New XBox One controller:
Looks like it is still not a HID device...

More Linux USB info on the device:
Code:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 045e:02ea Microsoft Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ lsusb -v -d  045e:02ea

Bus 001 Device 004: ID 045e:02ea Microsoft Corp.
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass        71
  bDeviceProtocol       208
  bMaxPacketSize0        64
  idVendor           0x045e Microsoft Corp.
  idProduct          0x02ea
  bcdDevice            3.01
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           96
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x00e4  1x 228 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

Should mention, also got an XBox Wireless Adapter for Windows 10... Again no HID information, but...
Code:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 005: ID 045e:02fe Microsoft Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ sudo usbhid-dump
No matching HID interfaces
pi@raspberrypi:~ $ lsusb -v -d  045e:02fe

Bus 001 Device 005: ID 045e:02fe Microsoft Corp.
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x045e Microsoft Corp.
  idProduct          0x02fe
  bcdDevice            1.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           74
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          2
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           8
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x08  EP 8 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x07  EP 7 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x09  EP 9 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
pi@raspberrypi:~ $
Not sure yet what it's usage is... Now soon try bluetooth connection and see what it does...
 
I say PUSH away with what you have. If it isn't current - but may be broken - it can't get fixed :) I'm going to tell GitHub to forget my Fork/Clone next time and try to start fresh.

>>> … started this post some hours ago - then ate and updated WSL to working and current … I wonder if I can get TyComm to build … and rewrite FrankB's Compile.cmd in Linux'ese … of course then I'd need SublimeText on Linux and a GUI … sounds like a big chore.
The Compile.cmd is working very well from SublimeText - Have not had the IDE open in some time except one quick question - compiled dozens of sketches for different Teensy's - and even used The NEW_Sketch command to good end.

rebooted and 240 MB to install the Ubuntu LTS 18.04 … installing this may take a few minutes …
>> Ugh :: Is Microsoft Edge Becoming Just a Clone of Google Chrome? --- Microsoft promised an early build of the new Chromium-based Edge browser in early 2019, but no further specifics were shared.
Manual update required … that is done so I can look around: > sudo apt update && sudo apt upgrade

Paired my Bt Rii with my computer - it is a useful tiny keyboard. But this isn't the Bt thread.

Would be interesting to use a USBHosted Joystick on a Teensy to trigger that Teensy to activate the Joystick features to a second USBHost.

Kurt - If you manually ask for Windows Update Check it may trigger a PULL request. If I scanned something I saw today they didn't enable the broader distribution on AutoUpdate until maybe Jan 17th? With two or more computers to do - Links to get the ISO image and then the latest Update to manually load it form personal Media is what I do and recommend.

>> Use Windows Media Creator Tool to get an ISO of about 4GB - [ or burn right to Bootable flash - but don't boot install] - then run Setup on that Media from Windows.
>> Then going here Windows 10 - Release information would lead to this for the latest cumulative update for 1809 : 17763.348 KB 4482887 from here Microsoft Update Catalog.
Then click "Download" there for 2019-02 Cumulative Update for Windows 10 Version 1809 for x64-based Systems (KB4482887) - where you click the named .msu file to actually start the next 153MB download.
>> Run that download package to get the CORES updated - reboot and run Windows Update to get the rest of the device changes.

I do that once for the Major release [have been each 6 months] then each numbered Cumulative update to my read only switched flash drives so I can update multiple computers a month - keep my Flash safe and not download the same thing dozens of times. And it is bootable for fresh re-installs.
I was behind with .316 on my local copies so I just downloaded that newest .348.
 
Kurt: Bt Addr association to PS3 controller sounds very cool! - Nice work - looking forward to seeing it in action and looking at the code.

Mike - the Tset Compile.Cmd can work from the command line just as well - except for on compile error I think it still closes the console window I saw last night because of the exit at the end, but that is useful for SublimeText.
The other good thing about Sublime is that it monitors files for change and reloads and has very extensive Undo/Redo in addition to the search File and Folder. Free trial hooked me - it had the global search my 1992 era editor did - so I was sold. I have 5 Sublime instances open - each to a different folder - with files counts open of 8/8/6/8/13 to various parts of Teensy by Folder: Debug_tt, USBHost_T36, Teensy Install Folder, ILI9488, XPT2046 so I can text search anything in that folder and jump right to it, or click any file name in the left bar folder list and pop it open. And with the RegEx search on Compile.cmd building - double click on Error line # opens whatever file that is in - just a tiny bit better than IDE or Notepad :)

Mike - did you ever get one of FrankB's Teensy64 unit kits TFT or VGA? I came across one I built - fully complete with TFT&T_3.6 with USB Host connected on PCB and my missing RF Keyboard adapter. It is now the 7th Teensy on my monitor stand - lucky for 7 port powered Hub! but I need one more short USB cable.

Kurt - My K66 Proto is here - did you ever use that for USBHost testing? I suppose that must work.
 
@KurtE and @defragster

I would agree, push away to GitHub - shouldn't hurt :)

Wonder if this
Figured out my name copy function had an off by one error which turns out this controller has a name > size of buffer and so I overwrote the joystick type with trailing NULL character... Fixed,
Now that cheap joystick is outputting data...
was preventing that other PS3 controller from working as well.

Do have a question on your new PS3 mapping

Right now you have the LX, LY, RX,RY mapped to axes - 0,1,2,5 (took a few minutes to figure out the mask :)). But from the wired test it looks like the HID structure is:
Code:
  usage = 10030  data = 129     <==== LX
  usage = 10031  data = 126     <==== LY
  usage = 10032  data = 122     <==== RX
  usage = 10033  data = 0         <==== L2
  usage = 10034  data = 0         <==== R2
  usage = 10035  data = 125     <==== RY

So axes[3] and axes[4] would be L2, R2. Wouldn't it be better if we keep the LX,LY,RX,RY contiguous then put the L2,R2 next. Know this is not exactly the same but may be a little more intuitive.
 
defragster said:
Mike - did you ever get one of FrankB's Teensy64 unit kits TFT or VGA? I came across one I built - fully complete with TFT&T_3.6 with USB Host connected on PCB and my missing RF Keyboard adapter. It is now the 7th Teensy on my monitor stand - lucky for 7 port powered Hub! but I need one more short USB cable.
Ok just saw this - still having my morning coffee :)

I don't think I ever saw Franks Teensy64 - is that the same as his commodore64?
 
Ok just saw this - still having my morning coffee :)

I don't think I ever saw Franks Teensy64 - is that the same as his commodore64?

Yes, that is the same thing :: github.com/FrankBoesing/Teensy64. Give that thread a look. I still have parts to assemble kits TFT or VGA. Only limitation is to get Serial1 looked like it would pull lines from Joystick - if I read the file I compiled properly. It seems I sent one to KurtE - forget if it was VGA or TFT - VGA ( with room for yet another desktop display ) would be fun for debug - more so that 2.8" TFT it is fitted for. It would hold my 3.5" - but not screw down to be a solid unit since the mount holes moved.

Enjoy your coffee - time for (too little) sleep
 
@KurtE
I added these lines to your PS3 axis mapping:
Code:
			axis_mask_ = 0x0c;	// assume bits 3,4 for triggers
			if (axis[3] != data[18]) {
				axis_changed_mask_ |= (1<<3);
				axis[3] = data[18];
			}
			
			if (axis[4] != data[19]) {
				axis_changed_mask_ |= (1<<4);
				axis[4] = data[19];
			}

Left everything else the same.

@Frank B
I looked at the GitHub page for the Teensy64 but didn't see the Gerbers - are they available?
 
no, they're not open source. the board is the only way to get at least a part of my dev- costs back( had to buy some old c64- hardware , I have two original c64 now, two disk drives and some more..). If you're interested I send you both boards (vga+display) for free (drop me a mail..)
 
Hi guys, Ok I pushed up my current stuff.

Mike, as to why for example PS3 currently L2/R2 are on 18, 19 where as PS4 they are on 3,4?

I have no idea ;) That was how in both cases Sony decided to use the HID descriptor.

Would it be great to have them both mapped the same? Absolutely Should we remap them? Maybe, especially if we can do it in a reliable way for both HID and BT...
Would it be better if LX, LY, RX, RY where contiguous numbers? Again Maybe, but then again I would likely try to use #define names or enum names so probably does not matter.


The interesting question is what about the logical joysticks someone might create, example If I make a default Teensy joystick (12 data size), And I write to index 5 for Rz, If I then plug it into my Teensy 3.6/4 and wish to use the joystick device should it return back on the same axis index as I wrote it out? Or some new standardized order?

Again Feel free to try making the changes in mappings as you think make sense and we will see if/when someone gives some feedback.

But I am getting pretty happy with some of this stuff, as it looks like we have a workable cheap PS3/BT solution for adding wireless controllers :D
 
Back to the aside - howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

Did the Linux enable - now need to reboot. Then this might have added ref info : microsoft.com/commandline/2018/11/05/whats-new-for-wsl-in-the-windows-10-october-2018-update/

Ick - just saw a virus called Chrome on my computer - how did that get installed 2/25/19???

Ok Guys

Just installed ubuntu, etc per the post but when I run usbhid-dump it is not picking up any hid devices even if I have the Logitech joystick installed. Any ideas.
 
Hi guys, Ok I pushed up my current stuff.

Mike, as to why for example PS3 currently L2/R2 are on 18, 19 where as PS4 they are on 3,4?

I have no idea ;) That was how in both cases Sony decided to use the HID descriptor.

Would it be great to have them both mapped the same? Absolutely Should we remap them? Maybe, especially if we can do it in a reliable way for both HID and BT...
Would it be better if LX, LY, RX, RY where contiguous numbers? Again Maybe, but then again I would likely try to use #define names or enum names so probably does not matter.


The interesting question is what about the logical joysticks someone might create, example If I make a default Teensy joystick (12 data size), And I write to index 5 for Rz, If I then plug it into my Teensy 3.6/4 and wish to use the joystick device should it return back on the same axis index as I wrote it out? Or some new standardized order?

Again Feel free to try making the changes in mappings as you think make sense and we will see if/when someone gives some feedback.

But I am getting pretty happy with some of this stuff, as it looks like we have a workable cheap PS3/BT solution for adding wireless controllers :D

Actually for the PS4 the mapping looks something like this:
* [1] LX, [2] = LY, [3] = RX, [4] = RY
* [5] combo, tri, cir, x, sqr, D-PAD (4bits, 0-3 <====> these are buttons, d-pad are the arrows
* [6] R3,L3, opt, share, R2, L2, R1, L1
* [7] Counter (bit7-2), T-PAD, PS
* [8] Left Trigger, [9] Right Trigger
* [10-11] Timestamp
* [12] Battery (0 to 0xff)
* [13-14] acceleration x
* [15-16] acceleration y
* [17-18] acceleration z
* [19-20] gyro x
* [21-22] gyro y
* [23-24] gyro z
* [25-29] unknown
* [30] 0x00,phone,mic, usb, battery level (4bits)
* rest is trackpad? to do implement?

If we map the buttons the same way as for the PS3 then we can map the 0-5 exactly the same. Should be doable. Just have to go back to my notes on the buttons.
 
Hi Mike,

As you mentioned - At least by default I don't think the current release of the Ubuntu stuff is seeing the devices.

I currently have the 1803 version of windows and my quick look, I am not sure that Microsoft ever continued with installing the October release after some had issues of losing data....

Maybe there is a setting somewhere that allows you to see more of the devices. At least on the Mac where I have Windows and some Ubuntu installed, you can choose who sees a device.

Which is why I have an RPI sitting 5 feet from me, where I can plug it in and Putty(Kitty) to it and run those types of commands...

Also have my old DELL desktop sitting next to me as well if I need to do some serious Linux stuff.

But right now (like most mornings) doing more Annie stuff ;)
 
@mjs513 - Annie is happy!

I tried connecting XBox One by Bluetooth, not seeing much yet... Also looks like I may be on my own as I don't think the HS2 has support for it either?

Of course maybe I busted something with pairing as well...
Code:
BluetoothController claim this=20004280 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
    Control callback (bluetooth): 1 : 3 c 0
BT rx_data(6): e 4 1 3 c 0
    Command Completed!
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
    Control callback (bluetooth): 3 : 24 c 3 4 8 0
BT rx_data(6): e 4 1 24 c 0
    Command Completed!
HCI_Read_BD_ADDR called (09 10 00 )
    Control callback (bluetooth): 4 : 9 10 0
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0
    Command Completed!
   BD Addr:13:71:da:7d:1a:0
HCI_Read_Local_Version_Information called (01 10 00 )
    Control callback (bluetooth): 4 : 1 10 0
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22
    Command Completed!
    Local Version: 6
HCI_INQUIRY called (01 04 05 33 8b 9e 30 0a )
    Control callback (bluetooth): 6 : 1 4 5 33 8b 9e 30 a
BT rx_data(6): f 4 0 1 1 4
    Command 401 Status 0
[COLOR="#FF0000"]BT rx_data(16): 2 f 1 dc 13 d6 1b aa 9c 1 2 0 8 5 0 39
BT rx_data(1): 76
    Inquiry Result - Count: 1
      BD:dc:13:d6:1b:aa:9c, PS:1, class: 508
BT rx_data(3): 1 1 0
    Inquiry Complete - status: 0
[/COLOR]
The only data I am seeing when I press the pair button on XBox is the last part...

Need to see why I am not processing it? Or what is different

EDIT - A little farther - was only allowing class of 25xx to go through now let 5xx go through and see:
Code:
BT rx_data(6): f 4 0 1 1 4
    Command 401 Status 0
BT rx_data(16): 2 f 1 dc 13 d6 1b aa 9c 1 2 0 8 5 0 a7
BT rx_data(1): 71
    Inquiry Result - Count: 1
      BD:dc:13:d6:1b:aa:9c, PS:1, class: 508
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 200050b8
JoystickController::claim_bluetooth TRUE
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
    Control callback (bluetooth): 100 : 2 4 0
BT rx_data(6): e 4 1 2 4 0
    Command Completed!
HCI_CREATE_CONNECTION called (05 04 0d dc 13 d6 1b aa 9c 18 cc 01 00 00 00 00 )
    Control callback (bluetooth): 101 : 5 4 d dc 13 d6 1b aa 9c 18 cc 1 0 0 0 0
BT rx_data(6): f 4 0 1 5 4
    Command 405 Status 0
BT rx_data(13): 3 b 0 48 0 dc 13 d6 1b aa 9c 1 0
    Connection Complete - ST:0 LH:48
HCI_AUTH_REQUESTED called (11 04 02 48 00 )
    Control callback (bluetooth): 110 : 11 4 2 48 0
BT rx_data(6): f 4 0 0 11 4
    Command 411 Status 0

=====================
BT rx2_data(16): 48 20 c 0 8 0 1 0 2 1 4 0 1 0 40 0
    L2CAP Connection Request: ID: 1, PSM: 1, SCID: 40
BT rx_data(5): 1b 3 48 0 5
BT rx_data(8): 17 6 dc 13 d6 1b aa 9c
    Event: Link Key Request dc:13:d6:1b:aa:9c
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 dc 13 d6 1b aa 9c )
BT rx_data(6): f 4 0 1 0 0
    Command 0 Status 0
    Control callback (bluetooth): 120 : c 4 6 dc 13 d6 1b aa 9c
BT rx_data(12): e a 1 c 4 0 dc 13 d6 1b aa 9c
    Command Completed!
BT rx_data(8): 16 6 dc 13 d6 1b aa 9c
    Event: Pin Code Request dc:13:d6:1b:aa:9c
HCI_PIN_CODE_REPLY called (0d 04 17 dc 13 d6 1b aa 9c 04 30 30 30 30 00 00 00 00 00 00 00 00 00 00 00 00 )
    Control callback (bluetooth): 130 : d 4 17 dc 13 d6 1b aa 9c 4 30 30 30 30 0 0 0 0 0 0 0 0 0 0 0 0
BT rx_data(12): e a 1 d 4 0 dc 13 d6 1b aa 9c
    Command Completed!
BT rx_data(5): 6 3 6 48 0
    Event: HCI Authentication complete(6): handle: 48
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )
tx_data callback (bluetooth): 0 : 48 20 c 0 8 0 1 0 2 0 4 0 11 0 70 0
BT rx_data(7): 13 5 1 48 0 1 0

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 3 0 0 0
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:3, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )
tx_data callback (bluetooth): 0 : 48 20 10 0 c 0 1 0 4 0 8 0 40 0 0 0 1 2 ff ff
BT rx_data(7): 13 5 1 48 0 1 0

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 1 0 6 0 2 0 40 0 0 0
    L2CAP command reject: ID: 0, length:6, Reason:2,  Data: 0 40
BT rx_data(6): 5 4 0 48 0 8
    Event: HCI Disconnect complete(0): handle: 48, reason:8

Again so far on my own, as HS2 does not support yet: https://github.com/felis/USB_Host_Shield_2.0/issues/252
 
Last edited:
Hi Kurt

Always nice when our kids are happy :)

Anyway you may want to substitute this for ps4 0x11 in joystick.cpp
Code:
		} else if(data[0] == 0x11){
			DBGPrintf("\n  Joystick Data: ");
			uint64_t mask = 0x1;
			axis_mask_ = 0;
			axis_changed_mask_ = 0;
			
			//This moves data to be equivalent to what we see for
			//data[0] = 0x01
			uint8_t tmp_data[length-2];
			
			for (uint16_t i = 0; i < (length-2); i++ ) {
				tmp_data[i] = 0;
				tmp_data[i] = data[i+2];
			}
			
			/*
			 * [1] LX, [2] = LY, [3] = RX, [4] = RY
			 * [5] combo, tri, cir, x, sqr, D-PAD (4bits, 0-3
			 * [6] R3,L3, opt, share, R2, L2, R1, L1
			 * [7] Counter (bit7-2), T-PAD, PS
			 * [8] Left Trigger, [9] Right Trigger
			 * [10-11] Timestamp
			 * [12] Battery (0 to 0xff)
			 * [13-14] acceleration x
			 * [15-16] acceleration y
			 * [17-18] acceleration z
			 * [19-20] gyro x
			 * [21-22] gyro y
			 * [23-24] gyro z
			 * [25-29] unknown
			 * [30] 0x00,phone,mic, usb, battery level (4bits)
			 * rest is trackpad?  to do implement?
			 */
			//PS Bit
			tmp_data[7] = (tmp_data[7] >> 0) & 1;
			//set arrow buttons to axis[0]
			tmp_data[10] = tmp_data[5] & ((1 << 4) - 1);
			//set buttons for last 4bits in the axis[5]
			tmp_data[5] = tmp_data[5] >> 4;
			
			// Quick and dirty hack to match PS3 HID data
			uint32_t cur_buttons = tmp_data[7] | ((uint16_t)tmp_data[10] << 8) | ((uint32_t)tmp_data[5] << 16); 
			if (cur_buttons != buttons) {
				buttons = cur_buttons;
				joystickEvent = true;	// something changed.
			}
			
			mask = 0x1;
			axis_mask_ = 0x27;	// assume bits 0, 1, 2, 5
			for (uint16_t i = 0; i < 3; i++) {
				if (axis[i] != tmp_data[i+1]) {
					axis_changed_mask_ |= mask;
					axis[i] = tmp_data[i+1];
				}
				mask <<= 1;	// shift down the mask.
			}
			if (axis[5] != tmp_data[4]) {
				axis_changed_mask_ |= (1<<5);
				axis[5] = tmp_data[4];
			}
			
			if (axis[3] != tmp_data[8]) {
				axis_changed_mask_ |= (1<<3);
				axis[3] = tmp_data[8];
			}
			
			if (axis[4] != tmp_data[9]) {
				axis_changed_mask_ |= (1<<4);
				axis[4] = tmp_data[9];
			}
			
			//limit for masking
			for (uint16_t i = 11; i < (64); i++ ) {
				axis_mask_ |= mask;
				if(tmp_data[i] != axis[i]) { 
					axis_changed_mask_ |= mask;
					axis[i] = tmp_data[i];
				}
				mask <<= 1;	// shift down the mask.
				DBGPrintf("%02x ", axis[i]);
			}
			DBGPrintf("\n");
			//DBGPrintf("Axis Mask (axis_mask_, axis_changed_mask_; %d, %d\n", axis_mask_,axis_changed_mask_);
			joystickEvent = true;
			connected_ = true;
		}
	}

It makes it look exactly like what you did for PS3 with the exception that I put rumble buttons on axes 3,4. Here is the whole joystick.cpp.
View attachment joystick.zip

EDIT: Think I messed up on the buttons though - you may want to work your magic on those :)
 
Re: USBHost ( not to be on topic :) )- I removed my Github desktop Clone link to my Web Fork repository - then reForked to Web and Cloned to Desktop. Will see if it stays cleaner going forward again. I suppose I'll trash my current Lib Copy and migrate to this new set of code.

RE: Windows 1809: After mid Nov the October Update was approved for release in WinUpdate. I'm not sure I've seen many machines that got it yet - there are a couple hundred million folks in line - they are keeping the 1803 release up to date with regular updates was .500 something last I saw - linked page above would show the number. Win 10 is at or near matching/exceeding the number of Win 7 installs.

If you do it Manually grabbing the install sources [ISO and latest CUM update] as linked - you can do all the X64 devices you have with it and limit download bandwidth to 1X of perhaps 4.5GB - and issues with started/stalled installs (perhaps multiple partial downloads) - or having it show up and want to reboot your machine at a time you don't like. The major problem noted with the Oct2018 release was some 1% or 1% of folks that picked custom replacement/extended folders for the "MY 'files'" would have that link clipped and files lost - very ugly - but affecting small subset of installs - none that I did on casual user machines. When I do it from my lockable Flash I manually copy all the files/folders from FLASH root to C:\tmp\Win1809 folder then run setup from there so I can remove the Flash and not have it BOOT to the flash. I also copy over the CUMxxx.msu to C:\tmp and run that after the 1809 install is complete. If you have ANY old Win7 or Win8 machine you can booth the Flash and do a clean install of Win 10 and say "don't have Serial #" after selecting "Custom" install - this works with a fresh HDD or to fresh install on older system. Then on booting each time I've seen it going to the SYSTEM tab and 'Activate Windows' will show 'Activated' without providing a Serial##Key. Not sure if they are checking a 'machine fingerprint' against prior installs - or just letting everyone move to Win10. Only gotcha is that a machine with rights to "HOME" must be installed as home and not professional - so they do know that much.

RE: ubuntu/WSL - I saw some notes in one of the links that Speed was not optimal - that may have been CPU? It was referring to some unique neural or other intensive stuff - but not everything is likely to map perhaps, especially given it is CmdLine only - what would the CmdLine do with a JoyStick? Wondering if a GUI might map that? One thing I did on my EARLY install was find where the Linux files mapped to Windows disk drives. Yesterday I read a WARNING - do not find or use that! The Linux OS file attributes will not be preserved/set when Windows adds or edits files within the Linux file space making them invisible or unusable to the Linux install. So there are some areas of contention with this being native mapping of Linux into the Windows machine.

So if I did the weeklong 'diversion' to try to get a GUI WSL install [Windows Subsystem for Linux, or WSL] - put on SublimeText and TyComm I could find out how much really works with Teensy on WSL. So far I just have an open Ubuntu CMDline console window open where I can do ls and cd :)
 
My cat is less than happy/content - sitting here staring at a cold woodstove I need to get fired up. She just stood up with nails into my chair armrest as she has been patiently waiting about an hour now as I sit here …

Mike I just sent email re Frank's boards.
 
@mjs513 - Annie is happy!

I tried connecting XBox One by Bluetooth, not seeing much yet... Also looks like I may be on my own as I don't think the HS2 has support for it either?

Of course maybe I busted something with pairing as well...
Code:
BluetoothController claim this=20004280 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
    Control callback (bluetooth): 1 : 3 c 0
BT rx_data(6): e 4 1 3 c 0
    Command Completed!
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
    Control callback (bluetooth): 3 : 24 c 3 4 8 0
BT rx_data(6): e 4 1 24 c 0
    Command Completed!
HCI_Read_BD_ADDR called (09 10 00 )
    Control callback (bluetooth): 4 : 9 10 0
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0
    Command Completed!
   BD Addr:13:71:da:7d:1a:0
HCI_Read_Local_Version_Information called (01 10 00 )
    Control callback (bluetooth): 4 : 1 10 0
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22
    Command Completed!
    Local Version: 6
HCI_INQUIRY called (01 04 05 33 8b 9e 30 0a )
    Control callback (bluetooth): 6 : 1 4 5 33 8b 9e 30 a
BT rx_data(6): f 4 0 1 1 4
    Command 401 Status 0
[COLOR="#FF0000"]BT rx_data(16): 2 f 1 dc 13 d6 1b aa 9c 1 2 0 8 5 0 39
BT rx_data(1): 76
    Inquiry Result - Count: 1
      BD:dc:13:d6:1b:aa:9c, PS:1, class: 508
BT rx_data(3): 1 1 0
    Inquiry Complete - status: 0
[/COLOR]
The only data I am seeing when I press the pair button on XBox is the last part...

Need to see why I am not processing it? Or what is different

EDIT - A little farther - was only allowing class of 25xx to go through now let 5xx go through and see:
Code:
BT rx_data(6): f 4 0 1 1 4
    Command 401 Status 0
BT rx_data(16): 2 f 1 dc 13 d6 1b aa 9c 1 2 0 8 5 0 a7
BT rx_data(1): 71
    Inquiry Result - Count: 1
      BD:dc:13:d6:1b:aa:9c, PS:1, class: 508
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 200050b8
JoystickController::claim_bluetooth TRUE
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
    Control callback (bluetooth): 100 : 2 4 0
BT rx_data(6): e 4 1 2 4 0
    Command Completed!
HCI_CREATE_CONNECTION called (05 04 0d dc 13 d6 1b aa 9c 18 cc 01 00 00 00 00 )
    Control callback (bluetooth): 101 : 5 4 d dc 13 d6 1b aa 9c 18 cc 1 0 0 0 0
BT rx_data(6): f 4 0 1 5 4
    Command 405 Status 0
BT rx_data(13): 3 b 0 48 0 dc 13 d6 1b aa 9c 1 0
    Connection Complete - ST:0 LH:48
HCI_AUTH_REQUESTED called (11 04 02 48 00 )
    Control callback (bluetooth): 110 : 11 4 2 48 0
BT rx_data(6): f 4 0 0 11 4
    Command 411 Status 0

=====================
BT rx2_data(16): 48 20 c 0 8 0 1 0 2 1 4 0 1 0 40 0
    L2CAP Connection Request: ID: 1, PSM: 1, SCID: 40
BT rx_data(5): 1b 3 48 0 5
BT rx_data(8): 17 6 dc 13 d6 1b aa 9c
    Event: Link Key Request dc:13:d6:1b:aa:9c
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 dc 13 d6 1b aa 9c )
BT rx_data(6): f 4 0 1 0 0
    Command 0 Status 0
    Control callback (bluetooth): 120 : c 4 6 dc 13 d6 1b aa 9c
BT rx_data(12): e a 1 c 4 0 dc 13 d6 1b aa 9c
    Command Completed!
BT rx_data(8): 16 6 dc 13 d6 1b aa 9c
    Event: Pin Code Request dc:13:d6:1b:aa:9c
HCI_PIN_CODE_REPLY called (0d 04 17 dc 13 d6 1b aa 9c 04 30 30 30 30 00 00 00 00 00 00 00 00 00 00 00 00 )
    Control callback (bluetooth): 130 : d 4 17 dc 13 d6 1b aa 9c 4 30 30 30 30 0 0 0 0 0 0 0 0 0 0 0 0
BT rx_data(12): e a 1 d 4 0 dc 13 d6 1b aa 9c
    Command Completed!
BT rx_data(5): 6 3 6 48 0
    Event: HCI Authentication complete(6): handle: 48
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )
tx_data callback (bluetooth): 0 : 48 20 c 0 8 0 1 0 2 0 4 0 11 0 70 0
BT rx_data(7): 13 5 1 48 0 1 0

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 3 0 0 0
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:3, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )
tx_data callback (bluetooth): 0 : 48 20 10 0 c 0 1 0 4 0 8 0 40 0 0 0 1 2 ff ff
BT rx_data(7): 13 5 1 48 0 1 0

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 1 0 6 0 2 0 40 0 0 0
    L2CAP command reject: ID: 0, length:6, Reason:2,  Data: 0 40
BT rx_data(6): 5 4 0 48 0 8
    Event: HCI Disconnect complete(0): handle: 48, reason:8

Again so far on my own, as HS2 does not support yet: https://github.com/felis/USB_Host_Shield_2.0/issues/252

Ok refocusing now :)

U might want to check this out: https://github.com/360Controller/360Controller
 
Back
Top