test hid controller with rp2040

This commit is contained in:
hathach 2021-08-24 21:34:51 +07:00
parent 3c0c051df1
commit 3debeb637a
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
3 changed files with 12 additions and 13 deletions

View File

@ -16,7 +16,6 @@ add_executable(${PROJECT})
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
)
# Example include

View File

@ -64,7 +64,7 @@
// Sony DS4 report layout detail https://www.psdevwiki.com/ps4/DS4-USB
typedef struct TU_ATTR_PACKED
{
int8_t x, y, z, rz; // joystick
uint8_t x, y, z, rz; // joystick
struct {
uint8_t dpad : 4; // (hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW)
@ -160,7 +160,7 @@ void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance)
}
// check if different than 2
bool diff_than_2(int8_t x, int8_t y)
bool diff_than_2(uint8_t x, uint8_t y)
{
return (x - y > 2) || (y - x > 2);
}
@ -205,7 +205,7 @@ void process_sony_ds4(uint8_t const* report, uint16_t len)
// We need more than memcmp to check if report is different enough
if ( diff_report(&prev_report, &ds4_report) )
{
printf("(x, y, z, rz) = (%d, %d, %d, %d)\r\n", ds4_report.x, ds4_report.y, ds4_report.z, ds4_report.rz);
printf("(x, y, z, rz) = (%u, %u, %u, %u)\r\n", ds4_report.x, ds4_report.y, ds4_report.z, ds4_report.rz);
printf("DPad = %s ", dpad_str[ds4_report.dpad]);
if (ds4_report.square ) printf("Square ");

View File

@ -252,7 +252,7 @@ bool tuh_vid_pid_get(uint8_t dev_addr, uint16_t* vid, uint16_t* pid)
tusb_speed_t tuh_speed_get (uint8_t dev_addr)
{
return (tusb_speed_t) get_device(dev_addr)->speed;
return (tusb_speed_t) (dev_addr ? get_device(dev_addr)->speed : _dev0.speed);
}
#if CFG_TUSB_OS == OPT_OS_NONE