[dali_2.3.31] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / common / physical-keyboard-impl.h
1 #ifndef DALI_INTERNAL_PHYSICAL_KEYBOARD_H
2 #define DALI_INTERNAL_PHYSICAL_KEYBOARD_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/physical-keyboard.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 class PhysicalKeyboard : public BaseObject
34 {
35 public:
36   /**
37    * Creates a new instance of the PhysicalKeyboard.
38    */
39   static Dali::PhysicalKeyboard New();
40
41   /**
42    * Gets the singleton instance of the Physical Keyboard.
43    */
44   static Dali::PhysicalKeyboard Get();
45
46   /**
47    * @copydoc Dali::PhysicalKeyboard::IsAttached()
48    */
49   bool IsAttached() const;
50
51   /**
52    * Should be called by the EventHandler when a key is received. If it's received from a physical
53    * keyboard then the parameter should be true.
54    * @param[in]  fromPhysicalKeyboard  true if received from a physical keyboard, false otherwise.
55    */
56   void KeyReceived(bool fromPhysicalKeyboard);
57
58   // Signals
59
60   /**
61    * @copydoc Dali::PhysicalKeyboard::StatusChangedSignal()
62    */
63   Dali::PhysicalKeyboard::PhysicalKeyboardSignalType& StatusChangedSignal()
64   {
65     return mStatusChangedSignal;
66   }
67
68 protected:
69   /**
70    * A reference counted object may only be deleted by calling Unreference()
71    */
72   ~PhysicalKeyboard() override;
73
74 private:
75   // Undefined
76   PhysicalKeyboard(const PhysicalKeyboard&);
77   PhysicalKeyboard& operator=(PhysicalKeyboard&);
78
79   /**
80    * Constructor
81    */
82   PhysicalKeyboard();
83
84 private:
85   Dali::PhysicalKeyboard::PhysicalKeyboardSignalType mStatusChangedSignal; ///< Status changed signal
86   bool                                               mAttached;            ///< true if the physical keyboard is attached, false otherwise
87 };
88
89 } // namespace Adaptor
90
91 } // namespace Internal
92
93 // Helpers for public-api forwarding methods
94
95 inline static Internal::Adaptor::PhysicalKeyboard& GetImplementation(PhysicalKeyboard& keyboard)
96 {
97   DALI_ASSERT_ALWAYS(keyboard && "PhysicalKeyboard handle is empty");
98
99   BaseObject& handle = keyboard.GetBaseObject();
100
101   return static_cast<Internal::Adaptor::PhysicalKeyboard&>(handle);
102 }
103
104 inline static const Internal::Adaptor::PhysicalKeyboard& GetImplementation(const PhysicalKeyboard& keyboard)
105 {
106   DALI_ASSERT_ALWAYS(keyboard && "PhysicalKeyboard handle is empty");
107
108   const BaseObject& handle = keyboard.GetBaseObject();
109
110   return static_cast<const Internal::Adaptor::PhysicalKeyboard&>(handle);
111 }
112
113 } // namespace Dali
114
115 #endif // DALI_INTERNAL_PHYSICAL_KEYBOARD_H