SameBoy/SDL/gui.h

69 lines
1.7 KiB
C
Raw Permalink Normal View History

2017-10-04 09:43:31 +00:00
#ifndef gui_h
#define gui_h
#include <SDL.h>
#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"
#include "configuration.h"
2017-10-04 09:43:31 +00:00
#define JOYSTICK_HIGH 0x4000
#define JOYSTICK_LOW 0x3800
#ifdef __APPLE__
#define MODIFIER KMOD_GUI
#else
#define MODIFIER KMOD_CTRL
#endif
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;
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,
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
};
#define GB_SDL_DEFAULT_SCALE_MAX 8
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;
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);
void connect_joypad(void);
2017-12-22 22:39:04 +00:00
joypad_button_t get_joypad_button(uint8_t physical_button);
joypad_axis_t get_joypad_axis(uint8_t physical_axis);
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