void lircCheckInput(void) { struct pollfd lircpoll; lircpoll.fd = g_lircfd; lircpoll.events = POLLIN; if(poll(&lircpoll, 1, 0) > 0) { char *code; char *c; int ret; if(lirc_nextcode(&code) == 0 && code != NULL) { while((ret = lirc_code2char(g_config, code, &c)) == 0 && c!=NULL) { char *c_ind = c; while(*c_ind != '\0') { *c_ind = toupper(*c_ind); c_ind++; } DebugMessage(M64MSG_VERBOSE, "LIRC Execing command \"%s\"", c); if(strcmp(c, "SAVE") == 0) main_state_save(1, NULL); /* save in mupen64plus format using current slot */ else if(strcmp(c, "LOAD") == 0) main_state_load(NULL); /* load using current slot */ else if(strcmp(c, "QUIT") == 0) main_stop(); else if(strcmp(c, "FULLSCREEN") == 0) gfx.changeWindow(); else if(strcmp(c, "MUTE") == 0) main_volume_mute(); else if(strcmp(c, "VOL+") == 0) main_volume_up(); else if(strcmp(c, "VOL-") == 0) main_volume_down(); else if(strcmp(c, "SCREENSHOT") == 0) main_take_next_screenshot(); else if(strcmp(c, "SPEED+") == 0) main_speedup(5); else if(strcmp(c, "SPEED-") == 0) main_speeddown(5); else if(strcmp(c, "ADVANCE") == 0) main_advance_one(); else if(strcmp(c, "PAUSE") == 0) main_toggle_pause(); else { int val = ((int)c[0])-((int) '0'); if (val >= 0 && val <= 9) savestates_select_slot( val ); } } free(code); } } }
void event_sdl_keydown(int keysym, int keymod) { int slot; /* check for the only 2 hard-coded key commands: Alt-enter for fullscreen and 0-9 for save state slot */ if (keysym == SDL_SCANCODE_RETURN && keymod & (KMOD_LALT | KMOD_RALT)) gfx.changeWindow(); else if ((slot = get_saveslot_from_keysym(keysym)) >= 0) main_state_set_slot(slot); /* check all of the configurable commands */ else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdStop))) main_stop(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdFullscreen))) gfx.changeWindow(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSave))) main_state_save(0, NULL); /* save in mupen64plus format using current slot */ else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdLoad))) main_state_load(NULL); /* load using current slot */ else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdIncrement))) main_state_inc_slot(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdReset))) reset_soft(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSpeeddown))) main_speeddown(5); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSpeedup))) main_speedup(5); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdScreenshot))) main_take_next_screenshot(); /* screenshot will be taken at the end of frame rendering */ else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdPause))) main_toggle_pause(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdMute))) main_volume_mute(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdIncrease))) main_volume_up(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdDecrease))) main_volume_down(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdForward))) main_set_fastforward(1); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdAdvance))) main_advance_one(); else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdGameshark))) event_set_gameshark(1); else { /* pass all other keypresses to the input plugin */ input.keyDown(keymod, keysym); } }
void event_sdl_keydown(int keysym, int keymod) { /* check for the only 2 hard-coded key commands: Alt-enter for fullscreen and 0-9 for save state slot */ if (keysym == SDLK_RETURN && keymod & (KMOD_LALT | KMOD_RALT)) { changeWindow(); } else if (keysym >= SDLK_0 && keysym <= SDLK_9) { main_state_set_slot(keysym - SDLK_0); } /* check all of the configurable commands */ else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdStop)) main_stop(); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdFullscreen)) changeWindow(); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdSave)) main_state_save(0, NULL); /* save in mupen64plus format using current slot */ else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdLoad)) main_state_load(NULL); /* load using current slot */ else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdIncrement)) main_state_inc_slot(); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdReset)) { add_interupt_event(HW2_INT, 0); /* Hardware 2 Interrupt immediately */ add_interupt_event(NMI_INT, 50000000); /* Non maskable Interrupt after 1/2 second */ } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdSpeeddown)) main_speeddown(5); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdSpeedup)) main_speedup(5); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdScreenshot)) main_take_next_screenshot(); /* screenshot will be taken at the end of frame rendering */ else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdPause)) main_toggle_pause(); else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdMute)) { volumeMute(); main_draw_volume_osd(); } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdIncrease)) { volumeUp(); main_draw_volume_osd(); } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdDecrease)) { volumeDown(); main_draw_volume_osd(); } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdForward)) { main_set_fastforward(1); } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdAdvance)) { main_advance_one(); } else if (keysym == ConfigGetParamInt(g_CoreConfig, kbdGameshark)) { KbdGamesharkPressed = 1; } else { /* pass all other keypresses to the input plugin */ keyDown(keymod, keysym); } }