/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
stage.GetRootLayer().TouchSignal().Connect( this, &TiltController::OnTouch );
CreateSensor();
+
+ // Connect signals to allow Back and Escape to exit.
+ stage.KeyEventSignal().Connect( this, &TiltController::OnKeyEvent );
}
void CreateSensor()
{
mTiltSensor = TiltSensor::Get();
- if ( mTiltSensor.Enable() )
+ if ( mTiltSensor.Start() )
{
// Get notifications when the device is tilted
mTiltSensor.TiltedSignal().Connect( this, &TiltController::OnTilted );
mTextLabel.RotateBy(pitchRot);;
}
+ /**
+ * @brief OnKeyEvent signal handler.
+ * @param[in] event The key event information
+ */
+ void OnKeyEvent( const KeyEvent& event )
+ {
+ if( event.state == KeyEvent::Down )
+ {
+ if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
private:
Application& mApplication;
TiltSensor mTiltSensor;
TextLabel mTextLabel;
};
-// Entry point for Linux & Tizen applications
-//
int DALI_EXPORT_API main( int argc, char **argv )
{
Application application = Application::New( &argc, &argv );