I'm making a HID joystick, (actually a DJ controller but the code is for a joystick) My problem is my HEX file to make the arduino HID is 22KB so it is too big.
In my source files, usb_gamepad.c, I have some long lists that I think I could shorten with a i++ operation
Being a noob, I'm not sure how to do it
Below is my code and ............... represents missing numbers.
Could someone help me out please.
// zero when we are not configured, non-zero when enumerated
static volatile uint8_t usb_configuration = 0;
static const gamepad_state_t PROGMEM gamepad_idle_state = {
.b0_btn = 0, .b1_btn = 0, .b2_btn = 0, .b3_btn = 0,
....................... .b126_btn = 0, .b127_btn = 0,
.a0_axis = 0x80, .a1_axis = 0x80, .a2_axis = 0x80, .a3_axis = 0x80,
........................... .a46_axis = 0x80, .a47_axis = 0x80,
.b0_axis = 0x00, .b1_axis = 0x00, .b2_axis = 0x00, .b3_axis = 0x00,
.................. .b126_axis = 0x00, .b127_axis = 0x00
};
There's also this bit where I think the implementation would be slightly different
int8_t sendPS3Data(dataForController_t btnList){
gamepad_state.b0_axis = btnList.bt0On;
gamepad_state.b1_btn = btnList.bt1On;
gamepad_state.b2_btn = btnList.bt2On;
....................
gamepad_state.b127_btn = btnList.bt127On;
if (gamepad_state.b0_btn == 1)
gamepad_state.b0_axis = 0x01;
else
gamepad_state.b0_axis = 0;
if (gamepad_state.b1_btn == 1)
gamepad_state.b1_axis = 0x01;
else
gamepad_state.b1_axis = 0;
if (gamepad_state.b2_btn == 1)
gamepad_state.b2_axis = 0x01;
else
gamepad_state.b2_axis = 0;
.....................................
if (gamepad_state.b127_btn == 1)
gamepad_state.b127_axis = 0x01;
else
gamepad_state.b127_axis = 0;
// left and right analog sticks, 0x00 left/up, 0x80 middle, 0xff right/down
gamepad_state.a0_axis = btnList.al0;
gamepad_state.a1_axis = btnList.al1;
gamepad_state.a2_axis = btnList.al2;
..........................
gamepad_state.a47_axis = btnList.al47;
// Send the data out via USB
return usb_gamepad_send();
}
Thanks for reading.