Skip to content

Commit 76672a8

Browse files
authored
Merge pull request #28 from dmadison/t4-fixup
Teensy 4 Support Fixup
2 parents 02d55c2 + f5daff0 commit 76672a8

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ jobs:
7676

7777
- name: Teensy 4.1
7878
run: arduino --verify --board teensy:avr:teensy41:usb=${{ matrix.usb_mode }},speed=600,opt=o2std,keys=en-us ${{ matrix.sketch }};
79+
80+
- name: Teensy MicroMod
81+
run: arduino --verify --board teensy:avr:teensyMM:usb=${{ matrix.usb_mode }},speed=600,opt=o2std,keys=en-us ${{ matrix.sketch }};

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Teensy XInput USB Mode [![Build Status](https://github.com/dmadison/ArduinoXInput_Teensy/workflows/build/badge.svg?branch=master)](https://github.com/dmadison/ArduinoXInput_Teensy/actions?query=workflow%3Abuild)
22

3-
The files in this repository will add an additional USB mode ("XInput") to your Teensy 3 board, allowing it to emulate an Xbox gamepad.
3+
The files in this repository will add an additional USB mode ("XInput") to your Teensy board, allowing it to emulate an Xbox gamepad.
44

55
This is meant to be used in conjunction with the [ArduinoXInput library](https://github.com/dmadison/ArduinoXInput).
66

@@ -19,9 +19,10 @@ To uninstall, restore your 'teensy' folder from a backup or reinstall Teensyduin
1919
* [Teensy 3.6](https://www.pjrc.com/store/teensy36.html)
2020
* [Teensy 3.5](https://www.pjrc.com/store/teensy35.html)
2121
* [Teensy 3.1](https://www.pjrc.com/store/teensy31.html) / [3.2](https://www.pjrc.com/store/teensy32.html)
22-
* [Teensy LC](https://www.pjrc.com/teensy/teensyLC.html)
22+
* [Teensy LC](https://www.pjrc.com/store/teensylc.html)
23+
* [Teensy 4.0](https://www.pjrc.com/store/teensy40.html)
2324
* [Teensy 4.1](https://www.pjrc.com/store/teensy41.html)
24-
* Probably works on the [Teensy 4.0](https://www.pjrc.com/store/teensy40.html) as well, but untested!
25+
* [Teensy MicroMod](https://www.sparkfun.com/products/16402)
2526

2627
## Limitations
2728

@@ -37,6 +38,8 @@ These board definitions make use of Microsoft's VID and PID in order to latch on
3738

3839
A massive thank you to Zach Littell, whose did all of the original legwork in putting this together. Check out some of his stuff at [zlittell.com](http://www.zlittell.com).
3940

41+
Another big thanks for Tom Mason ([@wheybags](https://github.com/wheybags)), who added support for the Teensy 4 boards ([#26](https://github.com/dmadison/ArduinoXInput_Teensy/pull/26)).
42+
4043
## License
4144

4245
The original Teensy core files and their modified versions are licensed under a modified version of the permissive [MIT license](https://opensource.org/licenses/MIT). Newly contributed files are licensed under the MIT license with no additional stipulations.

teensy/avr/boards.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ teensyMM.menu.usb.flightsim.fake_serial=teensy_gateway
298298
teensyMM.menu.usb.flightsimjoystick=Flight Sim Controls + Joystick
299299
teensyMM.menu.usb.flightsimjoystick.build.usbtype=USB_FLIGHTSIM_JOYSTICK
300300
teensyMM.menu.usb.flightsimjoystick.fake_serial=teensy_gateway
301+
teensyMM.menu.usb.xinput=XInput
302+
teensyMM.menu.usb.xinput.build.usbtype=USB_XINPUT
303+
teensyMM.menu.usb.xinput.fake_serial=teensy_gateway
301304
#teensyMM.menu.usb.disable=No USB
302305
#teensyMM.menu.usb.disable.build.usbtype=USB_DISABLED
303306

teensy/avr/cores/teensy4/usb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ static void endpoint0_complete(void)
822822
usb_audio_set_feature(&endpoint0_setupdata, endpoint0_buffer);
823823
}
824824
#endif
825+
#ifdef XINPUT_INTERFACE
826+
// dummy reads to suppress '-Wunused-but-set-variable' and '-Wunused-variable' warnings from GCC
827+
(void) setup.wIndex;
828+
(void) endpoint0_buffer;
829+
#endif
825830
}
826831

827832
static void usb_endpoint_config(endpoint_t *qh, uint32_t config, void (*callback)(transfer_t *))

teensy/avr/cores/teensy4/usb_xinput.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ static void rx_event(transfer_t *t)
9292

9393
void usb_xinput_configure()
9494
{
95-
pinMode(LED_BUILTIN, OUTPUT);
96-
digitalWrite(LED_BUILTIN, LOW);
97-
9895
memset(tx_transfer, 0, sizeof(tx_transfer));
9996
tx_head = 0;
10097
usb_config_tx(XINPUT_TX_ENDPOINT, XINPUT_TX_SIZE, 0, NULL);
@@ -147,12 +144,6 @@ int usb_xinput_recv(void *buffer, uint8_t nbytes)
147144
uint8_t* p = rx_buffer + ii * XINPUT_RX_SIZE;
148145
memcpy(buffer, p, count);
149146

150-
if (count >= 5 && p[0] == 0x00)
151-
{
152-
int rumbling = (p[3] > 0 || p[4] > 0 );
153-
digitalWrite(LED_BUILTIN, rumbling);
154-
}
155-
156147
rx_available -= rx_count[ii];
157148
rx_tail = tail;
158149
rx_queue_transfer(ii);

0 commit comments

Comments
 (0)