|
| 1 | +{ |
| 2 | + This file is part of: |
| 3 | +
|
| 4 | + SDL3 for Pascal |
| 5 | + (https://github.com/PascalGameDevelopment/SDL3-for-Pascal) |
| 6 | + SPDX-License-Identifier: Zlib |
| 7 | +} |
| 8 | + |
| 9 | +{* |
| 10 | + * # CategoryTouch |
| 11 | + * |
| 12 | + * SDL touch management. |
| 13 | + } |
| 14 | + |
1 | 15 | type |
2 | 16 | PPSDL_TouchID = ^PSDL_TouchID; |
3 | 17 | PSDL_TouchID = ^TSDL_TouchID; |
|
7 | 21 | PSDL_FingerID = ^TSDL_FingerID; |
8 | 22 | TSDL_FingerID = cuint64; |
9 | 23 |
|
| 24 | +type |
| 25 | + PPSDL_TouchDeviceType = ^PSDL_TouchDeviceType; |
| 26 | + PSDL_TouchDeviceType = ^TSDL_TouchDeviceType; |
| 27 | + TSDL_TouchDeviceType = type Integer; |
| 28 | +const |
| 29 | + SDL_TOUCH_DEVICE_INVALID = TSDL_TouchDeviceType(-1); |
| 30 | + SDL_TOUCH_DEVICE_DIRECT = TSDL_TouchDeviceType(0); { touch screen with window-relative coordinates } |
| 31 | + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE = TSDL_TouchDeviceType(1); { trackpad with absolute device coordinates } |
| 32 | + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE = TSDL_TouchDeviceType(2); { trackpad with screen cursor-relative coordinates } |
| 33 | + |
| 34 | +{* |
| 35 | + * Data about a single finger in a multitouch event. |
| 36 | + * |
| 37 | + * Each touch even is a collection of fingers that are simultaneously in |
| 38 | + * contact with the touch device (so a "touch" can be a "multitouch," in |
| 39 | + * reality), and this struct reports details of the specific fingers. |
| 40 | + * |
| 41 | + * \since This struct is available since SDL 3.1.3. |
| 42 | + * |
| 43 | + * \sa SDL_GetTouchFingers |
| 44 | + } |
| 45 | +type |
| 46 | + PPSDL_Finger = ^PSDL_Finger; |
| 47 | + PSDL_Finger = ^TSDL_Finger; |
| 48 | + TSDL_Finger = record |
| 49 | + id: TSDL_FingerID; {*< the finger ID } |
| 50 | + x: cfloat; {*< the x-axis location of the touch event, normalized (0...1) } |
| 51 | + y: cfloat; {*< the y-axis location of the touch event, normalized (0...1) } |
| 52 | + pressure: cfloat; {*< the quantity of pressure applied, normalized (0...1) } |
| 53 | + end; |
| 54 | + |
| 55 | +{ #todo : SDL3-for-Pascal: Translate macro } |
| 56 | +{ Used as the device ID for mouse events simulated with touch input } |
| 57 | +{ #define SDL_TOUCH_MOUSEID ((SDL_MouseID)-1) } |
| 58 | + |
| 59 | +{ #todo : SDL3-for-Pascal: Translate macro } |
| 60 | +{ Used as the SDL_TouchID for touch events simulated with mouse input } |
| 61 | +{ #define SDL_MOUSE_TOUCHID ((SDL_TouchID)-1) } |
| 62 | + |
| 63 | +{* |
| 64 | + * Get a list of registered touch devices. |
| 65 | + * |
| 66 | + * On some platforms SDL first sees the touch device if it was actually used. |
| 67 | + * Therefore the returned list might be empty, although devices are available. |
| 68 | + * After using all devices at least once the number will be correct. |
| 69 | + * |
| 70 | + * \param count a Pointer filled in with the number of devices returned, may |
| 71 | + * be nil. |
| 72 | + * \returns a 0 terminated array of touch device IDs or nil on failure; call |
| 73 | + * SDL_GetError() for more information. This should be freed with |
| 74 | + * SDL_free() when it is no longer needed. |
| 75 | + * |
| 76 | + * \since This function is available since SDL 3.1.3. |
| 77 | + } |
| 78 | +function SDL_GetTouchDevices(count: pcint): PSDL_TouchID; cdecl; |
| 79 | + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTouchDevices' {$ENDIF} {$ENDIF}; |
| 80 | + |
| 81 | +{* |
| 82 | + * Get the touch device name as reported from the driver. |
| 83 | + * |
| 84 | + * \param touchID the touch device instance ID. |
| 85 | + * \returns touch device name, or nil on failure; call SDL_GetError() for |
| 86 | + * more information. |
| 87 | + * |
| 88 | + * \since This function is available since SDL 3.1.3. |
| 89 | + } |
| 90 | +function SDL_GetTouchDeviceName(touchID: TSDL_TouchID): PAnsiChar; cdecl; |
| 91 | + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTouchDeviceName' {$ENDIF} {$ENDIF}; |
| 92 | + |
| 93 | +{* |
| 94 | + * Get the type of the given touch device. |
| 95 | + * |
| 96 | + * \param touchID the ID of a touch device. |
| 97 | + * \returns touch device type. |
| 98 | + * |
| 99 | + * \since This function is available since SDL 3.1.3. |
| 100 | + } |
| 101 | +function SDL_GetTouchDeviceType(touchID: TSDL_TouchID): TSDL_TouchDeviceType; cdecl; |
| 102 | + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTouchDeviceType' {$ENDIF} {$ENDIF}; |
| 103 | + |
| 104 | +{* |
| 105 | + * Get a list of active fingers for a given touch device. |
| 106 | + * |
| 107 | + * \param touchID the ID of a touch device. |
| 108 | + * \param count a Pointer filled in with the number of fingers returned, can |
| 109 | + * be nil. |
| 110 | + * \returns a nil terminated array of SDL_Finger pointers or nil on failure; |
| 111 | + * call SDL_GetError() for more information. This is a single |
| 112 | + * allocation that should be freed with SDL_free() when it is no |
| 113 | + * longer needed. |
| 114 | + * |
| 115 | + * \since This function is available since SDL 3.1.3. |
| 116 | + } |
| 117 | +function SDL_GetTouchFingers(touchID: TSDL_TouchID; count: pcint):PPSDL_Finger; cdecl; |
| 118 | + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTouchFingers' {$ENDIF} {$ENDIF}; |
| 119 | + |
0 commit comments