[dali_1.2.35] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.cpp
index 0a329a0..7ed937f 100644 (file)
@@ -1,22 +1,27 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
 #include <dali/public-api/events/key-event.h>
 
+// INTERNAL INCLUDES
+#include <dali/devel-api/events/key-event-devel.h>
+#include <dali/devel-api/common/map-wrapper.h>
+
 namespace Dali
 {
 
@@ -27,6 +32,17 @@ const unsigned int MODIFIER_CTRL  = 0x2;
 const unsigned int MODIFIER_ALT   = 0x4;
 const int KEY_INVALID_CODE = -1;
 
+struct KeyEventImpl
+{
+  std::string deviceName;
+};
+
+typedef std::map< KeyEvent*, KeyEventImpl*> KeyEventMap;
+typedef KeyEventMap::const_iterator KeyEventMapIter;
+
+
+KeyEventMap keyEventImplMap;
+
 }
 
 KeyEvent::KeyEvent()
@@ -34,50 +50,29 @@ KeyEvent::KeyEvent()
   keyPressed(""),
   keyCode(KEY_INVALID_CODE),
   keyModifier(0),
-  cursorOffset(0),
-  numberOfChars(0),
-  state(KeyEvent::Down)
-{
-}
-
-KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyPressed, const int& keyModifier, const int& offset, const int& characters, const State& keyState)
-: keyPressedName(keyName),
-  keyPressed(keyPressed),
-  keyCode(KEY_INVALID_CODE),
-  keyModifier(keyModifier),
-  cursorOffset(offset),
-  numberOfChars(characters),
-  time(0),
-  state(keyState)
-{
-}
-
-KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, const int& keyCode, const int& keyModifier, const int& cursorOffset, const int& numberOfChars, const State& keyState)
-: keyPressedName(keyName),
-  keyPressed(keyString),
-  keyCode(keyCode),
-  keyModifier(keyModifier),
-  cursorOffset(cursorOffset),
-  numberOfChars(numberOfChars),
   time(0),
-  state(keyState)
+  state(KeyEvent::Down)
 {
+  KeyEventImpl* impl = new KeyEventImpl;
+  keyEventImplMap[this] = impl;
 }
 
-KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, const int& keyCode, const int& keyModifier, const int& cursorOffset, const int& numberOfChars, const unsigned long& timeStamp, const State& keyState)
+KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,unsigned long timeStamp, const State& keyState)
 : keyPressedName(keyName),
   keyPressed(keyString),
   keyCode(keyCode),
   keyModifier(keyModifier),
-  cursorOffset(cursorOffset),
-  numberOfChars(numberOfChars),
   time(timeStamp),
   state(keyState)
 {
+  KeyEventImpl* impl = new KeyEventImpl;
+  keyEventImplMap[this] = impl;
 }
 
 KeyEvent::~KeyEvent()
 {
+  delete keyEventImplMap[this];
+  keyEventImplMap.erase( this );
 }
 
 bool KeyEvent::IsShiftModifier() const
@@ -110,4 +105,31 @@ bool KeyEvent::IsAltModifier() const
   return false;
 }
 
+std::string DevelKeyEvent::GetDeviceName( KeyEvent& keyEvent )
+{
+  KeyEventMapIter search;
+
+  search = keyEventImplMap.find( &keyEvent );
+
+  std::string result = "";
+
+  if( search != keyEventImplMap.end())
+  {
+    result = search->second->deviceName;
+  }
+
+  return result;
+}
+
+void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, std::string deviceName )
+{
+  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
+
+  if( search != keyEventImplMap.end())
+  {
+    search->second->deviceName = deviceName;
+  }
+}
+
+
 } // namespace Dali