#include #include #include #include "CORE_console.h" #include "CORE_turbo_keys.h" #define COUNT_RELOAD 20000 static u16 turbo_count = 0; static u8 turbo_pressed = 1; /* Process turbo keys */ void turbo_keys_process_input(turbo_keys_t* t, console_t* c){ if(!t->enabled) return; /* nothing to do */ /* check timing */ if(!turbo_count--) return; //turbo_count = COUNT_RELOAD; if(turbo_pressed) turbo_pressed = 0; else turbo_pressed = 1; if(t->A && c->A) c->A = turbo_pressed; if(t->B && c->B) c->B = turbo_pressed; if(t->X && c->X) c->X = turbo_pressed; if(t->Y && c->Y) c->Y = turbo_pressed; if(t->L && c->L) c->L = turbo_pressed; if(t->R && c->R) c->R = turbo_pressed; if(t->Start && c->Start) c->Start = turbo_pressed; if(t->Select && c->Select) c->Select = turbo_pressed; return; } /* Init turbo keys variables */ void turbo_keys_init(turbo_keys_t* t){ memset((void*)t, 0, sizeof(turbo_keys_t)); return; } /* Process xml atoms */ int turbo_keys_process_xml(void* elem, char* tag, char* content){ turbo_keys_t* t = (turbo_keys_t*)elem; if(tag != NULL && content != NULL){ if(strcmp(content, "")){ /* process atom: */ if(!strcmp(tag, "a")){ t->A = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "b")){ t->B = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "x")){ t->X = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "y")){ t->Y = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "l")){ t->L = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "r")){ t->R = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "start")){ t->Start = atoi(content); return 1; } /* process atom: */ if(!strcmp(tag, "select")){ t->Select = atoi(content); return 1; } return xml_read(elem, turbo_keys_process_xml, content); } } /* Should not happend... (compiler warning) */ return 0; } /* Write xml atoms */ void turbo_keys_write_xml(turbo_keys_t* t, FILE* out){ fprintf(out, " \n"); fprintf(out, " \n"); fprintf(out, " %d\n", t->A); fprintf(out, " %d\n", t->B); fprintf(out, " %d\n", t->X); fprintf(out, " %d\n", t->Y); fprintf(out, " %d\n", t->L); fprintf(out, " %d\n", t->R); fprintf(out, " %d\n", t->Start); fprintf(out, " \n", t->Select); fprintf(out, " \n"); return; }