There are no shortage of posts about Linux/RetroPie/Retroarch/Emulationstation seeing the Teensy as multiple joysticks when using "Keyboard + Mouse + Joystick". It turns out that somehow the Linux OS is recognizing the keyboard and the mouse as also being joysticks and assigns js* handlers to them. For some reason, media keys do not have this problem. Retroarch then takes the OS at its word and uses the keyboard (but not the mouse) as a joystick. This results in a single Teensy using player 1 AND player 2. A second Teensy is assigned to player 3 AND player 4.

To test the theory, I modified "usb_desc.h" for teensy3 and changed the USB_HID to only have a joystick. I reused USB_HID (Keyboard + Mouse + Joystick) as I don't know how to modify the GUI. The modification below causes Linux to only see one joystick that behaves as intended. A second Teensy will be assigned player 2, also as intended.

#elif defined(USB_HID)
#define VENDOR_ID 0x16C0
#define PRODUCT_ID 0x0490 //changed to force Win and Linux to see this as a new device
#define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
#define MANUFACTURER_NAME_LEN 11
#define PRODUCT_NAME {'J','o','y','s','t','i','c','k'}
#define PRODUCT_NAME_LEN 8
#define EP0_SIZE 64
#define NUM_ENDPOINTS 3
#define NUM_USB_BUFFERS 24
#define NUM_INTERFACE 2
#define SEREMU_INTERFACE 2 // Serial emulation
#define SEREMU_TX_ENDPOINT 1
#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 JOYSTICK_INTERFACE 1 // Joystick
#define JOYSTICK_ENDPOINT 3
#define JOYSTICK_SIZE 12 // 12 = normal, 64 = extreme joystick
#define JOYSTICK_INTERVAL 1
#define ENDPOINT1_CONFIG ENDPOINT_TRANSMIT_ONLY
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
#define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_ONLY
Of course, I'd prefer to remove whatever the bug is as mapping a physical joystick to keyboard keys is useful sometimes, but this at least allows multiple joysticks on a single machine and can be implemented with almost no effort.

Request: add "joystick" as a choice for the GUI. Even better would be "joystick-p1", "joystick-p2", "joystick-p3", "joystick-p4", "joystick-p5", "joystick-p6", "joystick-p7", "joystick-p8" using PRODUCT_ID 0x0490 to 0x0497 as a submenu. This would allow the OS or software to differentiate and configure otherwise identical joysticks.