Add pepper-dali
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / input-impl.h
1 #ifndef __DALI_PEPPER_INTERNAL_INPUT_H__
2 #define __DALI_PEPPER_INTERNAL_INPUT_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <pepper-dali/internal/input.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/common/intrusive-ptr.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <Ecore.h>
28
29 struct xkb_context;
30
31 namespace Dali
32 {
33
34 namespace Pepper
35 {
36
37 namespace Internal
38 {
39
40 class Input;
41 typedef IntrusivePtr<Input> InputPtr;
42
43 class Input : public BaseObject
44 {
45 public:
46
47   static InputPtr New( Pepper::Compositor compositor );
48
49   static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event );
50   static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event );
51
52   pepper_pointer_t* GetPointer();
53   pepper_keyboard_t* GetKeyboard();
54   pepper_touch_t* GetTouch();
55
56 private:
57
58   /**
59    * Construct a new Input.
60    */
61   Input();
62
63   /**
64    * A reference counted object may only be deleted by calling Unreference()
65    */
66   virtual ~Input();
67
68   /**
69    * Second-phase constructor. Must be called immediately after creating a new Input;
70    */
71   void Initialize( Pepper::Compositor& compositor );
72
73   void SetKeymap();
74
75 private:
76
77   // Undefined
78   Input( const Input& );
79
80   // Undefined
81   Input& operator=( const Input& rhs );
82
83 private: // Data
84
85   Pepper::Compositor mCompositor;
86
87   pepper_seat_t* mSeat;
88   pepper_input_device_t* mDevice;
89   pepper_pointer_t* mPointer;
90   pepper_keyboard_t* mKeyboard;
91   pepper_touch_t* mTouch;
92
93   xkb_context* mContext;
94
95   std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
96 };
97
98 } // namespace Internal
99
100 // Helpers for public-api forwarding methods
101
102 inline Pepper::Internal::Input& GetImplementation( Pepper::Input& input )
103 {
104   DALI_ASSERT_ALWAYS( input && "Input handle is empty" );
105
106   BaseObject& handle = input.GetBaseObject();
107
108   return static_cast< Internal::Input& >( handle );
109 }
110
111 inline const Pepper::Internal::Input& GetImplementation( const Pepper::Input& input )
112 {
113   DALI_ASSERT_ALWAYS( input && "Input handle is empty" );
114
115   const BaseObject& handle = input.GetBaseObject();
116
117   return static_cast< const Internal::Input& >( handle );
118 }
119
120 } // namespace Pepper
121
122 } // namespace Dali
123
124 #endif // __DALI_PEPPER_INTERNAL_INPUT_H__