// -----------------------------------------------------------------------------
// 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;
    }
Exemple #2
0
/**	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;
	}
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;
    }
Exemple #4
0
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;
}
Exemple #5
0
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;
	}
// -----------------------------------------------------------------------------
// 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);
        }
    }