Beispiel #1
0
	void showDebugMessage( const char* source, const char* message )
	{
		if ( source && message )
		{
			memset(g_szSource, 0, sizeof(g_szSource) );
			memset(g_szMessage, 0, sizeof(g_szMessage) );
			
			memcpy( g_szSource, source, strlen(source) > 20 ? 20 : strlen(source) );
			memcpy( g_szMessage, message, strlen(message) > 100 ? 100 : strlen(message));
		
			// Create a window server event
			RWsSession wsSession;
			TWsEvent event;

			if ( wsSession.Connect() == KErrNone )
			{
				// Set event data. eventType.data = KData;
				event.SetType(EEventUser + ECmdShowDebugWindow); // set event type
				event.SetTimeNow(); // set the event time
				event.SetHandle(wsSession.WsHandle()); // set window server handle
				
				// Send the created event
				wsSession.SendEventToAllWindowGroups(event);
			}
		}
	}
/**
  Inform with a message ,the timer seconds remaining till its up.\n
  Send event to windows group when timer time is up .\n
*/
void CTestTimer::RunL()
	{
	--iSecondsRemaining;
	if (iSecondsRemaining>0)
		{
		QueueAndInfoPrint();
		}
	else
		{
		User::InfoPrint(_L("Time's up"));
		iCompleted = ETrue;
		
		CCoeEnv* env = CCoeEnv::Static();
		TWsEvent theEvent;
		theEvent.SetType(EEventUser + 1);

		RWsSession	ws;
		TInt theRes = ws.Connect();

		if(theRes == KErrNone)
			{
			RWindowGroup& winGroup = env->RootWin();
			theEvent.SetType(EEventUser + 1);
			theEvent.SetTimeNow();
			TInt theId = winGroup.Identifier();
			ws.SendEventToWindowGroup(theId, theEvent);
			}
		ws.Close();	
		}
	}
Beispiel #3
0
void CEPongAppUi::HandleWsEventL(const TWsEvent &aEvent, CCoeControl *aDestination)
	{
	if (aEvent.Type() == EEventUser)
		{
		TApaSystemEvent* eventData = reinterpret_cast<TApaSystemEvent*> (aEvent.EventData());
		if ((*eventData) == EApaSystemEventShutdown)
			{
			eventData++;
			if ((*eventData) == KGoomMemoryLowEvent)
				{
				return; // skip default handling
				}
			}
		}

	if (aEvent.Type() == EEventFocusGained)
		{
		if (iAppView)
			iAppView->startEngine();
		}
	else if (aEvent.Type() == EEventFocusLost)
		{
		if (iAppView)
			iAppView->stopEngine(ETrue);
		}

	CAknAppUi::HandleWsEventL(aEvent, aDestination);
	}
/**
 Utility to close the dialogs once the screen has been compared
 with a previous capture of an expected display.
 */	
void CConeErrorMsgTestAppUi::CloseDialogsL()
	{	
	User::LeaveIfError(iWs.Connect());
	TInt wgFocus = iWs.GetFocusWindowGroup();

	const TUint32 ENullWsHandle = 0xFFFFFFFF;	// Events delivered to this handle are thrown away
	RWindowGroup wg = RWindowGroup(iWs);

	wg.Construct(ENullWsHandle);
	TInt wgId = wg.Identifier();

	TWsEvent event;
	event.SetType(EEventKey);
	TKeyEvent *keyEvent = event.Key();
	keyEvent->iCode = EKeyEscape;
	keyEvent->iScanCode = EStdKeyEscape;
	keyEvent->iModifiers = 0;

	TInt limit = 0;
	for(limit = 0; wgFocus != wgId && (limit < 50); limit++)
		{
		iWs.SendEventToAllWindowGroups(event);
		wgFocus = iWs.GetFocusWindowGroup();
		RDebug::Print(_L("CloseAllPanicWindowsL() - EKeyEscape sent to Windows Group"));
		}

	wg.Close();
	iWs.Close();
	}
void CAknKeyLockControl::SendMessageToSysAp(TInt aMessage)
    {
    RWsSession& ws = iEikonEnv->WsSession();
    TInt wgId=0;
    CApaWindowGroupName::FindByAppUid(KSysApUid, ws, wgId);
    if (wgId)
        {
        TWsEvent event;
        event.SetType(aMessage);
        event.SetTimeNow();
        ws.SendEventToWindowGroup(wgId, event);
        }
    }
Beispiel #6
0
EXPORT_C TInt CSDL::RedrawRequest()
	{
	if(gEpocEnv && gEpocEnv->iDsa)
		{
		//const TInt err =  gEpocEnv->iDsa->RedrawRequest();
		TWsEvent event;
		event.SetType(EEventScreenDeviceChanged),
		event.SetTimeNow();
		AppendWsEvent(event);/*
		EpocSdlEnv::PostUpdate();
		return err; */
		}
	return KErrNotReady;
	}
/**
   @SYMTestCaseID 		UIF-FEPTEST-0001
   @SYMPREQ				0000
   @SYMTestCaseDesc  	Launch the application and offer events.
   @SYMTestPriority 	High 
   @SYMTestStatus 		Implemented
   @SYMTestActions 		Launch an application with the editor window. The application is made to exit, when a timer expires.   
   						Load the FEP (TFEP1). Create character codes for text events. Offer the texts to the applciation for 
   						the TFEP1 to intercept.  
   						A succesful implementation ensures that the application exits without a crash.
  						Here the layout of the FEP UI is such that the Composition Window is integrated into the Target Control.  
   @SYMTestExpectedResults The test case fails if the app crashed with an exception and passes if the app exits cleanly
 */
void CDefocusingEdwinUi::RunTestStepL(TInt aStep)
	{
	User::After(TTimeIntervalMicroSeconds32(1));

	TTimeIntervalSeconds theInterval;

	TTime tm;
	tm.HomeTime();
	tm.SecondsFrom(iTmStart,theInterval);

	TInt theInt = theInterval.Int();

	if(iCurrentSecond < theInt)
		{
		if(KNumberOfSeconds-iCurrentSecond < 0)
			{
			iCoeEnv->InstallFepL(KNullUid);
			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
			return;
			}
		else
			{
			TBuf<100> message;
			message.Format(_L("%d seconds remaining"), KNumberOfSeconds-iCurrentSecond);
			User::InfoPrint(message);
		
			iCurrentSecond = theInt;
			}
		}
	TWsEvent theEvent;
	TKeyEvent *theKey = theEvent.Key();
	theKey->iScanCode = 0;
	theKey->iModifiers= 0;
	theKey->iRepeats=0;
	theKey->iCode = 'A';
	
	TInt nRes = aStep % 7;

	if(nRes == 6)
		{
		theKey->iCode = EKeyEnter;
		}
	else
		{
		theKey->iCode += nRes;
		}

	INFO_PRINTF2(_L("Simulate Key Event with code %d"), theKey->iCode);
	SendEventToWindowGroups(theEvent);
	}
void CMicroDialog::CMicroDialogInt::EventLoopL(void)
{
  TRequestStatus eventStatus,timerStatus;

  iWsSession.EventReady(&eventStatus);
  iTimer.After(timerStatus,100000);
  iDoLoop=ETrue;
  TInt focus=EFalse;
  while(iDoLoop)
  {
    User::WaitForAnyRequest();
    if(eventStatus.Int()!=KRequestPending)
    {
      User::LeaveIfError(eventStatus.Int());
      TWsEvent event;
      iWsSession.GetEvent(event);
      switch(event.Type())
      {
        case EEventFocusLost:
          focus=EFalse;
          break;
        case EEventFocusGained:
          focus=ETrue;
          break;
        case EEventFocusGroupChanged:
          if(iWsSession.GetFocusWindowGroup()==iOwner->iId)
            iRootWin.SetOrdinalPosition(0);
          break;
        case EEventKey:
          iOwner->iCallback->MicroDialogKey(*(event.Key()));
          break;
      }
      iWsSession.EventReady(&eventStatus);
    }
    else if(timerStatus.Int()!=KRequestPending)
    {
      User::LeaveIfError(timerStatus.Int());
      if(focus) iOwner->iCallback->MicroDialogTimer();
      iTimer.After(timerStatus,100000);
    }
    else
    {
      iOwner->iCallback->MicroDialogRequest();
    }
  }
  iTimer.Cancel();
  iWsSession.EventReadyCancel();
}
Beispiel #9
0
LOCAL_C TInt ModifiersChangedEvent(const TWsEvent& aWsEvent)
    {
    TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
    TUint modstate = KMOD_NONE;
    if (modEvent->iModifiers & EModifierLeftShift)
        modstate |= KMOD_LSHIFT;
    if (modEvent->iModifiers & EModifierRightShift)
        modstate |= KMOD_RSHIFT;
    if (modEvent->iModifiers & EModifierLeftCtrl)
        modstate |= KMOD_LCTRL;
    if (modEvent->iModifiers & EModifierRightCtrl)
        modstate |= KMOD_RCTRL;
    if (modEvent->iModifiers & EModifierLeftAlt)
        modstate |= KMOD_LALT;
    if (modEvent->iModifiers & EModifierRightAlt)
        modstate |= KMOD_RALT;
    if (modEvent->iModifiers & EModifierLeftFunc)
        modstate |= KMOD_LMETA;
    if (modEvent->iModifiers & EModifierRightFunc)
        modstate |= KMOD_RMETA;
    if (modEvent->iModifiers & EModifierCapsLock)
        modstate |= KMOD_CAPS;
    SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
    return 0;
    }
Beispiel #10
0
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    switch (aWsEvent.Type())
		{    
		case EEventSwitchOff:
			SDL_PrivateQuit();
			return 0;
    	case EEventPointerBufferReady:
    	    return PointerBufferReadyEvent(_this/*, aWsEvent.Time()*/);
        case EEventPointer: /* Mouse pointer events */
            return PointerEvent(_this, aWsEvent);
        case EEventKeyDown: /* Key events */
            return KeyDownEvent(_this, aWsEvent);
        case EEventKeyUp: /* Key events */
            return KeyUpEvent(_this, aWsEvent);
        case EEventFocusGained: /* SDL window got focus */
            return FocusGainedEvent(_this);	   
        case EEventFocusLost: /* SDL window lost focus */
        	return FocusLostEvent(_this);
        case EEventModifiersChanged: 
            return ModifiersChangedEvent(aWsEvent);         
    	case EEventScreenDeviceChanged:
    	    return ScreenDeviceChanged();
    	case ESDLWsEvent:
    	    return InternalEvent(aWsEvent);
        default:            
            return 0;
		} 
    }
Beispiel #11
0
void CSyncEngineWrap::SendWindowEvent(TInt aEvent)
	{
	// Create a window server event
	RWsSession wsSession;
	TWsEvent event;

	if (wsSession.Connect() == KErrNone)
		{
		// Set event data. eventType.data = KData;
		event.SetType(EEventUser + aEvent); // set event type
		event.SetTimeNow(); // set the event time
		event.SetHandle(wsSession.WsHandle()); // set window server handle

		// Send the created event
		wsSession.SendEventToAllWindowGroups(event);
		}
	}
Beispiel #12
0
/** Fetches a message
*/
TInt COomMessageFetch::Fail()
	{
	TWsEvent event;
	TPtr8 ptr(NULL,0);
	TUid uid;
	event.SetType(EEventMessageReady);
	event.SetHandle(CLIENT_HANDLE);
	event.SetTimeNow();
	SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData();
	eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier();
	eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE);
	eventMessageReady.iMessageParametersSize=MESSAGE_LEN;
	TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event);
	if (ret==KErrNone)
		User::Free((TAny *)ptr.Ptr());
	return(ret);
	}
Beispiel #13
0
void CButton::GetWgEvent()
    {
    #ifdef __DEBUG
    __LOGSTR1("GetWgEvent,iStatus: %d",iStatus.Int());
    #endif
   if(iStatus == KErrNone)
	{
    TWsEvent e;
    iWs.GetEvent(e);
    #ifdef __DEBUG
    __LOGSTR1("event: %d",e.Type());
    #endif
    switch(e.Type())
    	{
    	case EEventPointer:
    	case EEventPointerEnter:
    	case EEventDragDrop:
    	{
    	__LOGSTR("SendClose");
    	iMconnect->SendClose();
    	break;
    	}
    	case EEventFocusGained:
    		__LOGSTR("Focus gained");
    		iIsFocus = ETrue;
    		//iColor = KRgbGreen;
    		break;
    	case EEventFocusLost:
    		__LOGSTR("Focus lost");
    		iIsFocus = EFalse;
    		//iColor = KRgbRed;
    		break;
    	case EEventKeyDown:
    		__LOGSTR2("EEventKeyDown,iIsFocus: %d,iScanCode: %d",iIsFocus,e.Key()->iScanCode);
    		if(iIsFocus && e.Key()->iScanCode == 167)
    			{
    			iMconnect->SendClose();
    			}
    		break;
    	}
	}
	Draw();
	iWs.Flush();
    WaitWgEvent();
    }
void CAppOomMonitorPlugin::SendMessageToApp(TInt aMessage)
    {
    RWsSession& ws = WsSession();
    TInt wgId = 0;

    do 
        {
        CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId);
        if (wgId>0)
            {
            TWsEvent event;
            event.SetType(aMessage);
            event.SetTimeNow();
            ws.SendEventToWindowGroup(wgId, event);
            }
        }
    while (wgId>0);
    }
Beispiel #15
0
void SendWindowEvent(TInt aEvent, const char* data)
{
	// Create a window server event
	RWsSession wsSession;
	TWsEvent event;

	if ( wsSession.Connect() == KErrNone )
	{
		// Set event data. eventType.data = KData;
		event.SetType(EEventUser + aEvent); // set event type
		event.SetTimeNow(); // set the event time
		event.SetHandle(wsSession.WsHandle()); // set window server handle
		
		if ( data )
			((char**)event.EventData())[0] = strdup(data);
		// Send the created event
		wsSession.SendEventToAllWindowGroups(event);
	}
}
/**
  Handle the user defined events.\n
  Handle the System events
  Call made to the static implementation CEikAppUi::HandleSystemEventL().\n
*/
void CDefocusingEdwinUi::HandleApplicationSpecificEventL(TInt , const TWsEvent& aEvent)
	{
	if(aEvent.Type() == (EEventUser + 1))
		{
		Exit();
		}
	else
		{
		CEikAppUi::HandleSystemEventL(aEvent);
		}
	}
Beispiel #17
0
/**
 *	Handles system events
 *	@param aEvent - event that has to be handled by the function
 *	
 */  
void CTApp1Ui::HandleSystemEventL(const TWsEvent& aEvent)
	{
	switch (*(TApaSystemEvent*)(aEvent.EventData()))
		{
		case EApaSystemEventBroughtToForeground:
			RProcess::Rendezvous(KErrNone);
			break;
         default:
			User::Leave(KErrAbort);
			break;
		}	
	}
Beispiel #18
0
void CMyServer::GetWgEvent()
    {
    #ifdef __DEBUG
    __LOGSTR1("GetWgEvent,iStatus: %d",iStatus.Int());
    #endif
   if(iStatus == KErrNone)
	{
    TWsEvent e;
    iWs.GetEvent(e);
    #ifdef __DEBUG
    __LOGSTR1("event: %d",e.Type());
    #endif
	}
    TInt WgId = iWs.GetFocusWindowGroup();
    CApaWindowGroupName* gn = CApaWindowGroupName::NewLC(iWs, WgId);
    #ifdef __DEBUG
    __LOGSTR2("focused app with uid: 0x%x,config uid: 0x%x",gn->AppUid(),iConfig.iUid);
    #endif
    if(gn->AppUid() == iConfig.iUid)
	{

    	Show();
	//Draw();
    //iWindow.SetVisible(ETrue);
    //iWs.Flush();
    #ifdef __DEBUG
	__LOGSTR("UIDs ==");
    #endif
	}else{
	//iWindow.SetVisible(EFalse);
		Hide();
	iWs.Flush();
    #ifdef __DEBUG
	__LOGSTR("UIDs !=");
    #endif
	}
    WaitWgEvent();
    }
Beispiel #19
0
TInt CSdlAppServ::ObserverEvent(TInt aEvent, TInt aParam)
	{
	if(iObserver != NULL)
		{
		if(RThread().Id() == iMainId)
		    {
		    return iObserver->SdlEvent(aEvent, aParam);
		    }
		else if(RThread().Id() == gEpocEnv->iId  && EnvUtils::IsOwnThreaded())
			{
			return iObserver->SdlThreadEvent(aEvent, aParam);
			}
		else
		    {
		    TWsEvent event;
		    event.SetType(ESDLWsEvent);
		    TInt load[] = {aEvent, aParam};
		    Mem::Copy(event.EventData(), load, sizeof(TInt) * 2);
		    event.SetTimeNow();
		    EpocSdlEnv::EventQueue().Append(event);
		    }
		}
	return 0;
	}
Beispiel #20
0
void COokjorAppUi::HandleWsEventL(const TWsEvent &aEvent, CCoeControl *aDestination)
	{
		switch (aEvent.Type())
		{
			//case KAknUidValueEndKeyCloseEvent:  0x101F87F0 that's the red key press handling
			case 0x101F87F0:
			{
				TApaTask task(iEikonEnv->WsSession( ));
				task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
				task.SendToBackground();
			}
			break;

			default:
			{
			CAknAppUi::HandleWsEventL(aEvent, aDestination);
			}
		}
	}
Beispiel #21
0
LOCAL_C TInt PointerEvent(_THIS, const TWsEvent& aWsEvent)
    {
    
    const TPointerEvent* pointerEvent = aWsEvent.Pointer();
    const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition - Private->iScreenPos);

    TInt posted = 0;
    
    if(mousePos.iX >= 0 && mousePos.iY >= 0 && mousePos.iX < _this->screen->w && mousePos.iY < _this->screen->h)
        {
        posted = SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
        }
    
    switch (pointerEvent->iType)
        {
        case TPointerEvent::EButton1Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton1Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton2Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton2Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton3Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        case TPointerEvent::EButton3Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        default:;
        } // switch
    return posted;
    }
/**
  Handle the window events.\n
  Create a window server session and connect the client\n
  Set the event type and call the SendEventToWindowGroup().\n
  Close the session on completion \n
*/
void CDefocusingEdwinUi::SendEventToWindowGroups(TWsEvent&	aEvent)
	{
	RWsSession	ws;
	TInt theRes = ws.Connect();
	TEST(theRes == KErrNone);

	RWindowGroup& winGroup = iCoeEnv->RootWin();
	TInt theId = winGroup.Identifier();
	
	aEvent.SetType(EEventKeyDown);
	aEvent.SetTimeNow();
	ws.SendEventToWindowGroup(theId, aEvent);
		
	aEvent.SetType(EEventKey);
	aEvent.SetTimeNow();
	ws.SendEventToWindowGroup(theId, aEvent);

	aEvent.SetType(EEventKeyUp);
	aEvent.SetTimeNow();
	ws.SendEventToWindowGroup(theId, aEvent);
	
	ws.Close();
	}
void TAdvancedPointerEventHelper::SetZ(TWsEvent& aWsEvent, TInt aPosZ)
	{
	aWsEvent.Pointer()->SetPointerZ(aPosZ);
	}
TInt TAdvancedPointerEventHelper::Z(const TWsEvent& aWsEvent)
	{
	return aWsEvent.Pointer()->iData.multiPos3D.iPosZ;
	}
void TAdvancedPointerEventHelper::SetPointerNumber(TWsEvent& aWsEvent, TUint8 aPointerNumber)
	{
	aWsEvent.Pointer()->SetPointerNumber(aPointerNumber);
	}
TUint8 TAdvancedPointerEventHelper::PointerNumber(const TWsEvent& aWsEvent)
	{
	return aWsEvent.Pointer()->iData.multiPos3D.iPointerNumber;
	}
void TAdvancedPointerEventHelper::InitAdvancedPointerEvent(TWsEvent& aEvent, TPointerEvent::TType aType, TUint aModifiers, const TPoint3D &aPoint3D, const TPoint &aParentPosition, TUint8 aPointerNumber)
	{
	aEvent.Pointer()->Init(aType, aModifiers, aPoint3D, aPointerNumber);
	aEvent.Pointer()->iParentPosition = aParentPosition;
	};
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    int posted = 0;
    SDL_keysym keysym;
    
//    SDL_TRACE1("hws %d", aWsEvent.Type());

    switch (aWsEvent.Type())
		{    
    case EEventPointer: /* Mouse pointer events */
		{

        const TPointerCursorMode mode =  Private->EPOC_WsSession.PointerCursorMode();

        if(mode == EPointerCursorNone) 
            {
            return 0; //TODO: Find out why events are get despite of cursor should be off
            }

        const TPointerEvent* pointerEvent = aWsEvent.Pointer();
        TPoint mousePos = pointerEvent->iPosition;

        /*!! TODO Pointer do not yet work properly
        //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!

        if (Private->EPOC_ShrinkedHeight) {
            mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
        }
        if (Private->EPOC_ShrinkedWidth) {
            mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
        }
        */

		posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */

		switch (pointerEvent->iType)
			{
        case TPointerEvent::EButton1Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
			break;
        case TPointerEvent::EButton1Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
			break;
        case TPointerEvent::EButton2Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
			break;
		case TPointerEvent::EButton2Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
			break;
        case TPointerEvent::EButton3Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
			break;
        case TPointerEvent::EButton3Up:
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
			break;
			} // switch
        break;
	    }
    
    case EEventKeyDown: /* Key events */
    {
#ifdef SYMBIAN_CRYSTAL
		// special case: 9300/9500 rocker down, simulate left mouse button
		if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
			{
            const TPointerCursorMode mode =  Private->EPOC_WsSession.PointerCursorMode();
            if(mode != EPointerCursorNone) 
                posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
			}
#endif
       (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
            
#ifndef DISABLE_JOYSTICK
        /* Special handling */
        switch((int)keysym.sym) {
        case SDLK_CAPSLOCK:
            if (!isCursorVisible) {
                /* Enable virtual cursor */
	            HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
            }
            else {
                /* Disable virtual cursor */
                HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
            }
            isCursorVisible = !isCursorVisible;
            break;
        }
#endif        
	    posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
        break;
	} 

    case EEventKeyUp: /* Key events */
		{
#ifdef SYMBIAN_CRYSTAL
		// special case: 9300/9500 rocker up, simulate left mouse button
		if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
			{
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
			}
#endif
	    posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym));
        break;
		}
    
    case EEventFocusGained: /* SDL window got focus */
	    {
        Private->EPOC_IsWindowFocused = ETrue;
		posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
        /* Draw window background and screen buffer */
        DisableKeyBlocking(_this);  //Markus: guess why:-)
 
        RedrawWindowL(_this);  
        break;
	    }

    case EEventFocusLost: /* SDL window lost focus */
		{
/*        
        CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
        bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode);
        Private->EPOC_WsScreen->CopyScreenToBitmap(bmp);
        Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
        Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size()));
	    Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp);
	    Private->EPOC_WsWindow.EndRedraw();
	    Private->EPOC_WindowGc->Deactivate();
        bmp->Save(_L("C:\\scr.mbm"));
        delete bmp;
*/       

		Private->EPOC_IsWindowFocused = EFalse;

		posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);

        RWsSession s;
        s.Connect();
        RWindowGroup g(s);
        g.Construct(TUint32(&g), EFalse);
        g.EnableReceiptOfFocus(EFalse);
        RWindow w(s);
        w.Construct(g, TUint32(&w));
        w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size());
        w.SetOrdinalPosition(0);
        w.Activate();
        w.Close();
        g.Close();
        s.Close();

/*
        Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1);

            
        SDL_Delay(500);
        TInt focus = -1;
        while(focus < 0)
            {
            const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup();
            if(curr != Private->EPOC_WsWindowGroupID)
                focus = curr;
            else
                SDL_Delay(500);
            }

        if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID))
            {
            Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1);
            SDL_Delay(500);
            Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0);
            }
*/
        /*//and the request redraw
        TRawEvent redrawEvent;
        redrawEvent.Set(TRawEvent::ERedraw);
        Private->EPOC_WsSession.SimulateRawEvent(redrawEvent);
        Private->EPOC_WsSession.Flush();*/
#if 0
        //!! Not used
        // Wait and eat events until focus is gained again
	    while (ETrue) {
            Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            User::WaitForRequest(Private->EPOC_WsEventStatus);
		    Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
            TInt eventType = Private->EPOC_WsEvent.Type();
		    Private->EPOC_WsEventStatus = KRequestPending;
		    //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            if (eventType == EEventFocusGained) {
                RedrawWindowL(_this);
                break;
            }
	    }
#endif
        break;
	    }

    case EEventModifiersChanged: 
    {
	    TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
        TUint modstate = KMOD_NONE;
        if (modEvent->iModifiers == EModifierLeftShift)
            modstate |= KMOD_LSHIFT;
        if (modEvent->iModifiers == EModifierRightShift)
            modstate |= KMOD_RSHIFT;
        if (modEvent->iModifiers == EModifierLeftCtrl)
            modstate |= KMOD_LCTRL;
        if (modEvent->iModifiers == EModifierRightCtrl)
            modstate |= KMOD_RCTRL;
        if (modEvent->iModifiers == EModifierLeftAlt)
            modstate |= KMOD_LALT;
        if (modEvent->iModifiers == EModifierRightAlt)
            modstate |= KMOD_RALT;
        if (modEvent->iModifiers == EModifierLeftFunc)
            modstate |= KMOD_LMETA;
        if (modEvent->iModifiers == EModifierRightFunc)
            modstate |= KMOD_RMETA;
        if (modEvent->iModifiers == EModifierCapsLock)
            modstate |= KMOD_CAPS;
        SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
        break;
    }
    default:            
        break;
	} 
	
    return posted;
}
Beispiel #29
0
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    int posted = 0;
    SDL_keysym keysym;


    switch (aWsEvent.Type()) {
    
    case EEventPointer: /* Mouse pointer events */
    {
        const TPointerEvent* pointerEvent = aWsEvent.Pointer();
        TPoint mousePos = pointerEvent->iPosition;

        //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!

        if (Private->EPOC_ShrinkedHeight) {
            mousePos.iY <<= 1; /* Scale y coordinate to shrinked screen height */
        }
		posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
        if (pointerEvent->iType==TPointerEvent::EButton1Down) {
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton1Up) {
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton2Down) {
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
        }
        else if (pointerEvent->iType==TPointerEvent::EButton2Up) {
			posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
        }
	    //!!posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
        break;
    }
    
    case EEventKeyDown: /* Key events */
    {
       (void*)TranslateKey(aWsEvent.Key()->iScanCode, &keysym);
        
        /* Special handling */
        switch((int)keysym.sym) {
        case SDLK_CAPSLOCK:
            if (!isCursorVisible) {
                /* Enable virtual cursor */
	            HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
            }
            else {
                /* Disable virtual cursor */
                HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
            }
            isCursorVisible = !isCursorVisible;
            break;
        }
        
	    posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
        break;
	} 

    case EEventKeyUp: /* Key events */
    {
	    posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
        break;
	} 
    
    case EEventFocusGained: /* SDL window got focus */
    {
        //Private->EPOC_IsWindowFocused = ETrue;
        /* Draw window background and screen buffer */
        RedrawWindowL(_this);  
        break;
    }

    case EEventFocusLost: /* SDL window lost focus */
    {
        //Private->EPOC_IsWindowFocused = EFalse;

        // Wait and eat events until focus is gained again
        /*
	    while (ETrue) {
            Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            User::WaitForRequest(Private->EPOC_WsEventStatus);
		    Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
            TInt eventType = Private->EPOC_WsEvent.Type();
		    Private->EPOC_WsEventStatus = KRequestPending;
		    //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
            if (eventType == EEventFocusGained) {
                RedrawWindowL(_this);
                break;
            }
	    }
        */
        break;
    }

    case EEventModifiersChanged: 
    {
	    TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
        TUint modstate = KMOD_NONE;
        if (modEvent->iModifiers == EModifierLeftShift)
            modstate |= KMOD_LSHIFT;
        if (modEvent->iModifiers == EModifierRightShift)
            modstate |= KMOD_RSHIFT;
        if (modEvent->iModifiers == EModifierLeftCtrl)
            modstate |= KMOD_LCTRL;
        if (modEvent->iModifiers == EModifierRightCtrl)
            modstate |= KMOD_RCTRL;
        if (modEvent->iModifiers == EModifierLeftAlt)
            modstate |= KMOD_LALT;
        if (modEvent->iModifiers == EModifierRightAlt)
            modstate |= KMOD_RALT;
        if (modEvent->iModifiers == EModifierLeftFunc)
            modstate |= KMOD_LMETA;
        if (modEvent->iModifiers == EModifierRightFunc)
            modstate |= KMOD_RMETA;
        if (modEvent->iModifiers == EModifierCapsLock)
            modstate |= KMOD_CAPS;
        SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
        break;
    }
    default:            
        break;
	} 
	
    return posted;
}
Beispiel #30
0
// -----------------------------------------------------------------------------
// CGameController::HandleWsEvent
// This function is called by the CWsEventReceiver 
// Active Object, whenever it receives a Windows Server
// event.
// -----------------------------------------------------------------------------
//
void CGameController::HandleWsEvent( const TWsEvent& aWsEvent )
{
    TInt eventType = aWsEvent.Type();
     
    // Handle Key and Screen Size change Events.
    switch( eventType )
    {
        case EEventKeyDown:
        {
            if( iGame )
                iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, EFalse );
            
            break;            
        }
        case EEventKeyUp:
        {
            if( iGame )
                iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, ETrue );
            
            break;            
        }        
        case( EEventScreenDeviceChanged ): // The screen size has changed.
        {
            TPixelsTwipsAndRotation pixnrot; 
            iWsScreenDevice->GetScreenModeSizeAndRotation( 
                                  iWsScreenDevice->CurrentScreenMode(),
                                  pixnrot 
                                                         );       
            if( pixnrot.iPixelSize != iWindow->Size() )
            {
                 
                // Update the window.
                iWindow->SetExtent( TPoint( 0, 0 ),
                                    pixnrot.iPixelSize
                                  );                
                                        
                // If a game is running, notify it about the change.
                if( iGame )
                {
                    iGame->SetScreenSize( pixnrot.iPixelSize.iWidth,
                                          pixnrot.iPixelSize.iHeight 
                                        );                    
                    
                    // Call eglSwapBuffers after the window size has changed.
                    // This updates the window size used by egl. 
                    eglSwapBuffers( iEglDisplay, iEglSurface );                                        
                }                
                                
            }                    
            break;            
        }
        case EEventFocusLost: 
        {
            iIsAppInFocus = EFalse;
            break;
        }
        case EEventFocusGained:
        {
            iIsAppInFocus = ETrue;
            break;
        }
        case EEventWindowVisibilityChanged:
        {
            // Check if the event is for the iWindow
            if( aWsEvent.Handle() ==
                        reinterpret_cast<TUint32>( this )
                  
              )
            {
                if( aWsEvent.VisibilityChanged()->iFlags &
                    TWsVisibilityChangedEvent::ECanBeSeen 
                )                
                {
                      iIsVisible = ETrue;
                }
                else
                      iIsVisible = EFalse;
                
            }                            
            break;
        }
        case EEventNull:
        case EEventKey:        
        case EEventUser:                                
        case EEventWindowGroupListChanged:
        case EEventModifiersChanged:
        case EEventSwitchOn:
        case EEventPassword:
        case EEventWindowGroupsChanged:
        case EEventErrorMessage:
        case EEventPointer:
        case EEventPointerEnter:
        case EEventPointerExit:
        case EEventPointerBufferReady:
        case EEventDragDrop:
            break;
        default:
            break;
    }        
}