| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // WIP! Does not function yet.
- #+build linux
- #+private file
- package karl2d
- @(private="package")
- WINDOW_INTERFACE_X11 :: Window_Interface {
- state_size = x11_state_size,
- init = x11_init,
- shutdown = x11_shutdown,
- window_handle = x11_window_handle,
- process_events = x11_process_events,
- get_events = x11_get_events,
- get_width = x11_get_width,
- get_height = x11_get_height,
- clear_events = x11_clear_events,
- set_position = x11_set_position,
- set_size = x11_set_size,
- get_window_scale = x11_get_window_scale,
- set_flags = x11_set_flags,
- is_gamepad_active = x11_is_gamepad_active,
- get_gamepad_axis = x11_get_gamepad_axis,
- set_gamepad_vibration = x11_set_gamepad_vibration,
- set_internal_state = x11_set_internal_state,
- }
- import "vendor:x11/xlib"
- import "base:runtime"
- import "core:log"
- import "core:fmt"
- _ :: xlib
- _ :: log
- _ :: fmt
- x11_state_size :: proc() -> int {
- return size_of(X11_State)
- }
- x11_init :: proc(
- window_state: rawptr,
- window_width: int,
- window_height: int,
- window_title: string,
- flags: Window_Flags,
- allocator: runtime.Allocator,
- ) {
- s = (^X11_State)(window_state)
- s.allocator = allocator
- s.flags = flags
- s.width = window_width
- s.height = window_height
- }
- x11_shutdown :: proc() {
- }
- x11_window_handle :: proc() -> Window_Handle {
- return {}
- }
- x11_process_events :: proc() {
- }
- x11_get_events :: proc() -> []Window_Event {
- return s.events[:]
- }
- x11_get_width :: proc() -> int {
- return s.width
- }
- x11_get_height :: proc() -> int {
- return s.height
- }
- x11_clear_events :: proc() {
- runtime.clear(&s.events)
- }
- x11_set_position :: proc(x: int, y: int) {
- }
- x11_set_size :: proc(w, h: int) {
- }
- x11_get_window_scale :: proc() -> f32 {
- return 1
- }
- x11_set_flags :: proc(flags: Window_Flags) {
- s.flags = flags
- }
- x11_is_gamepad_active :: proc(gamepad: int) -> bool {
- if gamepad < 0 || gamepad >= MAX_GAMEPADS {
- return false
- }
- return false
- }
- x11_get_gamepad_axis :: proc(gamepad: int, axis: Gamepad_Axis) -> f32 {
- if gamepad < 0 || gamepad >= MAX_GAMEPADS {
- return 0
- }
- return 0
- }
- x11_set_gamepad_vibration :: proc(gamepad: int, left: f32, right: f32) {
- if gamepad < 0 || gamepad >= MAX_GAMEPADS {
- return
- }
- }
- x11_set_internal_state :: proc(state: rawptr) {
- assert(state != nil)
- s = (^X11_State)(state)
- }
- X11_State :: struct {
- allocator: runtime.Allocator,
- width: int,
- height: int,
- events: [dynamic]Window_Event,
- flags: Window_Flags,
- }
- s: ^X11_State
|