Hi, I have this switch-case operator and it works fine. When I press OK key it takes a picture. I want to make it after 5 sec. to send a simulate key OK. I found some sources about that , but I don't know where to put them into the Switch operator, to make them work. This is the switch
Code:
TKeyResponse CCameraExAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (!iController)
{
return EKeyWasNotConsumed;
}
if (iController->IsCameraUsedByAnotherApp())
{
return EKeyWasNotConsumed;
}
// handle autofocus requests
if ( aKeyEvent.iScanCode == KStdKeyCameraFocus
|| aKeyEvent.iScanCode == KStdKeyCameraFocus2 )
{
TEngineState state = iController->GetEngineState();
if ( state != EEngineIdle && state != EFocusing )
{
return EKeyWasConsumed;
}
switch ( aType )
{
case EEventKeyDown:
iController->StartFocusL();
break;
case EEventKeyUp:
iController->FocusCancel();
break;
default:
break;
}
return EKeyWasConsumed;
}
switch ( aKeyEvent.iCode )
{
case EKeyUpArrow:
{
// Increase the zoom factor if possible. It has reached the high
// limit then it will not change.
if ( iCameraMode == EViewFinding )
iController->SetZoomL( ETrue );
return EKeyWasConsumed;
}
case EKeyDownArrow:
{
// Decrease the zoom factor if possible. It has reached the low
// limit then it will not change.
if ( iCameraMode == EViewFinding )
iController->SetZoomL( EFalse );
return EKeyWasConsumed;
}
case EKeyOK:
case EKeyCamera:
case KKeyCameraShutter:
case EKeyCameraNseries2:
{
DoSnapL();
return EKeyWasConsumed;
}
default:
break;
}
return EKeyWasNotConsumed;
}
This is what I want to implement. Can I do that?
Code:
User::After(3000000);
TWsEvent event;
RWsSession wsSession=CCoeEnv::Static()->WsSession();
TInt id = wsSession.GetFocusWindowGroup();
event.SetType(EEventKey);
event.SetTimeNow();
event.Key()->iCode = EKeyOK;
event.Key()->iModifiers = 0;
event.Key()->iRepeats = 0;
event.Key()->iScanCode = EKeyOK;
wsSession.SendEventToWindowGroup( id, event );
wsSession.Flush();
or this:
Code:
RWsSession wsSession=CCoeEnv::Static()->WsSession();
TKeyEvent keyEvent;
keyEvent.iCode = EKeyYes; //member of TKeyCode
keyEvent.iScanCode = EStdKeyYes;
keyEvent.iModifiers = 0;
keyEvent.iRepeats = 0;
wsSession.SimulateKeyEvent(keyEvent);
wsSession.Flush();