Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIDDeviceInfo - Structure prints the HID Report descriptor #96

Merged
merged 6 commits into from Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion USBHost_t36.h
Expand Up @@ -680,6 +680,8 @@ class USBHIDParser : public USBDriver {
void startTimer(uint32_t microseconds) {hidTimer.start(microseconds);}
void stopTimer() {hidTimer.stop();}
uint8_t interfaceNumber() { return bInterfaceNumber;}
const uint8_t * getHIDReportDescriptor() {return descriptor;}
uint16_t getHIDReportDescriptorSize() { return descsize;}
protected:
enum { TOPUSAGE_LIST_LEN = 4 };
enum { USAGE_LIST_LEN = 24 };
Expand Down Expand Up @@ -776,7 +778,8 @@ typedef union {
void forceBootProtocol();
enum {MAX_KEYS_DOWN=4};


//method to allow HID controller to check if VID/PID should be claimed or not
static bool processUsingHID(uint16_t vid, uint16_t pid);
protected:
virtual bool claim(Device_t *device, int type, const uint8_t *descriptors, uint32_t len);
virtual void control(const Transfer_t *transfer);
Expand Down
100 changes: 100 additions & 0 deletions examples/HIDDeviceInfo/Compile.cmd
@@ -0,0 +1,100 @@
@echo off
SETLOCAL DisableDelayedExpansion EnableExtensions
title TSET Arduino CMD line build
rem *******************************
rem Frank Bösing 11/2018
rem Windows Batch to compile Arduino sketches

rem Usage:
rem compile.cmd 0 : compile sketch
rem compile.cmd 1 : compile & upload sketch
rem compile.cmd 2 : rebuild & upload sketch
rem - Attention: Place compile.cmd in Sketch folder!
rem
rem Edit these paths:

set arduino=C:\arduino-1.8.19
rem set TyTools=C:\Program Files\TyQt
set TyTools=D:\GitHub\tytools\build\win64\Release
set libs=C:\Users\kurte\Documents\Arduino\libraries
set tools=D:\GitHub\Tset
REM Pick a TEMP folder IF not the Windows Default folder - remove REM
REM set TsetTemp=t:\temp

rem *******************************
rem Set Teensy-specific variables here:
rem


REM defragster was here

set model=teensyMM
set speed=600
set opt=o2std
set usb=serial
cd.
set sketchcmd=HIDDeviceInfo.ino

rem set keys=de-de
set keys=en-us

rem *******************************
rem Don't edit below this line
rem *******************************

if EXIST %sketchcmd% (
set sketchname=%sketchcmd%
) ELSE for %%i in (*.ino) do set sketchname=%%i

if "%sketchname%"=="" (
echo No Arduino Sketch found!
exit 1
)

set myfolder=.\
set ino="%myfolder%%sketchname%"
if "x%TsetTemp%"=="%TsetTemp%x" set TsetTemp=%temp%
set temp1="%TsetTemp%\\arduino_build_%sketchname%"
set temp2="%TsetTemp%\\arduino_cache_%sketchname%"
set fqbn=teensy:avr:%model%:usb=%usb%,speed=%speed%,opt=%opt%,keys=%keys%

if "%model%"=="teensyMM" set model=TEENSY_MICROMOD
rem Comment line below to build prior to TeensyDuino 1.50
if "%model%"=="teensy31" set model=teensy32

if "%1"=="2" (
echo Temp: %temp1%
echo Temp: %temp2%
del /s /q %temp1%>NUL
del /s /q %temp2%>NUL
echo Temporary files deleted.
)

if not exist %temp1% mkdir %temp1%
if not exist %temp2% mkdir %temp2%

REM if not exist %temp1%\pch mkdir %temp1%\pch
REM if exist userConfig.h copy userConfig.h %temp1%\pch

if exist %arduino%\portable\sketchbook\libraries\. set libs=%arduino%\portable\sketchbook\libraries
if exist %arduino%\portable\sketchbook\libraries\. echo Building PORTABLE: %libs%

echo Building Sketch: %ino%
"%arduino%\arduino-builder" -verbose=1 -warnings=more -compile -logger=human -hardware "%arduino%\hardware" -hardware "%LOCALAPPDATA%\Arduino15\packages" -tools "%arduino%\tools-builder" -tools "%arduino%\hardware\tools\avr" -tools "%LOCALAPPDATA%\Arduino15\packages" -built-in-libraries "%arduino%\libraries" -libraries "%libs%" -fqbn=%fqbn% -build-path %temp1% -build-cache "%temp2%" %ino%

if not "%1"=="0" (
REM Use TyComm with IDE to reboot for TeensyLoader Update // tycmd reset -b
if "%errorlevel%"=="0" (
"%TyTools%\TyCommanderC.exe" upload --autostart --wait --delegate "%temp1%\%sketchname%.hex" )
)

if "%1x"=="x%1" PAUSE
if not "%1x"=="x%1" exit %errorlevel%


rem "T:\arduino-1.8.12\hardware\tools\arm\bin\arm-none-eabi-gdb.exe" "T:\TEMP\arduino_build_breakpoint_test.ino\breakpoint_test.ino.elf"
rem "T:\arduino-1.8.12\hardware\tools\arm\bin\arm-none-eabi-gdb-py.exe"
REM "%arduino%\hardware\tools\arm\bin\arm-none-eabi-gdb.exe" "%temp1%\%sketchname%.%model%.elf"

rem "%tools%\GDB.cmd" "%arduino%\hardware\tools\arm\bin\arm-none-eabi-gdb-py.exe" "%temp1%\%sketchname%.elf" --tui
rem (gdb) target remote \\.\com21
33 changes: 17 additions & 16 deletions examples/HIDDeviceInfo/HIDDeviceInfo.ino
Expand Up @@ -38,11 +38,11 @@ USBHIDParser hid3(myusb);
USBHIDParser hid4(myusb);
USBHIDParser hid5(myusb);

HIDDumpController hdc1(myusb);
HIDDumpController hdc2(myusb);
HIDDumpController hdc3(myusb);
HIDDumpController hdc4(myusb);
HIDDumpController hdc5(myusb);
HIDDumpController hdc1(myusb, 1);
HIDDumpController hdc2(myusb, 2);
HIDDumpController hdc3(myusb, 3);
HIDDumpController hdc4(myusb, 4);
HIDDumpController hdc5(myusb, 5);

USBDriver *drivers[] = {&hub1, &hub2, &hid1, &hid2, &hid3, &hid4, &hid5};
#define CNT_DEVICES (sizeof(drivers)/sizeof(drivers[0]))
Expand Down Expand Up @@ -110,38 +110,39 @@ void loop()
for (uint8_t i = 0; i < CNT_DEVICES; i++) {
if (*drivers[i] != driver_active[i]) {
if (driver_active[i]) {
Serial.printf("*** Device % s - disconnected ***\n", driver_names[i]);
Serial.printf("*** Device %s - disconnected ***\n", driver_names[i]);
driver_active[i] = false;
} else {
Serial.printf("*** Device % s % x: % x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
Serial.printf("*** Device %s %x:%x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
driver_active[i] = true;

const uint8_t *psz = drivers[i]->manufacturer();
if (psz && *psz) Serial.printf(" manufacturer: % s\n", psz);
if (psz && *psz) Serial.printf(" manufacturer: %s\n", psz);
psz = drivers[i]->product();
if (psz && *psz) Serial.printf(" product: % s\n", psz);
if (psz && *psz) Serial.printf(" product: %s\n", psz);
psz = drivers[i]->serialNumber();
if (psz && *psz) Serial.printf(" Serial: % s\n", psz);
if (psz && *psz) Serial.printf(" Serial: %s\n", psz);

}
}
}

for (uint8_t i = 0; i < CNT_HIDDEVICES; i++) {
if (*hiddrivers[i] != hid_driver_active[i]) {
if (hid_driver_active[i]) {
Serial.printf("*** HID Device % s - disconnected ***\n", hid_driver_names[i]);
Serial.printf("*** HID Device %s - disconnected ***\n", hid_driver_names[i]);
hid_driver_active[i] = false;
} else {
Serial.printf("*** HID Device % s % x: % x - connected ***\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
Serial.printf("*** HID Device %s %x: %x - connected ***\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
hid_driver_active[i] = true;

const uint8_t *psz = hiddrivers[i]->manufacturer();
if (psz && *psz) Serial.printf(" manufacturer: % s\n", psz);
if (psz && *psz) Serial.printf(" manufacturer: %s\n", psz);
psz = hiddrivers[i]->product();
if (psz && *psz) Serial.printf(" product: % s\n", psz);
if (psz && *psz) Serial.printf(" product: %s\n", psz);
psz = hiddrivers[i]->serialNumber();
if (psz && *psz) Serial.printf(" Serial: % s\n", psz);
if (psz && *psz) Serial.printf(" Serial: %s\n", psz);
}
}
}
}
}