int main(void) { libgba_init(); int selection = 0; bool needs_init = true; // this is how the demo selection will be laid out on screen const demo demos[NUM_DEMOS] = { demo1_main, demo2_main, demo3_main, demo4_main, demo5_main, demo6_main, demo7_main, demo8_main }; for (;;) // main loop; loop forever { if (needs_init) { main_init(); needs_init = false; } u16 key_state = get_curr_keys(); int tribool_horz = tribool_dpad_horz(key_state); int tribool_vert = tribool_dpad_vert(key_state); int horz = (selection + tribool_horz) & 1; int vert = (((selection >> 1) + tribool_vert) << 1) & (NUM_DEMOS - 1); selection = horz + vert; if (key_state & KEY_A) { demos[selection](); needs_init = true; } VBlankIntrWait(); } // never actually get here; behavior after main returns is undefined on GBA return 0; }
int key_just_pressed(int key) { return get_curr_keys()[key] && !get_last_keys()[key]; }
int key_pressed(int key) { return get_curr_keys()[key]; }
void update_keys() { memcpy(get_last_keys(), get_curr_keys(), GLFW_KEY_LAST+1); }
void GLFWCALL set_key(int key, int state) { get_curr_keys()[key] = (state == GLFW_PRESS); }