|
15 | 15 | * handling, e.g., for input and drawing tablets or suitably equipped mobile / |
16 | 16 | * tablet devices. |
17 | 17 | * |
18 | | - * To get started with pens, simply handle SDL_EVENT_PEN_* events. When a pen |
19 | | - * starts providing input, SDL will assign it a unique SDL_PenID, which will |
20 | | - * remain for the life of the process, as long as the pen stays connected. |
| 18 | + * To get started with pens, simply handle pen events: |
| 19 | + * |
| 20 | + * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT |
| 21 | + * (SDL_PenProximityEvent) |
| 22 | + * - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent) |
| 23 | + * - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent) |
| 24 | + * - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent) |
| 25 | + * - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent) |
21 | 26 | * |
22 | 27 | * Pens may provide more than simple touch input; they might have other axes, |
23 | 28 | * such as pressure, tilt, rotation, etc. |
| 29 | + * |
| 30 | + * When a pen starts providing input, SDL will assign it a unique SDL_PenID, |
| 31 | + * which will remain for the life of the process, as long as the pen stays |
| 32 | + * connected. A pen leaving proximity (being taken far enough away from the |
| 33 | + * digitizer tablet that it no longer reponds) and then coming back should |
| 34 | + * fire proximity events, but the SDL_PenID should remain consistent. |
| 35 | + * Unplugging the digitizer and reconnecting may cause future input to have a |
| 36 | + * new SDL_PenID, as SDL may not know that this is the same hardware. |
| 37 | + * |
| 38 | + * Please note that various platforms vary wildly in how (and how well) they |
| 39 | + * support pen input. If your pen supports some piece of functionality but SDL |
| 40 | + * doesn't seem to, it might actually be the operating system's fault. For |
| 41 | + * example, some platforms can manage multiple devices at the same time, but |
| 42 | + * others will make any connected pens look like a single logical device, much |
| 43 | + * how all USB mice connected to a computer will move the same system cursor. |
| 44 | + * Other platforms might not support pen buttons, or the distance axis, etc. |
| 45 | + * Very few platforms can even report _what_ functionality the pen supports in |
| 46 | + * the first place, so best practices is to either build UI to let the user |
| 47 | + * configure their pens, or be prepared to handle new functionality for a pen |
| 48 | + * the first time an event is reported. |
24 | 49 | } |
25 | 50 |
|
26 | 51 | {* |
|
30 | 55 | * |
31 | 56 | * These show up in pen events when SDL sees input from them. They remain |
32 | 57 | * consistent as long as SDL can recognize a tool to be the same pen; but if a |
33 | | - * pen physically leaves the area and returns, it might get a new ID. |
| 58 | + * pen's digitizer table is physically detached from the computer, it might |
| 59 | + * get a new ID when reconnected, as SDL won't know it's the same device. |
| 60 | + * |
| 61 | + * These IDs are only stable within a single run of a program; the next time a |
| 62 | + * program is run, the pen's ID will likely be different, even if the hardware |
| 63 | + * hasn't been disconnected, etc. |
34 | 64 | * |
35 | 65 | * \since This datatype is available since SDL 3.2.0. |
36 | 66 | } |
|
72 | 102 | SDL_PEN_INPUT_BUTTON_4 = TSDL_PenInputFlags(1 shl 4); {*< button 4 is pressed } |
73 | 103 | SDL_PEN_INPUT_BUTTON_5 = TSDL_PenInputFlags(1 shl 5); {*< button 5 is pressed } |
74 | 104 | SDL_PEN_INPUT_ERASER_TIP = TSDL_PenInputFlags(1 shl 30); {*< eraser tip is used } |
| 105 | + SDL_PEN_INPUT_IN_PROXIMITY = TSDL_PenInputFlags(1 shl 31); {*< pen is in proximity (since SDL 3.4.0) } |
75 | 106 |
|
76 | 107 | {* |
77 | 108 | * Pen axis indices. |
@@ -102,3 +133,29 @@ const |
102 | 133 | SDL_PEN_AXIS_TANGENTIAL_PRESSURE = TSDL_PenAxis(6); {*< Pressure from squeezing the pen ("barrel pressure"). } |
103 | 134 | SDL_PEN_AXIS_COUNT = TSDL_PenAxis(7); {*< Total known pen axis types in this version of SDL. This number may grow in future releases! } |
104 | 135 |
|
| 136 | +{* |
| 137 | + * An enum that describes the type of a pen device. |
| 138 | + * |
| 139 | + * A "direct" device is a pen that touches a graphic display (like an Apple |
| 140 | + * Pencil on an iPad's screen). "Indirect" devices touch an |
| 141 | + external tablet |
| 142 | + * surface that is connected to the machine but is not a display (like a |
| 143 | + * lower-end Wacom tablet connected over USB). |
| 144 | + * |
| 145 | + * Apps may use this information to decide if they should draw a cursor; if |
| 146 | + * the pen is touching the screen directly, a cursor doesn't make sense and |
| 147 | + * can be in the way, but becomes necessary for indirect devices to know where |
| 148 | + * on the display they are interacting. |
| 149 | + * |
| 150 | + * \since This enum is available since SDL 3.4.0. |
| 151 | + } |
| 152 | +type |
| 153 | + PPSDL_PenDeviceType = ^PSDL_PenDeviceType; |
| 154 | + PSDL_PenDeviceType = ^TSDL_PenDeviceType; |
| 155 | + TSDL_PenDeviceType = type Integer; |
| 156 | +const |
| 157 | + SDL_PEN_DEVICE_TYPE_INVALID = TSDL_PenDeviceType(-1); {*< Not a valid pen device. } |
| 158 | + SDL_PEN_DEVICE_TYPE_UNKNOWN = TSDL_PenDeviceType(0); {*< Don't know specifics of this pen. } |
| 159 | + SDL_PEN_DEVICE_TYPE_DIRECT = TSDL_PenDeviceType(1); {*< Pen touches display. } |
| 160 | + SDL_PEN_DEVICE_TYPE_INDIRECT = TSDL_PenDeviceType(2); {*< Pen touches something that isn't the display. } |
| 161 | + |
0 commit comments