Go to the documentation of this file.00001
00006 #ifndef __LIBDRAGON_CONTROLLER_H
00007 #define __LIBDRAGON_CONTROLLER_H
00008
00021 #define CONTROLLER_1_INSERTED 0xF000
00022
00023 #define CONTROLLER_2_INSERTED 0x0F00
00024
00025 #define CONTROLLER_3_INSERTED 0x00F0
00026
00027 #define CONTROLLER_4_INSERTED 0x000F
00028
00036 #define ACCESSORY_NONE 0
00037
00038 #define ACCESSORY_MEMPAK 1
00039
00040 #define ACCESSORY_RUMBLEPAK 2
00041
00042 #define ACCESSORY_VRU 3
00043
00050 #define ERROR_NONE 0x0
00051
00052 #define ERROR_BAD_COMMAND 0x1
00053
00054 #define ERROR_NOT_PRESENT 0x2
00055
00058 typedef struct SI_condat
00059 {
00061 unsigned : 16;
00063 unsigned err : 2;
00065 unsigned : 14;
00066
00067 union
00068 {
00069 struct
00070 {
00072 unsigned int data : 32;
00073 };
00074 struct
00075 {
00077 unsigned A : 1;
00079 unsigned B : 1;
00081 unsigned Z : 1;
00083 unsigned start : 1;
00085 unsigned up : 1;
00087 unsigned down : 1;
00089 unsigned left : 1;
00091 unsigned right : 1;
00093 unsigned : 2;
00095 unsigned L : 1;
00097 unsigned R : 1;
00099 unsigned C_up : 1;
00101 unsigned C_down : 1;
00103 unsigned C_left : 1;
00105 unsigned C_right : 1;
00107 signed x : 8;
00109 signed y : 8;
00110 };
00111 };
00112 } _SI_condat;
00113
00117 typedef struct controller_data
00118 {
00120 struct SI_condat c[4];
00122 unsigned long unused[4*8];
00123 } _controller_data;
00124
00125 #ifdef __cplusplus
00126 extern "C" {
00127 #endif
00128
00129 void controller_init();
00130 void controller_read( struct controller_data * data);
00131 int get_controllers_present();
00132 int get_accessories_present();
00133 void controller_scan();
00134 struct controller_data get_keys_down();
00135 struct controller_data get_keys_up();
00136 struct controller_data get_keys_held();
00137 struct controller_data get_keys_pressed();
00138 int get_dpad_direction( int controller );
00139 int read_mempak_address( int controller, uint16_t address, uint8_t *data );
00140 int write_mempak_address( int controller, uint16_t address, uint8_t *data );
00141 int identify_accessory( int controller );
00142 void rumble_start( int controller );
00143 void rumble_stop( int controller );
00144 void execute_raw_command( int controller, int command, int bytesout, int bytesin, unsigned char *out, unsigned char *in );
00145 int eeprom_present();
00146 void eeprom_read(int block, uint8_t * const buf);
00147 void eeprom_write(int block, const uint8_t * const data);
00148
00149 #ifdef __cplusplus
00150 }
00151 #endif
00152
00154
00155 #endif