X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fubuntu%2Ftilt-sensor-impl-ubuntu.cpp;h=95f5724a5f535b1642959262ab393e3479d09298;hb=9b639a223f9e0c389f646bbb6f09608476495c3d;hp=b30b0de7842ece45310c0a12901970b1af0999cf;hpb=a8a3a09e8281be7f2e690cd53a56e7f45e80f03d;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp b/adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp index b30b0de..95f5724 100644 --- a/adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp +++ b/adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp @@ -25,24 +25,26 @@ #include // INTERNAL INCLUDES -#include +#include namespace // unnamed namespace { +const char* const SIGNAL_TILTED = "tilted"; + const int NUMBER_OF_SAMPLES = 10; const float MAX_ACCELEROMETER_XY_VALUE = 9.8f; // Type Registration -Dali::BaseHandle Create() +Dali::BaseHandle GetInstance() { return Dali::Internal::Adaptor::TiltSensor::Get(); } -Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), Create ); +Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), GetInstance ); -Dali::SignalConnectorType signalConnector1( typeRegistration, Dali::TiltSensor::SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal ); +Dali::SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal ); } // unnamed namespace @@ -66,10 +68,11 @@ Dali::TiltSensor TiltSensor::Get() { Dali::TiltSensor sensor; - if ( Adaptor::IsAvailable() ) + Dali::SingletonService service( SingletonService::Get() ); + if ( service ) { // Check whether the keyboard focus manager is already created - Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::TiltSensor ) ); + Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TiltSensor ) ); if(handle) { // If so, downcast the handle of singleton to keyboard focus manager @@ -78,9 +81,8 @@ Dali::TiltSensor TiltSensor::Get() else { // Create a singleton instance - Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) ); sensor = TiltSensor::New(); - adaptorImpl.RegisterSingleton( typeid( sensor ), sensor ); + service.Register( typeid( sensor ), sensor ); handle = sensor; } } @@ -90,10 +92,10 @@ Dali::TiltSensor TiltSensor::Get() TiltSensor::~TiltSensor() { - Disable(); + Stop(); } -bool TiltSensor::Enable() +bool TiltSensor::Start() { // Make sure sensor API is responding bool success = Update(); @@ -116,7 +118,7 @@ bool TiltSensor::Enable() return success; } -void TiltSensor::Disable() +void TiltSensor::Stop() { if ( mTimer ) { @@ -125,7 +127,7 @@ void TiltSensor::Disable() } } -bool TiltSensor::IsEnabled() const +bool TiltSensor::IsStarted() const { return ( mTimer && mTimer.IsRunning() ); } @@ -145,9 +147,9 @@ Quaternion TiltSensor::GetRotation() const return mRotation; } -TiltSensor::TiltedSignalV2& TiltSensor::TiltedSignal() +TiltSensor::TiltedSignalType& TiltSensor::TiltedSignal() { - return mTiltedSignalV2; + return mTiltedSignal; } void TiltSensor::SetUpdateFrequency( float frequencyHertz ) @@ -185,8 +187,7 @@ bool TiltSensor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface bool connected( true ); TiltSensor* sensor = dynamic_cast( object ); - if( sensor && - Dali::TiltSensor::SIGNAL_TILTED == signalName ) + if( sensor && ( SIGNAL_TILTED == signalName ) ) { sensor->TiltedSignal().Connect( tracker, functor ); } @@ -205,7 +206,7 @@ TiltSensor::TiltSensor() mSensorFrameworkHandle( -1 ), mRoll( 0.0f ), mPitch( 0.0f ), - mRotation( 0.0f, Vector3::YAXIS ), + mRotation( Dali::ANGLE_0, Vector3::YAXIS ), mRotationThreshold( 0.0f ) { mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f ); @@ -226,10 +227,10 @@ bool TiltSensor::Update() mPitch = newPitch; mRotation = newRotation; - if ( !mTiltedSignalV2.Empty() ) + if ( !mTiltedSignal.Empty() ) { Dali::TiltSensor handle( this ); - mTiltedSignalV2.Emit( handle ); + mTiltedSignal.Emit( handle ); } }