Add the logical key to Integration::KeyEvent 41/193441/2
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 20 Nov 2018 07:02:20 +0000 (16:02 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 17 Dec 2018 02:11:43 +0000 (11:11 +0900)
- Should get Logical key symbol and send it to Ecore_IMF_Event

Change-Id: Idfb91eb9a60caaa8c0ceb5d0ad365710bd600f82
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali/utc-Dali-KeyEvent.cpp
automated-tests/src/dali/utc-Dali-Stage.cpp
dali/integration-api/events/key-event-integ.cpp
dali/integration-api/events/key-event-integ.h
dali/internal/event/events/key-event-impl.cpp
dali/internal/event/events/key-event-impl.h
dali/internal/event/events/key-event-processor.cpp

index df15b65..e2de6e5 100755 (executable)
@@ -295,6 +295,7 @@ int UtcDaliIntegrationKeyEvent(void)
     Integration::KeyEvent keyEvent;
     DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION );
     DALI_TEST_CHECK( keyEvent.keyName == std::string() );
+    DALI_TEST_CHECK( keyEvent.logicalKey == std::string() );
     DALI_TEST_CHECK( keyEvent.keyString == std::string() );
     DALI_TEST_EQUALS( keyEvent.keyCode, -1, TEST_LOCATION );
     DALI_TEST_EQUALS( keyEvent.keyModifier, 0, TEST_LOCATION );
@@ -304,6 +305,7 @@ int UtcDaliIntegrationKeyEvent(void)
 
   {
     const std::string keyName("keyName");
+    const std::string logicalKey("logicalKey");
     const std::string keyString("keyString");
     const int keyCode(333);
     const int keyModifier(312);
@@ -314,9 +316,10 @@ int UtcDaliIntegrationKeyEvent(void)
     const Device::Class::Type deviceClass = Device::Class::KEYBOARD;
     const Device::Subclass::Type deviceSubclass = Device::Subclass::NONE;
 
-    Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass );
+    Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass );
     DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION );
     DALI_TEST_CHECK( keyEvent.keyName == keyName );
+    DALI_TEST_CHECK( keyEvent.logicalKey == logicalKey );
     DALI_TEST_CHECK( keyEvent.keyString == keyString );
     DALI_TEST_EQUALS( keyEvent.keyCode, keyCode, TEST_LOCATION );
     DALI_TEST_EQUALS( keyEvent.keyModifier, keyModifier, TEST_LOCATION );
@@ -340,6 +343,7 @@ int UtcDaliIntegrationKeyEventConvertor(void)
 
   DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION );
   DALI_TEST_CHECK( keyEvent.keyName == TEST_STRING_1 );
+  DALI_TEST_CHECK( keyEvent.logicalKey == "" );
   DALI_TEST_CHECK( keyEvent.keyString == "i" );
   DALI_TEST_EQUALS( keyEvent.keyCode, 99, TEST_LOCATION );
   DALI_TEST_EQUALS( keyEvent.keyModifier, SHIFT_MODIFIER, TEST_LOCATION );
index 5115340..954957f 100755 (executable)
@@ -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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::Up, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event( "i", "", "i", 0, 0, 0, Integration::KeyEvent::Down, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event2( "i", "", "i", 0, 0, 0, Integration::KeyEvent::Up, "i", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event3( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::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, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+  Integration::KeyEvent event4( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
   application.ProcessEvent( event4 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
index 3be352d..db7e1bc 100755 (executable)
@@ -18,6 +18,9 @@
 // CLASS HEADER
 #include <dali/integration-api/events/key-event-integ.h>
 
+// INTERNAL INCLUDES
+#include <dali/internal/event/events/key-event-impl.h>
+
 namespace Dali
 {
 
@@ -27,6 +30,7 @@ namespace Integration
 KeyEvent::KeyEvent()
 : Event( Key ),
   keyName(),
+  logicalKey(),
   keyString(),
   keyCode( -1 ),
   keyModifier( 0 ),
@@ -39,11 +43,12 @@ KeyEvent::KeyEvent()
 {
 }
 
-KeyEvent::KeyEvent( const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,
+KeyEvent::KeyEvent( const std::string& keyName, const std::string& logicalKey, const std::string& keyString, int keyCode, int keyModifier,
                     unsigned long timeStamp, const State& keyState, const std::string& compose, const std::string& deviceName,
                     const Device::Class::Type deviceClass, const Device::Subclass::Type deviceSubclass )
 : Event( Key ),
   keyName( keyName ),
+  logicalKey( logicalKey ),
   keyString( keyString ),
   keyCode( keyCode ),
   keyModifier( keyModifier ),
@@ -59,6 +64,7 @@ KeyEvent::KeyEvent( const std::string& keyName, const std::string& keyString, in
 KeyEvent::KeyEvent( const Dali::KeyEvent& event )
 : Event( Key ),
   keyName( event.keyPressedName ),
+  logicalKey( "" ),
   keyString( event.keyPressed ),
   keyCode( event.keyCode ),
   keyModifier( event.keyModifier ),
@@ -69,6 +75,12 @@ KeyEvent::KeyEvent( const Dali::KeyEvent& event )
   deviceClass( Device::Class::NONE ),
   deviceSubclass( Device::Subclass::NONE )
 {
+  const Internal::KeyEventImpl* keyEventImpl = GetImplementation( &event );
+  logicalKey = keyEventImpl->GetLogicalKey();
+  compose = keyEventImpl->GetCompose();
+  deviceName = keyEventImpl->GetDeviceName();
+  deviceClass = keyEventImpl->GetDeviceClass();
+  deviceSubclass = keyEventImpl->GetDeviceSubclass();
 }
 
 KeyEvent::~KeyEvent()
index cf74794..52055e4 100755 (executable)
@@ -56,6 +56,7 @@ struct DALI_CORE_API KeyEvent : public Event
   /**
    * Constructor
    * @param[in]  keyName       The name of the key pressed or command from the IMF, if later then the some following parameters will be needed.
+   * @param[in]  logicalKey    The logical key symbol (eg. shift + 1 == "exclamation")
    * @param[in]  keyString     A string of input characters or key pressed
    * @param[in]  keyCode       The unique key code for the key pressed.
    * @param[in]  keyModifier   The key modifier for special keys like shift and alt
@@ -67,6 +68,7 @@ struct DALI_CORE_API KeyEvent : public Event
    * @param[in]  deviceSubclass  Subclass of device KeyEvent originated from
    */
   KeyEvent(const std::string& keyName,
+           const std::string& logicalKey,
            const std::string& keyString,
            int keyCode,
            int keyModifier,
@@ -77,7 +79,7 @@ struct DALI_CORE_API KeyEvent : public Event
            const Device::Class::Type deviceClass,
            const Device::Subclass::Type deviceSubclass );
 
-  /*
+  /**
    * Constructor, creates a Integration::KeyEvent from a Dali::KeyEvent
    * @param[in] event Dali::KeyEvent to convert from
    */
@@ -96,6 +98,11 @@ struct DALI_CORE_API KeyEvent : public Event
   std::string keyName;
 
   /**
+   * The logical key symbol
+   */
+  std::string logicalKey;
+
+  /**
    *@copydoc Dali::KeyEvent::keyPressed
    */
   std::string keyString;
index 4184c98..8f0c84f 100755 (executable)
@@ -44,7 +44,8 @@ namespace Internal
 {
 
 KeyEventImpl::KeyEventImpl( KeyEvent* keyEvent )
-: mCompose( "" ),
+: mLogicalKey( "" ),
+  mCompose( "" ),
   mDeviceName( "" ),
   mDeviceClass( Device::Class::NONE ),
   mDeviceSubclass( Device::Subclass::NONE )
@@ -68,6 +69,7 @@ KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs )
 {
   if( this != &rhs )
   {
+    mLogicalKey = rhs.mLogicalKey;
     mCompose = rhs.mCompose;
     mDeviceName = rhs.mDeviceName;
     mDeviceClass = rhs.mDeviceClass;
@@ -77,6 +79,16 @@ KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs )
   return *this;
 }
 
+std::string KeyEventImpl::GetLogicalKey() const
+{
+  return mLogicalKey;
+}
+
+void KeyEventImpl::SetLogicalKey( const std::string& logicalKey )
+{
+  mLogicalKey = logicalKey;
+}
+
 std::string KeyEventImpl::GetCompose() const
 {
   return mCompose;
index 63318d3..1f581dc 100755 (executable)
@@ -49,6 +49,18 @@ public:
   KeyEventImpl& operator=( const KeyEventImpl& rhs );
 
   /**
+   * @brief Get the key symbol string.
+   * @return The key symbol
+   */
+  std::string GetLogicalKey() const;
+
+  /**
+   * @brief Set the key symbol string to the KeyEvent.
+   * @param[in] key The key symbol to set
+   */
+  void SetLogicalKey( const std::string& logicalKey );
+
+  /**
    * @brief Get the compose string.
    *
    * @return The compose string.
@@ -116,6 +128,7 @@ private:
 
 private:
 
+  std::string mLogicalKey;
   std::string mCompose;
   std::string mDeviceName;
   Device::Class::Type mDeviceClass;
index 4a50e95..750654b 100755 (executable)
@@ -44,6 +44,7 @@ void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
 {
   KeyEvent keyEvent(event.keyName, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>(event.state));
 
+  GetImplementation( &keyEvent )->SetLogicalKey( event.logicalKey );
   GetImplementation( &keyEvent )->SetCompose( event.compose );
   GetImplementation( &keyEvent )->SetDeviceName( event.deviceName );
   GetImplementation( &keyEvent )->SetDeviceClass( event.deviceClass );