mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
546c4b4c6c
Summary: Changelog: [iOS][Internal] - Add isPrimary property implementation to the PointerEvent object This diff adds the `isPrimary` property to the PointerEvent object iOS implementation. In addition this adds a related change where we "reserve" the 0 touch identifier for mouse events and the 1 identifier for apple pencil events. This is an easy way to ensure that these pointers are always consistent no matter what happens. Since mouse & pencil pointers should always be considered the primary pointer, that allows us to focus the more advanced primary pointer differentiation purely on touch events. The logic for this touch event primary pointer differentiation is essentially setting the first touch it recieves as a primary pointer, setting it on touch registration, and sets all subsequent touchs (while the first touch is down) as not the primary pointers. When that primary pointer is lifted, the class property keeping track of the primary pointer is reset and then the **next** pointer (secondary pointers which had already started before the previous primary pointer was lifted are not "upgraded" to primary) is marked as primary. A new platform test is also included in this diff in order to verify the aforementioned behavior. Reviewed By: lunaleaps Differential Revision: D37961707 fbshipit-source-id: ae8b78c5bfea6902fb73094fca1552e4e648ea44
121 lines
3.2 KiB
C++
121 lines
3.2 KiB
C++
/*
|
||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <react/renderer/core/ReactPrimitives.h>
|
||
#include <react/renderer/debug/DebugStringConvertible.h>
|
||
#include <react/renderer/graphics/Geometry.h>
|
||
|
||
namespace facebook {
|
||
namespace react {
|
||
|
||
struct PointerEvent {
|
||
/*
|
||
* A unique identifier for the pointer causing the event.
|
||
*/
|
||
int pointerId;
|
||
/*
|
||
* The normalized pressure of the pointer input in the range 0 to 1, where 0
|
||
* and 1 represent the minimum and maximum pressure the hardware is capable of
|
||
* detecting, respectively.
|
||
*/
|
||
Float pressure;
|
||
/*
|
||
* Indicates the device type that caused the event (mouse, pen, touch, etc.)
|
||
*/
|
||
std::string pointerType;
|
||
/*
|
||
* Point within the application's viewport at which the event occurred (as
|
||
* opposed to the coordinate within the page).
|
||
*/
|
||
Point clientPoint;
|
||
/*
|
||
* The X/Y coordinate of the pointer in global (screen) coordinates.
|
||
*/
|
||
Point screenPoint;
|
||
/*
|
||
* The X/Y coordinate of the pointer relative to the position of the padding
|
||
* edge of the target node.
|
||
*/
|
||
Point offsetPoint;
|
||
/*
|
||
* The width (magnitude on the X axis), in CSS pixels, of the contact geometry
|
||
* of the pointer
|
||
*/
|
||
Float width;
|
||
/*
|
||
* The height (magnitude on the y axis), in CSS pixels, of the contact
|
||
* geometry of the pointer
|
||
*/
|
||
Float height;
|
||
/*
|
||
* The plane angle (in degrees, in the range of -90 to 90) between the Y–Z
|
||
* plane and the plane containing both the pointer (e.g. pen stylus) axis and
|
||
* the Y axis.
|
||
*/
|
||
int tiltX;
|
||
/*
|
||
* The plane angle (in degrees, in the range of -90 to 90) between the X–Z
|
||
* plane and the plane containing both the pointer (e.g. pen stylus) axis and
|
||
* the X axis.
|
||
*/
|
||
int tiltY;
|
||
/*
|
||
* Returns a long with details about the event, depending on the event type.
|
||
*/
|
||
int detail;
|
||
/*
|
||
* The buttons being depressed (if any) when the mouse event was fired.
|
||
*/
|
||
int buttons;
|
||
/*
|
||
* The normalized tangential pressure of the pointer input (also known as
|
||
* barrel pressure or cylinder stress) in the range -1 to 1, where 0 is the
|
||
* neutral position of the control.
|
||
*/
|
||
Float tangentialPressure;
|
||
/*
|
||
* The clockwise rotation of the pointer (e.g. pen stylus) around its major
|
||
* axis in degrees, with a value in the range 0 to 359.
|
||
*/
|
||
int twist;
|
||
/*
|
||
* Returns true if the control key was down when the event was fired.
|
||
*/
|
||
bool ctrlKey;
|
||
/*
|
||
* Returns true if the shift key was down when the event was fired.
|
||
*/
|
||
bool shiftKey;
|
||
/*
|
||
* Returns true if the alt key was down when the event was fired.
|
||
*/
|
||
bool altKey;
|
||
/*
|
||
* Returns true if the meta key was down when the event was fired.
|
||
*/
|
||
bool metaKey;
|
||
/*
|
||
* Indicates if the pointer represents the primary pointer of this pointer
|
||
* type.
|
||
*/
|
||
bool isPrimary;
|
||
};
|
||
|
||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||
|
||
std::string getDebugName(PointerEvent const &pointerEvent);
|
||
std::vector<DebugStringConvertibleObject> getDebugProps(
|
||
PointerEvent const &pointerEvent,
|
||
DebugStringConvertibleOptions options);
|
||
|
||
#endif
|
||
|
||
} // namespace react
|
||
} // namespace facebook
|