2017-10-04 09:43:31 +00:00
|
|
|
#ifndef gui_h
|
|
|
|
#define gui_h
|
|
|
|
|
2019-06-26 03:01:54 +00:00
|
|
|
#include <SDL.h>
|
2017-10-14 11:10:26 +00:00
|
|
|
#include <Core/gb.h>
|
2018-05-27 16:30:23 +00:00
|
|
|
#include <stdbool.h>
|
2017-12-23 15:29:42 +00:00
|
|
|
#include "shader.h"
|
2022-07-08 14:51:42 +00:00
|
|
|
#include "configuration.h"
|
2017-10-04 09:43:31 +00:00
|
|
|
|
2018-06-26 16:36:14 +00:00
|
|
|
#define JOYSTICK_HIGH 0x4000
|
|
|
|
#define JOYSTICK_LOW 0x3800
|
|
|
|
|
2019-06-01 11:29:46 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#define MODIFIER KMOD_GUI
|
|
|
|
#else
|
|
|
|
#define MODIFIER KMOD_CTRL
|
|
|
|
#endif
|
|
|
|
|
2018-06-22 21:10:28 +00:00
|
|
|
extern GB_gameboy_t gb;
|
2018-05-27 16:30:23 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
extern SDL_Window *window;
|
|
|
|
extern SDL_Renderer *renderer;
|
|
|
|
extern SDL_Texture *texture;
|
|
|
|
extern SDL_PixelFormat *pixel_format;
|
2020-05-24 20:04:36 +00:00
|
|
|
extern SDL_Haptic *haptic;
|
2017-12-23 15:29:42 +00:00
|
|
|
extern shader_t shader;
|
2017-10-04 09:43:31 +00:00
|
|
|
|
2017-10-13 22:41:51 +00:00
|
|
|
enum pending_command {
|
|
|
|
GB_SDL_NO_COMMAND,
|
|
|
|
GB_SDL_SAVE_STATE_COMMAND,
|
|
|
|
GB_SDL_LOAD_STATE_COMMAND,
|
|
|
|
GB_SDL_RESET_COMMAND,
|
|
|
|
GB_SDL_NEW_FILE_COMMAND,
|
2017-10-14 11:10:26 +00:00
|
|
|
GB_SDL_QUIT_COMMAND,
|
2021-04-14 12:20:01 +00:00
|
|
|
GB_SDL_LOAD_STATE_FROM_FILE_COMMAND,
|
2017-10-13 22:41:51 +00:00
|
|
|
};
|
|
|
|
|
2020-08-06 01:08:19 +00:00
|
|
|
#define GB_SDL_DEFAULT_SCALE_MAX 8
|
2018-06-23 19:27:05 +00:00
|
|
|
|
2017-10-13 22:41:51 +00:00
|
|
|
extern enum pending_command pending_command;
|
|
|
|
extern unsigned command_parameter;
|
2021-04-14 12:20:01 +00:00
|
|
|
extern char *dropped_state_file;
|
2018-06-23 19:27:05 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
void update_viewport(void);
|
2017-10-13 22:41:51 +00:00
|
|
|
void run_gui(bool is_running);
|
2017-12-23 15:29:42 +00:00
|
|
|
void render_texture(void *pixels, void *previous);
|
2018-11-10 17:39:57 +00:00
|
|
|
void connect_joypad(void);
|
2017-12-22 22:39:04 +00:00
|
|
|
|
2018-06-23 19:27:05 +00:00
|
|
|
joypad_button_t get_joypad_button(uint8_t physical_button);
|
|
|
|
joypad_axis_t get_joypad_axis(uint8_t physical_axis);
|
|
|
|
|
2020-12-23 21:50:19 +00:00
|
|
|
static SDL_Scancode event_hotkey_code(SDL_Event *event)
|
|
|
|
{
|
|
|
|
if (event->key.keysym.sym >= SDLK_a && event->key.keysym.sym < SDLK_z) {
|
|
|
|
return SDL_SCANCODE_A + event->key.keysym.sym - SDLK_a;
|
|
|
|
}
|
|
|
|
|
|
|
|
return event->key.keysym.scancode;
|
|
|
|
}
|
|
|
|
|
2021-05-30 20:39:59 +00:00
|
|
|
void draw_text(uint32_t *buffer, unsigned width, unsigned height, unsigned x, signed y, const char *string, uint32_t color, uint32_t border, bool is_osd);
|
|
|
|
void show_osd_text(const char *text);
|
|
|
|
extern const char *osd_text;
|
|
|
|
extern unsigned osd_countdown;
|
|
|
|
extern unsigned osd_text_lines;
|
2022-06-10 20:51:06 +00:00
|
|
|
void convert_mouse_coordinates(signed *x, signed *y);
|
2021-05-30 20:39:59 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
#endif
|