void FCEUD_UpdateInput() { bool joy=false,mouse=false; EMOVIEMODE FCEUMOVState = FCEUMOV_Mode(); UpdateRawInputAndHotkeys(); { for(int x=0;x<2;x++) switch(InputType[x]) { case SI_GAMEPAD: joy=true; break; case SI_SNES: UpdateGamepad(true); break; case SI_MOUSE: mouse=true; break; case SI_SNES_MOUSE: mouse=true; break; case SI_ARKANOID: mouse=true; break; case SI_ZAPPER: mouse=true; break; case SI_POWERPADA: case SI_POWERPADB: powerpadbuf[x]=UpdatePPadData(x); break; } switch(InputType[2]) { case SIFC_ARKANOID: mouse=true; break; case SIFC_SHADOW: mouse=true; break; case SIFC_FKB: if(cidisabled) UpdateFKB(); break; case SIFC_PEC586KB: case SIFC_SUBORKB: if(cidisabled) UpdateSuborKB(); break; case SIFC_HYPERSHOT: UpdateHyperShot();break; case SIFC_MAHJONG: UpdateMahjong();break; case SIFC_QUIZKING: UpdateQuizKing();break; case SIFC_FTRAINERB: case SIFC_FTRAINERA: UpdateFTrainer();break; case SIFC_TOPRIDER: UpdateTopRider();break; case SIFC_OEKAKIDS: mouse=true; break; } if(joy) UpdateGamepad(false); if(mouse) if(FCEUMOVState != MOVIEMODE_PLAY) //FatRatKnight: Moved this if out of the function GetMouseData(MouseData); //A more concise fix may be desired. } }
void EmuScreen::update(InputState &input) { if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", errorMessage_)); errorMessage_ = ""; return; } if (invalid_) return; // First translate touches into pad input. UpdateGamepad(input); UpdateInputState(&input); // Then translate pad input into PSP pad input. static const int mapping[12][2] = { {PAD_BUTTON_A, CTRL_CROSS}, {PAD_BUTTON_B, CTRL_CIRCLE}, {PAD_BUTTON_X, CTRL_SQUARE}, {PAD_BUTTON_Y, CTRL_TRIANGLE}, {PAD_BUTTON_UP, CTRL_UP}, {PAD_BUTTON_DOWN, CTRL_DOWN}, {PAD_BUTTON_LEFT, CTRL_LEFT}, {PAD_BUTTON_RIGHT, CTRL_RIGHT}, {PAD_BUTTON_LBUMPER, CTRL_LTRIGGER}, {PAD_BUTTON_RBUMPER, CTRL_RTRIGGER}, {PAD_BUTTON_START, CTRL_START}, {PAD_BUTTON_SELECT, CTRL_SELECT}, }; for (int i = 0; i < 12; i++) { if (input.pad_buttons_down & mapping[i][0]) { __CtrlButtonDown(mapping[i][1]); } if (input.pad_buttons_up & mapping[i][0]) { __CtrlButtonUp(mapping[i][1]); } } __CtrlSetAnalog(input.pad_lstick_x, input.pad_lstick_y); if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK)) { if (g_Config.bBufferedRendering) fbo_unbind(); screenManager()->push(new InGameMenuScreen()); } }
void FCEUD_UpdateInput(void) { int x; int t = 0; KeyboardUpdateState(); UpdateJoysticks(); //UpdatePhysicalInput(); KeyboardCommands(); for (x = 0; x < 2; x++) switch (InputType[x]) { case SI_GAMEPAD: t |= 1; break; case SI_ARKANOID: t |= 2; break; case SI_MOUSE: t |= 2; break; case SI_ZAPPER: t |= 2; break; case SI_POWERPADA: case SI_POWERPADB: powerpadbuf[x] = UpdatePPadData(x); break; } switch (InputType[2]) { case SIFC_ARKANOID: t |= 2; break; case SIFC_SHADOW: t |= 2; break; case SIFC_FKB: if (cidisabled) UpdateFKB(); break; case SIFC_SUBORKB: if (cidisabled) UpdateSuborKB(); break; case SIFC_HYPERSHOT: UpdateHyperShot(); break; case SIFC_MAHJONG: UpdateMahjong(); break; case SIFC_QUIZKING: UpdateQuizKing(); break; case SIFC_FTRAINERB: case SIFC_FTRAINERA: UpdateFTrainer(); break; case SIFC_TOPRIDER: UpdateTopRider(); break; case SIFC_OEKAKIDS: t |= 2; break; } if (t & 1) UpdateGamepad(); if (t & 2) GetMouseData(MouseData); }
void EmuScreen::update(InputState &input) { globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", errorMessage_)); errorMessage_ = ""; return; } if (invalid_) return; float leftstick_x = 0.0f; float leftstick_y = 0.0f; float rightstick_x = 0.0f; float rightstick_y = 0.0f; // Virtual keys. __CtrlSetRapidFire(virtKeys[VIRTKEY_RAPID_FIRE - VIRTKEY_FIRST]); // First translate touches into native pad input. // Do this no matter the value of g_Config.bShowTouchControls, some people // like to use invisible controls... // Don't force on platforms that likely don't have a touchscreen, like Win32, OSX, and Linux... // TODO: What are good ifdefs for OSX and Linux, without breaking other mobile platforms? #ifdef _WIN32 if(g_Config.bShowTouchControls) { #endif // TODO: Make new better touch buttons so we don't have to do this crap. // Copy over the mouse data from the real inputstate. fakeInputState.mouse_valid = input.mouse_valid; fakeInputState.pad_last_buttons = fakeInputState.pad_buttons; fakeInputState.pad_buttons = input.pad_buttons; memcpy(fakeInputState.pointer_down, input.pointer_down, sizeof(input.pointer_down)); memcpy(fakeInputState.pointer_x, input.pointer_x, sizeof(input.pointer_x)); memcpy(fakeInputState.pointer_y, input.pointer_y, sizeof(input.pointer_y)); fakeInputState.pad_lstick_x = 0.0f; fakeInputState.pad_lstick_y = 0.0f; fakeInputState.pad_rstick_x = 0.0f; fakeInputState.pad_rstick_y = 0.0f; UpdateGamepad(fakeInputState); UpdateInputState(&fakeInputState); for (size_t i = 0; i < ARRAY_SIZE(legacy_touch_mapping); i++) { if (fakeInputState.pad_buttons_down & legacy_touch_mapping[i].from) __CtrlButtonDown(legacy_touch_mapping[i].to); if (fakeInputState.pad_buttons_up & legacy_touch_mapping[i].from) __CtrlButtonUp(legacy_touch_mapping[i].to); } leftstick_x += fakeInputState.pad_lstick_x; leftstick_y += fakeInputState.pad_lstick_y; rightstick_x += fakeInputState.pad_rstick_x; rightstick_y += fakeInputState.pad_rstick_y; if (g_Config.bShowAnalogStick) { __CtrlSetAnalogX(clamp1(leftstick_x), CTRL_STICK_LEFT); __CtrlSetAnalogY(clamp1(leftstick_y), CTRL_STICK_LEFT); } __CtrlSetAnalogX(clamp1(rightstick_x), CTRL_STICK_RIGHT); __CtrlSetAnalogY(clamp1(rightstick_y), CTRL_STICK_RIGHT); // Also send the special buttons to input, since that's where they're handled. input.pad_buttons_down |= fakeInputState.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB | PAD_BUTTON_LEFT_THUMB); input.pad_buttons_up |= fakeInputState.pad_buttons_up & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB | PAD_BUTTON_LEFT_THUMB); input.pad_buttons = fakeInputState.pad_buttons; #ifdef _WIN32 } #endif // Still checking input.pad_buttons here to support the onscreen throttle button. PSP_CoreParameter().unthrottle = virtKeys[VIRTKEY_UNTHROTTLE - VIRTKEY_FIRST] || (input.pad_buttons & PAD_BUTTON_UNTHROTTLE) != 0; // Apply tilt to left stick if (g_Config.bAccelerometerToAnalogHoriz) { // TODO: Deadzone, etc. leftstick_x += clamp1(curve1(input.acc.y) * 2.0f); __CtrlSetAnalogX(clamp1(leftstick_x), CTRL_STICK_LEFT); } // Make sure fpsLimit starts at 0 if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1) { PSP_CoreParameter().fpsLimit = 0; } // This is still here to support the iOS on screen back button. if (input.pad_buttons_down & (PAD_BUTTON_BACK)) { screenManager()->push(new PauseScreen()); } }
void EmuScreen::update(InputState &input) { globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", errorMessage_)); errorMessage_ = ""; return; } if (invalid_) return; // First translate touches into native pad input. // Do this no matter the value of g_Config.bShowTouchControls, some people // like to use invisible controls... // Don't force on platforms that likely don't have a touchscreen, like Win32, OSX, and Linux... // TODO: What are good ifdefs for OSX and Linux, without breaking other mobile platforms? #ifdef _WIN32 if(g_Config.bShowTouchControls) { #endif UpdateGamepad(input); UpdateInputState(&input); #ifdef _WIN32 } #endif // Then translate pad input into PSP pad input. Also, add in tilt. static const int mapping[12][2] = { {PAD_BUTTON_A, CTRL_CROSS}, {PAD_BUTTON_B, CTRL_CIRCLE}, {PAD_BUTTON_X, CTRL_SQUARE}, {PAD_BUTTON_Y, CTRL_TRIANGLE}, {PAD_BUTTON_UP, CTRL_UP}, {PAD_BUTTON_DOWN, CTRL_DOWN}, {PAD_BUTTON_LEFT, CTRL_LEFT}, {PAD_BUTTON_RIGHT, CTRL_RIGHT}, {PAD_BUTTON_LBUMPER, CTRL_LTRIGGER}, {PAD_BUTTON_RBUMPER, CTRL_RTRIGGER}, {PAD_BUTTON_START, CTRL_START}, {PAD_BUTTON_SELECT, CTRL_SELECT}, }; for (int i = 0; i < 12; i++) { if (input.pad_buttons_down & mapping[i][0]) { __CtrlButtonDown(mapping[i][1]); } if (input.pad_buttons_up & mapping[i][0]) { __CtrlButtonUp(mapping[i][1]); } } float stick_x = input.pad_lstick_x; float stick_y = input.pad_lstick_y; float rightstick_x = input.pad_rstick_x; float rightstick_y = input.pad_rstick_y; I18NCategory *s = GetI18NCategory("Screen"); // Apply tilt to left stick if (g_Config.bAccelerometerToAnalogHoriz) { // TODO: Deadzone, etc. stick_x += clamp1(curve1(input.acc.y) * 2.0f); stick_x = clamp1(stick_x); } __CtrlSetAnalog(stick_x, stick_y, 0); __CtrlSetAnalog(rightstick_x, rightstick_x, 1); if (PSP_CoreParameter().fpsLimit != 2) { // Don't really need to show these, it's pretty obvious what unthrottle does, // in contrast to the three state toggle /* if (input.pad_buttons_down & PAD_BUTTON_UNTHROTTLE) { osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF); } if (input.pad_buttons_up & PAD_BUTTON_UNTHROTTLE) { osm.Show(s->T("standard", "Speed: standard"), 1.0); }*/ } if (input.pad_buttons & PAD_BUTTON_UNTHROTTLE) { PSP_CoreParameter().unthrottle = true; } else { PSP_CoreParameter().unthrottle = false; } // Make sure fpsLimit starts at 0 if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1 && PSP_CoreParameter().fpsLimit != 2) { PSP_CoreParameter().fpsLimit = 0; } //Toggle between 3 different states of fpsLimit if (input.pad_buttons_down & PAD_BUTTON_LEFT_THUMB) { if (PSP_CoreParameter().fpsLimit == 0) { PSP_CoreParameter().fpsLimit = 1; osm.Show(s->T("fixed", "Speed: fixed"), 1.0); } else if (PSP_CoreParameter().fpsLimit == 1) { PSP_CoreParameter().fpsLimit = 2; osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF); } else if (PSP_CoreParameter().fpsLimit == 2) { PSP_CoreParameter().fpsLimit = 0; osm.Show(s->T("standard", "Speed: standard"), 1.0); } } if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) { if (g_Config.bBufferedRendering) fbo_unbind(); screenManager()->push(new PauseScreen()); } }
void EmuScreen::update(InputState &input) { globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", errorMessage_)); errorMessage_ = ""; return; } if (invalid_) return; // First translate touches into native pad input. if (g_Config.bShowTouchControls) UpdateGamepad(input); UpdateInputState(&input); // Then translate pad input into PSP pad input. Also, add in tilt. static const int mapping[12][2] = { {PAD_BUTTON_A, CTRL_CROSS}, {PAD_BUTTON_B, CTRL_CIRCLE}, {PAD_BUTTON_X, CTRL_SQUARE}, {PAD_BUTTON_Y, CTRL_TRIANGLE}, {PAD_BUTTON_UP, CTRL_UP}, {PAD_BUTTON_DOWN, CTRL_DOWN}, {PAD_BUTTON_LEFT, CTRL_LEFT}, {PAD_BUTTON_RIGHT, CTRL_RIGHT}, {PAD_BUTTON_LBUMPER, CTRL_LTRIGGER}, {PAD_BUTTON_RBUMPER, CTRL_RTRIGGER}, {PAD_BUTTON_START, CTRL_START}, {PAD_BUTTON_SELECT, CTRL_SELECT}, }; for (int i = 0; i < 12; i++) { if (input.pad_buttons_down & mapping[i][0]) { __CtrlButtonDown(mapping[i][1]); } if (input.pad_buttons_up & mapping[i][0]) { __CtrlButtonUp(mapping[i][1]); } } float stick_x = input.pad_lstick_x; float stick_y = input.pad_lstick_y; // Apply tilt if (g_Config.bAccelerometerToAnalogHoriz) { // TODO: Deadzone, etc. stick_x += clamp1(curve1(input.acc.y) * 2.0f); stick_x = clamp1(stick_x); } __CtrlSetAnalog(stick_x, stick_y); if (input.pad_buttons & PAD_BUTTON_LEFT_THUMB) { PSP_CoreParameter().unthrottle = true; } else { PSP_CoreParameter().unthrottle = false; } if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) { if (g_Config.bBufferedRendering) fbo_unbind(); screenManager()->push(new PauseScreen()); } }
void EmuScreen::update(InputState &input) { globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", errorMessage_)); errorMessage_ = ""; return; } if (invalid_) return; // First translate touches into native pad input. // Do this no matter the value of g_Config.bShowTouchControls, some people // like to use invisible controls... UpdateGamepad(input); UpdateInputState(&input); // Then translate pad input into PSP pad input. Also, add in tilt. static const int mapping[12][2] = { {PAD_BUTTON_A, CTRL_CROSS}, {PAD_BUTTON_B, CTRL_CIRCLE}, {PAD_BUTTON_X, CTRL_SQUARE}, {PAD_BUTTON_Y, CTRL_TRIANGLE}, {PAD_BUTTON_UP, CTRL_UP}, {PAD_BUTTON_DOWN, CTRL_DOWN}, {PAD_BUTTON_LEFT, CTRL_LEFT}, {PAD_BUTTON_RIGHT, CTRL_RIGHT}, {PAD_BUTTON_LBUMPER, CTRL_LTRIGGER}, {PAD_BUTTON_RBUMPER, CTRL_RTRIGGER}, {PAD_BUTTON_START, CTRL_START}, {PAD_BUTTON_SELECT, CTRL_SELECT}, }; for (int i = 0; i < 12; i++) { if (input.pad_buttons_down & mapping[i][0]) { __CtrlButtonDown(mapping[i][1]); } if (input.pad_buttons_up & mapping[i][0]) { __CtrlButtonUp(mapping[i][1]); } } float stick_x = input.pad_lstick_x; float stick_y = input.pad_lstick_y; float rightstick_x = input.pad_rstick_x; float rightstick_y = input.pad_rstick_y; // Apply tilt to left stick if (g_Config.bAccelerometerToAnalogHoriz) { // TODO: Deadzone, etc. stick_x += clamp1(curve1(input.acc.y) * 2.0f); stick_x = clamp1(stick_x); } __CtrlSetAnalog(stick_x, stick_y, 0); __CtrlSetAnalog(rightstick_x, rightstick_x, 1); if (input.pad_buttons & PAD_BUTTON_UNTHROTTLE) { PSP_CoreParameter().unthrottle = true; } else { PSP_CoreParameter().unthrottle = false; } // Make sure fpsLimit starts at 0 if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1 && PSP_CoreParameter().fpsLimit != 2) { PSP_CoreParameter().fpsLimit = 0; } //Toggle between 3 different states of fpsLimit if (input.pad_buttons_down & PAD_BUTTON_LEFT_THUMB) { if (PSP_CoreParameter().fpsLimit == 0){ PSP_CoreParameter().fpsLimit = 1; } else if (PSP_CoreParameter().fpsLimit == 1){ PSP_CoreParameter().fpsLimit = 2; } else if (PSP_CoreParameter().fpsLimit == 2){ PSP_CoreParameter().fpsLimit = 0; } } if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) { if (g_Config.bBufferedRendering) fbo_unbind(); screenManager()->push(new PauseScreen()); } }