Adding deviceClass to KeyEvent Integ 48/125448/4
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 17 Apr 2017 07:36:28 +0000 (16:36 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 21 Apr 2017 08:27:39 +0000 (17:27 +0900)
Change-Id: I8cf899bf17d93d0462571b01d69697bf58a6ff22

automated-tests/src/dali/utc-Dali-KeyEvent.cpp
automated-tests/src/dali/utc-Dali-Stage.cpp
dali/devel-api/events/key-event-devel.h
dali/integration-api/events/key-event-integ.cpp
dali/integration-api/events/key-event-integ.h
dali/internal/event/events/key-event-impl.cpp [new file with mode: 0644]
dali/internal/event/events/key-event-impl.h [new file with mode: 0644]
dali/internal/event/events/key-event-processor.cpp
dali/internal/file.list
dali/public-api/events/key-event.cpp

index fc7aeae..0429ffb 100644 (file)
@@ -311,8 +311,9 @@ int UtcDaliIntegrationKeyEvent(void)
     const unsigned long timeStamp(132);
     const Integration::KeyEvent::State keyState(Integration::KeyEvent::Up);
     const std::string deviceName("hwKeyboard");
+    const DevelKeyEvent::DeviceClass::Type deviceClass = DevelKeyEvent::DeviceClass::KEYBOARD;
 
-    Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState, deviceName );
+    Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState, deviceName, deviceClass );
     DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION );
     DALI_TEST_CHECK( keyEvent.keyName == keyName );
     DALI_TEST_CHECK( keyEvent.keyString == keyString );
@@ -321,6 +322,7 @@ int UtcDaliIntegrationKeyEvent(void)
     DALI_TEST_EQUALS( keyEvent.time, timeStamp, TEST_LOCATION );
     DALI_TEST_EQUALS( keyEvent.state, keyState, TEST_LOCATION);
     DALI_TEST_EQUALS( keyEvent.deviceName, deviceName, TEST_LOCATION);
+    DALI_TEST_EQUALS( keyEvent.deviceClass, deviceClass, TEST_LOCATION);
   }
   END_TEST;
 }
@@ -341,6 +343,7 @@ int UtcDaliIntegrationKeyEventConvertor(void)
   DALI_TEST_EQUALS( keyEvent.time, 0lu, TEST_LOCATION );
   DALI_TEST_EQUALS( keyEvent.state, Integration::KeyEvent::Down, TEST_LOCATION);
   DALI_TEST_EQUALS( keyEvent.deviceName, "", TEST_LOCATION);
+  DALI_TEST_EQUALS( keyEvent.deviceClass, DevelKeyEvent::DeviceClass::NONE, TEST_LOCATION);
 
   END_TEST;
 }
@@ -353,12 +356,16 @@ int UtcDaliKeyEventSetDeviceName(void)
 
   DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceName( event ), "", TEST_LOCATION);
 
-  DevelKeyEvent::SetDeviceName( event, "finger" );
+  END_TEST;
+}
+
+int UtcDaliKeyEventSetDeviceClass(void)
+{
+  TestApplication application;
 
-  DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceName( event ), "finger", TEST_LOCATION);
+  KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down);
 
-  KeyEvent event2;
-  DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceName( event2 ), "", TEST_LOCATION);
+  DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceClass( event ), DevelKeyEvent::DeviceClass::NONE, TEST_LOCATION);
 
   END_TEST;
 }
index b8c3504..24c13e7 100644 (file)
@@ -883,7 +883,7 @@ int UtcDaliStageKeyEventGeneratedSignalP(void)
   KeyEventGeneratedReceivedFunctor functor2( data2 );
   GetImplementation( stage ).ConnectSignal( &application, "keyEventGenerated", functor2 );
 
-  Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -894,7 +894,7 @@ int UtcDaliStageKeyEventGeneratedSignalP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event2 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -905,7 +905,7 @@ int UtcDaliStageKeyEventGeneratedSignalP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event3 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -916,7 +916,7 @@ int UtcDaliStageKeyEventGeneratedSignalP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event4 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -936,7 +936,7 @@ int UtcDaliStageSignalKeyEventP(void)
   KeyEventReceivedFunctor functor( data );
   stage.KeyEventSignal().Connect( &application, functor );
 
-  Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -947,7 +947,7 @@ int UtcDaliStageSignalKeyEventP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event2 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -958,7 +958,7 @@ int UtcDaliStageSignalKeyEventP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event3 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
@@ -969,7 +969,7 @@ int UtcDaliStageSignalKeyEventP(void)
 
   data.Reset();
 
-  Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME );
+  Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
   application.ProcessEvent( event4 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
index 13ffd20..ec2a85e 100644 (file)
@@ -26,24 +26,45 @@ namespace Dali
 
 namespace DevelKeyEvent
 {
-  /**
-   * @brief Get the device name the key event originated from
-   *
-   * @param[in] keyEvent the KeyEvent to retrieve the device name from
-   * @return the device name
-   */
-  std::string GetDeviceName( const KeyEvent& keyEvent );
-
-  /**
-   * @brief Set the device name to the KeyEvent
-   *
-   * @param[in] keyEvent the KeyEvent to set the device name on
-   * @param[in] deviceName device name string to set
-   */
-  void SetDeviceName( KeyEvent& keyEvent, const std::string& deviceName );
-
-}
-
-}
+
+namespace DeviceClass
+{
+
+/**
+ * @brief An enum of Device Classe types.
+ */
+enum Type
+{
+  NONE,      ///< Not a device
+  USER,      ///< The user/seat (the user themselves)
+  KEYBOARD,  ///< A regular keyboard, numberpad or attached buttons
+  MOUSE,     ///< A mouse, trackball or touchpad relative motion device
+  TOUCH,     ///< A touchscreen with fingers or stylus
+  PEN,       ///< A special pen device
+  POINTER,   ///< A laser pointer, wii-style or 7"minority report" pointing device
+  GAMEPAD    ///< A gamepad controller or joystick
+};
+
+} // namespace DeviceClass
+
+/**
+ * @brief Get the device name the key event originated from
+ *
+ * @param[in] keyEvent The KeyEvent to retrieve the device name from
+ * @return The device name
+ */
+DALI_IMPORT_API std::string GetDeviceName( const KeyEvent& keyEvent );
+
+/**
+ * @brief Get the device class the key event originated from
+ *
+ * @param[in] keyEvent The KeyEvent to retrieve the device class from
+ * @return The device class
+ */
+DALI_IMPORT_API DeviceClass::Type GetDeviceClass( const KeyEvent& keyEvent );
+
+} // namespace DevelKeyEvent
+
+} // namespace Dali
 
 #endif  //DALI_KEY_EVENT_DEVEL_H
index ed46ccf..b3bcdee 100644 (file)
@@ -25,39 +25,42 @@ namespace Integration
 {
 
 KeyEvent::KeyEvent()
-: Event(Key),
+: Event( Key ),
   keyName(),
   keyString(),
-  keyCode(-1),
-  keyModifier(0),
-  time(0),
-  state(KeyEvent::Down),
-  deviceName("")
+  keyCode( -1 ),
+  keyModifier( 0 ),
+  time( 0 ),
+  state( KeyEvent::Down ),
+  deviceName( "" ),
+  deviceClass( DevelKeyEvent::DeviceClass::NONE )
 {
 }
 
 KeyEvent::KeyEvent( const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,
-                    unsigned long timeStamp, const State& keyState, const std::string deviceName )
-: Event(Key),
-  keyName(keyName),
-  keyString(keyString),
-  keyCode(keyCode),
-  keyModifier(keyModifier),
-  time(timeStamp),
-  state(keyState),
-  deviceName(deviceName)
+                    unsigned long timeStamp, const State& keyState, const std::string deviceName, const DevelKeyEvent::DeviceClass::Type deviceClass )
+: Event( Key ),
+  keyName( keyName ),
+  keyString( keyString ),
+  keyCode( keyCode ),
+  keyModifier( keyModifier ),
+  time( timeStamp ),
+  state( keyState ),
+  deviceName( deviceName ),
+  deviceClass( deviceClass )
 {
 }
 
 KeyEvent::KeyEvent( const Dali::KeyEvent& event )
-: Event(Key),
+: Event( Key ),
   keyName( event.keyPressedName ),
   keyString( event.keyPressed ),
   keyCode( event.keyCode ),
   keyModifier( event.keyModifier ),
   time( event.time ),
   state( static_cast< Integration::KeyEvent::State >( event.state ) ),
-  deviceName("")
+  deviceName( "" ),
+  deviceClass( DevelKeyEvent::DeviceClass::NONE )
 {
 }
 
index e448a30..d98970d 100644 (file)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/events/event.h>
 #include <dali/public-api/events/key-event.h>
+#include <dali/devel-api/events/key-event-devel.h>
 
 namespace Dali DALI_IMPORT_API
 {
@@ -62,6 +63,7 @@ struct KeyEvent : public Event
    * @param[in]  timeStamp     The time (in ms) that the key event occurred.
    * @param[in]  keyState      The state of the key event.
    * @param[in]  deviceName    Name of device KeyEvent originated from
+   * @param[in]  deviceClass   Class of device KeyEvent originated from
    */
   KeyEvent(const std::string& keyName,
            const std::string& keyString,
@@ -69,7 +71,8 @@ struct KeyEvent : public Event
            int keyModifier,
            unsigned long timeStamp,
            const State& keyState,
-           const std::string deviceName );
+           const std::string deviceName,
+           const DevelKeyEvent::DeviceClass::Type deviceClass );
 
   /*
    * Constructor, creates a Integration::KeyEvent from a Dali::KeyEvent
@@ -120,6 +123,10 @@ struct KeyEvent : public Event
    */
   std::string deviceName;
 
+  /**
+   * Class of device KeyEvent originated from
+   */
+  DevelKeyEvent::DeviceClass::Type deviceClass;
 };
 
 } // namespace Integration
diff --git a/dali/internal/event/events/key-event-impl.cpp b/dali/internal/event/events/key-event-impl.cpp
new file mode 100644 (file)
index 0000000..e04d8c8
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2017 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/internal/event/events/key-event-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/common/map-wrapper.h>
+
+namespace Dali
+{
+
+namespace
+{
+
+typedef std::map< const KeyEvent*, Internal::KeyEventImpl*> KeyEventMap;
+typedef KeyEventMap::iterator KeyEventMapIter;
+
+KeyEventMap keyEventImplMap;
+
+}
+
+namespace Internal
+{
+
+KeyEventImpl::KeyEventImpl( KeyEvent* keyEvent )
+: mDeviceName( "" ),
+  mDeviceClass( DevelKeyEvent::DeviceClass::NONE )
+{
+  keyEventImplMap[keyEvent] = this;
+}
+
+KeyEventImpl::~KeyEventImpl()
+{
+  for( KeyEventMapIter iter = keyEventImplMap.begin(); iter != keyEventImplMap.end(); ++iter )
+  {
+    if( this == iter->second )
+    {
+      keyEventImplMap.erase( iter );
+      break;
+    }
+  }
+}
+
+KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs )
+{
+  if( this != &rhs )
+  {
+    mDeviceName = rhs.mDeviceName;
+    mDeviceClass = rhs.mDeviceClass;
+  }
+
+  return *this;
+}
+
+std::string KeyEventImpl::GetDeviceName() const
+{
+  return mDeviceName;
+}
+
+void KeyEventImpl::SetDeviceName( const std::string& deviceName )
+{
+  mDeviceName = deviceName;
+}
+
+DevelKeyEvent::DeviceClass::Type KeyEventImpl::GetDeviceClass() const
+{
+  return mDeviceClass;
+}
+
+void KeyEventImpl::SetDeviceClass( const DevelKeyEvent::DeviceClass::Type& deviceClass )
+{
+  mDeviceClass = deviceClass;
+}
+
+} // namsespace Internal
+
+Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent )
+{
+  return keyEventImplMap[keyEvent];
+}
+
+const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent )
+{
+  return keyEventImplMap[keyEvent];
+}
+
+} // namespace Dali
diff --git a/dali/internal/event/events/key-event-impl.h b/dali/internal/event/events/key-event-impl.h
new file mode 100644 (file)
index 0000000..57b8cbe
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef __DALI_INTERNAL_KEY_EVENT_H__
+#define __DALI_INTERNAL_KEY_EVENT_H__
+
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/events/key-event.h>
+#include <dali/devel-api/events/key-event-devel.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+struct KeyEventImpl
+{
+public:
+
+  /**
+   * @brief Constructor.
+   */
+  KeyEventImpl( Dali::KeyEvent* keyEvent );
+
+  /**
+   * @brief Destructor.
+   */
+  ~KeyEventImpl();
+
+  /**
+   * @brief Assignment operator.
+   * @param[in] rhs A reference to the copied handle
+   * @return A reference to this
+   */
+  KeyEventImpl& operator=( const KeyEventImpl& rhs );
+
+  /**
+   * @brief Get the device name the key event originated from
+   *
+   * @param[in] keyEvent The KeyEvent to retrieve the device name from
+   * @return The device name
+   */
+   std::string GetDeviceName() const;
+
+  /**
+   * @brief Set the device name to the KeyEvent
+   *
+   * @param[in] keyEvent The KeyEvent to set the device name on
+   * @param[in] deviceName Device name string to set
+   */
+  void SetDeviceName( const std::string& deviceName );
+
+  /**
+   * @brief Get the device class the key event originated from
+   *
+   * @param[in] keyEvent The KeyEvent to retrieve the device class from
+   * @return The device class
+   */
+  DevelKeyEvent::DeviceClass::Type GetDeviceClass() const;
+
+  /**
+   * @brief Set the device class to the KeyEvent
+   *
+   * @param[in] keyEvent The KeyEvent to set the device class on
+   * @param[in] deviceClass Device class to set
+   */
+  void SetDeviceClass( const DevelKeyEvent::DeviceClass::Type& deviceClass );
+
+private:
+
+  // Undefined
+  KeyEventImpl();
+
+  // Undefined
+  KeyEventImpl( const KeyEventImpl& rhs );
+
+private:
+
+  std::string mDeviceName;
+  DevelKeyEvent::DeviceClass::Type mDeviceClass;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent );
+
+const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent );
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_KEY_EVENT_H__
index 9d5b6de..bfc1f43 100644 (file)
@@ -19,8 +19,8 @@
 #include <dali/internal/event/events/key-event-processor.h>
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/events/key-event-devel.h>
 #include <dali/public-api/events/key-event.h>
+#include <dali/internal/event/events/key-event-impl.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/common/stage-impl.h>
 #include <dali/integration-api/events/key-event-integ.h>
@@ -43,8 +43,11 @@ KeyEventProcessor::~KeyEventProcessor()
 void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
 {
   bool consumed = false;
-  KeyEvent keyEvent(event.keyName, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<KeyEvent::State>(event.state));
-  DevelKeyEvent::SetDeviceName( keyEvent, event.deviceName );
+  KeyEvent keyEvent(event.keyName, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>(event.state));
+
+  GetImplementation( &keyEvent )->SetDeviceName( event.deviceName );
+  GetImplementation( &keyEvent )->SetDeviceClass( event.deviceClass );
+
   // Emit the key event signal from stage.
   consumed = mStage.EmitKeyEventGeneratedSignal( keyEvent );
 
index 422b028..0b2c600 100644 (file)
@@ -44,6 +44,7 @@ internal_src_files = \
   $(internal_src_dir)/event/events/actor-gesture-data.cpp \
   $(internal_src_dir)/event/events/actor-observer.cpp \
   $(internal_src_dir)/event/events/event-processor.cpp \
+  $(internal_src_dir)/event/events/key-event-impl.cpp \
   $(internal_src_dir)/event/events/key-event-processor.cpp \
   $(internal_src_dir)/event/events/gesture-detector-impl.cpp \
   $(internal_src_dir)/event/events/gesture-event-processor.cpp \
index 27e3ed4..40498f3 100644 (file)
@@ -20,7 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/events/key-event-devel.h>
-#include <dali/devel-api/common/map-wrapper.h>
+#include <dali/internal/event/events/key-event-impl.h>
 
 namespace Dali
 {
@@ -31,38 +31,6 @@ const unsigned int MODIFIER_SHIFT = 0x1;
 const unsigned int MODIFIER_CTRL  = 0x2;
 const unsigned int MODIFIER_ALT   = 0x4;
 const int KEY_INVALID_CODE = -1;
-
-struct KeyEventImpl
-{
-  KeyEventImpl()
-    :deviceName("")
-  {
-  };
-
-  KeyEventImpl& operator=( const KeyEventImpl& rhs )
-  {
-    if( this != &rhs )
-    {
-      deviceName = rhs.deviceName;
-    }
-
-    return *this;
-  }
-
-  KeyEventImpl( const KeyEventImpl& rhs )
-  {
-    deviceName =  rhs.deviceName;
-  }
-
-  std::string deviceName;
-};
-
-typedef std::map< const KeyEvent*, KeyEventImpl*> KeyEventMap;
-typedef KeyEventMap::const_iterator KeyEventMapIter;
-
-
-KeyEventMap keyEventImplMap;
-
 }
 
 KeyEvent::KeyEvent()
@@ -73,8 +41,7 @@ KeyEvent::KeyEvent()
   time(0),
   state(KeyEvent::Down)
 {
-  KeyEventImpl* impl = new KeyEventImpl;
-  keyEventImplMap[this] = impl;
+  new Internal::KeyEventImpl( this );
 }
 
 KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,unsigned long timeStamp, const State& keyState)
@@ -85,7 +52,7 @@ KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int
   time(timeStamp),
   state(keyState)
 {
-  keyEventImplMap[this] = new KeyEventImpl;
+  new Internal::KeyEventImpl( this );
 }
 
 KeyEvent::KeyEvent( const KeyEvent& rhs )
@@ -96,7 +63,8 @@ KeyEvent::KeyEvent( const KeyEvent& rhs )
   time( rhs.time ),
   state( rhs.state )
 {
-  keyEventImplMap[this] = new KeyEventImpl( *keyEventImplMap[ &rhs ] );
+  Internal::KeyEventImpl* impl = new Internal::KeyEventImpl( this );
+  *impl = *GetImplementation( &rhs );
 }
 
 KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
@@ -110,7 +78,7 @@ KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
     time = rhs.time;
     state = rhs.state;
 
-    *keyEventImplMap[ this ] = *keyEventImplMap[ &rhs ];
+    *GetImplementation( this ) = *GetImplementation( &rhs );
   }
 
   return *this;
@@ -118,8 +86,7 @@ KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
 
 KeyEvent::~KeyEvent()
 {
-  delete keyEventImplMap[this];
-  keyEventImplMap.erase( this );
+  delete GetImplementation( this );
 }
 
 bool KeyEvent::IsShiftModifier() const
@@ -154,25 +121,12 @@ bool KeyEvent::IsAltModifier() const
 
 std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent )
 {
-  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
-
-  if( search != keyEventImplMap.end())
-  {
-    return search->second->deviceName;
-  }
-
-  return std::string("");
+  return GetImplementation( &keyEvent )->GetDeviceName();
 }
 
-void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, const std::string& deviceName )
+DevelKeyEvent::DeviceClass::Type DevelKeyEvent::GetDeviceClass( const KeyEvent& keyEvent )
 {
-  KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
-
-  if( search != keyEventImplMap.end())
-  {
-    search->second->deviceName = deviceName;
-  }
+  return GetImplementation( &keyEvent )->GetDeviceClass();
 }
 
-
 } // namespace Dali