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 );
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;
}
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;
}
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;
}
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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
{
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 )
{
}
// 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
{
* @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,
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
*/
std::string deviceName;
+ /**
+ * Class of device KeyEvent originated from
+ */
+ DevelKeyEvent::DeviceClass::Type deviceClass;
};
} // namespace Integration
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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__
#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>
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 );
$(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 \
// 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
{
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()
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)
time(timeStamp),
state(keyState)
{
- keyEventImplMap[this] = new KeyEventImpl;
+ new Internal::KeyEventImpl( this );
}
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 )
time = rhs.time;
state = rhs.state;
- *keyEventImplMap[ this ] = *keyEventImplMap[ &rhs ];
+ *GetImplementation( this ) = *GetImplementation( &rhs );
}
return *this;
KeyEvent::~KeyEvent()
{
- delete keyEventImplMap[this];
- keyEventImplMap.erase( this );
+ delete GetImplementation( this );
}
bool KeyEvent::IsShiftModifier() 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