Implement SDL_GetPenDeviceType() for Android

This commit is contained in:
Susko3
2025-05-17 15:33:30 +02:00
committed by Ryan C. Gordon
parent 23b487ceda
commit e2bbbdc515
12 changed files with 75 additions and 12 deletions

View File

@@ -199,6 +199,15 @@ SDL_PenInputFlags SDL_GetPenStatus(SDL_PenID instance_id, float *axes, int num_a
return result;
}
SDL_PenDeviceType SDL_GetPenDeviceType(SDL_PenID instance_id)
{
SDL_LockRWLockForReading(pen_device_rwlock);
const SDL_Pen *pen = FindPenByInstanceId(instance_id);
const SDL_PenDeviceType result = pen ? pen->info.device_type : SDL_PEN_DEVICE_TYPE_INVALID;
SDL_UnlockRWLock(pen_device_rwlock);
return result;
}
SDL_PenCapabilityFlags SDL_GetPenCapabilityFromAxis(SDL_PenAxis axis)
{
// the initial capability bits happen to match up, but as

View File

@@ -36,6 +36,8 @@ typedef Uint32 SDL_PenCapabilityFlags;
#define SDL_PEN_CAPABILITY_TANGENTIAL_PRESSURE (1u << 6) /**< Provides barrel pressure on SDL_PEN_AXIS_TANGENTIAL_PRESSURE. */
#define SDL_PEN_CAPABILITY_ERASER (1u << 7) /**< Pen also has an eraser tip. */
// Rename before making this public as it clashes with SDL_PenDeviceType.
// Prior art in Android calls this "tool type".
typedef enum SDL_PenSubtype
{
SDL_PEN_TYPE_UNKNOWN, /**< Unknown pen device */
@@ -53,6 +55,7 @@ typedef struct SDL_PenInfo
Uint32 wacom_id; /**< For Wacom devices: wacom tool type ID, otherwise 0 (useful e.g. with libwacom) */
int num_buttons; /**< Number of pen buttons (not counting the pen tip), or -1 if unknown. */
SDL_PenSubtype subtype; /**< type of pen device */
SDL_PenDeviceType device_type;
} SDL_PenInfo;
// Backend calls this when a new pen device is hotplugged, plus once for each pen already connected at startup.