[Tizen] Adding deviceClass to KeyEvent Integ
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.cpp
index 7ed937f..960174a 100644 (file)
@@ -34,10 +34,34 @@ const int KEY_INVALID_CODE = -1;
 
 struct KeyEventImpl
 {
+  KeyEventImpl()
+  : deviceName( "" ),
+    deviceClass( DevelKeyEvent::DeviceClass::NONE )
+  {
+  }
+
+  KeyEventImpl& operator=( const KeyEventImpl& rhs )
+  {
+    if( this != &rhs )
+    {
+      deviceName = rhs.deviceName;
+      deviceClass = rhs.deviceClass;
+    }
+
+    return *this;
+  }
+
+  KeyEventImpl( const KeyEventImpl& rhs )
+  {
+    deviceName =  rhs.deviceName;
+    deviceClass = rhs.deviceClass;
+  }
+
   std::string deviceName;
+  DevelKeyEvent::DeviceClass::Type deviceClass;
 };
 
-typedef std::map< KeyEvent*, KeyEventImpl*> KeyEventMap;
+typedef std::map< const KeyEvent*, KeyEventImpl*> KeyEventMap;
 typedef KeyEventMap::const_iterator KeyEventMapIter;
 
 
@@ -65,8 +89,35 @@ KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int
   time(timeStamp),
   state(keyState)
 {
-  KeyEventImpl* impl = new KeyEventImpl;
-  keyEventImplMap[this] = impl;
+  keyEventImplMap[this] = new KeyEventImpl;
+}
+
+KeyEvent::KeyEvent( const KeyEvent& rhs )
+: keyPressedName( rhs.keyPressedName ),
+  keyPressed( rhs.keyPressed ),
+  keyCode( rhs.keyCode ),
+  keyModifier( rhs.keyModifier ),
+  time( rhs.time ),
+  state( rhs.state )
+{
+  keyEventImplMap[this] = new KeyEventImpl( *keyEventImplMap[ &rhs ] );
+}
+
+KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
+{
+  if( this != &rhs )
+  {
+    keyPressedName = rhs.keyPressedName;
+    keyPressed = rhs.keyPressed;
+    keyCode = rhs.keyCode;
+    keyModifier = rhs.keyModifier;
+    time = rhs.time;
+    state = rhs.state;
+
+    *keyEventImplMap[ this ] = *keyEventImplMap[ &rhs ];
+  }
+
+  return *this;
 }
 
 KeyEvent::~KeyEvent()
@@ -105,23 +156,19 @@ bool KeyEvent::IsAltModifier() const
   return false;
 }
 
-std::string DevelKeyEvent::GetDeviceName( KeyEvent& keyEvent )
+std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent )
 {
-  KeyEventMapIter search;
-
-  search = keyEventImplMap.find( &keyEvent );
-
-  std::string result = "";
+  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
 
   if( search != keyEventImplMap.end())
   {
-    result = search->second->deviceName;
+    return search->second->deviceName;
   }
 
-  return result;
+  return std::string("");
 }
 
-void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, std::string deviceName )
+void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, const std::string& deviceName )
 {
   KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
 
@@ -131,5 +178,28 @@ void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, std::string deviceName )
   }
 }
 
+DevelKeyEvent::DeviceClass::Type DevelKeyEvent::GetDeviceClass( const KeyEvent& keyEvent )
+{
+  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
+
+  DevelKeyEvent::DeviceClass::Type result = DevelKeyEvent::DeviceClass::NONE;
+
+  if( search != keyEventImplMap.end() )
+  {
+    result = search->second->deviceClass;
+  }
+
+  return result;
+}
+
+void DevelKeyEvent::SetDeviceClass( KeyEvent& keyEvent, const DeviceClass::Type& deviceClass )
+{
+  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
+
+  if( search != keyEventImplMap.end() )
+  {
+    search->second->deviceClass = deviceClass;
+  }
+}
 
 } // namespace Dali