Separate PIDs for Keyboard, Mouse, and HID on Teensy 4.0?

alcnonl42

Member
Hi everyone,


Is it possible to use separate PIDs (Product IDs) for keyboard, mouse, and other HID devices when using the Teensy 4.0? I'm trying to implement distinct USB device profiles and would like each to be recognized independently by the host system.


Thanks in advance!
 
I would think you should be able to.
That is for each of the USB_TYPES there are defines in usb_desc.h for them.

But my guess is that you might need to provide your own PID/VID. And by doing so, you may need to provide
an appropriate udev rules file Linux boards.
 
Code:
#elif defined(USB_KEYBOARD_RAWHID)
  #define VENDOR_ID               0x16C0
  #define PRODUCT_ID              0x0482
  #define RAWHID_USAGE_PAGE       0xFFAB
  #define RAWHID_USAGE            0x0200
  #define MANUFACTURER_NAME       {'T','e','e','n','s','y','d','u','i','n','o'}
  #define MANUFACTURER_NAME_LEN   11
  #define PRODUCT_NAME            {'K','e','y','b','o','a','r','d','R','M'}
  #define PRODUCT_NAME_LEN        10
  #define EP0_SIZE                64
  #define NUM_ENDPOINTS           6
  #define NUM_INTERFACE           4
                                    
  #define KEYBOARD_INTERFACE      0 
  #define MOUSE_INTERFACE         1
  #define SEREMU_INTERFACE        2
  #define RAWHID_INTERFACE        3 
                                    
  #define KEYBOARD_ENDPOINT       3
  #define KEYBOARD_SIZE           16
  #define KEYBOARD_INTERVAL       1
                                    
  #define MOUSE_ENDPOINT          5
  #define MOUSE_SIZE              8
  #define MOUSE_INTERVAL          1
                                    
  #define SEREMU_TX_ENDPOINT      2
  #define SEREMU_TX_SIZE          64
  #define SEREMU_TX_INTERVAL      1
  #define SEREMU_RX_ENDPOINT      2
  #define SEREMU_RX_SIZE          32
  #define SEREMU_RX_INTERVAL      2
                                    
  #define RAWHID_TX_ENDPOINT      4
  #define RAWHID_TX_SIZE          64
  #define RAWHID_TX_INTERVAL      1
  #define RAWHID_RX_ENDPOINT      6
  #define RAWHID_RX_SIZE          64
  #define RAWHID_RX_INTERVAL      1
                                    
  #define ENDPOINT2_CONFIG        ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
  #define ENDPOINT3_CONFIG        ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
  #define ENDPOINT4_CONFIG        ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
  #define ENDPOINT5_CONFIG        ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
  #define ENDPOINT6_CONFIG        ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_UNUSED

My composite USB device appears correctly on the computer as three separate interfaces: a keyboard, a mouse, and a Raw HID device. There are no issues with that.


However, when connecting to the device from software, I see multiple interfaces under the same VID/PID. My goal is to connect specifically to the Raw HID interface.


I can differentiate them using identifiers like mi_01, mi_02, etc., but I’m not sure how reliable this method is in the long term.


My question is: is it possible to assign a different PID to each of these interfaces (keyboard, mouse, Raw HID), or is having a single PID inevitable since it's still technically a single USB device?
 
Back
Top