SameBoy/gtk3/types.h

130 lines
2.5 KiB
C

#ifndef types_h
#define types_h
#include "SDL.h"
#include "shader.h"
#include "vram_viewer.h"
typedef struct{
int16_t x, y;
uint16_t width, height;
} Rect;
typedef struct GuiData {
struct CliOptionData {
gchar *config_path;
gchar *boot_rom_path;
gboolean fullscreen;
GB_model_t model;
gboolean force_software_renderer;
} cli_options;
GFile *file;
gint sample_rate;
GDateTime *config_modification_date;
char *battery_save_path;
char *cheats_save_path;
GB_model_t prev_model;
const GThread *main_thread;
volatile bool running;
volatile bool stopping;
volatile bool stopped;
// GTK pointers
GtkApplication *main_application;
GtkBuilder *builder;
GtkApplicationWindow *main_window;
GtkBox *main_window_container;
GtkGLArea *gl_area;
GtkDrawingArea *fallback_canvas;
GtkWindow *preferences;
VramViewerWindow *vram_viewer;
GtkWindow *memory_viewer;
GtkWindow *console;
GtkWindow *printer;
// Debugger state
GtkTextBuffer *pending_console_output;
gboolean in_sync_input;
gchar *last_console_input;
gboolean log_to_sidebar;
gboolean should_clear_sidebar;
GMutex debugger_input_mutex;
GCond debugger_input_cond;
GRecMutex console_output_lock;
GPtrArray *debugger_input_queue;
// Audio and video
bool audio_initialized;
uint32_t *image_buffers[3];
unsigned char current_buffer;
Rect viewport;
bool border_mode_changed;
bool is_fullscreen;
bool supports_gl;
shader_t shader;
unsigned last_screen_width;
unsigned last_screen_height;
// Fast forward / slow motion
bool underclock_down;
bool rewind_down;
bool do_rewind;
bool rewind_paused;
bool turbo_down;
double clock_mutliplier;
double analog_clock_multiplier;
bool analog_clock_multiplier_valid;
// Input
uint8_t pressed_buttons;
struct Controller_t {
SDL_GameController *controller;
SDL_Haptic *haptic;
bool ignore_rumble;
} *controllers;
unsigned controller_count;
struct Controller_t *last_used_controller; // Used for rumble
} GuiData;
typedef enum {
INPUT_UP,
INPUT_DOWN,
INPUT_LEFT,
INPUT_RIGHT,
INPUT_A,
INPUT_B,
INPUT_START,
INPUT_SELECT,
INPUT_TURBO,
INPUT_REWIND,
INPUT_SLOWDOWN,
INPUT_FULLSCREEN,
} input_names_t;
static unsigned key_map[] = {
[INPUT_UP] = GDK_KEY_w,
[INPUT_LEFT] = GDK_KEY_a,
[INPUT_DOWN] = GDK_KEY_s,
[INPUT_RIGHT] = GDK_KEY_d,
[INPUT_A] = GDK_KEY_l,
[INPUT_B] = GDK_KEY_k,
[INPUT_START] = GDK_KEY_h,
[INPUT_SELECT] = GDK_KEY_g,
[INPUT_TURBO] = GDK_KEY_space,
[INPUT_REWIND] = GDK_KEY_Tab,
[INPUT_SLOWDOWN] = GDK_KEY_Shift_L,
[INPUT_FULLSCREEN] = GDK_KEY_F11,
};
#endif