2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <physical-keyboard-impl.h>
24 #include <adaptor-impl.h>
35 Dali::PhysicalKeyboard PhysicalKeyboard::New()
37 Dali::PhysicalKeyboard keyboardHandle;
39 if ( Adaptor::IsAvailable() )
41 Dali::Adaptor& adaptor = Adaptor::Get();
42 keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
43 adaptor.RegisterSingleton( typeid( keyboardHandle ), keyboardHandle );
46 return keyboardHandle;
49 Dali::PhysicalKeyboard PhysicalKeyboard::Get()
51 Dali::PhysicalKeyboard keyboardHandle;
53 // Ensure the adaptor has been created
54 if ( Adaptor::IsAvailable() )
56 Dali::Adaptor& adaptor = Adaptor::Get();
58 BaseHandle handle = adaptor.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
61 // If so, downcast the handle of singleton to focus manager
62 keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
66 return keyboardHandle;
69 bool PhysicalKeyboard::IsAttached() const
74 void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
76 if ( mAttached != fromPhysicalKeyboard )
78 mAttached = fromPhysicalKeyboard;
80 Dali::PhysicalKeyboard handle( this );
81 mStatusChangedSignal.Emit( handle );
85 PhysicalKeyboard::~PhysicalKeyboard()
89 PhysicalKeyboard::PhysicalKeyboard()