aboutsummaryrefslogtreecommitdiff
path: root/vendor/sdl3/include/SDL_pen.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sdl3/include/SDL_pen.h')
-rw-r--r--vendor/sdl3/include/SDL_pen.h95
1 files changed, 83 insertions, 12 deletions
diff --git a/vendor/sdl3/include/SDL_pen.h b/vendor/sdl3/include/SDL_pen.h
index 5182eeb0c..97c22e506 100644
--- a/vendor/sdl3/include/SDL_pen.h
+++ b/vendor/sdl3/include/SDL_pen.h
@@ -28,12 +28,37 @@
* handling, e.g., for input and drawing tablets or suitably equipped mobile /
* tablet devices.
*
- * To get started with pens, simply handle SDL_EVENT_PEN_* events. When a pen
- * starts providing input, SDL will assign it a unique SDL_PenID, which will
- * remain for the life of the process, as long as the pen stays connected.
+ * To get started with pens, simply handle pen events:
+ *
+ * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT
+ * (SDL_PenProximityEvent)
+ * - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent)
+ * - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent)
+ * - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent)
+ * - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent)
*
* Pens may provide more than simple touch input; they might have other axes,
* such as pressure, tilt, rotation, etc.
+ *
+ * When a pen starts providing input, SDL will assign it a unique SDL_PenID,
+ * which will remain for the life of the process, as long as the pen stays
+ * connected. A pen leaving proximity (being taken far enough away from the
+ * digitizer tablet that it no longer reponds) and then coming back should
+ * fire proximity events, but the SDL_PenID should remain consistent.
+ * Unplugging the digitizer and reconnecting may cause future input to have a
+ * new SDL_PenID, as SDL may not know that this is the same hardware.
+ *
+ * Please note that various platforms vary wildly in how (and how well) they
+ * support pen input. If your pen supports some piece of functionality but SDL
+ * doesn't seem to, it might actually be the operating system's fault. For
+ * example, some platforms can manage multiple devices at the same time, but
+ * others will make any connected pens look like a single logical device, much
+ * how all USB mice connected to a computer will move the same system cursor.
+ * cursor. Other platforms might not support pen buttons, or the distance
+ * axis, etc. Very few platforms can even report _what_ functionality the pen
+ * supports in the first place, so best practices is to either build UI to let
+ * the user configure their pens, or be prepared to handle new functionality
+ * for a pen the first time an event is reported.
*/
#ifndef SDL_pen_h_
@@ -43,6 +68,7 @@
#include <SDL3/SDL_mouse.h>
#include <SDL3/SDL_touch.h>
+#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
@@ -55,7 +81,12 @@ extern "C" {
*
* These show up in pen events when SDL sees input from them. They remain
* consistent as long as SDL can recognize a tool to be the same pen; but if a
- * pen physically leaves the area and returns, it might get a new ID.
+ * pen's digitizer table is physically detached from the computer, it might
+ * get a new ID when reconnected, as SDL won't know it's the same device.
+ *
+ * These IDs are only stable within a single run of a program; the next time a
+ * program is run, the pen's ID will likely be different, even if the hardware
+ * hasn't been disconnected, etc.
*
* \since This datatype is available since SDL 3.2.0.
*/
@@ -75,7 +106,6 @@ typedef Uint32 SDL_PenID;
*/
#define SDL_PEN_TOUCHID ((SDL_TouchID)-2)
-
/**
* Pen input flags, as reported by various pen events' `pen_state` field.
*
@@ -83,13 +113,14 @@ typedef Uint32 SDL_PenID;
*/
typedef Uint32 SDL_PenInputFlags;
-#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */
-#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */
-#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */
-#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */
-#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */
-#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */
-#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */
+#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */
+#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */
+#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */
+#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */
+#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */
+#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */
+#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */
+#define SDL_PEN_INPUT_IN_PROXIMITY (1u << 31) /**< pen is in proximity (since SDL 3.4.0) */
/**
* Pen axis indices.
@@ -118,10 +149,50 @@ typedef enum SDL_PenAxis
SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */
} SDL_PenAxis;
+/**
+ * An enum that describes the type of a pen device.
+ *
+ * A "direct" device is a pen that touches a graphic display (like an Apple
+ * Pencil on an iPad's screen). "Indirect" devices touch an external tablet
+ * surface that is connected to the machine but is not a display (like a
+ * lower-end Wacom tablet connected over USB).
+ *
+ * Apps may use this information to decide if they should draw a cursor; if
+ * the pen is touching the screen directly, a cursor doesn't make sense and
+ * can be in the way, but becomes necessary for indirect devices to know where
+ * on the display they are interacting.
+ *
+ * \since This enum is available since SDL 3.4.0.
+ */
+typedef enum SDL_PenDeviceType
+{
+ SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */
+ SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */
+ SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */
+ SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */
+} SDL_PenDeviceType;
+
+/**
+ * Get the device type of the given pen.
+ *
+ * Many platforms do not supply this information, so an app must always be
+ * prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result.
+ *
+ * \param instance_id the pen instance ID.
+ * \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID
+ * on failure; call SDL_GetError() for more information.
+ *
+ * \threadsafety It is safe to call this function from any thread.
+ *
+ * \since This function is available since SDL 3.4.0.
+ */
+extern SDL_DECLSPEC SDL_PenDeviceType SDLCALL SDL_GetPenDeviceType(SDL_PenID instance_id);
+
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
+#include <SDL3/SDL_close_code.h>
#endif /* SDL_pen_h_ */