aboutsummaryrefslogtreecommitdiff
path: root/src/sfml/window
diff options
context:
space:
mode:
Diffstat (limited to 'src/sfml/window')
-rw-r--r--src/sfml/window/Style.zig5
-rw-r--r--src/sfml/window/context_settings.zig28
-rw-r--r--src/sfml/window/event.zig162
-rw-r--r--src/sfml/window/keyboard.zig11
-rw-r--r--src/sfml/window/mouse.zig26
5 files changed, 0 insertions, 232 deletions
diff --git a/src/sfml/window/Style.zig b/src/sfml/window/Style.zig
deleted file mode 100644
index e9b401d..0000000
--- a/src/sfml/window/Style.zig
+++ /dev/null
@@ -1,5 +0,0 @@
-pub const none: u32 = 0;
-pub const titlebar: u32 = 1;
-pub const resize: u32 = 2;
-pub const close: u32 = 4;
-pub const defaultStyle = titlebar | resize | close;
diff --git a/src/sfml/window/context_settings.zig b/src/sfml/window/context_settings.zig
deleted file mode 100644
index 19b8f03..0000000
--- a/src/sfml/window/context_settings.zig
+++ /dev/null
@@ -1,28 +0,0 @@
-const sf = @import("../sfml.zig");
-
-pub const ContextSettings = packed struct {
- const PaddingType = @import("std").meta.Int(.unsigned, @bitSizeOf(c_int) - @bitSizeOf(bool));
-
- depth_bits: c_uint = 0,
- stencil_bits: c_uint = 0,
- antialiasing_level: c_uint = 0,
- major_version: c_uint = 1,
- minor_version: c_uint = 1,
- attribute_flags: u32 = 0,
- srgb_capable: bool = false,
- _padding: PaddingType = 0,
-
- pub const Attribute = struct {
- pub const default: u32 = 0;
- pub const core: u32 = 1;
- pub const debug: u32 = 4;
- };
-
- pub fn _toCSFML(self: ContextSettings) sf.c.sfContextSettings {
- return @bitCast(sf.c.sfContextSettings, self);
- }
-
- pub fn _fromCSFML(context_settings: sf.c.sfContextSettings) ContextSettings {
- return @bitCast(ContextSettings, context_settings);
- }
-}; \ No newline at end of file
diff --git a/src/sfml/window/event.zig b/src/sfml/window/event.zig
deleted file mode 100644
index a73c192..0000000
--- a/src/sfml/window/event.zig
+++ /dev/null
@@ -1,162 +0,0 @@
-//! Defines a system event and its parameters.
-
-const sf = struct {
- pub usingnamespace @import("../sfml.zig");
- pub usingnamespace sf.system;
-};
-
-pub const Event = union(Event.Type) {
- const Self = @This();
-
- pub const Type = enum(c_int) {
- closed,
- resized,
- lostFocus,
- gainedFocus,
- textEntered,
- keyPressed,
- keyReleased,
- mouseWheelScrolled,
- mouseButtonPressed,
- mouseButtonReleased,
- mouseMoved,
- mouseEntered,
- mouseLeft,
- joystickButtonPressed,
- joystickButtonReleased,
- joystickMoved,
- joystickConnected,
- joystickDisconnected,
- touchBegan,
- touchMoved,
- touchEnded,
- sensorChanged,
- };
-
- // Big oof
- /// Creates this event from a csfml one
- pub fn _fromCSFML(event: sf.c.sfEvent) Self {
- return switch (event.type) {
- sf.c.sfEvtClosed => .{ .closed = {} },
- sf.c.sfEvtResized => .{ .resized = .{ .size = .{ .x = event.size.width, .y = event.size.height } } },
- sf.c.sfEvtLostFocus => .{ .lostFocus = {} },
- sf.c.sfEvtGainedFocus => .{ .gainedFocus = {} },
- sf.c.sfEvtTextEntered => .{ .textEntered = .{ .unicode = event.text.unicode } },
- sf.c.sfEvtKeyPressed => .{ .keyPressed = .{ .code = @intToEnum(sf.window.keyboard.KeyCode, event.key.code), .alt = (event.key.alt != 0), .control = (event.key.control != 0), .shift = (event.key.shift != 0), .system = (event.key.system != 0) } },
- sf.c.sfEvtKeyReleased => .{ .keyReleased = .{ .code = @intToEnum(sf.window.keyboard.KeyCode, event.key.code), .alt = (event.key.alt != 0), .control = (event.key.control != 0), .shift = (event.key.shift != 0), .system = (event.key.system != 0) } },
- sf.c.sfEvtMouseWheelScrolled => .{ .mouseWheelScrolled = .{ .wheel = @intToEnum(sf.window.mouse.Wheel, event.mouseWheelScroll.wheel), .delta = event.mouseWheelScroll.delta, .pos = .{ .x = event.mouseWheelScroll.x, .y = event.mouseWheelScroll.y } } },
- sf.c.sfEvtMouseButtonPressed => .{ .mouseButtonPressed = .{ .button = @intToEnum(sf.window.mouse.Button, event.mouseButton.button), .pos = .{ .x = event.mouseButton.x, .y = event.mouseButton.y } } },
- sf.c.sfEvtMouseButtonReleased => .{ .mouseButtonReleased = .{ .button = @intToEnum(sf.window.mouse.Button, event.mouseButton.button), .pos = .{ .x = event.mouseButton.x, .y = event.mouseButton.y } } },
- sf.c.sfEvtMouseMoved => .{ .mouseMoved = .{ .pos = .{ .x = event.mouseMove.x, .y = event.mouseMove.y } } },
- sf.c.sfEvtMouseEntered => .{ .mouseEntered = {} },
- sf.c.sfEvtMouseLeft => .{ .mouseLeft = {} },
- sf.c.sfEvtJoystickButtonPressed => .{ .joystickButtonPressed = .{ .joystickId = event.joystickButton.joystickId, .button = event.joystickButton.button } },
- sf.c.sfEvtJoystickButtonReleased => .{ .joystickButtonReleased = .{ .joystickId = event.joystickButton.joystickId, .button = event.joystickButton.button } },
- sf.c.sfEvtJoystickMoved => .{ .joystickMoved = .{ .joystickId = event.joystickMove.joystickId, .axis = event.joystickMove.axis, .position = event.joystickMove.position } },
- sf.c.sfEvtJoystickConnected => .{ .joystickConnected = .{ .joystickId = event.joystickConnect.joystickId } },
- sf.c.sfEvtJoystickDisconnected => .{ .joystickDisconnected = .{ .joystickId = event.joystickConnect.joystickId } },
- sf.c.sfEvtTouchBegan => .{ .touchBegan = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } },
- sf.c.sfEvtTouchMoved => .{ .touchMoved = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } },
- sf.c.sfEvtTouchEnded => .{ .touchEnded = .{ .finger = event.touch.finger, .pos = .{ .x = event.touch.x, .y = event.touch.y } } },
- sf.c.sfEvtSensorChanged => .{ .sensorChanged = .{ .sensorType = event.sensor.sensorType, .vector = .{ .x = event.sensor.x, .y = event.sensor.y, .z = event.sensor.z } } },
- sf.c.sfEvtCount => @panic("sfEvtCount should't exist as an event!"),
- else => @panic("Unknown event!"),
- };
- }
-
- /// Gets how many types of event exist
- pub fn getEventCount() c_uint {
- return @enumToInt(sf.c.sfEventType.sfEvtCount);
- }
-
- /// Size events parameters
- pub const SizeEvent = struct {
- size: sf.Vector2u,
- };
-
- /// Keyboard event parameters
- pub const KeyEvent = struct {
- code: sf.window.keyboard.KeyCode,
- alt: bool,
- control: bool,
- shift: bool,
- system: bool,
- };
-
- /// Text event parameters
- pub const TextEvent = struct {
- unicode: u32,
- };
-
- /// Mouse move event parameters
- pub const MouseMoveEvent = struct {
- pos: sf.Vector2i,
- };
-
- /// Mouse buttons events parameters
- pub const MouseButtonEvent = struct {
- button: sf.window.mouse.Button,
- pos: sf.Vector2i,
- };
-
- /// Mouse wheel events parameters
- pub const MouseWheelScrollEvent = struct {
- wheel: sf.window.mouse.Wheel,
- delta: f32,
- pos: sf.Vector2i,
- };
-
- /// Joystick axis move event parameters
- pub const JoystickMoveEvent = struct {
- joystickId: c_uint,
- axis: sf.c.sfJoystickAxis,
- position: f32,
- };
-
- /// Joystick buttons events parameters
- pub const JoystickButtonEvent = struct {
- joystickId: c_uint,
- button: c_uint,
- };
-
- /// Joystick connection/disconnection event parameters
- pub const JoystickConnectEvent = struct {
- joystickId: c_uint,
- };
-
- /// Touch events parameters
- pub const TouchEvent = struct {
- finger: c_uint,
- pos: sf.Vector2i,
- };
-
- /// Sensor event parameters
- pub const SensorEvent = struct {
- sensorType: sf.c.sfSensorType,
- vector: sf.Vector3f,
- };
-
- // An event is one of those
- closed: void,
- resized: SizeEvent,
- lostFocus: void,
- gainedFocus: void,
- textEntered: TextEvent,
- keyPressed: KeyEvent,
- keyReleased: KeyEvent,
- mouseWheelScrolled: MouseWheelScrollEvent,
- mouseButtonPressed: MouseButtonEvent,
- mouseButtonReleased: MouseButtonEvent,
- mouseMoved: MouseMoveEvent,
- mouseEntered: void,
- mouseLeft: void,
- joystickButtonPressed: JoystickButtonEvent,
- joystickButtonReleased: JoystickButtonEvent,
- joystickMoved: JoystickMoveEvent,
- joystickConnected: JoystickConnectEvent,
- joystickDisconnected: JoystickConnectEvent,
- touchBegan: TouchEvent,
- touchMoved: TouchEvent,
- touchEnded: TouchEvent,
- sensorChanged: SensorEvent,
-};
diff --git a/src/sfml/window/keyboard.zig b/src/sfml/window/keyboard.zig
deleted file mode 100644
index 8e4e970..0000000
--- a/src/sfml/window/keyboard.zig
+++ /dev/null
@@ -1,11 +0,0 @@
-//! Give access to the real-time state of the keyboard.
-
-const sf = @import("../sfml_import.zig");
-
-/// Keycodes
-pub const KeyCode = enum(c_int) { Unknown = -1, A = 0, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Escape, LControl, LShift, LAlt, LSystem, RControl, RShift, RAlt, RSystem, Menu, LBracket, RBracket, Semicolon, Comma, Period, Quote, Slash, Backslash, Tilde, Equal, Hyphen, Space, Enter, Backspace, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, Subtract, Multiply, Divide, Left, Right, Up, Down, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Pause, KeyCount };
-
-/// Returns true if the specified key is pressed
-pub fn isKeyPressed(key: KeyCode) bool {
- return sf.c.sfKeyboard_isKeyPressed(@enumToInt(key)) == 1;
-}
diff --git a/src/sfml/window/mouse.zig b/src/sfml/window/mouse.zig
deleted file mode 100644
index b60ff00..0000000
--- a/src/sfml/window/mouse.zig
+++ /dev/null
@@ -1,26 +0,0 @@
-//! Give access to the real-time state of the mouse.
-
-const sf = @import("../sfml.zig");
-
-/// Mouse buttons
-pub const Button = enum(c_uint) { Left, Right, Middle, XButton1, XButton2 };
-/// Mouse wheels
-pub const Wheel = enum(c_uint) { Vertical, Horizontal };
-
-/// Returns true if the specified mouse button is pressed
-pub fn isButtonPressed(button: Button) bool {
- return sf.c.sfMouse_isButtonPressed(@intToEnum(sf.c.sfMouseButton, @enumToInt(button))) == 1;
-}
-
-/// Gets the position of the mouse cursor relative to the window passed or desktop
-pub fn getPosition(window: ?sf.graphics.RenderWindow) sf.system.Vector2i {
- if (window) |w| {
- return sf.system.Vector2i._fromCSFML(sf.c.sfMouse_getPosition(@ptrCast(*sf.c.sfWindow, w._ptr)));
- } else return sf.system.Vector2i._fromCSFML(sf.c.sfMouse_getPosition(null));
-}
-/// Set the position of the mouse cursor relative to the window passed or desktop
-pub fn setPosition(position: sf.system.Vector2i, window: ?sf.graphics.RenderWindow) void {
- if (window) |w| {
- sf.c.sfMouse_setPosition(position._toCSFML(), @ptrCast(*sf.c.sfWindow, w._ptr));
- } else sf.c.sfMouse_setPosition(position._toCSFML(), null);
-}