PopSessionPowerCommand::PopSessionPowerCommand(PopSession& session, const std::string& reason) : PopSessionCommand(session), m_stayAwakeReason(reason), m_powerManager(session.GetPowerManager()) { PowerUp(); }
int CEnumerator::OnAddUnifyingReceiver(DEVINST dnDevInst, HANDLE HidDeviceObject, const wchar_t *DevicePath, PHIDD_ATTRIBUTES Attributes, int PreparsedData, HIDP_CAPS *Capabilities, int a8) { if(PowerUp(0, dnDevInst)) { return 0; } CHidDevice* pHidDevice = new CHidDevice(dnDevInst); if(!pHidDevice) { return 0; } if(CEnumerator::LinkRawDeviceHandleWithDevice(pThis, (CReceiver *)pHidDevice, 0xFFu)) { char ReportID = GetReportID(PreparsedData, Capabilities); HDEVNOTIFY hDevNotify = GetRegisteredDevNotify(HidDeviceObject); if (pHidDevice->Setup(HidDeviceObject, ReportID, (int)Capabilities, Attributes, DevicePath, hDevNotify) ) { pHidDevice->GenerateDeviceArrivalEvent(); if(m_ModelID) { pThis->field_EC = CDevice::GetRawDeviceHandle((CReceiver *)pHidDevice); v11 = (DFU *)DFUController::GetSingleton(); DFUController::UnknownY(v11, 6); } } return 1; } if(pHidDevice) { delete pHidDevice; } return 0; }
void AUETutorialCharacter::CollectBatteries() { UE_LOG(LogTemp, Log, TEXT("TESTING LOG")); float BatteryPower = 0.0f; AUETutorialGameMode * GameMode = Cast<AUETutorialGameMode>(UGameplayStatics::GetGameMode(this)); if (GameMode->GetCurrentState() == EUETutorialGameModeState::EPlaying) { TArray<AActor*> CollectedActors; CollectionSphere->GetOverlappingActors(CollectedActors); for (int32 i = 0; i < CollectedActors.Num(); ++i) { ABatteryPickup * const TestBattery = Cast<ABatteryPickup>(CollectedActors[i]); if (TestBattery && !TestBattery->IsPendingKill() && TestBattery->bIsActive) { BatteryPower = BatteryPower + TestBattery->PowerLevel; TestBattery->OnPickedUp(); TestBattery->bIsActive = false; } } if (BatteryPower > 0.f) { PowerUp(BatteryPower); } } }
int CEnumerator::OnEnumFindDevice(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData, int a5) { if(PowerUp(0, DeviceInfoData->DevInst)) { return 1; } return AddDevice(DeviceInfoSet, DeviceInfoData, DeviceInterfaceDetailData, a5); }
int PowerClosest(int value){ int up = PowerUp(value); int down = PowerDown(value); int v1 = value - up; if (v1 < 0){v1*=-1;} int v2 = value - down; if (v2 < 0){v2*=-1;} if (v1 <= v2){ return up; }else{ return down; } }
void ATest1Character::PickUp() { float BatteryPower = 0.f; ATest1GameMode* MyGameMode = Cast<ATest1GameMode>(UGameplayStatics::GetGameMode(this)); //if we are currently playing if (MyGameMode->GetCurrentState() == ETest1PlayState::EPlaying) { //Get all overlapping Actors and store them in a CollectedActors array TArray<AActor*> CollectedActors; CollectionSphere->GetOverlappingActors(CollectedActors); //For each Actor collected for (int32 iCollected = 0; iCollected < CollectedActors.Num(); ++iCollected) { // Cast the collected Actor to ABatteryPickup ABatteryPickup* const TestBattery = Cast<ABatteryPickup>(CollectedActors[iCollected]); //if the cast is successful, and the battery is valid and active if (TestBattery && !TestBattery->IsPendingKill() && TestBattery->bIsActive){ // Store its battter power for adding to the character's power BatteryPower = BatteryPower + TestBattery->PowerLevel; // Call the battery's OnPickedUp function TestBattery->OnPickedUp(); //Deactivate the battery TestBattery->bIsActive = false; } // Cast the collected Actor to AItem AItem* Item = Cast<AItem>(CollectedActors[iCollected]); if (Item && !Item->IsPendingKill() && Item->bIsActive){ Inv->PickUp(Item); } } if (BatteryPower > 0.f) { // Call the blueprinted implementation of PowerUp PowerUp(BatteryPower); } } }
void FlashPollProc(void) { if((USBDeviceState >= CONFIGURED_STATE) && (!USBSuspendControl)) FlashDoTX(); switch(gCurrentCommand) { case 0x01: FlashDataRead(); break; case 0x02: FlashDataWrite(); break; case 0x03: FlashDataInit(); break; case 0x04: FlashDataDeInit(); break; case 0x05: FlashDataStatus(); break; case 0x06: FlashDataErase(); break; case 0x10: PowerUp(); break; case 0x11: Shutdown(); break; case 0xF0: Update(); break; } }
void Game::SpawnPowerUps(GameObject &block) { if (ShouldSpawn(75)) // 1 in 75 chance this->PowerUps.push_back(PowerUp("speed", glm::vec3(0.5f, 0.5f, 1.0f), 0.0f, block.Position, ResourceManager::GetTexture("powerup_speed"))); if (ShouldSpawn(75)) this->PowerUps.push_back(PowerUp("sticky", glm::vec3(1.0f, 0.5f, 1.0f), 20.0f, block.Position, ResourceManager::GetTexture("powerup_sticky"))); if (ShouldSpawn(75)) this->PowerUps.push_back(PowerUp("pass-through", glm::vec3(0.5f, 1.0f, 0.5f), 10.0f, block.Position, ResourceManager::GetTexture("powerup_passthrough"))); if (ShouldSpawn(75)) this->PowerUps.push_back(PowerUp("pad-size-increase", glm::vec3(1.0f, 0.6f, 0.4), 0.0f, block.Position, ResourceManager::GetTexture("powerup_increase"))); if (ShouldSpawn(15)) // Negative powerups should spawn more often this->PowerUps.push_back(PowerUp("confuse", glm::vec3(1.0f, 0.3f, 0.3f), 15.0f, block.Position, ResourceManager::GetTexture("powerup_confuse"))); if (ShouldSpawn(15)) this->PowerUps.push_back(PowerUp("chaos", glm::vec3(0.9f, 0.25f, 0.25f), 15.0f, block.Position, ResourceManager::GetTexture("powerup_chaos"))); }
// 게이지를 사용한 파워업 void PowerUpGauge( bool power_up_button // 파워업 버튼의 입력 ) { static POWER_UP_TYPE cursor=NONE; // 커서의 위치 // 아이템을 주웠을 때의 처리: // 아이템을 주웄으면 커서를 오른쪽으로 한 칸 이동시킴 // 맨 오른쪽까지 움직였다면 맨 왼쪽으로 되돌림 // 아이템 취득 판정 처리는 PickItem함수로 처리한다고 가정함 if (PickItem()) { cursor++; if (cursor==END) cursor=SPEED; } // 파워업의 처리: // 버튼이 눌렸다면 현재 커서가 가리키는 파워업을 적용한다 // 구체적인 파워업 처리는 PowerUp함수로 처리한다고 가정함 if (power_up_button) { PowerUp(cursor); } }
void ATutorialCodeCharacter::CollectBatteries() { float BatteryPower = 0.f; // Get GameMode and cast ATutorialCodeGameMode* MyGameMode = Cast<ATutorialCodeGameMode>(UGameplayStatics::GetGameMode(this)); // If gamemode state is playing if (MyGameMode->GetCurrentState() == ETutorialCodePlayState::EPlaying) { // Get all overlapping actors and store them in a CollectedActors array TArray<AActor*> CollectedActors; CollectionSphere->GetOverlappingActors(CollectedActors); // For each actor collected for (int32 iCollected = 0; iCollected < CollectedActors.Num(); iCollected++) { // Cast the actor to ABatteryPickup ABatteryPickup* const TestBattery = Cast<ABatteryPickup>(CollectedActors[iCollected]); // If the cast is succesfull, and the battery is valid and active if (TestBattery && !TestBattery->IsPendingKill() && TestBattery->bIsActive) { // Store its battery power for adding to the character's power BatteryPower = BatteryPower + TestBattery->PowerLevel; // Call the battery's OnPickedUp function TestBattery->OnPickedUp(); // Deactivate the battery TestBattery->bIsActive = false; } } if (BatteryPower > 0.f) { // Call the blueprinted implementation of PowerUp with the total battery power as input PowerUp(BatteryPower); } } }
// for wakeup problem. hsjang 070823 DWORD CSDHCBase::IOControl(DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut) { BOOL RetVal = TRUE; DWORD dwErr = ERROR_SUCCESS; switch (dwCode) { //----------------------------------------------------------------------------------------- case IOCTL_POWER_CAPABILITIES: { PPOWER_CAPABILITIES ppc; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_CAPABILITIES\r\n"))); if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(POWER_CAPABILITIES)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } ppc = (PPOWER_CAPABILITIES)pBufOut; memset(ppc, 0, sizeof(POWER_CAPABILITIES)); // support D0, D4 ppc->DeviceDx = 0x11; // Report our power consumption in uAmps rather than mWatts. ppc->Flags = POWER_CAP_PREFIX_MICRO | POWER_CAP_UNIT_AMPS; // 25 m = 25000 uA // TODO: find out a more accurate value ppc->Power[D0] = 25000; *pdwActualOut = sizeof(POWER_CAPABILITIES); } break; case IOCTL_POWER_SET: { CEDEVICE_POWER_STATE NewDx; if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(CEDEVICE_POWER_STATE)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } NewDx = *(PCEDEVICE_POWER_STATE)pBufOut; if ( VALID_DX(NewDx) ) { switch ( NewDx ) { case D0: if (m_Dx != D0) { PowerUp(); m_Dx = D0; } break; default: if (m_Dx != (_CEDEVICE_POWER_STATE)D4) { PowerDown(); m_Dx = (_CEDEVICE_POWER_STATE)D4; } break; } // return our state *(PCEDEVICE_POWER_STATE)pBufOut = m_Dx; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_SET : D%u \r\n"), NewDx)); *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); } else { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; } } break; case IOCTL_POWER_GET: if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(CEDEVICE_POWER_STATE)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } *(PCEDEVICE_POWER_STATE)pBufOut = m_Dx; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_GET : D%u \r\n"), m_Dx)); *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); break; default: RETAILMSG(1, (TEXT("[HSMMC] This IOControl is not supported\r\n"))); dwErr = ERROR_INVALID_PARAMETER; } return dwErr; }
int PowerDown(int value){ value = PowerUp(value);//get the top power of this value value/=2;//divide it by two to get the closest lower value return value; }
int CEnumerator::OnAddReceiver(DEVINST dnDevInst, HANDLE HidDeviceObject, const wchar_t *DevicePath, HIDD_ATTRIBUTES *Attributes, int PreparsedData, HIDP_CAPS *Capabilities, int a8) { pReceiver = 0; v31 = 0; v30 = 0; v26 = 0; DEVINST* pdnDevInst; DEVINST dnDevInst; m_pfnCM_Get_Parent(&pdnDevInst, dnDevInst, 0); DWORD a2 = PowerUp(0, (PDEVINST)pdnDevInst); if ( a2 ) { pReceiver = (CReceiver *)GetDeviceHandle(a2); v30 = 1; } else { v29 = MatchProductIDs(pThis, Attributes->ProductID, (int)&v26); switch ( v29 ) { case 4: // CDJReceiver pReceiver = (CReceiver *)new CDJReceiver(pdnDevInst, 4); break; case 3: // CEQuadReceiver pReceiver = (CReceiver *)new CEQuadReceiver(pdnDevInst, 3); break; case 2: // CEQuadReceiver pReceiver = (CReceiver *)new CEQuadReceiver(pdnDevInst, 2); break; case 9: // CDJGamingReceiver pReceiver = (CReceiver *)new CDJGamingReceiver(pdnDevInst, 9); break; case 0: // CPalomarReceiver pReceiver = (CReceiver *)new CPalomarReceiver(pdnDevInst); break; case 10: // CEQuadReceiver pReceiver = (CReceiver *)new CEQuadReceiver(pdnDevInst, 10); break; default: break; } if(pReceiver && !LinkRawDeviceHandleWithDevice(pReceiver, 0xFFu)) { if(pReceiver) { delete pReceiver; } pReceiver = 0; } } if (pReceiver) { char ReportID = GetReportID(PreparsedData, Capabilities); if(!CHPPDevice::IsDeviceWithMatchingReportID((CHPPDevice *)&pReceiver->HPPDevice, ReportID)) { HDEVNOTIFY hDevNotify = CEnumerator::GetRegisteredDevNotify(pThis, (int)HidDeviceObject); v31 = CHPPDevice::AppendHidDevice((CHPPDevice *)&pReceiver->HPPDevice,dnDevInst,(int)HidDeviceObject,DevicePath,Capabilities,ReportID,hDevNotify); v23 = CHPPDevice::AreDevicesActive((CHPPDevice *)&pReceiver->HPPDevice, v26); if ( v31 ) { if ( v23 ) { (*(void (__thiscall **)(CReceiver *, HIDD_ATTRIBUTES *))(pReceiver->__parent.vtbl + 0x2C))(pReceiver,Attributes); (*(void (__thiscall **)(CReceiver *))(pReceiver->__parent.vtbl + 4))(pReceiver); CReceiver::ReceiverScan(pReceiver); } } } if ( v30 ) { pReceiver->DecrementRefCount(); } } return v31; }