glfw: make mouse buttons a proper enum
Helps hexops/mach#37 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
4d1b92666b
commit
7806709a90
2 changed files with 28 additions and 25 deletions
|
|
@ -1,20 +1,23 @@
|
|||
//! Mouse button IDs.
|
||||
//!
|
||||
//! See glfw.setMouseButtonCallback for how these are used.
|
||||
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
// TODO(enumify)
|
||||
pub const one = c.GLFW_MOUSE_BUTTON_1;
|
||||
pub const two = c.GLFW_MOUSE_BUTTON_2;
|
||||
pub const three = c.GLFW_MOUSE_BUTTON_3;
|
||||
pub const four = c.GLFW_MOUSE_BUTTON_4;
|
||||
pub const five = c.GLFW_MOUSE_BUTTON_5;
|
||||
pub const six = c.GLFW_MOUSE_BUTTON_6;
|
||||
pub const seven = c.GLFW_MOUSE_BUTTON_7;
|
||||
pub const eight = c.GLFW_MOUSE_BUTTON_8;
|
||||
/// Mouse button IDs.
|
||||
///
|
||||
/// See glfw.setMouseButtonCallback for how these are used.
|
||||
pub const MouseButton = enum(c_int) {
|
||||
// We use left/right/middle aliases here because those are more common and we cannot have
|
||||
// duplicate values in a Zig enum.
|
||||
left = c.GLFW_MOUSE_BUTTON_1,
|
||||
right = c.GLFW_MOUSE_BUTTON_2,
|
||||
middle = c.GLFW_MOUSE_BUTTON_3,
|
||||
four = c.GLFW_MOUSE_BUTTON_4,
|
||||
five = c.GLFW_MOUSE_BUTTON_5,
|
||||
six = c.GLFW_MOUSE_BUTTON_6,
|
||||
seven = c.GLFW_MOUSE_BUTTON_7,
|
||||
eight = c.GLFW_MOUSE_BUTTON_8,
|
||||
};
|
||||
|
||||
pub const last = eight;
|
||||
pub const left = one;
|
||||
pub const right = two;
|
||||
pub const middle = three;
|
||||
/// Not in the MouseButton enumeration as it is a duplicate value which is forbidden.
|
||||
pub const last = MouseButton.eight;
|
||||
pub const one = MouseButton.left;
|
||||
pub const two = MouseButton.right;
|
||||
pub const three = MouseButton.middle;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue