132 lines
4.5 KiB
Zig
132 lines
4.5 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
const scancode_api = @import("scancode.zig");
|
|
const video_api = @import("video.zig");
|
|
const keycode_api = @import("keycode.zig");
|
|
const rect_api = @import("rect.zig");
|
|
const properties_api = @import("properties.zig");
|
|
|
|
pub const Scancode = scancode_api.Scancode;
|
|
pub const Window = video_api.Window;
|
|
pub const Keymod = keycode_api.Keymod;
|
|
pub const Rect = rect_api.Rect;
|
|
pub const Keycode = keycode_api.Keycode;
|
|
pub const PropertiesID = properties_api.PropertiesID;
|
|
|
|
pub const KeyboardID = u32;
|
|
|
|
pub inline fn hasKeyboard() bool {
|
|
return @bitCast(c.SDL_HasKeyboard());
|
|
}
|
|
|
|
pub inline fn getKeyboards(count: ?*c_int) ?*KeyboardID {
|
|
return c.SDL_GetKeyboards(count);
|
|
}
|
|
|
|
pub inline fn getKeyboardNameForID(instance_id: KeyboardID) [*c]const u8 {
|
|
return c.SDL_GetKeyboardNameForID(instance_id);
|
|
}
|
|
|
|
pub inline fn getKeyboardFocus() ?*Window {
|
|
return @ptrCast(@alignCast(c.SDL_GetKeyboardFocus()));
|
|
}
|
|
|
|
pub inline fn getKeyboardState(numkeys: ?*c_int) *const bool {
|
|
return @ptrCast(@alignCast(c.SDL_GetKeyboardState(numkeys)));
|
|
}
|
|
|
|
pub inline fn resetKeyboard() void {
|
|
return c.SDL_ResetKeyboard();
|
|
}
|
|
|
|
pub inline fn getModState() Keymod {
|
|
return c.SDL_GetModState();
|
|
}
|
|
|
|
pub inline fn setModState(modstate: Keymod) void {
|
|
return c.SDL_SetModState(modstate);
|
|
}
|
|
|
|
pub inline fn getKeyFromScancode(scancode: Scancode, modstate: Keymod, key_event: bool) Keycode {
|
|
return c.SDL_GetKeyFromScancode(@intCast(@backingInt(scancode)), modstate, @bitCast(key_event));
|
|
}
|
|
|
|
pub inline fn getScancodeFromKey(key: Keycode, modstate: ?*Keymod) Scancode {
|
|
return @fromBackingInt(@intCast(c.SDL_GetScancodeFromKey(key, modstate)));
|
|
}
|
|
|
|
pub inline fn setScancodeName(scancode: Scancode, name: [*c]const u8) bool {
|
|
return @bitCast(c.SDL_SetScancodeName(@intCast(@backingInt(scancode)), name));
|
|
}
|
|
|
|
pub inline fn getScancodeName(scancode: Scancode) [*c]const u8 {
|
|
return c.SDL_GetScancodeName(@intCast(@backingInt(scancode)));
|
|
}
|
|
|
|
pub inline fn getScancodeFromName(name: [*c]const u8) Scancode {
|
|
return @fromBackingInt(@intCast(c.SDL_GetScancodeFromName(name)));
|
|
}
|
|
|
|
pub inline fn getKeyName(key: Keycode) [*c]const u8 {
|
|
return c.SDL_GetKeyName(key);
|
|
}
|
|
|
|
pub inline fn getKeyFromName(name: [*c]const u8) Keycode {
|
|
return c.SDL_GetKeyFromName(name);
|
|
}
|
|
|
|
pub inline fn startTextInput(window: ?*Window) bool {
|
|
return @bitCast(c.SDL_StartTextInput(@ptrCast(@alignCast(window))));
|
|
}
|
|
|
|
pub const TextInputType = enum(c_int) {
|
|
textinputTypeText, //The input is text
|
|
textinputTypeTextName, //The input is a person's name
|
|
textinputTypeTextEmail, //The input is an e-mail address
|
|
textinputTypeTextUsername, //The input is a username
|
|
textinputTypeTextPasswordHidden, //The input is a secure password that is hidden
|
|
textinputTypeTextPasswordVisible, //The input is a secure password that is visible
|
|
textinputTypeNumber, //The input is a number
|
|
textinputTypeNumberPasswordHidden, //The input is a secure PIN that is hidden
|
|
textinputTypeNumberPasswordVisible, //The input is a secure PIN that is visible
|
|
};
|
|
|
|
pub const Capitalization = enum(c_int) {
|
|
capitalizeNone, //No auto-capitalization will be done
|
|
capitalizeSentences, //The first letter of sentences will be capitalized
|
|
capitalizeWords, //The first letter of words will be capitalized
|
|
capitalizeLetters, //All letters will be capitalized
|
|
};
|
|
|
|
pub inline fn startTextInputWithProperties(window: ?*Window, props: PropertiesID) bool {
|
|
return @bitCast(c.SDL_StartTextInputWithProperties(@ptrCast(@alignCast(window)), props));
|
|
}
|
|
|
|
pub inline fn textInputActive(window: ?*Window) bool {
|
|
return @bitCast(c.SDL_TextInputActive(@ptrCast(@alignCast(window))));
|
|
}
|
|
|
|
pub inline fn stopTextInput(window: ?*Window) bool {
|
|
return @bitCast(c.SDL_StopTextInput(@ptrCast(@alignCast(window))));
|
|
}
|
|
|
|
pub inline fn clearComposition(window: ?*Window) bool {
|
|
return @bitCast(c.SDL_ClearComposition(@ptrCast(@alignCast(window))));
|
|
}
|
|
|
|
pub inline fn setTextInputArea(window: ?*Window, rect: ?*const Rect, cursor: c_int) bool {
|
|
return @bitCast(c.SDL_SetTextInputArea(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect)), cursor));
|
|
}
|
|
|
|
pub inline fn getTextInputArea(window: ?*Window, rect: ?*Rect, cursor: ?*c_int) bool {
|
|
return @bitCast(c.SDL_GetTextInputArea(@ptrCast(@alignCast(window)), @ptrCast(@alignCast(rect)), cursor));
|
|
}
|
|
|
|
pub inline fn hasScreenKeyboardSupport() bool {
|
|
return @bitCast(c.SDL_HasScreenKeyboardSupport());
|
|
}
|
|
|
|
pub inline fn screenKeyboardShown(window: ?*Window) bool {
|
|
return @bitCast(c.SDL_ScreenKeyboardShown(@ptrCast(@alignCast(window))));
|
|
}
|