#include "process_joystick.h" #include #include #ifdef __AVR__ # include #endif #include bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record); bool process_joystick(uint16_t keycode, keyrecord_t *record){ if (process_joystick_buttons(keycode, record) && (joystick_status.status & JS_UPDATED)>0){ send_joystick_packet(&joystick_status); joystick_status.status &= ~JS_UPDATED; } return true; } __attribute__ ((weak)) void joystick_task(void){ if (process_joystick_analog() && (joystick_status.status & JS_UPDATED)){ send_joystick_packet(&joystick_status); joystick_status.status &= ~JS_UPDATED; } } bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record){ if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX){ return true; } else { if (record->event.pressed){ joystick_status.buttons[(keycode-JS_BUTTON0)/8] |= 1<<(keycode%8); } else { joystick_status.buttons[(keycode-JS_BUTTON0)/8] &= ~(1<<(keycode%8)); } joystick_status.status |= JS_UPDATED; } return true; } __attribute__ ((weak)) bool process_joystick_analog(){ #if JOYSTICK_AXES_COUNT > 0 for (int axis_index=0 ; axis_index