cfd73200dd1623e00923ad99ce80f3beafd0d42a
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / common / physical-keyboard-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19
20 // CLASS HEADER
21 #include <dali/internal/input/common/physical-keyboard-impl.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/internal/system/common/singleton-service-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 Dali::PhysicalKeyboard PhysicalKeyboard::New()
36 {
37   Dali::PhysicalKeyboard keyboardHandle;
38
39   Dali::SingletonService service( SingletonService::Get() );
40   if ( service )
41   {
42     keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
43     service.Register( typeid( keyboardHandle ), keyboardHandle );
44   }
45
46   return keyboardHandle;
47 }
48
49 Dali::PhysicalKeyboard PhysicalKeyboard::Get()
50 {
51   Dali::PhysicalKeyboard keyboardHandle;
52
53   Dali::SingletonService service = SingletonService::Get();
54   if ( service )
55   {
56     BaseHandle handle = service.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
57     if( handle )
58     {
59       // If so, downcast the handle of singleton to focus manager
60       keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
61     }
62   }
63
64   return keyboardHandle;
65 }
66
67 bool PhysicalKeyboard::IsAttached() const
68 {
69   return mAttached;
70 }
71
72 void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
73 {
74   if ( mAttached != fromPhysicalKeyboard )
75   {
76     mAttached = fromPhysicalKeyboard;
77
78     Dali::PhysicalKeyboard handle( this );
79     mStatusChangedSignal.Emit( handle );
80   }
81 }
82
83 PhysicalKeyboard::~PhysicalKeyboard()
84 {
85 }
86
87 PhysicalKeyboard::PhysicalKeyboard()
88 : mAttached( false )
89 {
90 }
91
92 } // Adaptor
93
94 } // Internal
95
96 } // Dali