This repository has been archived on 2026-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
sdl3bindings2/official/release-3.2.22/api/touch.zig

36 lines
1.2 KiB
Zig

const std = @import("std");
pub const c = @import("c.zig").c;
pub const TouchID = u64;
pub const FingerID = u64;
pub const TouchDeviceType = enum(c_int) {
touchDeviceDirect, //touch screen with window-relative coordinates
touchDeviceIndirectAbsolute, //trackpad with absolute device coordinates
touchDeviceIndirectRelative, //trackpad with screen cursor-relative coordinates
};
pub const Finger = extern struct {
id: FingerID, // the finger ID
x: f32, // the x-axis location of the touch event, normalized (0...1)
y: f32, // the y-axis location of the touch event, normalized (0...1)
pressure: f32, // the quantity of pressure applied, normalized (0...1)
};
pub inline fn getTouchDevices(count: *c_int) ?*TouchID {
return c.SDL_GetTouchDevices(@ptrCast(count));
}
pub inline fn getTouchDeviceName(touchID: TouchID) [*c]const u8 {
return c.SDL_GetTouchDeviceName(touchID);
}
pub inline fn getTouchDeviceType(touchID: TouchID) TouchDeviceType {
return @intFromEnum(c.SDL_GetTouchDeviceType(touchID));
}
pub inline fn getTouchFingers(touchID: TouchID, count: *c_int) [*c][*c]Finger {
return c.SDL_GetTouchFingers(touchID, @ptrCast(count));
}