Skip to content

Commit c670be6

Browse files
Update SDL_pen.inc to 3.4.4
1 parent c50baf5 commit c670be6

2 files changed

Lines changed: 62 additions & 5 deletions

File tree

units/SDL3.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ interface
107107
{$I SDL_gamepad.inc} // 3.4.4
108108
{$I SDL_haptic.inc} // 3.4.4
109109
{$I SDL_touch.inc} // 3.4.4
110-
{$I SDL_pen.inc} // 3.2.20
110+
{$I SDL_pen.inc} // 3.4.4
111111
{$I SDL_camera.inc} // 3.4.4
112112
{$I SDL_events.inc} // 3.2.20
113113
{$I SDL_init.inc} // 3.2.20

units/SDL_pen.inc

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,37 @@
1515
* handling, e.g., for input and drawing tablets or suitably equipped mobile /
1616
* tablet devices.
1717
*
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)
2126
*
2227
* Pens may provide more than simple touch input; they might have other axes,
2328
* 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.
2449
}
2550

2651
{*
@@ -30,7 +55,12 @@
3055
*
3156
* These show up in pen events when SDL sees input from them. They remain
3257
* 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.
3464
*
3565
* \since This datatype is available since SDL 3.2.0.
3666
}
@@ -72,6 +102,7 @@ const
72102
SDL_PEN_INPUT_BUTTON_4 = TSDL_PenInputFlags(1 shl 4); {*< button 4 is pressed }
73103
SDL_PEN_INPUT_BUTTON_5 = TSDL_PenInputFlags(1 shl 5); {*< button 5 is pressed }
74104
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) }
75106

76107
{*
77108
* Pen axis indices.
@@ -102,3 +133,29 @@ const
102133
SDL_PEN_AXIS_TANGENTIAL_PRESSURE = TSDL_PenAxis(6); {*< Pressure from squeezing the pen ("barrel pressure"). }
103134
SDL_PEN_AXIS_COUNT = TSDL_PenAxis(7); {*< Total known pen axis types in this version of SDL. This number may grow in future releases! }
104135

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

Comments
 (0)