A fully-Android-compatible two joysticks USB driver for LPC1768. The joysticks have 1 hat, 6 buttons, and there are 1P, 2P buttons.
Fork of app-board-Joystick by
Diff: main.cpp
- Revision:
- 3:f1a8ec4659f8
- Parent:
- 2:84ea6e2fb4b6
--- a/main.cpp Sat Dec 17 13:13:59 2016 +0000 +++ b/main.cpp Sat Dec 17 15:10:12 2016 +0000 @@ -2,8 +2,7 @@ #include "mbed.h" #include "usbhid.h" - -#ifdef CONFIG_TWO_REPORTS +#if CONFIG_TWO_REPORTS || CONFIG_TWO_INTERFACES BusIn buttonsL ( p17, p16, p15, p20, // 3 top row, bottom-left @@ -20,7 +19,7 @@ BusIn stickR(p28, p26, p27, p29); #endif -#ifdef CONFIG_2ND_PAD_AS_BUTTONS +#if CONFIG_2ND_PAD_AS_BUTTONS BusIn buttonsL ( p17, p16, p15, p20, // 3 top row, bottom-left @@ -42,7 +41,7 @@ int main() { uint8_t stickL_old = 0; -#ifdef CONFIG_TWO_REPORTS +#if CONFIG_TWO_REPORTS || CONFIG_TWO_INTERFACES uint8_t stickR_old = 0; #endif uint32_t buttonsL_old = 0; @@ -51,13 +50,13 @@ while(1) { const uint8_t stickL_new = stickL.read(); -#ifdef CONFIG_TWO_REPORTS +#if CONFIG_TWO_REPORTS || CONFIG_TWO_INTERFACES const uint8_t stickR_new = stickR.read(); #endif const uint32_t buttonsL_new = buttonsL.read(); const uint32_t buttonsR_new = buttonsR.read(); -#ifdef CONFIG_TWO_REPORTS +#if CONFIG_TWO_REPORTS || CONFIG_TWO_INTERFACES if ((stickL_old != stickL_new) || (buttonsL_old != buttonsL_new)) { stickL_old = stickL_new; @@ -73,7 +72,7 @@ } #endif -#ifdef CONFIG_2ND_PAD_AS_BUTTONS +#if CONFIG_2ND_PAD_AS_BUTTONS if ((stickL_old != stickL_new) || (buttonsL_old != buttonsL_new) || (buttonsR_old != buttonsR_new)) { const uint32_t buttons = buttonsL_new | (buttonsR_new << 7);