//Play button function. void NTGVS1053::Play(char _index[]){ vs1053.startPlayingFile(_index); while(vs1053.playingMusic){ isButtonVolUp = IsButtonPressed(isButtonVolUp, VOL_UP, &VolUp); isButtonVolDown = IsButtonPressed(isButtonVolDown, VOL_DOWN, &VolDown); } }
void PSPSaveDialog::DisplaySaveList(bool canMove) { lock_guard guard(paramLock); static int upFramesHeld = 0; static int downFramesHeld = 0; for (int displayCount = 0; displayCount < param.GetFilenameCount(); displayCount++) { int textureColor = 0xFFFFFFFF; auto fileInfo = param.GetFileInfo(displayCount); if (fileInfo.size == 0 && fileInfo.texture != NULL) textureColor = 0xFF777777; // Calc save image position on screen float w, h , x, b; float y = 97; if (displayCount != currentSelectedSave) { w = 81; h = 45; x = 58.5f; } else { w = 144; h = 80; x = 27; b = 1.2; PPGeDrawRect(x-b, y-b, x+w+b, y, CalcFadedColor(0xD0FFFFFF)); // top border PPGeDrawRect(x-b, y, x, y+h, CalcFadedColor(0xD0FFFFFF)); // left border PPGeDrawRect(x-b, y+h, x+w+b, y+h+b, CalcFadedColor(0xD0FFFFFF)); //bottom border PPGeDrawRect(x+w, y, x+w+b, y+h, CalcFadedColor(0xD0FFFFFF)); //right border } if (displayCount < currentSelectedSave) y -= 13 + 45 * (currentSelectedSave - displayCount); else if (displayCount > currentSelectedSave) y += 48 + 45 * (displayCount - currentSelectedSave); // Skip if it's well outside the screen. if (y > 472.0f || y < -200.0f) continue; int tw = 256; int th = 256; if (fileInfo.texture != NULL) { fileInfo.texture->SetTexture(); tw = fileInfo.texture->Width(); th = fileInfo.texture->Height(); PPGeDrawImage(x, y, w, h, 0, 0, 1, 1, tw, th, textureColor); } PPGeSetDefaultTexture(); } if (canMove) { if ( (IsButtonPressed(CTRL_UP) || IsButtonHeld(CTRL_UP, upFramesHeld)) && currentSelectedSave > 0) currentSelectedSave--; else if ( (IsButtonPressed(CTRL_DOWN) || IsButtonHeld(CTRL_DOWN, downFramesHeld)) && currentSelectedSave < (param.GetFilenameCount() - 1)) currentSelectedSave++; } }
void PSPSaveDialog::DisplaySaveList(bool canMove) { int displayCount = 0; for(int i = 0; i < param.GetFilenameCount(); i++) { int textureColor = CalcFadedColor(0xFFFFFFFF); if(param.GetFileInfo(i).size == 0 && param.GetFileInfo(i).textureData == 0) { textureColor = CalcFadedColor(0xFF777777); } // Calc save image position on screen float w = 150; float h = 80; float x = 20; if(displayCount != currentSelectedSave) { w = 80; h = 40; x = 55; } float y = 96; if(displayCount < currentSelectedSave) y -= 10 + 40 * (currentSelectedSave - displayCount ); else if(displayCount > currentSelectedSave) { y += 91 + 40 * (displayCount - currentSelectedSave - 1); } int tw = 256; int th = 256; if(param.GetFileInfo(i).textureData != 0) { tw = param.GetFileInfo(i).textureWidth; th = param.GetFileInfo(i).textureHeight; PPGeSetTexture(param.GetFileInfo(i).textureData, param.GetFileInfo(i).textureWidth, param.GetFileInfo(i).textureHeight); } else { PPGeDisableTexture(); } PPGeDrawImage(x, y, w, h, 0, 0 ,1 ,1 ,tw, th, textureColor); PPGeSetDefaultTexture(); displayCount++; } if(canMove) { if (IsButtonPressed(CTRL_UP) && currentSelectedSave > 0) { currentSelectedSave--; } else if (IsButtonPressed(CTRL_DOWN) && currentSelectedSave < (param.GetFilenameCount()-1)) { currentSelectedSave++; } } }
void PSPSaveDialog::DisplaySaveList(bool canMove) { int displayCount = 0; for (int i = 0; i < param.GetFilenameCount(); i++) { int textureColor = 0xFFFFFFFF; if (param.GetFileInfo(i).size == 0 && param.GetFileInfo(i).textureData == 0) textureColor = 0xFF777777; // Calc save image position on screen float w, h , x, b; float y = 97; if (displayCount != currentSelectedSave) { w = 81; h = 45; x = 58.5f; } else { w = 144; h = 80; x = 27; b = 1.2; PPGeDrawRect(x-b, y-b, x+w+b, y, CalcFadedColor(0xD0FFFFFF)); // top border PPGeDrawRect(x-b, y, x, y+h, CalcFadedColor(0xD0FFFFFF)); // left border PPGeDrawRect(x-b, y+h, x+w+b, y+h+b, CalcFadedColor(0xD0FFFFFF)); //bottom border PPGeDrawRect(x+w, y, x+w+b, y+h, CalcFadedColor(0xD0FFFFFF)); //right border } if (displayCount < currentSelectedSave) y -= 13 + 45 * (currentSelectedSave - displayCount); else if (displayCount > currentSelectedSave) y += 48 + 45 * (displayCount - currentSelectedSave); int tw = 256; int th = 256; if (param.GetFileInfo(i).textureData != 0) { tw = param.GetFileInfo(i).textureWidth; th = param.GetFileInfo(i).textureHeight; PPGeSetTexture(param.GetFileInfo(i).textureData, param.GetFileInfo(i).textureWidth, param.GetFileInfo(i).textureHeight); PPGeDrawImage(x, y, w, h, 0, 0, 1, 1, tw, th, textureColor); } else PPGeDisableTexture(); PPGeSetDefaultTexture(); displayCount++; } if (canMove) { if (IsButtonPressed(CTRL_UP) && currentSelectedSave > 0) currentSelectedSave--; else if (IsButtonPressed(CTRL_DOWN) && currentSelectedSave < (param.GetFilenameCount()-1)) currentSelectedSave++; } }
void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo) { const float WRAP_WIDTH = 300.0f; float y = 125.0f; float h; int n; PPGeMeasureText(0, &h, &n, text.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH); float h2 = h * (float)n / 2.0f; if (hasYesNo) { I18NCategory *d = GetI18NCategory("Dialog"); const char *choiceText; u32 yesColor, noColor; float x, w; if (yesnoChoice == 1) { choiceText = d->T("Yes"); x = 208.0f; yesColor = 0xFFFFFFFF; noColor = 0xFFFFFFFF; } else { choiceText = d->T("No"); x = 272.0f; yesColor = 0xFFFFFFFF; noColor = 0xFFFFFFFF; } PPGeMeasureText(&w, &h, 0, choiceText, FONT_SCALE); w = w / 2.0f + 5.5f; h /= 2.0f; float y2 = y + h2 + 30.0f; h2 += h + 4.0f; y = 132.0f - h; PPGeDrawRect(x - w, y2 - h, x + w, y2 + h, CalcFadedColor(0x6DCFCFCF)); PPGeDrawText(d->T("Yes"), 209.0f, y2+3, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x30000000)); PPGeDrawText(d->T("Yes"), 208.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(yesColor)); PPGeDrawText(d->T("No"), 273.0f, y2+3, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x30000000)); PPGeDrawText(d->T("No"), 272.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(noColor)); if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) { yesnoChoice = 1; } else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) { yesnoChoice = 0; } } PPGeDrawTextWrapped(text.c_str(), 241.0f, y+3, WRAP_WIDTH, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x30000000)); PPGeDrawTextWrapped(text.c_str(), 240.0f, y, WRAP_WIDTH, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF)); float sy = 110.0f - h2, ey = 160.0f + h2; PPGeDrawRect(50.0f, sy, 420.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawRect(50.0f, ey, 420.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF)); }
void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo) { const float WRAP_WIDTH = 254.0f; float y = 136.0f, h; int n; PPGeMeasureText(0, &h, &n, text.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH); float h2 = h * (float)n / 2.0f; if (hasYesNo) { I18NCategory *di = GetI18NCategory("Dialog"); const char *choiceText; u32 yesColor, noColor; float x, w; if (yesnoChoice == 1) { choiceText = di->T("Yes"); x = 302.0f; yesColor = 0xFFFFFFFF; noColor = 0xFFFFFFFF; } else { choiceText = di->T("No"); x = 366.0f; yesColor = 0xFFFFFFFF; noColor = 0xFFFFFFFF; } PPGeMeasureText(&w, &h, 0, choiceText, FONT_SCALE); w = w / 2.0f + 5.5f; h /= 2.0f; float y2 = y + h2 + 4.0f; h2 += h + 4.0f; y = 132.0f - h; PPGeDrawRect(x - w, y2 - h, x + w, y2 + h, CalcFadedColor(0x40C0C0C0)); PPGeDrawText(di->T("Yes"), 303.0f, y2+2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000)); PPGeDrawText(di->T("Yes"), 302.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(yesColor)); PPGeDrawText(di->T("No"), 367.0f, y2+2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000)); PPGeDrawText(di->T("No"), 366.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(noColor)); if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) { yesnoChoice = 1; } else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) { yesnoChoice = 0; } } PPGeDrawTextWrapped(text.c_str(), 335.0f, y+2, WRAP_WIDTH, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000)); PPGeDrawTextWrapped(text.c_str(), 334.0f, y, WRAP_WIDTH, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF)); float sy = 122.0f - h2, ey = 150.0f + h2; PPGeDrawRect(202.0f, sy, 466.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawRect(202.0f, ey, 466.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF)); }
void PSPMsgDialog::DisplayYesNo() { PPGeDrawText("Yes", 200, 150, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(yesnoChoice == 1?0xFF0000FF:0xFFFFFFFF)); PPGeDrawText("No", 320, 150, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(yesnoChoice == 0?0xFF0000FF:0xFFFFFFFF)); if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) { yesnoChoice = 1; } else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) { yesnoChoice = 0; } }
void PSPMsgDialog::DisplayYesNo() { I18NCategory *d = GetI18NCategory("Dialog"); PPGeDrawText(d->T("Yes"), 200, 150, PPGE_ALIGN_LEFT, 0.55f, CalcFadedColor(yesnoChoice == 1?0xFF0000FF:0xFFFFFFFF)); PPGeDrawText(d->T("No"), 320, 150, PPGE_ALIGN_LEFT, 0.55f, CalcFadedColor(yesnoChoice == 0?0xFF0000FF:0xFFFFFFFF)); if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) { yesnoChoice = 1; } else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) { yesnoChoice = 0; } }
// Mission Screen Update logic void UpdateMissionScreen(void) { UpdateMusicStream(musMission); if (!writeEnd) WriteMissionText(); else { framesCounter++; if ((framesCounter%blinkFrames) == 0) { framesCounter = 0; blinkKeyWord = !blinkKeyWord; } } if (showButton) { if (IsKeyPressed(KEY_ENTER) || IsButtonPressed()) { if (!writeEnd) { writeEnd = true; writeKeyword = true; writeNumber = true; missionLenght = missionMaxLength; } else { finishScreen = true; showButton = false; } } } }
TBool CCommandParser::IsButtonJustPressed(TRemoteInfo& aInfo, TUint16 aButton) { TBool ret(EFalse); if( IsButtonPressed(aInfo,aButton) && !IsButtonHeld(aInfo,aButton)) ret = ETrue; return ret; }
void PSPSaveDialog::DisplayConfirmationYesNo(std::string text) { I18NCategory *d = GetI18NCategory("Dialog"); PPGeDrawRect(180, 105, 460, 106, CalcFadedColor(0xFFFFFFFF)); PPGeDrawRect(180, 160, 460, 161, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText(text.c_str(), 220, 110, PPGE_ALIGN_LEFT, 0.45f, 0xFFFFFFFF); PPGeDrawText(d->T("Yes"), 250, 140, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(yesnoChoice == 1?0xFF0000FF:0xFFFFFFFF)); PPGeDrawText(d->T("No"), 350, 140, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(yesnoChoice == 0?0xFF0000FF:0xFFFFFFFF)); if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) { yesnoChoice = 1; } else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) { yesnoChoice = 0; } }
bool InputObject::IsButtonReleased(unsigned int button) { if (button >= INPUTOBJECT_MOUSE_MAX) throw std::exception("Mouse button index out of bounds"); if (IsFocused()) return (IsPrevButtonPressed(button) && !IsButtonPressed(button)) != 0; return false; }
bool XboxController::IsButtonJustReleased(XboxButtons buttonType, WORD buttonState) { xboxButtonCurr[buttonType] = IsButtonPressed(buttonType, buttonState); // falling edge if (!xboxButtonCurr[buttonType] && xboxButtonPrev[buttonType]) { return true; } return false; }
//Function to set and control all physical buttons. void NTGVS1053::PhysicalButton(bool _isPlayingMusic){ if(_isPlayingMusic){ isButtonPlayStop = IsButtonPressed(isButtonPlayStop, PLAY_STOP, &Stop); } else if(!_isPlayingMusic){ isButtonPlayStop = IsButtonPressed(isButtonPlayStop, mp3IndexBufferCharArray, PLAY_STOP, &Play); } isButtonPauseUnpause = IsButtonPressed(isButtonPauseUnpause, vs1053.paused(), PAUSE_UNPAUSE, &PauseUnpause); isButtonNext = IsButtonPressed(isButtonNext, true, NEXT, &NextPrevious); isButtonPrevious = IsButtonPressed(isButtonPrevious, false, PREVIOUS, &NextPrevious); isButtonVolUp = IsButtonPressed(isButtonVolUp, VOL_UP, &VolUp); isButtonVolDown = IsButtonPressed(isButtonVolDown, VOL_DOWN, &VolDown); }
/** * * Checks if the buttons are pressed then sends them to the targets * * @author Jamie.Smith * @param _pMouseState the buffer in wich the mouse info is held * @return void * */ void CMouse::CheckMouseState(DIMOUSESTATE* _pMouseState) { for(int i = 0; i< 8; ++i) { m_bButtons[i] = IsButtonPressed(i, _pMouseState); if(m_bButtons[i] != m_bOldButtons[i]) { SendButtonStateToTargets(i, m_bButtons[i]); m_bOldButtons[i] = m_bButtons[i]; } } }
int PSPNetconfDialog::Update(int animSpeed) { UpdateButtons(); I18NCategory *d = GetI18NCategory("Dialog"); I18NCategory *err = GetI18NCategory("Error"); const float WRAP_WIDTH = 254.0f; const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : I_CIRCLE; const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE; if (status == SCE_UTILITY_STATUS_INITIALIZE) { status = SCE_UTILITY_STATUS_RUNNING; } else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_APNET || request.netAction == NETCONF_STATUS_APNET)) { UpdateFade(animSpeed); StartDraw(); DrawBanner(); PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363)); PPGeDrawTextWrapped(err->T("PPSSPPDoesNotSupportInternet", "PPSSPP currently does not support connecting to the Internet for DLC, PSN, or game updates."), 241, 132, WRAP_WIDTH, PPGE_ALIGN_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawImage(confirmBtnImage, 195, 250, 20, 20, 0, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText(d->T("OK"), 225, 252, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); if (IsButtonPressed(confirmBtn)) { StartFade(false); status = SCE_UTILITY_STATUS_FINISHED; // TODO: When the dialog is aborted, does it really set the result to this? // It seems to make Phantasy Star Portable 2 happy, so it should be okay for now. request.common.result = SCE_UTILITY_DIALOG_RESULT_ABORT; } } else if (status == SCE_UTILITY_STATUS_RUNNING && (request.netAction == NETCONF_CONNECT_ADHOC || request.netAction == NETCONF_CREATE_ADHOC || request.netAction == NETCONF_JOIN_ADHOC)) { if (request.NetconfData != NULL) { Shutdown(true); if (sceNetAdhocctlCreate(request.NetconfData->groupName) == 0) { status = SCE_UTILITY_STATUS_FINISHED; return 0; } return -1; } } else if (status == SCE_UTILITY_STATUS_FINISHED) { status = SCE_UTILITY_STATUS_SHUTDOWN; } EndDraw(); return 0; }
float XboxController::GetAnalogValue(XboxButtons buttonType, WORD buttonState) { switch (buttonType) { case LeftTrigger: return static_cast<float>(controllerState.Gamepad.bLeftTrigger) / 255; case RightTrigger: return static_cast<float>(controllerState.Gamepad.bRightTrigger) / 255; case LeftThumbLeft: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbLX); case LeftThumbRight: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbLX); case RightThumbLeft: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbRX); case RightThumbRight: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbRX); case LeftThumbUp: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbLY); case LeftThumbDown: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbLY); case RightThumbUp: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbRY); case RightThumbDown: return filterDeadzone(buttonType, controllerState.Gamepad.sThumbRY); default: return IsButtonPressed(buttonType, buttonState) ? 1.0f : 0.0f; } }
void TwoAxisValuatorModule::ModuleProcessSlider(InputManager::VirtualInputId SliderId, double MovedAmount) { if (IsButtonPressed(0)) { if (0 != m_Slide.GetSelectedObjectId()) { Wm5::Vector3d ToObject = m_Slide.GetSelectedObject().GetPosition() - Wm5::Vector3d(camera.x, camera.y, camera.z); ToObject.Normalize(); Wm5::Vector3d Horizontal(Wm5::Vector3d::ZERO), Vertical(Wm5::Vector3d::ZERO); Horizontal.X() += Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD); Horizontal.Y() += -Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD); Vertical.X() += Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD) * Wm5::Mathd::Sin(camera.rv * Wm5::Mathd::DEG_TO_RAD); Vertical.Y() += Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD) * Wm5::Mathd::Sin(camera.rv * Wm5::Mathd::DEG_TO_RAD); Vertical.Z() += -Wm5::Mathd::Cos(camera.rv * Wm5::Mathd::DEG_TO_RAD); Horizontal = Vertical.Cross(ToObject); Vertical = ToObject.Cross(Horizontal); if (0 == SliderId) { Wm5::Quaterniond RotateBy = Wm5::Quaterniond(Vertical, -0.008 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } else if (1 == SliderId) { Wm5::Quaterniond RotateBy = Wm5::Quaterniond(Horizontal, -0.008 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } else if (2 == SliderId) { Wm5::Vector3d ToObject = m_Slide.GetSelectedObject().GetPosition() - Wm5::Vector3d(camera.x, camera.y, camera.z); ToObject.Normalize(); Wm5::Quaterniond RotateBy = Wm5::Quaterniond(ToObject, 0.10 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } m_Slide.m_ModelRotatedByUser = true; } } }
//========================================================= //========================================================= void CAP_PlayerInfected::PostThink() { BaseClass::PostThink(); // Mientras estemos vivos if ( IsAlive() ) { // Estamos atacando // TODO: Creo que esto no es lo mejor if ( IsButtonPressed(IN_ATTACK) && gpGlobals->curtime >= m_iNextAttack ) { DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); m_iNextAttack = ATTACK_INTERVAL; } // ¡No sabemos nadar! // TODO: Animación de "ahogo" if ( GetWaterLevel() >= WL_Waist ) { SetBloodColor( DONT_BLEED ); TakeDamage( CTakeDamageInfo(this, this, GetMaxHealth(), DMG_GENERIC) ); } } }
void UnrealCameraModule::ModuleProcessSlider(InputManager::VirtualInputId SliderId, double MovedAmount) { if (IsButtonPressed(0) && !IsButtonPressed(1)) { if (1 == SliderId) camera.x += 0.012 * MovedAmount * Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD); if (1 == SliderId) camera.y += 0.012 * MovedAmount * Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD); if (0 == SliderId) camera.rh += 0.15 * MovedAmount; } else if (IsButtonPressed(0) && IsButtonPressed(1)) { if (0 == SliderId) camera.x += 0.012 * MovedAmount * Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD); if (0 == SliderId) camera.y += -0.012 * MovedAmount * Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD); if (1 == SliderId) camera.z += 0.012 * MovedAmount; } else if (!IsButtonPressed(0) && IsButtonPressed(1)) { if (0 == SliderId) camera.rh += 0.15 * MovedAmount; if (1 == SliderId) camera.rv += 0.15 * MovedAmount; } while (camera.rh < 0) camera.rh += 360; while (camera.rh >= 360) camera.rh -= 360; if (camera.rv > 90) camera.rv = 90; if (camera.rv < -90) camera.rv = -90; //printf("Cam rot h = %f, v = %f\n", camera.rh, camera.rv); }
//Main void LiftSystem::Update() { char myString[64]; //intakes if(IsButtonPressed(INTAKES_ON_BUTTON)) { TurnIntakesOn(); } if(IsButtonPressed(INTAKES_OFF_BUTTON)) { TurnIntakesOff(); } if(CheckInakeMotorsCurrentSpike()) TurnIntakesOff(); //forks // //manual control // //button input if(IsButtonPressed(BUT_FORKS_IN)) { forksIn = true; forksOut = false; //do not allow conflicting fork commands SetForkMotor(-FORK_MOTOR_SPEED_IN); } if(IsButtonPressed(BUT_FORKS_OUT)) { forksOut = true; forksIn = false; //do not allow conflicting fork commands SetForkMotor(FORK_MOTOR_SPEED_OUT); } if(IsButtonPressed(BUT_FORKS_STOP)) { forksOut = false; forksIn = false; //do not allow conflicting fork commands //motor set to stop below } if(!forksOut && !forksIn) { SetForkMotor(MOTOR_STOP); } // //limit switches if(GetForkLimitSwitchOuter()) { forksOut = false; } if(GetForkLimitSwitchInner()) { forksIn = false; } // //check for current spike if (CheckForkMotorCurrentSpike()) { SetForkMotor(MOTOR_STOP); forksIn= false; forksOut = false; } //lift // //prevent bouncing at the top if(GetLiftLimitSwitchHigh()) { atTop = true; // clock_gettime(CLOCK_REALTIME, &startTimeAtTop); } //test if sufficient duration from trip of upper limit switch has passed if(atTop) { /*clock_gettime(CLOCK_REALTIME, &curTime); timeDiffInSec = (curTime.tv_sec - startTimeAtTop.tv_sec) + SEC_IN_NANOSEC*(curTime.tv_nsec - startTimeAtTop.tv_nsec); if(timeDiffInSec > AT_TOP_LIFT_DUR)*/ curLiftPos = liftEncoder->GetDistance(); targetLiftPos = curLiftPos - HALF_INCH_OFFSET; controlLiftBack->Enable(); controlLiftBack->SetSetpoint(targetLiftPos); controlLiftFront->Enable(); controlLiftFront->SetSetpoint(targetLiftPos); atTop = false; atTopHold = true; } #if BUILD_VER == COMPETITION || BUILD_VER == PRACTICE liftDir = liftSysJoystick->GetY(); #else //parade bool liftDown, liftUp; liftDown = liftSysJoystick->GetRawButton(BUT_LIFT_DOWN); liftUp = liftSysJoystick->GetRawButton(BUT_LIFT_UP); if (liftDown) //if both buttons are pressed, lift goes down liftDir = -1; //val means pos(up) or neg(down), this val should be outside the deadband, because there is no deadband for parade else if (liftUp) liftDir = 1; if (!liftDown && !liftUp) liftDir = 0; #endif if(atTopHold) { if(liftDir < 0.0) //exit lift hold condition { controlLiftBack->Disable(); controlLiftFront->Disable(); atTopHold = false; } } else { //Filter deadband if ((liftDir > LIFT_DB_LOW) && (liftDir < LIFT_DB_HIGH)) //in the deadband so hold current position { if(!liftPidOn) { curLiftPos = liftEncoder->GetDistance(); controlLiftBack->Enable(); controlLiftBack->SetSetpoint(curLiftPos); controlLiftFront->Enable(); controlLiftFront->SetSetpoint(curLiftPos); liftPidOn = true; } /* sprintf(myString, "Dist: %f\n", liftEncoder->GetDistance()); SmartDashboard::PutString("DB/String 2", myString); sprintf(myString, "Dist to SP: %f\n", DistToSetpoint()); SmartDashboard::PutString("DB/String 3", myString); */ liftDir = ZERO_FL; } else //not in the deadband so do not hold current position { if(liftPidOn) { controlLiftBack->Disable(); controlLiftFront->Disable(); liftPidOn = false; } // sprintf(myString, "pid should be off"); // SmartDashboard::PutString("DB/String 0", myString); //manual control if ((liftDir > ZERO_FL) && !GetLiftLimitSwitchHigh() && !atTop) // move up #if BUILD_VER == COMPETITION || BUILD_VER == PRACTICE SetLiftMotor(0.3 + liftDir*0.5); //granular lift up speed - was 0.7 #else //parade SetLiftMotor(LIFT_MOTOR_SPEED_UP); //fixed lift up speed for parade #endif else if((liftDir < ZERO_FL) && !GetLiftLimitSwitchLow()) // move down SetLiftMotor(-LIFT_MOTOR_SPEED_DOWN); //fixed lift down speed else SetLiftMotor(MOTOR_STOP); //stop } }
int PSPSaveDialog::Update() { switch (status) { case SCE_UTILITY_STATUS_FINISHED: status = SCE_UTILITY_STATUS_SHUTDOWN; break; default: break; } if (status != SCE_UTILITY_STATUS_RUNNING) return SCE_ERROR_UTILITY_INVALID_STATUS; if (!param.GetPspParam()) { status = SCE_UTILITY_STATUS_SHUTDOWN; return 0; } // The struct may have been updated by the game. This happens in "Where Is My Heart?" // Check if it has changed, reload it. // TODO: Cut down on preloading? This rebuilds the list from scratch. int size = Memory::Read_U32(requestAddr); if (memcmp(Memory::GetPointer(requestAddr), &originalRequest, size) != 0) { memset(&request, 0, sizeof(request)); Memory::Memcpy(&request, requestAddr, size); Memory::Memcpy(&originalRequest, requestAddr, size); param.SetPspParam(&request); } buttons = __CtrlPeekButtons(); UpdateFade(); okButtonImg = I_CIRCLE; cancelButtonImg = I_CROSS; okButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CROSS; if (param.GetPspParam()->common.buttonSwap == 1) { okButtonImg = I_CROSS; cancelButtonImg = I_CIRCLE; okButtonFlag = CTRL_CROSS; cancelButtonFlag = CTRL_CIRCLE; } I18NCategory *d = GetI18NCategory("Dialog"); switch (display) { case DS_SAVE_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { // Save exist, ask user confirm if (param.GetFileInfo(currentSelectedSave).size > 0) { yesnoChoice = 0; display = DS_SAVE_CONFIRM_OVERWRITE; } else { display = DS_SAVE_SAVING; if (param.Save(param.GetPspParam(), GetSelectedSaveDirName())) { param.SetPspParam(param.GetPspParam()); // Optim : Just Update modified save display = DS_SAVE_DONE; } else display = DS_SAVE_LIST_CHOICE; // This will probably need error message ? } } EndDraw(); break; case DS_SAVE_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Confirm Save", "Do you want to save this data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_SAVE_SAVING; if (param.Save(param.GetPspParam(), GetSelectedSaveDirName())) { param.SetPspParam(param.GetPspParam()); // Optim : Just Update modified save display = DS_SAVE_DONE; } else { // TODO: This should probably show an error message? StartFade(false); } } EndDraw(); break; case DS_SAVE_CONFIRM_OVERWRITE: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Confirm Overwrite","Do you want to overwrite the data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { if (param.GetPspParam()->mode != SCE_UTILITY_SAVEDATA_TYPE_SAVE) display = DS_SAVE_LIST_CHOICE; else { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } } else if (IsButtonPressed(okButtonFlag)) { display = DS_SAVE_SAVING; if (param.Save(param.GetPspParam(), GetSelectedSaveDirName())) { param.SetPspParam(param.GetPspParam()); // Optim : Just Update modified save display = DS_SAVE_DONE; } else { // TODO: This should probably show an error message? if (param.GetPspParam()->mode != SCE_UTILITY_SAVEDATA_TYPE_SAVE) display = DS_SAVE_LIST_CHOICE; else StartFade(false); } } EndDraw(); break; case DS_SAVE_SAVING: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Saving","Saving\nPlease Wait...")); DisplayBanner(DB_SAVE); EndDraw(); break; case DS_SAVE_DONE: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Save completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS; // Set the save to use for autosave and autoload param.SetSelectedSave(param.GetFileInfo(currentSelectedSave).idx); StartFade(false); } EndDraw(); break; case DS_LOAD_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_LOAD_LOADING; if (param.Load(param.GetPspParam(), GetSelectedSaveDirName(), currentSelectedSave)) display = DS_LOAD_DONE; } EndDraw(); break; case DS_LOAD_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("ConfirmLoad", "Load this data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_LOAD_LOADING; if (param.Load(param.GetPspParam(), GetSelectedSaveDirName(), currentSelectedSave)) display = DS_LOAD_DONE; else { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } } EndDraw(); break; case DS_LOAD_LOADING: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Loading","Loading\nPlease Wait...")); DisplayBanner(DB_LOAD); EndDraw(); break; case DS_LOAD_DONE: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("Load completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS; // Set the save to use for autosave and autoload param.SetSelectedSave(param.GetFileInfo(currentSelectedSave).idx); StartFade(false); } EndDraw(); break; case DS_LOAD_NODATA: StartDraw(); DisplayMessage(d->T("There is no data")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA; StartFade(false); } EndDraw(); break; case DS_DELETE_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { yesnoChoice = 0; display = DS_DELETE_CONFIRM; } EndDraw(); break; case DS_DELETE_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(d->T("DeleteConfirm", "This save data will be deleted.\nAre you sure you want to continue?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) display = DS_DELETE_LIST_CHOICE; else if (IsButtonPressed(okButtonFlag)) { if (yesnoChoice == 0) display = DS_DELETE_LIST_CHOICE; else { display = DS_DELETE_DELETING; if (param.Delete(param.GetPspParam(),currentSelectedSave)) { param.SetPspParam(param.GetPspParam()); // Optim : Just Update modified save display = DS_DELETE_DONE; } else display = DS_DELETE_LIST_CHOICE; // This will probably need error message ? } } EndDraw(); break; case DS_DELETE_DELETING: StartDraw(); DisplayMessage(d->T("Deleting","Deleting\nPlease Wait...")); DisplayBanner(DB_DELETE); EndDraw(); break; case DS_DELETE_DONE: StartDraw(); DisplayMessage(d->T("Delete completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { if (param.GetFilenameCount() == 0) display = DS_DELETE_NODATA; else display = DS_DELETE_LIST_CHOICE; } EndDraw(); break; case DS_DELETE_NODATA: StartDraw(); DisplayMessage(d->T("There is no data")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA; StartFade(false); } EndDraw(); break; case DS_NONE: // For action which display nothing { switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: // Only load and exit case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: if (param.Load(param.GetPspParam(), GetSelectedSaveDirName(), currentSelectedSave)) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_SAVE: // Only save and exit case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE: if (param.Save(param.GetPspParam(), GetSelectedSaveDirName())) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_SIZES: param.GetPspParam()->common.result = param.GetSizes(param.GetPspParam()); status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_LIST: param.GetList(param.GetPspParam()); param.GetPspParam()->common.result = 0; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_FILES: param.GetPspParam()->common.result = param.GetFilesList(param.GetPspParam()); status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_GETSIZE: { bool result = param.GetSize(param.GetPspParam()); // TODO: According to JPCSP, should test/verify this part but seems edge casey. if (MemoryStick_State() != PSP_MEMORYSTICK_STATE_DRIVER_READY) param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_MEMSTICK; else if (result) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; status = SCE_UTILITY_STATUS_FINISHED; } break; case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA: // TODO: This should probably actually delete something. // For now, always say it couldn't be deleted. WARN_LOG(SCEUTILITY, "FAKE sceUtilitySavedata DELETEDATA: %s", param.GetPspParam()->saveName); param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_STATUS; status = SCE_UTILITY_STATUS_FINISHED; break; //case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE: case SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE: if (param.Delete(param.GetPspParam(), param.GetSelectedSave())) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA; status = SCE_UTILITY_STATUS_FINISHED; break; // TODO: Should reset the directory's other files. case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATA: case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE: if (param.Save(param.GetPspParam(), GetSelectedSaveDirName(), param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE)) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA: case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE: if (param.Save(param.GetPspParam(), GetSelectedSaveDirName(), param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE)) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_READDATA: case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE: if (param.Load(param.GetPspParam(), GetSelectedSaveDirName(), currentSelectedSave, param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE)) param.GetPspParam()->common.result = 0; else param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; // not sure if correct code status = SCE_UTILITY_STATUS_FINISHED; break; default: status = SCE_UTILITY_STATUS_FINISHED; break; } } break; default: status = SCE_UTILITY_STATUS_FINISHED; break; } lastButtons = buttons; if (status == SCE_UTILITY_STATUS_FINISHED) Memory::Memcpy(requestAddr, &request, request.common.size); return 0; }
int PSPMsgDialog::Update() { if (status != SCE_UTILITY_STATUS_RUNNING) { return 0; } if ((flag & DS_ERROR)) { status = SCE_UTILITY_STATUS_FINISHED; } else { UpdateFade(); buttons = __CtrlPeekButtons(); okButtonImg = I_CIRCLE; cancelButtonImg = I_CROSS; okButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CROSS; if (messageDialog.common.buttonSwap == 1) { okButtonImg = I_CROSS; cancelButtonImg = I_CIRCLE; okButtonFlag = CTRL_CROSS; cancelButtonFlag = CTRL_CIRCLE; } StartDraw(); // white -> RGB(168,173,189), black -> RGB(129,134,150) // (255 - a) + (x * a / 255) = 173, x * a / 255 = 134 // a = 255 - w + b = 158, x = b * 255 / a = ? // but is not drawn using x * a + y * (255 - a) here? //PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x9EF2D8D0)); PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0xC0C8B2AC)); if ((flag & DS_MSG) || (flag & DS_ERRORMSG)) DisplayMessage(msgText, (flag & DS_YESNO) != 0); if (flag & (DS_OK | DS_VALIDBUTTON)) DisplayButtons(DS_BUTTON_OK); if (flag & DS_CANCELBUTTON) DisplayButtons(DS_BUTTON_CANCEL); if (IsButtonPressed(cancelButtonFlag) && (flag & DS_CANCELBUTTON)) { if(messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V3 || ((messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V2) && (flag & DS_YESNO))) messageDialog.buttonPressed = 3; else messageDialog.buttonPressed = 0; StartFade(false); } else if (IsButtonPressed(okButtonFlag) && (flag & DS_VALIDBUTTON)) { if (yesnoChoice == 0) { messageDialog.buttonPressed = 2; } else { messageDialog.buttonPressed = 1; } StartFade(false); } EndDraw(); lastButtons = buttons; } Memory::Memcpy(messageDialogAddr,&messageDialog,messageDialog.common.size); return 0; }
void CInputManager::_Test() { short stickLeft = GetLeftStickX(0); USHORT left = 0; USHORT right = 0; if (stickLeft < 0) left = -stickLeft * 2; else right = stickLeft * 2; SetMotorSpeed(0, left, right); if (IsButtonDown(0, Buttons::A)) DebugManager->Debug(L"A", L"A"); if (IsButtonDown(0, Buttons::B)) DebugManager->Debug(L"B", L"B"); if (IsButtonDown(0, Buttons::Back)) DebugManager->Debug(L"Back", L"Back"); if (IsButtonDown(0, Buttons::Down)) DebugManager->Debug(L"Down", L"Down"); if (IsButtonDown(0, Buttons::LB)) DebugManager->Debug(L"LB", L"LB"); if (IsButtonDown(0, Buttons::Left)) DebugManager->Debug(L"Left", L"Left"); if (IsButtonDown(0, Buttons::LeftStick)) DebugManager->Debug(L"LeftStick", L"LeftStick"); if (IsButtonDown(0, Buttons::RB)) DebugManager->Debug(L"RB", L"RB"); if (IsButtonDown(0, Buttons::Right)) DebugManager->Debug(L"Right", L"Right"); if (IsButtonDown(0, Buttons::RightStick)) DebugManager->Debug(L"RightStick", L"RightStick"); if (IsButtonDown(0, Buttons::Start)) DebugManager->Debug(L"Start", L"Start"); if (IsButtonDown(0, Buttons::Up)) DebugManager->Debug(L"Up", L"Up"); if (IsButtonDown(0, Buttons::X)) DebugManager->Debug(L"X", L"X"); if (IsButtonDown(0, Buttons::Y)) DebugManager->Debug(L"Y", L"Y"); DebugManager->Debug(GetLeftTrigger(0), L"left trigger"); DebugManager->Debug(GetRightTrigger(0), L"right trigger"); DebugManager->Debug(GetLeftStickX(0), L"left stick x"); DebugManager->Debug(GetLeftStickY(0), L"left stick y"); DebugManager->Debug(GetRightStickX(0), L"right stick x"); DebugManager->Debug(GetRightStickY(0), L"right stick y"); DebugManager->Debug(GetLeftTriggerDelta(0), L"left trigger Delta"); DebugManager->Debug(GetRightTriggerDelta(0), L"right trigger Delta"); DebugManager->Debug(GetLeftStickXDelta(0), L"left stick x Delta"); DebugManager->Debug(GetLeftStickYDelta(0), L"left stick y Delta"); DebugManager->Debug(GetRightStickXDelta(0), L"right stick x Delta"); DebugManager->Debug(GetRightStickYDelta(0), L"right stick y Delta"); if (IsButtonPressed(0, Buttons::A)) printf("A pressed\n"); if (IsButtonPressed(0, Buttons::B)) printf("B pressed\n"); if (IsButtonPressed(0, Buttons::Back)) printf("Back pressed\n"); if (IsButtonPressed(0, Buttons::Down)) printf("Down pressed\n"); if (IsButtonPressed(0, Buttons::LB)) printf("LB pressed\n"); if (IsButtonPressed(0, Buttons::Left)) printf("Left pressed\n"); if (IsButtonPressed(0, Buttons::LeftStick)) printf("LeftStick pressed\n"); if (IsButtonPressed(0, Buttons::RB)) printf("RB pressed\n"); if (IsButtonPressed(0, Buttons::Right)) printf("Right pressed\n"); if (IsButtonPressed(0, Buttons::RightStick)) printf("RightStick pressed\n"); if (IsButtonPressed(0, Buttons::Start)) printf("Start pressed\n"); if (IsButtonPressed(0, Buttons::Up)) printf("Up pressed\n"); if (IsButtonPressed(0, Buttons::X)) printf("X pressed\n"); if (IsButtonPressed(0, Buttons::Y)) printf("Y pressed\n"); if (IsButtonReleased(0, Buttons::A)) printf("A released\n"); if (IsButtonReleased(0, Buttons::B)) printf("B released\n"); if (IsButtonReleased(0, Buttons::Back)) printf("Back released\n"); if (IsButtonReleased(0, Buttons::Down)) printf("Down released\n"); if (IsButtonReleased(0, Buttons::LB)) printf("LB released\n"); if (IsButtonReleased(0, Buttons::Left)) printf("Left released\n"); if (IsButtonReleased(0, Buttons::LeftStick)) printf("LeftStick released\n"); if (IsButtonReleased(0, Buttons::RB)) printf("RB released\n"); if (IsButtonReleased(0, Buttons::Right)) printf("Right released\n"); if (IsButtonReleased(0, Buttons::RightStick)) printf("RightStick released\n"); if (IsButtonReleased(0, Buttons::Start)) printf("Start released\n"); if (IsButtonReleased(0, Buttons::Up)) printf("Up released\n"); if (IsButtonReleased(0, Buttons::X)) printf("X released\n"); if (IsButtonReleased(0, Buttons::Y)) printf("Y released\n"); if (GamepadConnected()) printf("gamepad connected\n"); if (GamepadDisconnected()) printf("gamepad disconnected\n"); UINT connectedGamepads = 0; for (UINT i = 0; i < XUSER_MAX_COUNT; i++) if (IsGamepadActive(i)) connectedGamepads++; DebugManager->Debug((int)connectedGamepads, L"Connected gamepads"); }
int PSPMsgDialog::Update() { if (status != SCE_UTILITY_STATUS_RUNNING) { return 0; } if((flag & DS_ERROR)) { status = SCE_UTILITY_STATUS_FINISHED; } else { UpdateFade(); buttons = __CtrlPeekButtons(); okButtonImg = I_CIRCLE; cancelButtonImg = I_CROSS; okButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CROSS; if(messageDialog.common.buttonSwap == 1) { okButtonImg = I_CROSS; cancelButtonImg = I_CIRCLE; okButtonFlag = CTRL_CROSS; cancelButtonFlag = CTRL_CIRCLE; } StartDraw(); if((flag & DS_MSG) || (flag & DS_ERRORMSG)) DisplayMessage(msgText); if(flag & DS_YESNO) DisplayYesNo(); if(flag & DS_OK) DisplayOk(); if(flag & DS_VALIDBUTTON) DisplayEnter(); if(flag & DS_CANCELBUTTON) DisplayBack(); if (IsButtonPressed(cancelButtonFlag) && (flag & DS_CANCELBUTTON)) { if(messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V3 || ((messageDialog.common.size == SCE_UTILITY_MSGDIALOG_SIZE_V2) && (flag & DS_YESNO))) messageDialog.buttonPressed = 3; else messageDialog.buttonPressed = 0; StartFade(false); } else if(IsButtonPressed(okButtonFlag) && (flag & DS_VALIDBUTTON)) { if(yesnoChoice == 0) { messageDialog.buttonPressed = 2; } else { messageDialog.buttonPressed = 1; } StartFade(false); } EndDraw(); lastButtons = buttons; } Memory::Memcpy(messageDialogAddr,&messageDialog,messageDialog.common.size); return 0; }
//Main void LiftSystem::Update() { char myString[64]; //for debugging //intakes if(IsButtonPressed(INTAKES_IN_BUTTON)) IntakesIn(); if(IsButtonPressed(INTAKES_OUT_BUTTON)) IntakesOut(); if(IsButtonPressed(INTAKES_OFF_BUTTON) || CheckInakeMotorsCurrentSpike()) IntakesOff(); //lift // //prevent bouncing at the top if(GetLiftLimitSwitchHigh()) atTop = true; //move the lift away from the top if(atTop) { sprintf(myString, "lift stopped at ul\n"); SmartDashboard::PutString("DB/String 0", myString); curLiftPos = liftEncoder->GetDistance(); targetLiftPos = curLiftPos - HALF_INCH_OFFSET; controlLiftBack->Enable(); controlLiftBack->SetSetpoint(targetLiftPos); controlLiftFront->Enable(); controlLiftFront->SetSetpoint(targetLiftPos); atTop = false; atTopHold = true; } liftDir = liftSysJoystick->GetY(); if(atTopHold) //require a lift down command from the lift joystick before allowing the lift to move out of hold { if(liftDir < 0.0) //exit lift hold condition { controlLiftBack->Disable(); controlLiftFront->Disable(); atTopHold = false; } } else { //Filter deadband if ((liftDir > LIFT_DB_LOW) && (liftDir < LIFT_DB_HIGH)) //in the deadband so hold current position { if(!liftPidOn) { curLiftPos = liftEncoder->GetDistance(); controlLiftBack->Enable(); controlLiftBack->SetSetpoint(curLiftPos); controlLiftFront->Enable(); controlLiftFront->SetSetpoint(curLiftPos); liftPidOn = true; } } else //not in the deadband so do not hold current position { if(liftPidOn) { controlLiftBack->Disable(); controlLiftFront->Disable(); liftPidOn = false; } //manual control if ((liftDir > ZERO_FL) && !GetLiftLimitSwitchHigh() && !atTop) // move up { SetLiftMotor(LIFT_MOTOR_REV_STATE*LIFT_MOTOR_SPEED_UP); sprintf(myString, "lift moving up\n"); SmartDashboard::PutString("DB/String 0", myString); } else if((liftDir < ZERO_FL) && !GetLiftLimitSwitchLow()) // move down { SetLiftMotor(LIFT_MOTOR_REV_STATE*LIFT_MOTOR_SPEED_DOWN); //fixed lift down speed sprintf(myString, "lift moving down\n"); SmartDashboard::PutString("DB/String 0", myString); } else { SetLiftMotor(MOTOR_STOP); //stop sprintf(myString, "lift stopped at ll\n"); SmartDashboard::PutString("DB/String 0", myString); } } } }
int PSPSaveDialog::Update(int animSpeed) { if (GetStatus() != SCE_UTILITY_STATUS_RUNNING) return SCE_ERROR_UTILITY_INVALID_STATUS; if (!param.GetPspParam()) { ChangeStatusShutdown(SAVEDATA_SHUTDOWN_DELAY_US); return 0; } if (pendingStatus != SCE_UTILITY_STATUS_RUNNING) { // We're actually done, we're just waiting to tell the game that. return 0; } // The struct may have been updated by the game. This happens in "Where Is My Heart?" // Check if it has changed, reload it. // TODO: Cut down on preloading? This rebuilds the list from scratch. int size = Memory::Read_U32(requestAddr); if (memcmp(Memory::GetPointer(requestAddr), &originalRequest, size) != 0) { memset(&request, 0, sizeof(request)); Memory::Memcpy(&request, requestAddr, size); Memory::Memcpy(&originalRequest, requestAddr, size); lock_guard guard(paramLock); param.SetPspParam(&request); } UpdateButtons(); UpdateFade(animSpeed); okButtonImg = I_CIRCLE; cancelButtonImg = I_CROSS; okButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CROSS; if (param.GetPspParam()->common.buttonSwap == 1) { okButtonImg = I_CROSS; cancelButtonImg = I_CIRCLE; okButtonFlag = CTRL_CROSS; cancelButtonFlag = CTRL_CIRCLE; } I18NCategory *di = GetI18NCategory("Dialog"); switch (display) { case DS_SAVE_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { // Save exist, ask user confirm if (param.GetFileInfo(currentSelectedSave).size > 0) { yesnoChoice = 0; display = DS_SAVE_CONFIRM_OVERWRITE; } else { display = DS_SAVE_SAVING; StartIOThread(); } } EndDraw(); break; case DS_SAVE_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Confirm Save", "Do you want to save this data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_SAVE_SAVING; StartIOThread(); } EndDraw(); break; case DS_SAVE_CONFIRM_OVERWRITE: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Confirm Overwrite","Do you want to overwrite the data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { if (param.GetPspParam()->mode != SCE_UTILITY_SAVEDATA_TYPE_SAVE) display = DS_SAVE_LIST_CHOICE; else { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } } else if (IsButtonPressed(okButtonFlag)) { display = DS_SAVE_SAVING; StartIOThread(); } EndDraw(); break; case DS_SAVE_SAVING: if (ioThreadStatus != SAVEIO_PENDING) { JoinIOThread(); } StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Saving","Saving\nPlease Wait...")); DisplayBanner(DB_SAVE); EndDraw(); break; case DS_SAVE_FAILED: JoinIOThread(); StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("SavingFailed", "Unable to save data.")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag)) { // Go back to the list so they can try again. if (param.GetPspParam()->mode != SCE_UTILITY_SAVEDATA_TYPE_SAVE) { display = DS_SAVE_LIST_CHOICE; } else { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } } EndDraw(); break; case DS_SAVE_DONE: if (ioThread) { JoinIOThread(); param.SetPspParam(param.GetPspParam()); } StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Save completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS; // Set the save to use for autosave and autoload param.SetSelectedSave(param.GetFileInfo(currentSelectedSave).idx); StartFade(false); } EndDraw(); break; case DS_LOAD_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_LOAD_LOADING; StartIOThread(); } EndDraw(); break; case DS_LOAD_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("ConfirmLoad", "Load this data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag) || (IsButtonPressed(okButtonFlag) && yesnoChoice == 0)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { display = DS_LOAD_LOADING; StartIOThread(); } EndDraw(); break; case DS_LOAD_LOADING: if (ioThreadStatus != SAVEIO_PENDING) { JoinIOThread(); } StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Loading","Loading\nPlease Wait...")); DisplayBanner(DB_LOAD); EndDraw(); break; case DS_LOAD_FAILED: JoinIOThread(); StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("LoadingFailed", "Unable to load data.")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { // Go back to the list so they can try again. if (param.GetPspParam()->mode != SCE_UTILITY_SAVEDATA_TYPE_LOAD) { display = DS_LOAD_LIST_CHOICE; } else { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } } EndDraw(); break; case DS_LOAD_DONE: JoinIOThread(); StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("Load completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); // Allow OK to be pressed as well to confirm the save. // The PSP only allows cancel, but that's generally not great UX. // Allowing this here makes it quicker for most users to get into the actual game. if (IsButtonPressed(cancelButtonFlag) || IsButtonPressed(okButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS; // Set the save to use for autosave and autoload param.SetSelectedSave(param.GetFileInfo(currentSelectedSave).idx); StartFade(false); } EndDraw(); break; case DS_LOAD_NODATA: StartDraw(); DisplayMessage(di->T("There is no data")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_LOAD); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA; StartFade(false); } EndDraw(); break; case DS_DELETE_LIST_CHOICE: StartDraw(); DisplaySaveList(); DisplaySaveDataInfo1(); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_CANCEL; StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { yesnoChoice = 0; display = DS_DELETE_CONFIRM; } EndDraw(); break; case DS_DELETE_CONFIRM: StartDraw(); DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayMessage(di->T("DeleteConfirm", "This save data will be deleted.\nAre you sure you want to continue?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) display = DS_DELETE_LIST_CHOICE; else if (IsButtonPressed(okButtonFlag)) { if (yesnoChoice == 0) display = DS_DELETE_LIST_CHOICE; else { display = DS_DELETE_DELETING; StartIOThread(); } } EndDraw(); break; case DS_DELETE_DELETING: if (ioThreadStatus != SAVEIO_PENDING) { JoinIOThread(); } StartDraw(); DisplayMessage(di->T("Deleting","Deleting\nPlease Wait...")); DisplayBanner(DB_DELETE); EndDraw(); break; case DS_DELETE_FAILED: JoinIOThread(); StartDraw(); DisplayMessage(di->T("DeleteFailed", "Unable to delete data.")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { display = DS_DELETE_LIST_CHOICE; } EndDraw(); break; case DS_DELETE_DONE: if (ioThread) { JoinIOThread(); param.SetPspParam(param.GetPspParam()); } StartDraw(); DisplayMessage(di->T("Delete completed")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { if (param.GetFilenameCount() == 0) display = DS_DELETE_NODATA; else display = DS_DELETE_LIST_CHOICE; } EndDraw(); break; case DS_DELETE_NODATA: StartDraw(); DisplayMessage(di->T("There is no data")); DisplayButtons(DS_BUTTON_CANCEL); DisplayBanner(DB_DELETE); if (IsButtonPressed(cancelButtonFlag)) { param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA; StartFade(false); } EndDraw(); break; case DS_NONE: // For action which display nothing switch (ioThreadStatus) { case SAVEIO_NONE: StartIOThread(); break; case SAVEIO_PENDING: case SAVEIO_DONE: // To make sure there aren't any timing variations, we sync the next frame. JoinIOThread(); ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0); break; } break; default: ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0); break; } if (status == SCE_UTILITY_STATUS_FINISHED || pendingStatus == SCE_UTILITY_STATUS_FINISHED) Memory::Memcpy(requestAddr, &request, request.common.size); return 0; }
int main(void) { unsigned char tmp; wdt_disable(); /* Disable watchdog if enabled by bootloader/fuses */ power_usb_disable() ; power_usart1_disable(); power_spi_disable(); Buttons_Init(); LEDs_Init(); clock_prescale_set(clock_div_1); // run at x-tal frequency 16Mhz eeprom_read_block( &EE_data,0,sizeof(EE_data)); if (EE_data.bright_level == 0xff && EE_data.dim_level == 0xff) { EE_data.bright_level = LED_BRIGHT; EE_data.dim_level = LED_DIMM; eeprom_write_block(&EE_data,0,sizeof(EE_data)); eeprom_busy_wait(); } OCR0A = EE_data.bright_level; OCR0B = EE_data.dim_level; // Timer 0 setup for simple count mode, used as timebase LED PWM TCCR0A = 0; // simple count more TCCR0B = 4; // system Clock 16Mhz/256 = 16us per counter tick //TCCR0B = 3; // system Clock 16Mhz/64 = 4us per counter tick //TCCR0B = 5; // system Clock 16Mhz/1024 = 64us per counter tick //TCCR0B = 2; // system Clock 1Mhz/8 = 8us per counter tick TIMSK0 = 0x7; // Enable OverFLow , OCR0A and OCR0B interrupt enables MCUSR =0; //MCU status register clear // Timer 1 setup for fast PWM mode for servo pulse generation 1 to 2ms TIMSK1 = 0x2; // Enable OCR1A interrupt TCCR1A = 0x00; // No pin toggles on compare -- CTC (normal) mode TCCR1B = 0x0D; // CTC mode, F_CPU 16mhz/1024 clock ( 64us) //TCCR1B = 0x0B; // CTC mode, F_CPU 1Mhz/64 clock ( 64us) OCR1A = 15625-1; // counting 15625 counts of 64 us == 1 second sei(); while(1) // for ever { if (IsButtonPressed(BUTTON1) ) { // de-bounce -- 10 consecutive reads of switch open for (tmp =0; tmp<=10; tmp++) { _delay_ms(2); if (IsButtonPressed(BUTTON1)) tmp = 0; } if ( mode < 3) mode++; else { eeprom_write_block(&EE_data,0,sizeof(EE_data)); eeprom_busy_wait(); mode = 0; // enter running mode } } if (IsButtonPressed(BUTTON2) ) // increases Minutes and decrease brightness { // de-bounce -- 10 consecutive reads of switch open for (tmp =0; tmp<=10; tmp++) { _delay_ms(2); if (IsButtonPressed(BUTTON2)) tmp = 0; } switch (mode) { case 1: Minutes++; ripple(); break; case 2: if (OCR0B < 0xff ) // dim level { OCR0B++; EE_data.dim_level = OCR0B; } break; case 3: // bright level if (OCR0A < OCR0B-10 ) // make sure that bright is at least 10 counts brighter than dim { OCR0A +=10; // step in increments of 10 EE_data.bright_level =OCR0A; } break; } } if (IsButtonPressed(BUTTON3) ) // Increases Hours and increase brightness { // de-bounce -- 10 consecutive reads of switch open for (tmp =0; tmp<=10; tmp++) { _delay_ms(2); if (IsButtonPressed(BUTTON3)) tmp = 0; } switch (mode) { case 1: Hours++; ripple(); break; case 2: if (OCR0B > OCR0A+10) // dim level { OCR0B--; EE_data.dim_level = OCR0B; } break; case 3: // bright level if (OCR0A > 20) { OCR0A -=10; //step in increments of 10 EE_data.bright_level =OCR0A; } break; } } } // end of for-ever }
int PSPOskDialog::Update() { buttons = __CtrlReadLatch(); int selectedRow = selectedChar / KEYSPERROW; int selectedExtra = selectedChar % KEYSPERROW; u32 limit = oskData.outtextlimit; // TODO: Test more thoroughly. Encountered a game where this was 0. if (limit <= 0) limit = 16; if (status == SCE_UTILITY_STATUS_INITIALIZE) { status = SCE_UTILITY_STATUS_RUNNING; } else if (status == SCE_UTILITY_STATUS_RUNNING) { UpdateFade(); StartDraw(); RenderKeyboard(); PPGeDrawImage(I_CROSS, 100, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText("Select", 130, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawImage(I_CIRCLE, 200, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText("Delete", 230, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawImage(I_BUTTON, 290, 220, 50, 20, 0, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText("Start", 305, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText("Finish", 350, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); if (IsButtonPressed(CTRL_UP)) { selectedChar -= KEYSPERROW; } else if (IsButtonPressed(CTRL_DOWN)) { selectedChar += KEYSPERROW; } else if (IsButtonPressed(CTRL_LEFT)) { selectedChar--; if (((selectedChar + KEYSPERROW) % KEYSPERROW) == KEYSPERROW - 1) selectedChar += KEYSPERROW; } else if (IsButtonPressed(CTRL_RIGHT)) { selectedChar++; if ((selectedChar % KEYSPERROW) == 0) selectedChar -= KEYSPERROW; } selectedChar = (selectedChar + NUMBEROFVALIDCHARS) % NUMBEROFVALIDCHARS; if (IsButtonPressed(CTRL_CROSS)) { if (inputChars.size() < limit) inputChars += oskKeys[selectedRow][selectedExtra]; } else if (IsButtonPressed(CTRL_CIRCLE)) { if (inputChars.size() > 0) inputChars.resize(inputChars.size() - 1); } else if (IsButtonPressed(CTRL_START)) { StartFade(false); } EndDraw(); } else if (status == SCE_UTILITY_STATUS_FINISHED) { status = SCE_UTILITY_STATUS_SHUTDOWN; } for (u32 i = 0; i < limit; ++i) { u16 value = 0; if (i < inputChars.size()) value = 0x0000 ^ inputChars[i]; Memory::Write_U16(value, oskData.outtextPtr + (2 * i)); } oskData.outtextlength = inputChars.size(); oskParams.base.result= 0; oskData.result = PSP_UTILITY_OSK_RESULT_CHANGED; Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData); Memory::WriteStruct(oskParamsAddr, &oskParams); return 0; }
void LiftSystem::Update() { if(liftFailure) { //everything on the lift was already turned off when the liftFailure was detected return; } if(!liftInitDone) //initialize the position of the lift //lift pid is not on until lift initialization is complete { SetLiftMotor(LIFT_MOTOR_REV_STATE*LIFT_MOTOR_SPEED_DOWN); //fixed lift down speed //reached the bottom if(GetLiftLimitSwitchLow()) { SetLiftMotor(MOTOR_STOP); //stop liftRefPos = (liftEncoder->GetDistance()); liftInitDone = true; //enable lift pid and go to the low position setLiftStateLow(); controlLiftBack->Enable(); controlLiftFront->Enable(); } } else //lift position has been initialized { //intakes if (IsButtonPressed(INTAKES_IN_BUTTON) && liftStateGoal==HIGH) IntakesIn(); if(IsButtonPressed(INTAKES_OUT_BUTTON)) IntakesOut(); if(IsButtonPressed(INTAKES_OFF_BUTTON) || CheckIntakeMotorsCurrentSpike()) IntakesOff(); //lift if(GetLiftLimitSwitchHigh()) //major failure { liftFailure = true; //turn everything on the lift off controlLiftBack->Disable(); controlLiftFront->Disable(); SetLiftMotor(MOTOR_STOP); IntakesOff(); return; } else //no major failure { if(!pickupInProgress) //pickup not in progress { if(IsButtonPressed(LIFT_LOW_POS_BUTTON) && !(liftStateGoal == STEP)) //do not allow lift motion down if the current liftStateGoal is the STEP setLiftStateLow(); else if(IsButtonPressed(LIFT_STEP_POS_BUTTON)) setLiftStateStep(); else if(IsButtonPressed(LIFT_HIGH_POS_BUTTON)) setLiftStateHigh(); else if(IsButtonPressed(LIFT_PICKUP_BUTTON) && (liftStateGoal == HIGH)) //do not allow lift motion down if the current liftStateGoal is the STEP setLiftStatePickup(); } else //pickup in progress { if(liftStateGoal == LOW && (LiftOnTarget(controlLiftBack, liftEncoder) || LiftOnTarget(controlLiftFront, liftEncoder))) setLiftStateHigh(); else if(liftStateGoal == HIGH && (LiftOnTarget(controlLiftBack, liftEncoder) || LiftOnTarget(controlLiftFront, liftEncoder))) pickupInProgress = false; } //end pickup check } //end initial lift failure identification check } //end lift initialization check } //end Update()