T3.6 USB Host - Joysticks

@mjs513 - Wondering. I know it is probably my screw up... But I was wondering about the PS4 and my mapping of Button bits and was thinking maybe they are screwed up?

Code:
		/*
		 * [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 PS4 HID data
		uint32_t cur_buttons = tmp_data[7] | (tmp_data[10]) | ((tmp_data[6]*10)) | ((uint16_t)tmp_data[5] << 16) ; 
		if (cur_buttons != buttons) {
			buttons = cur_buttons;
			joystickEvent = true;	// something changed.
		}
Did I/we think the 10 is correct? I can see maybe 0x10, but this sets two multiple bits, which I was noticing and the values just feel wrong...
And if I fix was wondering if I should hack up the bits for D-PAD instead of 8 value for nothing pressed maybe quick map to bits like PS3?

Thoughts?
 
@mjs513 - Wondering. I know it is probably my screw up... But I was wondering about the PS4 and my mapping of Button bits and was thinking maybe they are screwed up?

Code:
		/*
		 * [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 PS4 HID data
		uint32_t cur_buttons = tmp_data[7] | (tmp_data[10]) | ((tmp_data[6]*10)) | ((uint16_t)tmp_data[5] << 16) ; 
		if (cur_buttons != buttons) {
			buttons = cur_buttons;
			joystickEvent = true;	// something changed.
		}
Did I/we think the 10 is correct? I can see maybe 0x10, but this sets two multiple bits, which I was noticing and the values just feel wrong...
And if I fix was wondering if I should hack up the bits for D-PAD instead of 8 value for nothing pressed maybe quick map to bits like PS3?

Thoughts?

Been awhile since I/we played with this - but I was never good with the button mapping. If i remember we originally had them mapped out to more array elements but then we combined buttons.

Be honest, i will leave to your discretion as long as it doesn't get too confusing :)
 
Ok, not sure what's going on, but when I try the USBHost_viewer sketch, I get the following error:

USBHost_viewer:28: error: 'ILI9341_TFTWIDTH' was not declared in this scope
DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];

^

USBHost_viewer:28: error: 'ILI9341_TFTHEIGHT' was not declared in this scope
DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];

^

USBHost_viewer:50: error: 'ILI9341_t3n' does not name a type
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);

^

USBHost_viewer: In function 'void setup()':
USBHost_viewer:153: error: 'tft' was not declared in this scope
tft.begin();

^

USBHost_viewer:155: error: 'frame_buffer' was not declared in this scope
tft.setFrameBuffer(frame_buffer);

^

USBHost_viewer:160: error: 'ILI9341_BLACK' was not declared in this scope
tft.fillScreen(ILI9341_BLACK);

^

USBHost_viewer:161: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer: In function 'void UpdateActiveDeviceInfo()':
USBHost_viewer:206: error: 'tft' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:206: error: 'ILI9341_BLACK' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:208: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer:232: error: 'tft' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:232: error: 'ILI9341_BLACK' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:234: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer:259: error: 'tft' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:259: error: 'ILI9341_BLACK' was not declared in this scope
tft.fillScreen(ILI9341_BLACK); // clear the screen.

^

USBHost_viewer:261: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer: In function 'void ProcessTabletData()':
USBHost_viewer:285: error: 'tft' was not declared in this scope
tft.getCursor(&x, &y_position_after_device_info);

^

USBHost_viewer:286: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer:324: error: 'tft' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:324: error: 'ILI9341_WHITE' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:324: error: 'ILI9341_BLACK' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer: In function 'void OutputNumberField(int16_t, int16_t, int, int16_t)':
USBHost_viewer:355: error: 'tft' was not declared in this scope
tft.setCursor(x, y);

^

USBHost_viewer:357: error: 'ILI9341_BLACK' was not declared in this scope
tft.fillRect(x2, y, field_width - (x2 - x), Arial_12.line_space, ILI9341_BLACK);

^

USBHost_viewer: In function 'void ProcessMouseData()':
USBHost_viewer:368: error: 'tft' was not declared in this scope
tft.getCursor(&x, &y_position_after_device_info);

^

USBHost_viewer:369: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer:399: error: 'tft' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:399: error: 'ILI9341_WHITE' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:399: error: 'ILI9341_BLACK' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer: In function 'void ProcessJoystickData()':
USBHost_viewer:483: warning: comparison between signed and unsigned integer expressions
if (buttons != buttons_cur) {

^

USBHost_viewer: In function 'void tft_JoystickData()':
USBHost_viewer:508: error: 'tft' was not declared in this scope
tft.getCursor(&x, &y_position_after_device_info);

^

USBHost_viewer:509: error: 'ILI9341_YELLOW' was not declared in this scope
tft.setTextColor(ILI9341_YELLOW);

^

USBHost_viewer:540: warning: enumeration value 'UNKNOWN' not handled in switch
switch (joystick.joystickType()) {

^

USBHost_viewer:540: warning: enumeration value 'PS3_MOTION' not handled in switch
USBHost_viewer:540: warning: enumeration value 'SpaceNav' not handled in switch
USBHost_viewer:568: error: 'tft' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:568: error: 'ILI9341_WHITE' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer:568: error: 'ILI9341_BLACK' was not declared in this scope
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);

^

USBHost_viewer: In function 'bool OnReceiveHidData(uint32_t, const uint8_t*, uint32_t)':
USBHost_viewer:634: error: 'tft' was not declared in this scope
tft.fillRect(45, 197, 240, 20, ILI9341_RED);

^

USBHost_viewer:634: error: 'ILI9341_RED' was not declared in this scope
tft.fillRect(45, 197, 240, 20, ILI9341_RED);

^

USBHost_viewer: In function 'void MaybeSetupTextScrollArea()':
USBHost_viewer:662: error: 'tft' was not declared in this scope
tft.enableScroll();

^

USBHost_viewer:664: error: 'ILI9341_GREEN' was not declared in this scope
tft.setScrollBackgroundColor(ILI9341_GREEN);

^

USBHost_viewer:666: error: 'ILI9341_BLACK' was not declared in this scope
tft.setTextColor(ILI9341_BLACK);

^

USBHost_viewer: In function 'void OnPress(int)':
USBHost_viewer:675: error: 'tft' was not declared in this scope
tft.print("key: ");

^

USBHost_viewer: In function 'void OnHIDExtrasPress(uint32_t, uint16_t)':
USBHost_viewer:729: error: 'tft' was not declared in this scope
tft.print("HID (");

^

USBHost_viewer: In function 'void OnHIDExtrasRelease(uint32_t, uint16_t)':
USBHost_viewer:966: error: 'tft' was not declared in this scope
tft.print("HID (");

^

Multiple libraries were found for "USBHost_t36.h"
Used: C:\Users\-\Documents\Arduino\libraries\USBHost_t36
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\USBHost_t36
'ILI9341_TFTWIDTH' was not declared in this scope

I directly cloned the following libs to my Arduino IDE "libraries" folder:
https://github.com/KurtE/USBHost_t36
https://github.com/KurtE/ILI9341_t3n


@KurtE - Any idea what's going on? I figured I downloaded the proper libraries, am I missing one?
 
Sounds like it did not find the header files for those libraries.

Might help to see the full set of output, which might include things like what the compiler options were. Example for T4? 4.1 or 3.6? Also what version of Teensyduino.

Also if you downloaded from my github, did you use the default branch (master?) Probably should be in sync with the master one that shipped with the current released teensyduino.
 
I installed the libraries in the correct place, so finding the installed headers is not the problem. Also, I'm compiling for T3.6 with the current Teensyduino version.

I'd really appreciate if you can figure out why it's broken.
 
Problem is missing DISPLAY library info ...ILI9341_TFTWIDTH' was not declared in this scope

Library info not shown as if one was found
 
Ok, I actually figured it out - you need to add
Code:
#include "ILI9341_t3n.h"
to either ili9341_t3n_font_Arial.h or to the example sketch in order for things to work. I think that should be updated in the repository. I can do a PR if you want.
 
Now when I plug my XBox One controller into my T3.6 and run the test sketch, the only thing that shows up in the serial monitor is "USB Host Testing". My controller on lights do not turn on and none of the buttons cause any printouts.

You mentioned something about uncommenting a #define with "debug" in it, but I've searched the sketch and several lib headers and can't for the life of me find what you're talking about.

Any suggestions?
 
Now when I plug my XBox One controller into my T3.6 and run the test sketch, the only thing that shows up in the serial monitor is "USB Host Testing". My controller on lights do not turn on and none of the buttons cause any printouts.

You mentioned something about uncommenting a #define with "debug" in it, but I've searched the sketch and several lib headers and can't for the life of me find what you're talking about.

Any suggestions?

It is there as #define USBHOST_PRINT_DEBUG in : ...\hardware\teensy\avr\libraries\USBHost_t36\USBHost_t36.h
 
XBox One controller: I believe we have some of it working for USB connections. However we still have not been able to make it work using Bluetooth. It requires more pieces of the Bluetooth system than we have implemented.

As @defragster mentioned, if you uncomment the line: #define USBHOST_PRINT_DEBUG
in USBHost_t36.h, which is a library file, and rebuild it should print out a lot more debug information.
 
Ok, cool - can't believe ctrl+f "debug" didn't find that statement, lol.

I ran it with my (hardwired) XBox One controller attached and got the following:
USB Host Testing

sizeof Device = 36

sizeof Pipe = 96

sizeof Transfer = 64

power up USBHS PHY

reset waited 5

USBHS_ASYNCLISTADDR = 0

USBHS_PERIODICLISTBASE = 2001B000

periodictable = 2001B000

port change: 10001803

connect

begin reset

port change: 10001005

port enabled

end recovery

new_Device: 12 Mbit/sec

new_Pipe

enumeration:

enumeration:

enumeration:

Device Descriptor:

12 01 00 02 FF FF FF 40 C6 24 1A 58 01 01 01 02 03 01

VendorID = 24C6, ProductID = 581A, Version = 0101

Class/Subclass/Protocol = 255 / 255 / 255

Number of Configurations = 1

enumeration:

enumeration:

Manufacturer: BDA

enumeration:

Product: XB1 Classic Controller

enumeration:

Serial Number: 00001AE88AC3F082

enumeration:

Config data length = 96

enumeration:

Configuration Descriptor:

09 02 60 00 03 01 00 A0 FA

NumInterfaces = 3

ConfigurationValue = 1

09 04 00 00 02 FF 47 D0 00

Interface = 0

Number of endpoints = 2

Class/Subclass/Protocol = 255 / 71 / 208

07 05 02 03 40 00 04

Endpoint = 2 OUT

Type = Interrupt

Max Size = 64

Polling Interval = 4

07 05 81 03 40 00 04

Endpoint = 1 IN

Type = Interrupt

Max Size = 64

Polling Interval = 4

09 04 01 00 00 FF 47 D0 00

Interface = 1

Number of endpoints = 0

Class/Subclass/Protocol = 255 / 71 / 208

09 04 01 01 02 FF 47 D0 00

Interface = 1

Number of endpoints = 2

Class/Subclass/Protocol = 255 / 71 / 208

07 05 08 01 E4 00 01

Endpoint = 8 OUT

Type = Isochronous

Max Size = 228

Polling Interval = 1

07 05 87 01 E4 00 01

Endpoint = 7 IN

Type = Isochronous

Max Size = 228

Polling Interval = 1

09 04 02 00 00 FF 47 D0 00

Interface = 2

Number of endpoints = 0

Class/Subclass/Protocol = 255 / 71 / 208

09 04 02 01 02 FF 47 D0 00

Interface = 2

Number of endpoints = 2

Class/Subclass/Protocol = 255 / 71 / 208

07 05 04 02 40 00 00

Endpoint = 4 OUT

Type = Bulk

Max Size = 64

Polling Interval = 0

07 05 83 02 40 00 00

Endpoint = 3 IN

Type = Bulk

Max Size = 64

Polling Interval = 0

enumeration:

USBHub memory usage = 960

USBHub claim_device this=20019140

USBHub memory usage = 960

USBHub claim_device this=20019500

KeyboardController claim this=20017260

KeyboardController claim this=20017500

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

BluetoothController claim this=2001A520

Descriptor 4 = INTERFACE

KeyboardController claim this=20017260

09 04 00 00 02 FF 47 D0 00 07 05 02 03 40 00 04 07 05 81 03 40 00 04 09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

KeyboardController claim this=20017500

09 04 00 00 02 FF 47 D0 00 07 05 02 03 40 00 04 07 05 81 03 40 00 04 09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

09 04 00 00 02 FF 47 D0 00 07 05 02 03 40 00 04 07 05 81 03 40 00 04 09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

Jtype=0

BluetoothController claim this=2001A520

Descriptor 5 = ENDPOINT

Descriptor 5 = ENDPOINT

Descriptor 4 = INTERFACE

KeyboardController claim this=20017260

09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

KeyboardController claim this=20017500

09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

09 04 01 00 00 FF 47 D0 00 09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

Jtype=0

BluetoothController claim this=2001A520

Descriptor 4 = INTERFACE

KeyboardController claim this=20017260

09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

KeyboardController claim this=20017500

09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

09 04 01 01 02 FF 47 D0 00 07 05 08 01 E4 00 01 07 05 87 01 E4 00 01 09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

Jtype=0

BluetoothController claim this=2001A520

Descriptor 5 = ENDPOINT

Descriptor 5 = ENDPOINT

Descriptor 4 = INTERFACE

KeyboardController claim this=20017260

09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

KeyboardController claim this=20017500

09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

09 04 02 00 00 FF 47 D0 00 09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

Jtype=0

BluetoothController claim this=2001A520

Descriptor 4 = INTERFACE

KeyboardController claim this=20017260

KeyboardController claim this=20017500

HIDParser claim this=200177A0

HIDParser claim this=20017DC0

HIDParser claim this=20018B00

HIDParser claim this=20019980

HIDParser claim this=20018400

JoystickController claim this=20019FC0

09 04 02 01 02 FF 47 D0 00 07 05 04 02 40 00 00 07 05 83 02 40 00 00

Jtype=0

BluetoothController claim this=2001A520

Descriptor 5 = ENDPOINT

Descriptor 5 = ENDPOINT

I'm not experienced with HID or USB enough to know what the printouts mean - is my device connecting correctly?
 
Any updates? I tried printing "joystick" class attributes in the "XBOXONE" case to see if I can get button press info, but the library doesn't recognize/initialize the controller correctly. Can you look into this?
 
Sorry, I have been (and mostly still am) distracted with other things.

But some of the information I see, in your output:
Code:
VendorID = 24C6, ProductID = 581A, Version = 0101
Class/Subclass/Protocol = 255 / 255 / 255
Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: BDA
enumeration:
Product: XB1 Classic Controller
enumeration:
Serial Number: 00001AE88AC3F082
Shows this is NOT a Microsoft XBox One controller, and as such our special casing code for the XBox One is not being run...

Don't know anything about your controller or the like, but the current code knows it is an XBox one IF the Vendor ID and Product ID match to some known values.
In particular at the start of joystick.cpp, is a static mapping table that maps a Vendor ID, Product ID, to what we think this joystick is....
Code:
JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = {
	{ 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false },
	{ 0x045e, 0x0719, XBOX360, false},
	{ 0x045e, 0x028E, SWITCH, false},  // Switch? 
	{ 0x054C, 0x0268, PS3, true}, 
	{ 0x054C, 0x042F, PS3, true},	// PS3 Navigation controller
	{ 0x054C, 0x03D5, PS3_MOTION, true},	// PS3 Motion controller
	{ 0x054C, 0x05C4, PS4, true}, 	{0x054C, 0x09CC, PS4, true },
	{ 0x046D, 0xC626, SpaceNav, true},  // 3d Connextion Space Navigator, 0x10008
	{ 0x046D, 0xC628, SpaceNav, true}  // 3d Connextion Space Navigator, 0x10008
};
Right now we show 2 different Product IDs under the one Vendor ID (0x45e for Microsoft)...

It might work for you if you simply add a new entry for your unit and see what happens.
Something like:
Code:
JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = {
	{ 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false },
[COLOR="#FF0000"]	{ 0x24C6, 0x581A, XBOXONE, false },[/COLOR]
	{ 0x045e, 0x0719, XBOX360, false},
	{ 0x045e, 0x028E, SWITCH, false},  // Switch? 
	{ 0x054C, 0x0268, PS3, true}, 
	{ 0x054C, 0x042F, PS3, true},	// PS3 Navigation controller
	{ 0x054C, 0x03D5, PS3_MOTION, true},	// PS3 Motion controller
	{ 0x054C, 0x05C4, PS4, true}, 	{0x054C, 0x09CC, PS4, true },
	{ 0x046D, 0xC626, SpaceNav, true},  // 3d Connextion Space Navigator, 0x10008
	{ 0x046D, 0xC628, SpaceNav, true}  // 3d Connextion Space Navigator, 0x10008
};
If it does work let us, and we can hopefully officially add it this list. Note: The red line I added, would be good to have comment of brand, model of your unit
 
Don't know if it's related or not, but that VID:pID (24c6:581a) seems to be reported <here> as having problems working with xboxdrv. Curiously, according to <this> reference, that VID belongs to ThrustMaster, Inc. & according to <this> reference, it belongs to "Xbox 3rd Party Partners".

Mark J Culross
KD5RXT
 
Note: Off and On, I look at seeing what it will take to support the XBox One in Bluetooth mode.

The question at some point may be, do we continue to make things work as needed or does someone try to take the whole beast on and try to fully understand and implement whole sub-systems, state machines... Not sure if better to discuss the XBox stuff here or in the Bluetooth thread (fits both categories)

But example in hand:

In my debug output when trying to bind to XBox One, includes:
Code:
BT rx_data(1): 0 
    Extended Inquiry Result - Count: 1
      BD:dc:13:d6:1b:aa:9c, PS:1, class: 508
      Local Name: Xbox Wireless Controller
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 200070f8
JoystickController::claim_bluetooth TRUE
  JoystickController::mapNameToJoystickType 200070e0 Xbox Wireless Controller - set to XBOXONE
  Joystick Type: 3
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
    control callback (bluetooth) 64

    Control callback (bluetooth): 100 : 2 4 0 
0E 04 01 02 04 00 

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) 65

    Control callback (bluetooth): 101 : 5 4 d dc 13 d6 1b aa 9c 18 cc 1 0 0 0 0 
0F 04 00 01 05 04 

BT rx_data(6): f 4 0 1 5 4 
    Command 405 Status 0
03 0B 00 48 00 DC 13 D6 1B AA 9C 01 00 

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) 6E

    Control callback (bluetooth): 110 : 11 4 2 48 0 
0F 04 00 00 11 04 

BT rx_data(6): f 4 0 0 11 4 
    Command 411 Status 0

=====================
[COLOR="#FF0000"]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
1B 03 48 00 05 

BT rx_data(5): 1b 3 48 0 5 
17 06 DC 13 D6 1B AA 9C [/COLOR]
...
You see the connection request has PSM: 1
Which we have not handled before:

If you look at the assigned numbers for this in: https://www.bluetooth.com/specifications/assigned-numbers/logical-link-control/
You see: 1 = SDP
We currently only try to handle: 0x11 - HID_Control and 0x13 - HID_Interrupt

So looks like, we need to learn more about SDP.

Note: As far as I know there have not gotten the XBOX One to work in BT mode with the USB Host Shield 2 code either. There is a WIP branch of it from a year ago, which was not working... But it looks like they have implemented some of SDP... But again I will probably first go down the rabbit hole of seeing of we can make sense of each new message we receive and fake it ;)
 
Morning @KurtE
There is a bunch of stuff i posted on the other thread regarding the XBOXONE BT driver starting around post #730 from the results of BT sniffing on the Android and USBHost shield2.0. But you are absolutely correct about SDP. It looks like it uses SDP for authenication and initization and everything else seems to be our normal stuff the log can be read using Wireshark and it may help.

Not sure where it is better to post the XBOX One?

EDIT: You might be able to fake it so that when certain PSM=1 requests hit you just send the expected respons?
 
Morning again,

As I mentioned it was unclear to do it here or in Bluetooth, will probably go back to BT thread. But probably BT so off to the other thread...
 
Hi
Thanks you guys for the amazing work on this topic.
I would like to read out a 3d Connexion Spacemouse, but struggling with some compiler error.

My setup:
- Teensy 4.0, USB cable soldered to board (red +5V, green -D, white +D, black GND)
teensy_usbhost.JPG
- Arduino IDE with Teensy Addon (Teensy 4.0 works fine with other sketches)
- Plugin 3DConnexion SpaceMouse Vendor ID / Product ID 0x46D, 0xC628
- Load Libraries from KurtE via Arduino IDE -> Sketches -> Include Library -> Add .Zip-File
Following Libraries are loaded:
USBHost_t36
ILI9341_t3n
SPIN
- Open Sketch Example USBHost_viewer.ino
- Compiling... and the error underneath occures

Could you give me a hint, how to get the SpaceNavigator work with Teensy 4.0?

Code:
USBHost_viewer:28: error: 'ILI9341_TFTWIDTH' was not declared in this scope
 DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
                              ^
USBHost_viewer:28: error: 'ILI9341_TFTHEIGHT' was not declared in this scope
 DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
                                                 ^
USBHost_viewer:42: error: 'ILI9341_t3n' does not name a type
 ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
 ^
USBHost_viewer: In function 'void setup()':
USBHost_viewer:153: error: 'tft' was not declared in this scope
   tft.begin();
   ^
USBHost_viewer:155: error: 'frame_buffer' was not declared in this scope
   tft.setFrameBuffer(frame_buffer);
                      ^
USBHost_viewer:160: error: 'ILI9341_BLACK' was not declared in this scope
   tft.fillScreen(ILI9341_BLACK);
                  ^
USBHost_viewer:161: error: 'ILI9341_YELLOW' was not declared in this scope
   tft.setTextColor(ILI9341_YELLOW);
                    ^
USBHost_viewer: In function 'void UpdateActiveDeviceInfo()':
USBHost_viewer:206: error: 'tft' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
         ^
USBHost_viewer:206: error: 'ILI9341_BLACK' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
                        ^
USBHost_viewer:208: error: 'ILI9341_YELLOW' was not declared in this scope
         tft.setTextColor(ILI9341_YELLOW);
                          ^
USBHost_viewer:232: error: 'tft' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
         ^
USBHost_viewer:232: error: 'ILI9341_BLACK' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
                        ^
USBHost_viewer:234: error: 'ILI9341_YELLOW' was not declared in this scope
         tft.setTextColor(ILI9341_YELLOW);
                          ^
USBHost_viewer:259: error: 'tft' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
         ^
USBHost_viewer:259: error: 'ILI9341_BLACK' was not declared in this scope
         tft.fillScreen(ILI9341_BLACK);  // clear the screen.
                        ^
USBHost_viewer:261: error: 'ILI9341_YELLOW' was not declared in this scope
         tft.setTextColor(ILI9341_YELLOW);
                          ^
USBHost_viewer: In function 'void ProcessTabletData()':
USBHost_viewer:285: error: 'tft' was not declared in this scope
       tft.getCursor(&x, &y_position_after_device_info);
       ^
USBHost_viewer:286: error: 'ILI9341_YELLOW' was not declared in this scope
       tft.setTextColor(ILI9341_YELLOW);
                        ^
USBHost_viewer:324: error: 'tft' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
       ^
USBHost_viewer:324: error: 'ILI9341_WHITE' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                        ^
USBHost_viewer:324: error: 'ILI9341_BLACK' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                                       ^
USBHost_viewer: In function 'void OutputNumberField(int16_t, int16_t, int, int16_t)':
USBHost_viewer:355: error: 'tft' was not declared in this scope
   tft.setCursor(x, y);
   ^
USBHost_viewer:357: error: 'ILI9341_BLACK' was not declared in this scope
   tft.fillRect(x2, y, field_width - (x2 - x), Arial_12.line_space, ILI9341_BLACK);
                                                                    ^
USBHost_viewer: In function 'void ProcessMouseData()':
USBHost_viewer:368: error: 'tft' was not declared in this scope
       tft.getCursor(&x, &y_position_after_device_info);
       ^
USBHost_viewer:369: error: 'ILI9341_YELLOW' was not declared in this scope
       tft.setTextColor(ILI9341_YELLOW);
                        ^
USBHost_viewer:399: error: 'tft' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
       ^
USBHost_viewer:399: error: 'ILI9341_WHITE' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                        ^
USBHost_viewer:399: error: 'ILI9341_BLACK' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                                       ^
USBHost_viewer: In function 'void ProcessJoystickData()':
USBHost_viewer:483: warning: comparison between signed and unsigned integer expressions 
     if (buttons != buttons_cur) {
                 ^
USBHost_viewer: In function 'void tft_JoystickData()':
USBHost_viewer:508: error: 'tft' was not declared in this scope
       tft.getCursor(&x, &y_position_after_device_info);
       ^
USBHost_viewer:509: error: 'ILI9341_YELLOW' was not declared in this scope
       tft.setTextColor(ILI9341_YELLOW);
                        ^
USBHost_viewer:540: warning: enumeration value 'UNKNOWN' not handled in switch 
      switch (joystick.joystickType()) {
             ^
USBHost_viewer:540: warning: enumeration value 'PS3_MOTION' not handled in switch 
USBHost_viewer:540: warning: enumeration value 'SpaceNav' not handled in switch 
USBHost_viewer:568: error: 'tft' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
       ^
USBHost_viewer:568: error: 'ILI9341_WHITE' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                        ^
USBHost_viewer:568: error: 'ILI9341_BLACK' was not declared in this scope
       tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
                                       ^
USBHost_viewer: In function 'bool OnReceiveHidData(uint32_t, const uint8_t*, uint32_t)':
USBHost_viewer:634: error: 'tft' was not declared in this scope
       tft.fillRect(45, 197, 240, 20, ILI9341_RED);
       ^
USBHost_viewer:634: error: 'ILI9341_RED' was not declared in this scope
       tft.fillRect(45, 197, 240, 20, ILI9341_RED);
                                      ^
USBHost_viewer: In function 'void MaybeSetupTextScrollArea()':
USBHost_viewer:662: error: 'tft' was not declared in this scope
     tft.enableScroll();
     ^
USBHost_viewer:664: error: 'ILI9341_GREEN' was not declared in this scope
     tft.setScrollBackgroundColor(ILI9341_GREEN);
                                  ^
USBHost_viewer:666: error: 'ILI9341_BLACK' was not declared in this scope
     tft.setTextColor(ILI9341_BLACK);
                      ^
USBHost_viewer: In function 'void OnPress(int)':
USBHost_viewer:675: error: 'tft' was not declared in this scope
   tft.print("key: ");
   ^
USBHost_viewer: In function 'void OnHIDExtrasPress(uint32_t, uint16_t)':
USBHost_viewer:729: error: 'tft' was not declared in this scope
   tft.print("HID (");
   ^
USBHost_viewer: In function 'void OnHIDExtrasRelease(uint32_t, uint16_t)':
USBHost_viewer:966: error: 'tft' was not declared in this scope
   tft.print("HID (");
   ^
'ILI9341_TFTWIDTH' was not declared in this scope
 
@teensyJoe It might help to know which version of Arduino and Teensyduino you have installed.

I assume if you loaded up USBHost_veiewer code that you commented out the USE_ST77XX comment to have it load up the ILI9341_t3n code.

Note: ILI9341_t3n should not need SPIN anymore..

I don't see any of the comments here that shows which libraries were loaded and from where... To give a better indication of what is going wrong.

As for the Space Mouse hard to say, I know nothing about it. For example does it output standard mouse HID data, in which case it should hopefully just work.

If not, may need to capture more data on it. A lot of the debug data can be captured by turning on the debug output from the USBHost library.

There is a #define in the header file not far down which turns this on... You just need to uncomment it.
 
Hi

- Open Sketch Example USBHost_viewer.ino
- Compiling... and the error underneath occures

Could you give me a hint, how to get the SpaceNavigator work with Teensy 4.0?

Code:
USBHost_viewer:28: error: 'ILI9341_TFTWIDTH' was not declared in this scope
 DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
                              ^
USBHost_viewer:28: error: 'ILI9341_TFTHEIGHT' was not declared in this scope
 DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
                                                 ^
USBHost_viewer:42: error: 'ILI9341_t3n' does not name a type
 ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
 ^
Those suggest the ILI9341_tfn library isn't #included.
 
Thanks for fast response.
@KurtE: Arduino IDE 1.8.13, TeensyAddon 1.53.
Libraries are loaded from (window 10):
1st trial: "C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries"
2nd trial: "C:\Users\muej\Documents\Arduino\libraries" (path of 1st trial disabled by rename it in windows explorer to "...librearies_old"
...both trials behave the same way (Error message)

@MarkT your hint brought me one step further. I've #include "ILI9341_t3n.h" and the errors are gone. I just have some warnings:
Code:
USBHost_viewer: In function 'void ProcessJoystickData()':
USBHost_viewer:484: warning: comparison between signed and unsigned integer expressions 
     if (buttons != buttons_cur) {
                 ^
USBHost_viewer: In function 'void tft_JoystickData()':
USBHost_viewer:541: warning: enumeration value 'UNKNOWN' not handled in switch 
      switch (joystick.joystickType()) {
             ^
USBHost_viewer:541: warning: enumeration value 'PS3_MOTION' not handled in switch 
USBHost_viewer:541: warning: enumeration value 'SpaceNav' not handled in switch 
Opening Teensy Loader...
Sketch uses 106528 bytes (5%) of program storage space. Maximum is 2031616 bytes.
Global variables use 139956 bytes (26%) of dynamic memory, leaving 384332 bytes for local variables. Maximum is 524288 bytes.

@myj513: My one looks similar like your amazon link, but it is an older one. Nevertheless it works with a HID binding in Python, where I have to define vendor and product ID as followed: 0x46D, 0xC628
The same ID's are also stored in the USBHost_t36\joystick.cpp (last entry), so I assume it should be supported
Code:
JoystickController::product_vendor_mapping_t JoystickController::pid_vid_mapping[] = {
	{ 0x045e, 0x02ea, XBOXONE, false },{ 0x045e, 0x02dd, XBOXONE, false },
	{ 0x045e, 0x0719, XBOX360, false},
	{ 0x054C, 0x0268, PS3, true}, 
	{ 0x054C, 0x042F, PS3, true},	// PS3 Navigation controller
	{ 0x054C, 0x03D5, PS3_MOTION, true},	// PS3 Motion controller
	{ 0x054C, 0x05C4, PS4, true}, 	{0x054C, 0x09CC, PS4, true },
	{ 0x046D, 0xC626, SpaceNav, true},  // 3d Connextion Space Navigator, 0x10008
	{ 0x046D, 0xC628, SpaceNav, true}  // 3d Connextion Space Navigator, 0x10008
};

@all: the SpaceNavigator is accessable as a HID device in Windows 10 and Python. I assume, it should behave like a regular HID Joystick with 6 axis.
The example USBHost Example: "...\USBHost_t36-master\examples\Serial\Joystick.ino" compiles without error and warning, but serial monitor only shows
Code:
USB Host Joystick Testing
*** Show only changed fields mode ***
*** Show All fields mode ***
Only notify on Basic Axis changes
Only notify on Full Axis changes

Could anybody please check my wiring?
teensy_usbhost_org.JPG
 
@defragster:
YES! you made my day.
Green and white were swapped.
Now it works :eek:

Sample strings from USBHost_viewer
Code:
SB Host Testing

*** Device HID1 46d:c628 - connected ***
*** HID Device joystick 46d:c628 - connected ***
Joystick: buttons = 0 0:0 1:-2 2:0
Joystick: buttons = 0 0:-14 1:-18 2:57
Joystick: buttons = 0 0:0 1:8 2:17
Joystick: buttons = 0 0:18 1:4 2:0
Joystick: buttons = 0 0:8 1:0 2:0
Joystick: buttons = 0 0:23 1:0 2:-18

Sample from Joystick.ino
Code:
USB Host Joystick Testing
*** Device HID1 46d:c628 - connected ***
  manufacturer: 3Dconnexion
  product: SpaceNavigator for Notebooks
*** HID Device joystick[0H] 46d:c628 - connected ***
  manufacturer: 3Dconnexion
  product: SpaceNavigator for Notebooks
Joystick(0): buttons = 0 0:0 1:0 2:0
Joystick(0): buttons = 0 3:0 4:0 5:1
Joystick(0): buttons = 0 0:0 1:0 2:0 3:0 4:0 5:2
Joystick(0): buttons = 0 0:0 1:0 2:0 3:0 4:0 5:4
Joystick(0): buttons = 0 0:0 1:0 2:1
Joystick(0): buttons = 0 0:0 1:0 2:0 3:0 4:0 5:4
Joystick(0): buttons = 0 3:0 4:0 5:2
Joystick(0): buttons = 0 0:0 1:0 2:0 3:0 4:2 5:0
Joystick(0): buttons = 0 0:0 1:0 2:0 3:0 4:0 5:0
Joystick(0): buttons = 1
Joystick(0): buttons = 0
Joystick(0): buttons = 2
Joystick(0): buttons = 0

Thank you all guys for the support.
 
Back
Top