From 94247a4aedeee1f04791586fdae8bca9da682969 Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Fri, 23 Jun 2017 17:34:01 +0900 Subject: [PATCH] Added device information in TouchData/KeyEvent Change-Id: Ib5a5c66147372da4933f0ef827992081dddeb501 --- automated-tests/src/dali/utc-Dali-KeyEvent.cpp | 22 +++++- automated-tests/src/dali/utc-Dali-Stage.cpp | 16 ++-- .../src/dali/utc-Dali-TouchDataProcessing.cpp | 36 +++++++++ dali/devel-api/events/device.h | 88 ++++++++++++++++++++++ dali/devel-api/events/key-event-devel.h | 35 ++++----- dali/devel-api/events/touch-event-devel.h | 55 ++++++++++++++ dali/devel-api/file.list | 2 + dali/integration-api/events/key-event-integ.cpp | 12 ++- dali/integration-api/events/key-event-integ.h | 10 ++- dali/integration-api/events/point.cpp | 24 ++++++ dali/integration-api/events/point.h | 29 +++++++ dali/internal/event/events/key-event-impl.cpp | 18 ++++- dali/internal/event/events/key-event-impl.h | 25 ++++-- dali/internal/event/events/key-event-processor.cpp | 1 + dali/internal/event/events/touch-data-impl.cpp | 18 +++++ dali/internal/event/events/touch-data-impl.h | 16 ++++ dali/public-api/events/key-event.cpp | 8 +- dali/public-api/events/touch-data.cpp | 11 +++ 18 files changed, 375 insertions(+), 51 deletions(-) create mode 100644 dali/devel-api/events/device.h create mode 100644 dali/devel-api/events/touch-event-devel.h diff --git a/automated-tests/src/dali/utc-Dali-KeyEvent.cpp b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp index 0429ffb..db3e48c 100644 --- a/automated-tests/src/dali/utc-Dali-KeyEvent.cpp +++ b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp @@ -311,9 +311,10 @@ 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; + const DevelDevice::Class::Type deviceClass = DevelDevice::Class::KEYBOARD; + const DevelDevice::Subclass::Type deviceSubclass = DevelDevice::Subclass::NONE; - Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState, deviceName, deviceClass ); + Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState, deviceName, deviceClass, deviceSubclass ); DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION ); DALI_TEST_CHECK( keyEvent.keyName == keyName ); DALI_TEST_CHECK( keyEvent.keyString == keyString ); @@ -323,6 +324,7 @@ int UtcDaliIntegrationKeyEvent(void) DALI_TEST_EQUALS( keyEvent.state, keyState, TEST_LOCATION); DALI_TEST_EQUALS( keyEvent.deviceName, deviceName, TEST_LOCATION); DALI_TEST_EQUALS( keyEvent.deviceClass, deviceClass, TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.deviceSubclass, deviceSubclass, TEST_LOCATION); } END_TEST; } @@ -343,7 +345,8 @@ 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); + DALI_TEST_EQUALS( keyEvent.deviceClass, DevelDevice::Class::NONE, TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.deviceSubclass, DevelDevice::Subclass::NONE, TEST_LOCATION); END_TEST; } @@ -365,7 +368,18 @@ int UtcDaliKeyEventSetDeviceClass(void) KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); - DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceClass( event ), DevelKeyEvent::DeviceClass::NONE, TEST_LOCATION); + DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceClass( event ), DevelDevice::Class::NONE, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliKeyEventSetDeviceSubclass(void) +{ + TestApplication application; + + KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + + DALI_TEST_EQUALS( DevelKeyEvent::GetDeviceSubclass( event ), DevelDevice::Subclass::NONE, TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 24c13e7..102e451 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -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, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::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, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ); + Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ); application.ProcessEvent( event4 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp index 2ec12df..844a67a 100644 --- a/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchDataProcessing.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include using namespace Dali; @@ -50,6 +51,8 @@ struct TestPoint Vector2 ellipseRadius; float pressure; Degree angle; + DevelDevice::Class::Type deviceClass; + DevelDevice::Subclass::Type deviceSubclass; TestPoint() : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0) @@ -139,6 +142,8 @@ struct TouchDataFunctor p.ellipseRadius = touchData.GetEllipseRadius(i); p.pressure = touchData.GetPressure(i); p.angle = touchData.GetAngle(i); + p.deviceClass = DevelTouchData::GetDeviceClass(touchData, i); + p.deviceSubclass = DevelTouchData::GetDeviceSubclass(touchData, i); signalData.touchData.points.push_back(p); } @@ -281,6 +286,8 @@ Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vecto Integration::Point point; point.SetState( state ); point.SetScreenPosition( screenPosition ); + point.SetDeviceClass( DevelDevice::Class::TOUCH ); + point.SetDeviceSubclass( DevelDevice::Subclass::NONE ); touchEvent.points.push_back( point ); return touchEvent; } @@ -1972,6 +1979,35 @@ int UtcDaliTouchDataAndEventUsage(void) DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION ); END_TEST; +} +int UtcDaliTouchDataGetDeviceAPINegative(void) +{ + TestApplication application; + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + HandleData handleData; + TouchDataHandleFunctor functor( handleData ); + actor.TouchSignal().Connect( &application, functor ); + + Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 localCoordinates; + actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) ); + + TouchData data = handleData.touchData; + DALI_TEST_EQUALS( DevelTouchData::GetDeviceClass( data, -1 ), DevelDevice::Class::NONE, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelTouchData::GetDeviceSubclass( data, -1 ), DevelDevice::Subclass::NONE, TEST_LOCATION ); + END_TEST; } diff --git a/dali/devel-api/events/device.h b/dali/devel-api/events/device.h new file mode 100644 index 0000000..aab32e0 --- /dev/null +++ b/dali/devel-api/events/device.h @@ -0,0 +1,88 @@ +#ifndef DALI_DEVICE_H +#define DALI_DEVICE_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. + * + */ + +namespace Dali +{ + +/** + * @brief Information about device types + * + * These types are for widget viewer applications. + * A widget viewer application by Dali have to deliver events to widget applications + * Server for handling events actually delivers any events to widget applications + * The server needs to know input device information such as type to deliver events of proper type to widget applications + */ +namespace DevelDevice +{ + +/** + * @brief Categorization type about input Device + */ +namespace Class +{ + +/** + * @brief An enum of Device Class 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 pointing device based on laser, infrared or similar technology + GAMEPAD ///< A gamepad controller or joystick +}; + +} // namespace DeviceClass + +/** + * @brief Subcategorization type about input device + */ +namespace Subclass +{ + +/** + * @brief An enum of Device Subclass types. + */ +enum Type +{ + NONE, ///< Not a device + FINGER, ///< The normal flat of your finger + FINGERNAIL, ///< A fingernail + KNUCKLE, ///< A Knuckle + PALM, ///< The palm of a users hand + HAND_SIDE, ///< The side of your hand + HAND_FLAT, ///< The flat of your hand + PEN_TIP, ///< The tip of a pen + TRACKPAD, ///< A trackpad style mouse + TRACKPOINT, //< A trackpoint style mouse + TRACKBALL, ///< A trackball style mouse +}; + +} // namespace DeviceSubclass + +} // namespace DevelDevice + +} // namespace Dali + +#endif //DALI_KEY_EVENT_DEVEL_H diff --git a/dali/devel-api/events/key-event-devel.h b/dali/devel-api/events/key-event-devel.h index ec2a85e..417dd48 100644 --- a/dali/devel-api/events/key-event-devel.h +++ b/dali/devel-api/events/key-event-devel.h @@ -20,6 +20,7 @@ // INTERNAL_INCLUDES #include +#include namespace Dali { @@ -27,26 +28,6 @@ namespace Dali namespace DevelKeyEvent { -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 * @@ -58,10 +39,20 @@ DALI_IMPORT_API std::string GetDeviceName( const KeyEvent& keyEvent ); /** * @brief Get the device class the key event originated from * + * The device class type is classification type of the input device of event received * @param[in] keyEvent The KeyEvent to retrieve the device class from - * @return The device class + * @return The type of the device class + */ +DALI_IMPORT_API DevelDevice::Class::Type GetDeviceClass( const KeyEvent& keyEvent ); + +/** + * @brief Get the device subclass the key event originated from + * + * The device subclass type is subclassification type of the input device of event received. + * @param[in] keyEvent The KeyEvent to retrieve the device subclass from + * @return The type of the device subclass */ -DALI_IMPORT_API DeviceClass::Type GetDeviceClass( const KeyEvent& keyEvent ); +DALI_IMPORT_API DevelDevice::Subclass::Type GetDeviceSubclass( const KeyEvent& keyEvent ); } // namespace DevelKeyEvent diff --git a/dali/devel-api/events/touch-event-devel.h b/dali/devel-api/events/touch-event-devel.h new file mode 100644 index 0000000..6ab21db --- /dev/null +++ b/dali/devel-api/events/touch-event-devel.h @@ -0,0 +1,55 @@ +#ifndef DALI_TOUCH_DATA_DEVEL_H +#define DALI_TOUCH_DATA_DEVEL_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 +#include + +namespace Dali +{ + +namespace DevelTouchData +{ + +/** + * @brief Get the device class type the mouse/touch event originated from + * + * The device class type is classification type of the input device of event received. + * @param[in] touch The TouchData to retrieve the device class from + * @param[in] point The point required + * @return The type of the device class + */ +DALI_IMPORT_API DevelDevice::Class::Type GetDeviceClass( const TouchData& touch, std::size_t point ); + +/** + * @brief Get the device subclass type the mouse/touch event originated from + * + * The device subclass type is subclassification type of the input device of event received. + * @param[in] touch The TouchData to retrieve the device subclass from + * @param[in] point The point required + * @return The type of the device subclass + */ +DALI_IMPORT_API DevelDevice::Subclass::Type GetDeviceSubclass( const TouchData& touch, std::size_t point ); + +} // namespace DevelTouchData + +} // namespace Dali + +#endif //DALI_TOUCH_DATA_DEVEL_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index d30f932..44b94a4a 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -43,6 +43,8 @@ devel_api_core_common_header_files = \ devel_api_core_events_header_files = \ $(devel_api_src_dir)/events/hit-test-algorithm.h \ + $(devel_api_src_dir)/events/device.h \ + $(devel_api_src_dir)/events/touch-event-devel.h \ $(devel_api_src_dir)/events/key-event-devel.h devel_api_core_images_header_files = \ diff --git a/dali/integration-api/events/key-event-integ.cpp b/dali/integration-api/events/key-event-integ.cpp index b3bcdee..79da685 100644 --- a/dali/integration-api/events/key-event-integ.cpp +++ b/dali/integration-api/events/key-event-integ.cpp @@ -33,12 +33,14 @@ KeyEvent::KeyEvent() time( 0 ), state( KeyEvent::Down ), deviceName( "" ), - deviceClass( DevelKeyEvent::DeviceClass::NONE ) + deviceClass( DevelDevice::Class::NONE ), + deviceSubclass( DevelDevice::Subclass::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, const DevelKeyEvent::DeviceClass::Type deviceClass ) + unsigned long timeStamp, const State& keyState, const std::string deviceName, + const DevelDevice::Class::Type deviceClass, const DevelDevice::Subclass::Type deviceSubclass ) : Event( Key ), keyName( keyName ), keyString( keyString ), @@ -47,7 +49,8 @@ KeyEvent::KeyEvent( const std::string& keyName, const std::string& keyString, in time( timeStamp ), state( keyState ), deviceName( deviceName ), - deviceClass( deviceClass ) + deviceClass( deviceClass ), + deviceSubclass( deviceSubclass ) { } @@ -60,7 +63,8 @@ KeyEvent::KeyEvent( const Dali::KeyEvent& event ) time( event.time ), state( static_cast< Integration::KeyEvent::State >( event.state ) ), deviceName( "" ), - deviceClass( DevelKeyEvent::DeviceClass::NONE ) + deviceClass( DevelDevice::Class::NONE ), + deviceSubclass( DevelDevice::Subclass::NONE ) { } diff --git a/dali/integration-api/events/key-event-integ.h b/dali/integration-api/events/key-event-integ.h index d98970d..536d3ef 100644 --- a/dali/integration-api/events/key-event-integ.h +++ b/dali/integration-api/events/key-event-integ.h @@ -72,7 +72,8 @@ struct KeyEvent : public Event unsigned long timeStamp, const State& keyState, const std::string deviceName, - const DevelKeyEvent::DeviceClass::Type deviceClass ); + const DevelDevice::Class::Type deviceClass, + const DevelDevice::Subclass::Type deviceSubclass ); /* * Constructor, creates a Integration::KeyEvent from a Dali::KeyEvent @@ -126,7 +127,12 @@ struct KeyEvent : public Event /** * Class of device KeyEvent originated from */ - DevelKeyEvent::DeviceClass::Type deviceClass; + DevelDevice::Class::Type deviceClass; + + /** + * Subclass of device KeyEvent originated from + */ + DevelDevice::Subclass::Type deviceSubclass; }; } // namespace Integration diff --git a/dali/integration-api/events/point.cpp b/dali/integration-api/events/point.cpp index 485c4ed..def483f 100644 --- a/dali/integration-api/events/point.cpp +++ b/dali/integration-api/events/point.cpp @@ -28,6 +28,8 @@ Point::Point() : mTouchPoint( 0, TouchPoint::Started, 0.0f, 0.0f ), mEllipseRadius(), mAngle( 0.0f ), + mDeviceClass( DevelDevice::Class::NONE ), + mDeviceSubclass( DevelDevice::Subclass::NONE ), mPressure( 1.0f ), mRadius( 0.0f ) { @@ -37,6 +39,8 @@ Point::Point( const TouchPoint& touchPoint ) : mTouchPoint( touchPoint ), mEllipseRadius(), mAngle( 0.0f ), + mDeviceClass( DevelDevice::Class::NONE ), + mDeviceSubclass( DevelDevice::Subclass::NONE ), mPressure( 1.0f ), mRadius( 0.0f ) { @@ -142,6 +146,26 @@ const TouchPoint& Point::GetTouchPoint() const return mTouchPoint; } +void Point::SetDeviceClass( DevelDevice::Class::Type deviceClass ) +{ + mDeviceClass = deviceClass; +} + +void Point::SetDeviceSubclass( DevelDevice::Subclass::Type deviceSubclass ) +{ + mDeviceSubclass = deviceSubclass; +} + +DevelDevice::Class::Type Point::GetDeviceClass() const +{ + return mDeviceClass; +} + +DevelDevice::Subclass::Type Point::GetDeviceSubclass() const +{ + return mDeviceSubclass; +} + } // namespace Integration } // namespace Dali diff --git a/dali/integration-api/events/point.h b/dali/integration-api/events/point.h index 3b05f5c..6570c65 100644 --- a/dali/integration-api/events/point.h +++ b/dali/integration-api/events/point.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace Dali { @@ -106,6 +107,18 @@ struct DALI_IMPORT_API Point void SetAngle( Degree angle ); /** + * @brief Sets the class of the device for the event + * @param[in] deviceClass The class of the device. + */ + void SetDeviceClass( DevelDevice::Class::Type deviceClass ); + + /** + * @brief Sets the subclass of the device for the event + * @param[in] deviceSubclass The subclass of the device. + */ + void SetDeviceSubclass( DevelDevice::Subclass::Type deviceSubclass ); + + /** * @brief Retrieve the Unique Device ID of the point. * @return The Unique Device ID of the point. */ @@ -153,6 +166,20 @@ struct DALI_IMPORT_API Point */ Degree GetAngle() const; + /** + * @brief Retrieve the class of the device for the event. + * @return The class of the device + */ + DevelDevice::Class::Type GetDeviceClass() const; + + /** + * @brief Retrieve the subclass of the device for the event. + * @return The subclass of the device + */ + DevelDevice::Subclass::Type GetDeviceSubclass() const; + + + public: // Not intended for Integration API developers /** @@ -192,6 +219,8 @@ private: TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse). Degree mAngle; ///< The angle of the press point, relative to the Y-Axis. + DevelDevice::Class::Type mDeviceClass; + DevelDevice::Subclass::Type mDeviceSubclass; float mPressure; ///< The touch pressure. float mRadius; ///< Radius of the press point, an average of the ellipse radius. }; diff --git a/dali/internal/event/events/key-event-impl.cpp b/dali/internal/event/events/key-event-impl.cpp index e04d8c8..f6a0a32 100644 --- a/dali/internal/event/events/key-event-impl.cpp +++ b/dali/internal/event/events/key-event-impl.cpp @@ -39,7 +39,8 @@ namespace Internal KeyEventImpl::KeyEventImpl( KeyEvent* keyEvent ) : mDeviceName( "" ), - mDeviceClass( DevelKeyEvent::DeviceClass::NONE ) + mDeviceClass( DevelDevice::Class::NONE ), + mDeviceSubclass( DevelDevice::Subclass::NONE ) { keyEventImplMap[keyEvent] = this; } @@ -62,6 +63,7 @@ KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs ) { mDeviceName = rhs.mDeviceName; mDeviceClass = rhs.mDeviceClass; + mDeviceSubclass = rhs.mDeviceSubclass; } return *this; @@ -77,16 +79,26 @@ void KeyEventImpl::SetDeviceName( const std::string& deviceName ) mDeviceName = deviceName; } -DevelKeyEvent::DeviceClass::Type KeyEventImpl::GetDeviceClass() const +DevelDevice::Class::Type KeyEventImpl::GetDeviceClass() const { return mDeviceClass; } -void KeyEventImpl::SetDeviceClass( const DevelKeyEvent::DeviceClass::Type& deviceClass ) +void KeyEventImpl::SetDeviceClass( DevelDevice::Class::Type deviceClass ) { mDeviceClass = deviceClass; } +DevelDevice::Subclass::Type KeyEventImpl::GetDeviceSubclass() const +{ + return mDeviceSubclass; +} + +void KeyEventImpl::SetDeviceSubclass( DevelDevice::Subclass::Type deviceSubclass ) +{ + mDeviceSubclass = deviceSubclass; +} + } // namsespace Internal Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent ) diff --git a/dali/internal/event/events/key-event-impl.h b/dali/internal/event/events/key-event-impl.h index 57b8cbe..b6245b1 100644 --- a/dali/internal/event/events/key-event-impl.h +++ b/dali/internal/event/events/key-event-impl.h @@ -52,7 +52,6 @@ public: /** * @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; @@ -60,7 +59,6 @@ public: /** * @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 ); @@ -68,18 +66,30 @@ public: /** * @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; + DevelDevice::Class::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 ); + void SetDeviceClass( DevelDevice::Class::Type deviceClass ); + + /** + * @brief Get the device subclass the key event originated from + * + * @return The device subclass + */ + DevelDevice::Subclass::Type GetDeviceSubclass() const; + + /** + * @brief Set the device subclass to the KeyEvent + * + * @param[in] deviceClass Device subclass to set + */ + void SetDeviceSubclass( DevelDevice::Subclass::Type deviceSubclass ); private: @@ -92,7 +102,8 @@ private: private: std::string mDeviceName; - DevelKeyEvent::DeviceClass::Type mDeviceClass; + DevelDevice::Class::Type mDeviceClass; + DevelDevice::Subclass::Type mDeviceSubclass; }; } // namespace Internal diff --git a/dali/internal/event/events/key-event-processor.cpp b/dali/internal/event/events/key-event-processor.cpp index bfc1f43..5afb81b 100644 --- a/dali/internal/event/events/key-event-processor.cpp +++ b/dali/internal/event/events/key-event-processor.cpp @@ -47,6 +47,7 @@ void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event) GetImplementation( &keyEvent )->SetDeviceName( event.deviceName ); GetImplementation( &keyEvent )->SetDeviceClass( event.deviceClass ); + GetImplementation( &keyEvent )->SetDeviceSubclass( event.deviceSubclass ); // Emit the key event signal from stage. consumed = mStage.EmitKeyEventGeneratedSignal( keyEvent ); diff --git a/dali/internal/event/events/touch-data-impl.cpp b/dali/internal/event/events/touch-data-impl.cpp index a041c82..678829d 100644 --- a/dali/internal/event/events/touch-data-impl.cpp +++ b/dali/internal/event/events/touch-data-impl.cpp @@ -159,6 +159,24 @@ void TouchData::AddPoint( const Integration::Point& point ) mPoints.push_back( point ); } +DevelDevice::Class::Type TouchData::GetDeviceClass( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetDeviceClass(); + } + return DevelDevice::Class::NONE; +} + +DevelDevice::Subclass::Type TouchData::GetDeviceSubclass( std::size_t point ) const +{ + if( point < mPoints.size() ) + { + return mPoints[ point ].GetDeviceSubclass(); + } + return DevelDevice::Subclass::NONE; +} + } // namsespace Internal } // namespace Dali diff --git a/dali/internal/event/events/touch-data-impl.h b/dali/internal/event/events/touch-data-impl.h index 5221db0..1f53a11 100644 --- a/dali/internal/event/events/touch-data-impl.h +++ b/dali/internal/event/events/touch-data-impl.h @@ -158,6 +158,20 @@ public: */ void AddPoint( const Integration::Point& point ); + /** + * @brief Get the device class the mouse/touch event originated from + * + * @return The device class + */ + DevelDevice::Class::Type GetDeviceClass( std::size_t point ) const; + + /** + * @brief Get the device subclass the mouse/touch event originated from + * + * @return The device subclass + */ + DevelDevice::Subclass::Type GetDeviceSubclass( std::size_t point ) const; + private: /// Undefined Copy constructor @@ -166,6 +180,8 @@ private: /// Undefined TouchData& operator=( const TouchData& other ); +private: + std::vector< Integration::Point > mPoints; ///< Container of the points for this touch event. unsigned long mTime; ///< The time (in ms) that the touch event occurred. }; diff --git a/dali/public-api/events/key-event.cpp b/dali/public-api/events/key-event.cpp index 40498f3..6d9b156 100644 --- a/dali/public-api/events/key-event.cpp +++ b/dali/public-api/events/key-event.cpp @@ -124,9 +124,15 @@ std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent ) return GetImplementation( &keyEvent )->GetDeviceName(); } -DevelKeyEvent::DeviceClass::Type DevelKeyEvent::GetDeviceClass( const KeyEvent& keyEvent ) +DevelDevice::Class::Type DevelKeyEvent::GetDeviceClass( const KeyEvent& keyEvent ) { return GetImplementation( &keyEvent )->GetDeviceClass(); } +DevelDevice::Subclass::Type DevelKeyEvent::GetDeviceSubclass( const KeyEvent& keyEvent ) +{ + return GetImplementation( &keyEvent )->GetDeviceSubclass(); +} + + } // namespace Dali diff --git a/dali/public-api/events/touch-data.cpp b/dali/public-api/events/touch-data.cpp index 215ae67..1dcdbd6 100644 --- a/dali/public-api/events/touch-data.cpp +++ b/dali/public-api/events/touch-data.cpp @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include #include @@ -102,6 +103,16 @@ Degree TouchData::GetAngle( std::size_t point ) const return GetImplementation( *this ).GetAngle( point ); } +DevelDevice::Class::Type DevelTouchData::GetDeviceClass( const TouchData& touch, std::size_t point ) +{ + return GetImplementation( touch ).GetDeviceClass( point ); +} + +DevelDevice::Subclass::Type DevelTouchData::GetDeviceSubclass( const TouchData& touch, std::size_t point ) +{ + return GetImplementation( touch ).GetDeviceSubclass( point ); +} + TouchData::TouchData( Internal::TouchData* internal ) : BaseHandle( internal ) { -- 2.7.4