diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h')
-rw-r--r-- | src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h b/src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h new file mode 100644 index 0000000..5182eeb --- /dev/null +++ b/src/contrib/SDL-3.2.20/include/SDL3/SDL_pen.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
4 | |||
5 | This software is provided 'as-is', without any express or implied | ||
6 | warranty. In no event will the authors be held liable for any damages | ||
7 | arising from the use of this software. | ||
8 | |||
9 | Permission is granted to anyone to use this software for any purpose, | ||
10 | including commercial applications, and to alter it and redistribute it | ||
11 | freely, subject to the following restrictions: | ||
12 | |||
13 | 1. The origin of this software must not be misrepresented; you must not | ||
14 | claim that you wrote the original software. If you use this software | ||
15 | in a product, an acknowledgment in the product documentation would be | ||
16 | appreciated but is not required. | ||
17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
18 | misrepresented as being the original software. | ||
19 | 3. This notice may not be removed or altered from any source distribution. | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * # CategoryPen | ||
24 | * | ||
25 | * SDL pen event handling. | ||
26 | * | ||
27 | * SDL provides an API for pressure-sensitive pen (stylus and/or eraser) | ||
28 | * handling, e.g., for input and drawing tablets or suitably equipped mobile / | ||
29 | * tablet devices. | ||
30 | * | ||
31 | * To get started with pens, simply handle SDL_EVENT_PEN_* events. When a pen | ||
32 | * starts providing input, SDL will assign it a unique SDL_PenID, which will | ||
33 | * remain for the life of the process, as long as the pen stays connected. | ||
34 | * | ||
35 | * Pens may provide more than simple touch input; they might have other axes, | ||
36 | * such as pressure, tilt, rotation, etc. | ||
37 | */ | ||
38 | |||
39 | #ifndef SDL_pen_h_ | ||
40 | #define SDL_pen_h_ | ||
41 | |||
42 | #include <SDL3/SDL_stdinc.h> | ||
43 | #include <SDL3/SDL_mouse.h> | ||
44 | #include <SDL3/SDL_touch.h> | ||
45 | |||
46 | /* Set up for C function definitions, even when using C++ */ | ||
47 | #ifdef __cplusplus | ||
48 | extern "C" { | ||
49 | #endif | ||
50 | |||
51 | /** | ||
52 | * SDL pen instance IDs. | ||
53 | * | ||
54 | * Zero is used to signify an invalid/null device. | ||
55 | * | ||
56 | * These show up in pen events when SDL sees input from them. They remain | ||
57 | * consistent as long as SDL can recognize a tool to be the same pen; but if a | ||
58 | * pen physically leaves the area and returns, it might get a new ID. | ||
59 | * | ||
60 | * \since This datatype is available since SDL 3.2.0. | ||
61 | */ | ||
62 | typedef Uint32 SDL_PenID; | ||
63 | |||
64 | /** | ||
65 | * The SDL_MouseID for mouse events simulated with pen input. | ||
66 | * | ||
67 | * \since This macro is available since SDL 3.2.0. | ||
68 | */ | ||
69 | #define SDL_PEN_MOUSEID ((SDL_MouseID)-2) | ||
70 | |||
71 | /** | ||
72 | * The SDL_TouchID for touch events simulated with pen input. | ||
73 | * | ||
74 | * \since This macro is available since SDL 3.2.0. | ||
75 | */ | ||
76 | #define SDL_PEN_TOUCHID ((SDL_TouchID)-2) | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Pen input flags, as reported by various pen events' `pen_state` field. | ||
81 | * | ||
82 | * \since This datatype is available since SDL 3.2.0. | ||
83 | */ | ||
84 | typedef Uint32 SDL_PenInputFlags; | ||
85 | |||
86 | #define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ | ||
87 | #define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ | ||
88 | #define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ | ||
89 | #define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ | ||
90 | #define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ | ||
91 | #define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ | ||
92 | #define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ | ||
93 | |||
94 | /** | ||
95 | * Pen axis indices. | ||
96 | * | ||
97 | * These are the valid values for the `axis` field in SDL_PenAxisEvent. All | ||
98 | * axes are either normalised to 0..1 or report a (positive or negative) angle | ||
99 | * in degrees, with 0.0 representing the centre. Not all pens/backends support | ||
100 | * all axes: unsupported axes are always zero. | ||
101 | * | ||
102 | * To convert angles for tilt and rotation into vector representation, use | ||
103 | * SDL_sinf on the XTILT, YTILT, or ROTATION component, for example: | ||
104 | * | ||
105 | * `SDL_sinf(xtilt * SDL_PI_F / 180.0)`. | ||
106 | * | ||
107 | * \since This enum is available since SDL 3.2.0. | ||
108 | */ | ||
109 | typedef enum SDL_PenAxis | ||
110 | { | ||
111 | SDL_PEN_AXIS_PRESSURE, /**< Pen pressure. Unidirectional: 0 to 1.0 */ | ||
112 | SDL_PEN_AXIS_XTILT, /**< Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). */ | ||
113 | SDL_PEN_AXIS_YTILT, /**< Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). */ | ||
114 | SDL_PEN_AXIS_DISTANCE, /**< Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 */ | ||
115 | SDL_PEN_AXIS_ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */ | ||
116 | SDL_PEN_AXIS_SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */ | ||
117 | SDL_PEN_AXIS_TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */ | ||
118 | SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ | ||
119 | } SDL_PenAxis; | ||
120 | |||
121 | /* Ends C function definitions when using C++ */ | ||
122 | #ifdef __cplusplus | ||
123 | } | ||
124 | #endif | ||
125 | |||
126 | #endif /* SDL_pen_h_ */ | ||
127 | |||