tiny.windowing.Gamepad
Defined in gamepad.
API (11)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/windowing/src/gamepad.zig:134
zig
pub const Gamepad = struct { connected: bool = false, name_bytes: []const u8 = &.{}, buttons: [button_count]bool = @splat(false), pressed: [button_count]bool = @splat(false), released: [button_count]bool = @splat(false), axes: [axis_count]f32 = @splat(0), pub fn name(self: *const Gamepad) []const u8 { return self.name_bytes; } pub fn isDown(self: *const Gamepad, control: Button) bool { return self.buttons[@backingInt(control)]; } pub fn isPressed(self: *const Gamepad, control: Button) bool { return self.pressed[@backingInt(control)]; } pub fn isReleased(self: *const Gamepad, control: Button) bool { return self.released[@backingInt(control)]; } pub fn axisValue(self: *const Gamepad, control: Axis) f32 { return self.axes[@backingInt(control)]; } fn beginPoll(self: *Gamepad) void { @memset(&self.pressed, false); @memset(&self.released, false); } fn setButton(self: *Gamepad, control: Button, down: bool) void { const index = @backingInt(control); if (down and !self.buttons[index]) self.pressed[index] = true; if (!down and self.buttons[index]) self.released[index] = true; self.buttons[index] = down; } fn setAxis(self: *Gamepad, control: Axis, value: f32) void { self.axes[@backingInt(control)] = value; }};Source: lib/windowing/src/root.zig:91
zig
pub const Gamepad = gamepad_module.Gamepad;Audit
| Definitions | 6 |
|---|---|
| Public names | 12 |
| Members | 6 |
| Version | 26.7.0 |
| Revision | daab053ee433 |