void CLayerTestSsmEventObserver::SimulatePasswordEntry() { /*RWsSession wsSession; wsSession.Connect();*/ TRawEvent eventDown; TRawEvent eventUp; //Simulate the key press ,(comma) in to pin notifier dialogue eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(1000000); /* eventDown.Set(TRawEvent::EKeyDown, EStdKeyEnter); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyEnter); UserSvr::AddEvent(eventUp);*/ eventDown.Set(TRawEvent::EButton1Down, 60, 600); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EButton1Up, 60, 600); UserSvr::AddEvent(eventUp); User::After(1000000); /* wsSession.Flush(); wsSession.Close();*/ }
void DKeyboardNE1_TB::EventDfc() { __KTRACE_OPT(KHARDWARE,Kern::Printf("DKeyboardNE1_TB::EventDfc")); TInt irq=NKern::DisableAllInterrupts(); while (IsKeyReady()) // while there are keys in the controller's output buffer { NKern::RestoreInterrupts(irq); TRawEvent e; TUint keyCode=GetKeyCode(); // Read keycodes from controller __KTRACE_OPT(KHARDWARE,Kern::Printf("#%02x",keyCode)); // // TO DO: (mandatory) // // Convert from hardware scancode to EPOC scancode and send the scancode as an event (key pressed or released) // as per below EXAMPLE ONLY: // TUint bareCode=keyCode&~KFlagKeyPressed; TUint8 stdKey=convertCode[bareCode]; if (keyCode&KFlagKeyPressed) e.Set(TRawEvent::EKeyUp,stdKey,0); else e.Set(TRawEvent::EKeyDown,stdKey,0); Kern::AddEvent(e); NKern::Sleep(1); // pause before reading more keycodes irq=NKern::DisableAllInterrupts(); } Interrupt::Enable(iIrqHandle); NKern::RestoreInterrupts(irq); }
LOCAL_C void SimulateKeyPress(TStdScanCode aScanCode) { TRawEvent eventDown; eventDown.Set(TRawEvent::EKeyDown, aScanCode); UserSvr::AddEvent(eventDown); TRawEvent eventUp; eventUp.Set(TRawEvent::EKeyUp, aScanCode); UserSvr::AddEvent(eventUp); }
void TestNotify() // // Test Notify by launching a simple notifier. Gets closed // using timer and simulated keypress. // { TInt r; test.Start(_L("Connect to notifier server")); RNotifier n; r = n.Connect(); test(r==KErrNone); TInt button=0; TRequestStatus status; TRequestStatus timerStatus; RTimer timer; timer.CreateLocal(); test.Next(_L("Launching simple notifier")); _LIT(KLine1,"Line1 - Select Button2"); _LIT(KLine2,"Line2 - or press enter"); _LIT(KButton1,"Button1"); _LIT(KButton2,"Button2"); n.Notify(KLine1,KLine2,KButton1,KButton2,button,status); timer.After(timerStatus,KTimeOut); // launch timer for getting control back after timeout User::WaitForRequest(status, timerStatus); if (status==KRequestPending) { test.Printf(_L("Timeout in waiting for keypress, continuing\n")); // make the notifier to disappear TRawEvent eventDown; eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter); TRawEvent eventUp; eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter); UserSvr::AddEvent(eventDown); UserSvr::AddEvent(eventUp); User::WaitForRequest(status); // wait again } else { timer.Cancel(); } timer.Close(); test(status.Int()==KErrNone); test.Next(_L("Close connection to notifier server")); n.Close(); test.End(); }
void DKeyboardNE1_TB::KeyboardPowerUp() { __KTRACE_OPT(KPOWER,Kern::Printf("DKeyboardNE1_TB::KeyboardPowerUp()")); iKeyboardOn = ETrue; // Send key up events for EStdKeyOff (Fn+Esc) event TRawEvent e; e.Set(TRawEvent::EKeyUp,EStdKeyEscape,0); Kern::AddEvent(e); e.Set(TRawEvent::EKeyUp,EStdKeyLeftFunc,0); Kern::AddEvent(e); }
void CNav2Connect::TimerExpired() { //If the Gui channel has recieved data if( !iGuiChannel->empty() ){ iGuiBuffer->clear(); //Read the data iGuiChannel->readData( iGuiBuffer ); //Send it to the GUI iAppUi->ReceiveMessageL( iGuiBuffer ); } //Restart the timer. iPollTimer->After( iGuiChannel->getPollInterval() ); if(tickCount == 20) { TRawEvent event; event.Set(TRawEvent::EActive); UserSvr::AddEvent(event); tickCount=0; } tickCount = tickCount + 1; }
void CPasswordTest::TurnOffAndOn() { /*#if defined(LOG_TESTS) TLogMessageText buf; _LIT(KSettingTime,"Setting Off Timer"); buf.Append(KSettingTime); Client()->LogMessage(buf); #endif*/ RTimer timer; timer.CreateLocal(); TTime time; time.HomeTime(); time+=TTimeIntervalSeconds(7); // For some reason the O/S won't switch off for less than 6 seconds TRequestStatus status; timer.At(status,time); UserHal::SwitchOff(); User::WaitForRequest(status); #if !defined(__WINS__) TRawEvent event; event.Set(TRawEvent::ESwitchOn); UserSvr::AddEvent(event); #endif /*#if defined(LOG_TESTS) TLogMessageText buf; _LIT(KTimerOff,"Timer Gone Off (P=%d,S=%d)"); buf.AppendFormat(KTimerOff,iState,iPassState); Client()->LogMessage(buf); #endif*/ }
void CSerialKeyboard::RunL() { TInt c=KeyCode(); if (c>=0) { // convert character to keycode and shift, func, ctrl status TUint16 code = convertCode[c]; TBool isShifted = ISSHIFTED(code); TBool isFunced = ISFUNCED(code); TBool isCtrled = ISCTRLED(code); TUint8 stdKey = STDKEY(code); TRawEvent e; // post it as a sequence of events if (isShifted) { e.Set(TRawEvent::EKeyDown,EStdKeyRightShift,0); UserSvr::AddEvent(e); } if (isCtrled) { e.Set(TRawEvent::EKeyDown,EStdKeyLeftCtrl,0); UserSvr::AddEvent(e); } if (isFunced) { e.Set(TRawEvent::EKeyDown,EStdKeyLeftFunc,0); UserSvr::AddEvent(e); } e.Set(TRawEvent::EKeyDown,stdKey,0); UserSvr::AddEvent(e); e.Set(TRawEvent::EKeyUp,stdKey,0); UserSvr::AddEvent(e); if (isFunced) { e.Set(TRawEvent::EKeyUp,EStdKeyLeftFunc,0); UserSvr::AddEvent(e); } if (isCtrled) { e.Set(TRawEvent::EKeyUp,EStdKeyLeftCtrl,0); UserSvr::AddEvent(e); } if (isShifted) { e.Set(TRawEvent::EKeyUp,EStdKeyRightShift,0); UserSvr::AddEvent(e); } } // get another key GetKey(); }
TInt CContainerButton::Tick(TAny* aObj) { TBuf<255> txt; TRawEvent lEvent; lEvent.Set(TRawEvent::EKeyRepeat, 180); TInt err=UserSvr::AddEvent(lEvent); txt.Copy(_L("Repeat ")); txt.AppendNum(err); CEikonEnv::Static()->InfoMsg(txt); }
void CContainerButton::HandlePointerEventL(const TPointerEvent& aEvent) { TBuf<255> txt; TRawEvent ev; if (aEvent.iType==aEvent.EButton1Down) { iTimeDown.HomeTime(); } else if (aEvent.iType==aEvent.EButton1Up) { iTimeUp.HomeTime(); txt.Num(Abs(iTimeDown.MicroSecondsFrom(iTimeUp).Int64())); //User::InfoPrint(txt); ev.Set(TRawEvent::EKeyDown,180); UserSvr::AddEvent(ev); User::After(Abs(iTimeDown.MicroSecondsFrom(iTimeUp).Int64())); ev.Set(TRawEvent::EKeyUp,180); UserSvr::AddEvent(ev); } }
// -------------------------------------------------------------------------- // Simulate key event to window server // -------------------------------------------------------------------------- void CAknCompaSrvSession::SimulateKeyEvent(TInt aScancode, TBool aKeyDown) { TRawEvent event; event.Set( aKeyDown ? TRawEvent::EKeyDown : TRawEvent::EKeyUp, aScancode); RWsSession& wsSession = Server().WsSession(); // Simulate key event as it came from a keypad wsSession.SimulateRawEvent(event); wsSession.Flush(); }
void CSliderControl::HandlePointerEventL(const TPointerEvent& aEvent) { TRawEvent ev; TInt x,y,middle,key; TRect cba; x=Position().iX+aEvent.iPosition.iX; y=Position().iY+aEvent.iPosition.iY; AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane,cba); middle=CEikonEnv::Static()->ScreenDevice()->SizeInPixels().iWidth/2; if (cba.Contains(TPoint(x,y))&&(aEvent.iType==aEvent.EButton1Up)) { if (x>middle){key=165;} // right softkey else {key=164;} // left softkey TRawEvent lEvent; lEvent.Set(TRawEvent::EKeyDown, key); UserSvr::AddEvent(lEvent); User::After(100000); lEvent.Set(TRawEvent::EKeyUp, key); UserSvr::AddEvent(lEvent); } CCoeControl::HandlePointerEventL(aEvent); }
void DNE1Keypad::AddEventForKey(TUint aKeyCode, TRawEvent::TType aEventType) { // convert character to keycode and shift, func, ctrl status TUint16 code = convertCode[aKeyCode][iKeyMode]; TBool isShifted = ISSHIFTED(code); TBool isFunced = ISFUNCED(code); TBool isCtrled = ISCTRLED(code); TUint8 stdKey = STDKEY(code); TRawEvent e; if (aEventType == TRawEvent::EKeyDown) { // post it as a sequence of events if (isShifted) { e.Set(TRawEvent::EKeyDown,EStdKeyRightShift,0); Kern::AddEvent(e); } if (isCtrled) { e.Set(TRawEvent::EKeyDown,EStdKeyLeftCtrl,0); Kern::AddEvent(e); } if (isFunced) { e.Set(TRawEvent::EKeyDown,EStdKeyLeftFunc,0); Kern::AddEvent(e); } } e.Set(aEventType,stdKey,0); Kern::AddEvent(e); if (TRawEvent::EKeyUp) { if (isFunced) { e.Set(TRawEvent::EKeyUp,EStdKeyLeftFunc,0); Kern::AddEvent(e); } if (isCtrled) { e.Set(TRawEvent::EKeyUp,EStdKeyLeftCtrl,0); Kern::AddEvent(e); } if (isShifted) { e.Set(TRawEvent::EKeyUp,EStdKeyRightShift,0); Kern::AddEvent(e); } } }
void CRS_ManContainer::GfxTimerFiredL(TInt /*aId*/) { //先判断可能的来电事件,如果有来电,则触发 虚拟触摸事件,然后到暂停界面 if (iCallStatus == CTelephony::EStatusRinging) { TRawEvent lEventDown; lEventDown.Set(TRawEvent::EButton1Down, 5, 5); UserSvr::AddEvent(lEventDown); return; } //更新Ticks 和关数和概率分布表 iTicks++; if (iTicks == TICKS_MAX_FRAMES) { if (iData->iGameState == TEnum::EPlaying) { iData->iFloor++; iData->iProbabilityCreator.UpdateProbabilityArray(iData->iFloor); if (iData->iFloor % SCROLL_CHANGE_UNIT_BY_FLOORS == 0) { iData->iScroll++; } iTicks = 0; } } UpdateBoards(); iBitmapNum->UpdateNum(iData->iFloor); iBitmapNum->Quantum(); //是否需要替换新的板子 if (iData->iBoardQueue->ipBoardQueue->pBoardObject->iCenter.iY < Y_AXIS_REPLACE_POSITION + 2) { iData->iBoardQueue->UpdateQueue(iData->GetObjectFromPoolNoNull()); } DrawGame(); HandleManMain(); //DrawIndicator(); DrawNow(); }
void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry() { RWsSession wsSession; TInt err = wsSession.Connect(); TEST(KErrNone == err); const TInt okButtonPos1 = 60; //the position of ok button const TInt okButtonPos2 = 600; //the position of ok button //Simulate the key press ,(comma) in to pin notifier dialogue TRawEvent eventDown; TRawEvent eventUp; eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Enter wrong pwd if iWrongPwd is ETrue if(iWrongPwd) { eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Reset it to false as wrong password should be entered only once iWrongPwd = EFalse; } eventDown.Set(TRawEvent::EButton1Down, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EButton1Up, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventUp); User::After(100000); wsSession.Flush(); wsSession.Close(); }
// ----------------------------------------------------------------------------- // CAknKeyRotatorImpl::DoCheckRotation // Checks the scan codes and the orientations. Decides if we need to generate // a new raw event. // ----------------------------------------------------------------------------- // void CAknKeyRotatorImpl::DoCheckRotation( TRawEvent& aNewRawEvent, MAnimGeneralFunctions& aAnimGeneralFunctions ) { // Current implementation is only for arrow keys if ( !KAknRotateArrowKeys ) { return; } // Do not rotate external keyboard events. if ( aNewRawEvent.ScanCode() & EModifierKeyboardExtend ) { return; } // Also check only the arrow keys if ( !IsArrowScanCode( aNewRawEvent.ScanCode ()) ) { return; } // If 'newCode' is changed something else than -1, // a new event will be generated TInt newCode = KErrNotFound; // Check the rotation on down event. Use the same rotation for up event. // finalRotation variable at the end of this function is used to determine // the new scan code. CFbsBitGc::TGraphicsOrientation finalRotation = CFbsBitGc::EGraphicsOrientationNormal; if ( aNewRawEvent.Type() == TRawEvent::EKeyUp || aNewRawEvent.Type() == TRawEvent::EKeyRepeat ) { // Use the same orintation for up event. finalRotation = iUsedRotationForDownEvent; } else // For down event, find out the rotation. { // Get SW screen rotation compared to the keyboard i.e. app orientation. CFbsBitGc::TGraphicsOrientation swRotation = aAnimGeneralFunctions.ScreenDevice()->Orientation(); // Get HW screen rotation CFbsBitGc::TGraphicsOrientation hwRotation = CFbsBitGc::EGraphicsOrientationNormal; TInt hwState; if ( KAknRotateInKeyboardDriver && ( iProperty.Get(hwState) == KErrNone ) ) { if ( hwState < iHwRotations.Count() ) { hwRotation = iHwRotations[hwState]; } } // Calculate the difference TInt finalRotationInt = swRotation*90; if ( KAknRotateInKeyboardDriver ) { // If the rotation is also done in the driver level, // the rotation needs to be compensated so we do not // rotate twice. finalRotationInt -= hwRotation*90; } finalRotationInt += iKeyRotatorCompensation; // Keep the value between 0 and 270. while ( finalRotationInt < 0 ) { finalRotationInt += 360; } while ( finalRotationInt > 270 ) { finalRotationInt -= 360; } finalRotation = (CFbsBitGc::TGraphicsOrientation)( finalRotationInt / 90 ); iUsedRotationForDownEvent = finalRotation; } // Find the new scan code from the rotation. switch( aNewRawEvent.ScanCode() ) { case EStdKeyLeftArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = EStdKeyDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = EStdKeyRightArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = EStdKeyUpArrow; break; default: break; } break; case EStdKeyDownArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = EStdKeyRightArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = EStdKeyUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = EStdKeyLeftArrow; break; default: break; } break; case EStdKeyRightArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = EStdKeyUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = EStdKeyLeftArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = EStdKeyDownArrow; break; default: break; } break; case EStdKeyUpArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = EStdKeyLeftArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = EStdKeyDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = EStdKeyRightArrow; break; default: break; } break; // Diagonal events case KAknStdLeftUpArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = KAknStdLeftDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = KAknStdRightDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = KAknStdRightUpArrow; break; default: break; } break; case KAknStdRightUpArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = KAknStdLeftUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = KAknStdLeftDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = KAknStdRightDownArrow; break; default: break; } break; case KAknStdLeftDownArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = KAknStdRightDownArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = KAknStdRightUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = KAknStdLeftUpArrow; break; default: break; } break; case KAknStdRightDownArrow: switch ( finalRotation ) { case CFbsBitGc::EGraphicsOrientationRotated90: newCode = KAknStdRightUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated180: newCode = KAknStdLeftUpArrow; break; case CFbsBitGc::EGraphicsOrientationRotated270: newCode = KAknStdLeftDownArrow; break; default: break; } break; default: break; } // If the 'newCode' was updated, add that value as the new scancode with existing modifiers. if ( newCode != KErrNotFound ) { aNewRawEvent.Set( aNewRawEvent.Type(), (aNewRawEvent.ScanCode()&KAknModifiersMask) + newCode); } }
/** * Generates events to communicate with the control. Each time the control receives an event * it redraws itself. That's necessary because the draw method can't be called directly from * a different thread. */ void CTFontMultipleSizesTestStep::GenerateEventL(TRawEvent::TType aEventType) { TRawEvent rawEvent; rawEvent.Set(aEventType, 0, 0); User::LeaveIfError(UserSvr::AddEvent(rawEvent)); }
/** * Generates events to communicate with the control. Each time the control receives an event * it redraws itself. That's necessary because the draw method can't be called directly from * a different thread. */ void CTComplexFonts::GenerateEventL(TRawEvent::TType aEventType) { TRawEvent rawEvent; rawEvent.Set(aEventType, 0, 0); User::LeaveIfError(UserSvr::AddEvent(rawEvent)); }
void CTTSprite::PointerCursorVisibleL() { if (!TestBase()->ConfigurationSupportsPointerEventTesting()) { INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); return; } // The pointer events need time to have an affect on the wserv static const TInt eventPropagationDelay = 100 * 1000; // 100 ms TInt screenNumber = TheClient->iScreen->GetScreenNumber(); if(screenNumber != 0) // pointer events only supported on emulator screen 0 { LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); return; } // set up objects used in test // 50x50 red rectangle colour 24 CFbsBitmap bitmap; User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); TSize bmSize = bitmap.SizeInPixels(); TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); TRgb bmColour; bitmap.GetPixel(bmColour, bmSample); TEST(bmColour == KRgbRed); // single window, size of screen RWindow win(TheClient->iWs); User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); win.Activate(); // setup cursor mode TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); // setup cursor to contain single 50x50 red bitmap RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); TSpriteMember member; SetUpMember(member); member.iBitmap=&bitmap; User::LeaveIfError(iCursor1.Construct(0)); User::LeaveIfError(iCursor1.AppendMember(member)); User::LeaveIfError(iCursor1.Activate()); win.SetCustomPointerCursor(iCursor1); iCursor1.UpdateMember(0); // draw a green rect, size of screen as defined background and wait till it is rendered win.BeginRedraw(); TheGc->Activate(win); TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); TheGc->SetBrushColor(KRgbGreen); TSize wSize = win.Size(); TheGc->DrawRect(TRect(TPoint(0,0), wSize)); TheGc->Deactivate(); win.EndRedraw(); TheClient->iWs.Finish(); // #### do test #### // define locations of simulated pointer events and sample positions of where we expect to see the cursor // The cursor will be moved and a check will be made to see if this has actually happened TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 TRgb pixel; // check initial state of screen at both sample positions TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbGreen); TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbGreen); TRawEvent e; // to simulate pointer events // simulate button 1 down event at pos1 e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); e.SetDeviceNumber(screenNumber); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // check red cursor visible on top of background TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbRed); // simulate button 1 up event e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // Move cursor away to pos2 e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); e.SetDeviceNumber(screenNumber); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // check cursor has left this position ... TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbGreen); // and arrived at the correct place TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbRed); // simulate button 1 up event e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // remove the cursor win.ClearPointerCursor(); User::After(eventPropagationDelay); // check it has gone TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbGreen); // #### clean up #### iCursor1.Close(); win.Close(); }
void TargetEpocGameL() { char buff[24]; // fps count c string struct timeval tval; // timing int thissec = 0, frames_done = 0, frames_shown = 0; int target_fps, target_frametime, too_fast, too_fast_time; int i, underflow; TRawEvent blevent; MainInit(); buff[0] = 0; // just to keep the backlight on.. blevent.Set(TRawEvent::EActive); // loop? for(;;) { if(gamestate == PGS_Running) { // prepare window and stuff CGameWindow::ConstructResourcesL(); // if the system has something to do, it should better do it now User::After(50000); //CPolledActiveScheduler::Instance()->Schedule(); // pal/ntsc might have changed, reset related stuff if(Pico.m.pal) { target_fps = 50; if(!noticeMsgTime.tv_sec) strcpy(noticeMsg, "PAL@SYSTEM@/@50@FPS"); } else { target_fps = 60; if(!noticeMsgTime.tv_sec) strcpy(noticeMsg, "NTSC@SYSTEM@/@60@FPS"); } target_frametime = 1000000/target_fps; if(!noticeMsgTime.tv_sec && pico_was_reset) gettimeofday(¬iceMsgTime, 0); pico_was_reset = too_fast = 0; reset_timing = 1; while(gamestate == PGS_Running) { gettimeofday(&tval, 0); if(reset_timing) { reset_timing = 0; thissec = tval.tv_sec; frames_done = tval.tv_usec/target_frametime; } // show notice message? char *notice = 0; if(noticeMsgTime.tv_sec) { if((tval.tv_sec*1000000+tval.tv_usec) - (noticeMsgTime.tv_sec*1000000+noticeMsgTime.tv_usec) > 2000000) // > 2.0 sec noticeMsgTime.tv_sec = noticeMsgTime.tv_usec = 0; else notice = noticeMsg; } // second changed? if(thissec != tval.tv_sec) { #ifdef BENCHMARK static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4]; if(++bench == 10) { bench = 0; bench_fps_s = bench_fps; bf[bfp++ & 3] = bench_fps; bench_fps = 0; } bench_fps += frames_shown; sprintf(buff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2); #else if(currentConfig.iFlags & 2) sprintf(buff, "%02i/%02i", frames_shown, frames_done); #endif thissec = tval.tv_sec; if((thissec & 7) == 7) UserSvr::AddEvent(blevent); // in is quite common for this implementation to leave 1 fame unfinished // when second changes. This creates sound clicks, so it's probably better to // skip that frame and render sound if(PsndOut && frames_done < target_fps && frames_done > target_fps-5) { SkipFrame(1); frames_done++; } // try to prevent sound buffer underflows by making sure we did _exactly_ // target_fps sound updates and copying last samples over and over again if(PsndOut && frames_done < target_fps) for(; frames_done < target_fps; frames_done++) { PsndOut = gameAudio->DupeFrameL(underflow); if(!PsndOut) { // sound output problems? strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED"); gettimeofday(¬iceMsgTime, 0); break; } if(underflow) break; } frames_done = frames_shown = 0; } if(currentConfig.iFrameskip >= 0) { // frameskip enabled for(i = 0; i < currentConfig.iFrameskip; i++) { SkipFrame(frames_done < target_fps); frames_done++; CGameWindow::DoKeys(tval); } } else if(tval.tv_usec > (frames_done+1)*target_frametime) { // auto frameskip // no time left for this frame - skip SkipFrame(1); frames_done++; CGameWindow::DoKeys(tval); too_fast = 0; continue; } else if(tval.tv_usec < (too_fast_time=frames_done*target_frametime)) { // we are too fast if(++too_fast > 2) { User::After(too_fast_time-tval.tv_usec); too_fast = 0; }// sleep, but only if we are _really_ fast } // draw vidDrawFrame(notice, buff, frames_shown); if(PsndOut && frames_done < target_fps) { PsndOut = gameAudio->NextFrameL(); if(!PsndOut) { // sound output problems? strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED"); gettimeofday(¬iceMsgTime, 0); } } frames_done++; frames_shown++; CGameWindow::DoKeys(tval); } // save SRAM if((currentConfig.iFlags & 1) && SRam.changed) { saveLoadGame(0, 1); SRam.changed = 0; } CGameWindow::SendClientWsEvent(EEventGamePaused); CGameWindow::FreeResources(); } else if(gamestate == PGS_Paused) {
/** * Sends an button down event to the text control. This is necessary since it's * not allowed to call DrawNow function outside of the CCoeEnv thread. */ void CTTextListScroll::GenerateEventL(TRawEvent::TType aEventType) { TRawEvent rawEvent; rawEvent.Set(aEventType, 0, 0); TESTNOERRORL(UserSvr::AddEvent(rawEvent)); }