TInt DKLDDChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) { TInt r=KErrNone; TInt repeats=0; switch(aReqNo) { case RTestKeyRepeatLdd::ESetRepeat: kumemget(&iStoredKeyEvent,a1,sizeof(RKeyEvent)); iStoredEvent.SetRepeat(TRawEvent::EKeyRepeat, iStoredKeyEvent.iKey, iStoredKeyEvent.iRepeatCount); NKern::ThreadEnterCS(); r=Kern::AddEvent(iStoredEvent); NKern::ThreadLeaveCS(); break; case RTestKeyRepeatLdd::ERepeats: repeats = iStoredEvent.Repeats(); if (repeats!=iStoredKeyEvent.iRepeatCount) { r=KErrGeneral; } break; default: r=KErrNotSupported; break; } return r; }
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 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 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); }
// ----------------------------------------------------------------------------- // CAknKeyRotatorImpl::CheckRotation // Check if this is our own generated event. // ----------------------------------------------------------------------------- // TBool CAknKeyRotatorImpl::CheckRotation( const TRawEvent &aRawEvent, MAnimGeneralFunctions& aAnimGeneralFunctions ) { if ( KMaxTInt == iKeyRotatorCompensation ) { // Key rotator is disabled - wsini.ini contains "S60_KEYROTATOR DISABLED". return EFalse; } // Check first that we are not processing just generated event again. if ( iRotatedRawEvent ) { // This is the generated avent from the last round. Do not modify again. iRotatedRawEvent = EFalse; } else if ( aRawEvent.Type() == TRawEvent::EKeyDown || aRawEvent.Type() == TRawEvent::EKeyUp || aRawEvent.Type() == TRawEvent::EKeyRepeat ) { // We get new event. Let's see if we need to modify that. TRawEvent newRawEvent( aRawEvent ); DoCheckRotation( newRawEvent, aAnimGeneralFunctions ); if ( aRawEvent.ScanCode() != newRawEvent.ScanCode() ) { // Generate new event, iRotatedRawEvent = ETrue; aAnimGeneralFunctions.PostRawEvent( newRawEvent ); // Calls this function again! return ETrue; } } return EFalse; }
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); }
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 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(); }
// -------------------------------------------------------------------------- // 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 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 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(); }
/** Adds an event to the event queue. @param "const TRawEvent& aEvent" a reference to the event to be added to the event queue. @param "TBool aResetUserActivity" Specifies whether this event should reset the user inactivity timer. For most cases this should be set to ETrue @return KErrNone, if successful; KErrOverflow if event queue is already full. @pre No fast mutex can be held. @pre Calling thread must be in a critical section. @pre Kernel must be unlocked @pre interrupts enabled @pre Call in a thread context */ EXPORT_C TInt Kern::AddEvent(const TRawEvent& aEvent, TBool aResetUserActivity) { CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"Kern::AddEvent"); __KTRACE_OPT(KEVENT,Kern::Printf("Kern::AddEvent %x, %x",K::EventHeadPtr,K::EventTailPtr)); if (aResetUserActivity) { K::InactivityQ->Reset(); if (K::PowerModel) K::PowerModel->RegisterUserActivity(aEvent); } #ifdef BTRACE_TRAWEVENT BTraceContext4(BTrace::ERawEvent, BTrace::EKernelAddEvent ,(TUint32)aEvent.Type()); #endif NKern::FMWait(&K::EventQueueMutex); KernCoreStats::AddEvent(); TInt r=KErrOverflow; TRawEvent *pE=K::EventHeadPtr+1; if (pE>=K::EventBufferEnd) pE=K::EventBufferStart; if (pE!=K::EventTailPtr) { *K::EventHeadPtr=aEvent; K::EventHeadPtr=pE; r=KErrNone; } K::TryDeliverEvent(); return r; }
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 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); } }
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();*/ }
TInt ExecHandler::AddEvent(const TRawEvent &aEvent) // // Add an event to the queue. // { __KTRACE_OPT(KEVENT,Kern::Printf("Exec::AddEvent")); if(!Kern::CurrentThreadHasCapability(ECapabilitySwEvent,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserSvr::AddEvent"))) return KErrPermissionDenied; TRawEvent event; kumemget32(&event,&aEvent,sizeof(TRawEvent)); TRawEvent::TType type = event.Type(); if( (type==TRawEvent::ESwitchOff || type==TRawEvent::ECaseOpen || type==TRawEvent::ECaseClose || type==TRawEvent::ERestartSystem) && !Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by UserSvr::AddEvent"))) return KErrPermissionDenied; #ifdef BTRACE_TRAWEVENT BTraceContext4(BTrace::ERawEvent, BTrace::EUserAddEvent ,(TUint32)type); #endif NKern::ThreadEnterCS(); TInt r=Kern::AddEvent(event); NKern::ThreadLeaveCS(); return r; }
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 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); }
TBool CNspsWsPlugin::OfferRawEvent( const TRawEvent& aRawEvent ) { if ( aRawEvent.Type() == TRawEvent::EKeyDown ) { TRACES( RDebug::Print( _L( "CNspsWsPlugin::OfferRawEvent:TRawEvent::EKeyDown" ) ) ); if ( iForwardRawKeyeventsToLights ) { TRACES( RDebug::Print(_L("CNspsWsPlugin::OfferRawEvent:TRawEvent::EKeyDown, Forwarded to Lights Controller" ) ) ); RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsLightsRawKeyEvent, ECoreAppUIsKeyEvent ); } if ( iForwardRawKeyeventsToSysAp ) { TRACES( RDebug::Print(_L("CNspsWsPlugin::OfferRawEvent:TRawEvent::EKeyDown, Forwarded to SysAp" ) ) ); RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsNspsRawKeyEvent, ECoreAppUIsKeyEvent ); } if ( iForwardRawKeyeventsToNcn ) { TRACES( RDebug::Print(_L("CNspsWsPlugin::OfferRawEvent:TRawEvent::EKeyDown, Forwarded to MessageToneQuitting" ) ) ); RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsStopTonePlaying ); } } if ( aRawEvent.Type() == TRawEvent::EButton1Down ) // tapping screen also silents message tone { if ( iForwardRawKeyeventsToNcn ) { TRACES( RDebug::Print(_L("CNspsWsPlugin::OfferRawEvent:TRawEvent::EPointerSwitchOn, Forwarded to MessageToneQuitting" ) ) ); RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsStopTonePlaying ); } } return EFalse; }
TBool CKeyEventsAnim::OfferRawEvent(const TRawEvent &raw_event) { if (raw_event.Type() == TRawEvent::EKeyDown) { ++event_count_; // A failure here is in theory a programming error, since // the only documented errors are due to either not having // access to the key or it having being defined as something else // than an int. Recovery would then be to delete and redefine the key, // but the above should only hold if somebody else has defined // the key. Don't really want to panic the client either, so we // just ignore any errors. // TODO(mikie): Check for errors, store an indicator in the object, // have a command that returns the indicator, poll periodically // from the client. keyevent_notification_property_.Set(event_count_); if(iIsHandleEnabled) return ETrue; } return EFalse; }
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(); }
// ----------------------------------------------------------------------------- // CImage::Command() // Function for buffered commands and commands that cannot fail/leave. // ----------------------------------------------------------------------------- // void CImage::Command( TInt aOpcode, TAny* aArgs ) { DBG(RDebug::Print(_L("CImage::Command %d"), aOpcode )); switch ( aOpcode ) { case KStartBTCursorAnim: { iSpriteFunctions->Activate(ETrue); } break; case KStopBTCursorAnim: { iSpriteFunctions->Activate(EFalse); } break; case KRedrawBTCursorAnim: { iSpriteFunctions->Activate(EFalse); iSpriteGc->Reset(); DBG(RDebug::Print( _L("[BTHID]\tCImage::Command iLastUsedPoint (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); iSpriteFunctions->SetPosition(iLastUsedPoint); iSpriteFunctions->SizeChangedL(); iSpriteFunctions->Activate(ETrue); } break; case KResetBTCursorAnim: { iSpriteFunctions->Activate(EFalse); iSpriteGc->Reset(); DBG(RDebug::Print(_L("[BTHID]\tCImage::Command KResetBTCursorAnim") )); iLastUsedPoint.iX = 0; iLastUsedPoint.iY = 0; iSpriteFunctions->SetPosition(iLastUsedPoint); iSpriteFunctions->SizeChangedL(); iSpriteFunctions->Activate(ETrue); } break; case KChangeCursor: { iLastUsedPoint = *(TPoint *)aArgs; DBG(RDebug::Print( _L("[BTHID]\tCImage::Command KChangeCursor *(TPoint *)aArgs (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); iSpriteFunctions->SetPosition(iLastUsedPoint); } break; case KSendRawEvent: { TRawEvent rawEvent = *(TRawEvent *)aArgs; iLastUsedPoint = rawEvent.Pos(); DBG(RDebug::Print( _L("[BTHID]\tCImage::Command KSendRawEvent rawEvent.Pos() (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); iSpriteFunctions->SetPosition(iLastUsedPoint); iFunctions->PostRawEvent( rawEvent ); } break; default: User::Panic( KAnimation, EPanicAnimationServer ); break; } }
/** * 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 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)); }
/** * 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)); }
// ----------------------------------------------------------------------------- // 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); } }
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(); }