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); } }
/********************************************************************************************************* * sdl event filter */ static int event_sdl_filter(const SDL_Event *event) { int cmd, action; switch(event->type) { // user clicked on window close button case SDL_QUIT: main_stop(); break; case SDL_KEYDOWN: event_sdl_keydown(event->key.keysym.sym, event->key.keysym.mod); return 0; case SDL_KEYUP: event_sdl_keyup(event->key.keysym.sym, event->key.keysym.mod); return 0; // if joystick action is detected, check if it's mapped to a special function case SDL_JOYAXISMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: case SDL_JOYHATMOTION: for (cmd = 0; cmd < NumJoyCommands; cmd++) { action = MatchJoyCommand(event, (eJoyCommand) cmd); if (action == 1) /* command was just activated (button down, etc) */ { if (cmd == joyFullscreen) changeWindow(); else if (cmd == joyStop) main_stop(); else if (cmd == joyPause) main_toggle_pause(); else if (cmd == joySave) main_state_save(0, NULL); /* save in mupen64plus format using current slot */ else if (cmd == joyLoad) main_state_load(NULL); /* load using current slot */ else if (cmd == joyIncrement) main_state_inc_slot(); else if (cmd == joyScreenshot) main_take_next_screenshot(); else if (cmd == joyMute) { volumeMute(); main_draw_volume_osd(); } else if (cmd == joyDecrease) { volumeDown(); main_draw_volume_osd(); } else if (cmd == joyIncrease) { volumeUp(); main_draw_volume_osd(); } else if (cmd == joyForward) main_set_fastforward(1); } else if (action == -1) /* command was just de-activated (button up, etc) */ { if (cmd == joyForward) main_set_fastforward(0); } } return 0; break; } return 1; }
/********************************************************************************************************* * sdl event filter */ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event) { int cmd, action; switch(event->type) { // user clicked on window close button case SDL_QUIT: main_stop(); break; case SDL_KEYDOWN: #if SDL_VERSION_ATLEAST(1,3,0) if (event->key.repeat) return 0; event_sdl_keydown(event->key.keysym.scancode, event->key.keysym.mod); #else event_sdl_keydown(event->key.keysym.sym, event->key.keysym.mod); #endif return 0; case SDL_KEYUP: #if SDL_VERSION_ATLEAST(1,3,0) event_sdl_keyup(event->key.keysym.scancode, event->key.keysym.mod); #else event_sdl_keyup(event->key.keysym.sym, event->key.keysym.mod); #endif return 0; #if SDL_VERSION_ATLEAST(2,0,0) case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_RESIZED: // call the video plugin. if the video plugin supports resizing, it will resize its viewport and call // VidExt_ResizeWindow to update the window manager handling our opengl output window gfx.resizeVideoOutput(event->window.data1, event->window.data2); return 0; // consumed the event break; } break; #else case SDL_VIDEORESIZE: // call the video plugin. if the video plugin supports resizing, it will resize its viewport and call // VidExt_ResizeWindow to update the window manager handling our opengl output window gfx.resizeVideoOutput(event->resize.w, event->resize.h); return 0; // consumed the event break; #endif // if joystick action is detected, check if it's mapped to a special function case SDL_JOYAXISMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: case SDL_JOYHATMOTION: for (cmd = 0; cmd < NumJoyCommands; cmd++) { action = MatchJoyCommand(event, (eJoyCommand) cmd); if (action == 1) /* command was just activated (button down, etc) */ { if (cmd == joyFullscreen) gfx.changeWindow(); else if (cmd == joyStop) main_stop(); else if (cmd == joyPause) main_toggle_pause(); else if (cmd == joySave) main_state_save(1, NULL); /* save in mupen64plus format using current slot */ else if (cmd == joyLoad) main_state_load(NULL); /* load using current slot */ else if (cmd == joyIncrement) main_state_inc_slot(); else if (cmd == joyScreenshot) main_take_next_screenshot(); else if (cmd == joyMute) main_volume_mute(); else if (cmd == joyDecrease) main_volume_down(); else if (cmd == joyIncrease) main_volume_up(); else if (cmd == joyForward) main_set_fastforward(1); else if (cmd == joyGameshark) event_set_gameshark(1); } else if (action == -1) /* command was just de-activated (button up, etc) */ { if (cmd == joyForward) main_set_fastforward(0); else if (cmd == joyGameshark) event_set_gameshark(0); } } return 0; break; } return 1; }