Subversion Repositories Code-Repo

Rev

Rev 238 | Blame | Last modification | View Log | RSS feed

#ifndef CONTROLLERS_H
#define CONTROLLERS_H

#define CONTROLLER_READ     0xA
#define CONTROLLER_WRITE    0xB

#define CONTROLLER_BTN_DEFAULT  0xC0
#define CONTROLLER_LED_DEFAULT  0x00

#define CONTROLLER_1_ADDRESS    0x24
#define CONTROLLER_2_ADDRESS    0x25

typedef struct {
    void (*btn_change_callback)(uint8_t ctrl_1, uint8_t ctrl_2);

    uint8_t ctrl_1_connected;
    uint8_t ctrl_1_buttons_prev;
    uint8_t ctrl_1_leds;
    uint8_t ctrl_1_active;
    
    uint8_t ctrl_2_connected;
    uint8_t ctrl_2_buttons_prev;
    uint8_t ctrl_2_leds;
    uint8_t ctrl_2_active;
} CONTROLLER_DATA;

void Controller_Init(CONTROLLER_DATA *data, 
        void (*btn_change_callback)(uint8_t, uint8_t));
void Controller_Update(void);
void Controller_Set_Leds(uint8_t ctrl_1, uint8_t ctrl_2);
void Controller_Btn_Change(void (*callback)(uint8_t, uint8_t));
uint8_t Controller_Query(void);

#endif  /* CONTROLLERS_H */