From 37d2ff64ded0786d07ea22a2c15fbe460dc8e1e5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Nov 2018 23:38:07 +0100 Subject: [PATCH] putil: add id and pressure fields to PointerData --- panda/src/putil/pointerData.I | 54 ++++++++++++++--------------------- panda/src/putil/pointerData.h | 19 +++++++----- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/panda/src/putil/pointerData.I b/panda/src/putil/pointerData.I index 6697c31d1a..a23b1c464b 100644 --- a/panda/src/putil/pointerData.I +++ b/panda/src/putil/pointerData.I @@ -11,37 +11,6 @@ * @date 2002-07-15 */ -/** - * - */ -INLINE PointerData:: -PointerData() { - _in_window = false; - _xpos = 0; - _ypos = 0; -} - -/** - * - */ -INLINE PointerData:: -PointerData(const PointerData ©) : - _in_window(copy._in_window), - _xpos(copy._xpos), - _ypos(copy._ypos) -{ -} - -/** - * - */ -INLINE void PointerData:: -operator = (const PointerData ©) { - _in_window = copy._in_window; - _xpos = copy._xpos; - _ypos = copy._ypos; -} - /** * */ @@ -59,13 +28,34 @@ get_y() const { } /** - * + * If this returns false, the pointer is not currently present in the window + * and the values returned by get_x() and get_y() may not be meaningful. */ INLINE bool PointerData:: get_in_window() const { return _in_window; } +/** + * Returns a unique identifier for this pointer. This is for tracking + * individual fingers. This value should not be assumed to have a specific + * meaning other than that there will not be two different pointers active + * simultaneously with the same identifier. + */ +INLINE int PointerData:: +get_id() const { + return _id; +} + +/** + * Returns the pressure of the pointer. For mice, this will be 1.0 if any + * button is pressed, 0.0 otherwise. + */ +INLINE double PointerData:: +get_pressure() const { + return _pressure; +} + INLINE std::ostream &operator << (std::ostream &out, const PointerData &md) { md.output(out); diff --git a/panda/src/putil/pointerData.h b/panda/src/putil/pointerData.h index aa3f3aeb62..ab0aee374e 100644 --- a/panda/src/putil/pointerData.h +++ b/panda/src/putil/pointerData.h @@ -24,24 +24,29 @@ */ class EXPCL_PANDA_PUTIL PointerData { PUBLISHED: - INLINE PointerData(); - INLINE PointerData(const PointerData ©); - INLINE void operator = (const PointerData ©); - INLINE double get_x() const; INLINE double get_y() const; INLINE bool get_in_window() const; +public: + INLINE int get_id() const; + INLINE double get_pressure() const; + void output(std::ostream &out) const; +PUBLISHED: MAKE_PROPERTY(x, get_x); MAKE_PROPERTY(y, get_y); + MAKE_PROPERTY(id, get_id); MAKE_PROPERTY(in_window, get_in_window); + MAKE_PROPERTY(pressure, get_pressure); public: - bool _in_window; - double _xpos; - double _ypos; + bool _in_window = false; + double _xpos = 0.0; + double _ypos = 0.0; + double _pressure = 0.0; + int _id = 0; }; INLINE std::ostream &operator << (std::ostream &out, const PointerData &md);