2026-03-21 19:41:43 +01:00

108 lines
2.1 KiB
C

#ifndef SL_CORE_H
# define SL_CORE_H
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <pthread.h>
#include <dirent.h>
#include <limits.h>
#include <atomic.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <linux/kd.h>
#include <linux/input.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <gbm.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <epoxy/gl.h>
#include <epoxy/glx.h>
#include <readline/readline.h>
#include <readline/history.h>
#define STB_DS_IMPLEMENTATION
#include "../include/stb_ds.h"
#define DEFAULT_EVDEV_PATH "/dev/input/"
typedef struct sl_dumbframebuffer {
uint32_t id; /* Issue de drmModeAddFB2() */
uint32_t width; /* Définie par le développeur */
uint32_t height; /* Définie par le développeur */
uint32_t stride; /* Issue de drmModeCreateDumbBuffer() */
uint32_t handle; /* Issue de drmModeCreateDumbBudder() */
uint64_t size; /* Issue de drmModeCreateDumbBuffer() */
uint8_t *data; /* Issue du mmap */
} sl_dumbframebuffer_t;
typedef struct sl_framebuffer {
drmModeFB fb;
drmModePlane plane;
} sl_framebuffer_t;
typedef struct sl_display{
drmModeConnector conn;
drmModeCrtc crtc;
drmModeRes res;
drmModeEncoder enc;
} sl_display_t;
typedef struct sl_term {
int fd_in;
int fd_out;
} sl_term_t;
typedef struct sl_window {
int height;
int width;
int id;
int flags;
int buffer_id;
} sl_window_t;
typedef struct {
int default_mode;
bool event_mode;
int file_flags;
struct termios setting;
int fd;
} sl_keyboard_t;
#ifndef MAX_MOUSE_BUTTON
# define MAX_MOUSE_BUTTON 8//defined by raylib in rcore.c
#endif
typedef struct {
Vector2 wheel_move;
char button_state_evdev[8];
bool cursor_relative;
int mouse_fd;
} sl_mouse_t;
typedef struct {
int fd;
drmModeConnector *monitor;
drmModeCrtc *crtc;
int mode_index;
uint32_t prev_framebuffer;
struct gbm_device *gbm_devices;
struct gbm_surface *gbm_surfaces;
struct gbm_bo *prev_bufferobj;
EGLDisplay device;
} sl_platform;
#endif