clang-format in src/unix/
This commit is contained in:
@@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
CF_IMPLICIT_BRIDGING_ENABLED
|
CF_IMPLICIT_BRIDGING_ENABLED
|
||||||
CF_EXTERN_C_BEGIN
|
CF_EXTERN_C_BEGIN
|
||||||
void getDefaultROMPath(char*);
|
void getDefaultROMPath(char *);
|
||||||
int toto();
|
int toto();
|
||||||
|
|
||||||
CF_EXTERN_C_END
|
CF_EXTERN_C_END
|
||||||
CF_IMPLICIT_BRIDGING_DISABLED
|
CF_IMPLICIT_BRIDGING_DISABLED
|
||||||
|
|
||||||
|
|
||||||
#endif /* macOSXGlue_h */
|
#endif /* macOSXGlue_h */
|
||||||
|
513
src/unix/unix.c
513
src/unix/unix.c
File diff suppressed because it is too large
Load Diff
@@ -39,8 +39,6 @@
|
|||||||
#include <86box/plat.h>
|
#include <86box/plat.h>
|
||||||
#include <86box/ui.h>
|
#include <86box/ui.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cassette_mount(char *fn, uint8_t wp)
|
cassette_mount(char *fn, uint8_t wp)
|
||||||
{
|
{
|
||||||
@@ -51,47 +49,43 @@ cassette_mount(char *fn, uint8_t wp)
|
|||||||
if (fn != NULL)
|
if (fn != NULL)
|
||||||
memcpy(cassette_fname, fn, MIN(511, strlen(fn)));
|
memcpy(cassette_fname, fn, MIN(511, strlen(fn)));
|
||||||
ui_sb_update_icon_state(SB_CASSETTE, (fn == NULL) ? 1 : 0);
|
ui_sb_update_icon_state(SB_CASSETTE, (fn == NULL) ? 1 : 0);
|
||||||
//media_menu_update_cassette();
|
// media_menu_update_cassette();
|
||||||
ui_sb_update_tip(SB_CASSETTE);
|
ui_sb_update_tip(SB_CASSETTE);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cassette_eject(void)
|
cassette_eject(void)
|
||||||
{
|
{
|
||||||
pc_cas_set_fname(cassette, NULL);
|
pc_cas_set_fname(cassette, NULL);
|
||||||
memset(cassette_fname, 0x00, sizeof(cassette_fname));
|
memset(cassette_fname, 0x00, sizeof(cassette_fname));
|
||||||
ui_sb_update_icon_state(SB_CASSETTE, 1);
|
ui_sb_update_icon_state(SB_CASSETTE, 1);
|
||||||
//media_menu_update_cassette();
|
// media_menu_update_cassette();
|
||||||
ui_sb_update_tip(SB_CASSETTE);
|
ui_sb_update_tip(SB_CASSETTE);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cartridge_mount(uint8_t id, char *fn, uint8_t wp)
|
cartridge_mount(uint8_t id, char *fn, uint8_t wp)
|
||||||
{
|
{
|
||||||
cart_close(id);
|
cart_close(id);
|
||||||
cart_load(id, fn);
|
cart_load(id, fn);
|
||||||
ui_sb_update_icon_state(SB_CARTRIDGE | id, strlen(cart_fns[id]) ? 0 : 1);
|
ui_sb_update_icon_state(SB_CARTRIDGE | id, strlen(cart_fns[id]) ? 0 : 1);
|
||||||
//media_menu_update_cartridge(id);
|
// media_menu_update_cartridge(id);
|
||||||
ui_sb_update_tip(SB_CARTRIDGE | id);
|
ui_sb_update_tip(SB_CARTRIDGE | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cartridge_eject(uint8_t id)
|
cartridge_eject(uint8_t id)
|
||||||
{
|
{
|
||||||
cart_close(id);
|
cart_close(id);
|
||||||
ui_sb_update_icon_state(SB_CARTRIDGE | id, 1);
|
ui_sb_update_icon_state(SB_CARTRIDGE | id, 1);
|
||||||
//media_menu_update_cartridge(id);
|
// media_menu_update_cartridge(id);
|
||||||
ui_sb_update_tip(SB_CARTRIDGE | id);
|
ui_sb_update_tip(SB_CARTRIDGE | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
floppy_mount(uint8_t id, char *fn, uint8_t wp)
|
floppy_mount(uint8_t id, char *fn, uint8_t wp)
|
||||||
{
|
{
|
||||||
@@ -99,36 +93,34 @@ floppy_mount(uint8_t id, char *fn, uint8_t wp)
|
|||||||
ui_writeprot[id] = wp;
|
ui_writeprot[id] = wp;
|
||||||
fdd_load(id, fn);
|
fdd_load(id, fn);
|
||||||
ui_sb_update_icon_state(SB_FLOPPY | id, strlen(floppyfns[id]) ? 0 : 1);
|
ui_sb_update_icon_state(SB_FLOPPY | id, strlen(floppyfns[id]) ? 0 : 1);
|
||||||
//media_menu_update_floppy(id);
|
// media_menu_update_floppy(id);
|
||||||
ui_sb_update_tip(SB_FLOPPY | id);
|
ui_sb_update_tip(SB_FLOPPY | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
floppy_eject(uint8_t id)
|
floppy_eject(uint8_t id)
|
||||||
{
|
{
|
||||||
fdd_close(id);
|
fdd_close(id);
|
||||||
ui_sb_update_icon_state(SB_FLOPPY | id, 1);
|
ui_sb_update_icon_state(SB_FLOPPY | id, 1);
|
||||||
//media_menu_update_floppy(id);
|
// media_menu_update_floppy(id);
|
||||||
ui_sb_update_tip(SB_FLOPPY | id);
|
ui_sb_update_tip(SB_FLOPPY | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
plat_cdrom_ui_update(uint8_t id, uint8_t reload)
|
plat_cdrom_ui_update(uint8_t id, uint8_t reload)
|
||||||
{
|
{
|
||||||
cdrom_t *drv = &cdrom[id];
|
cdrom_t *drv = &cdrom[id];
|
||||||
|
|
||||||
if (drv->host_drive == 0) {
|
if (drv->host_drive == 0) {
|
||||||
ui_sb_update_icon_state(SB_CDROM|id, 1);
|
ui_sb_update_icon_state(SB_CDROM | id, 1);
|
||||||
} else {
|
} else {
|
||||||
ui_sb_update_icon_state(SB_CDROM|id, 0);
|
ui_sb_update_icon_state(SB_CDROM | id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//media_menu_update_cdrom(id);
|
// media_menu_update_cdrom(id);
|
||||||
ui_sb_update_tip(SB_CDROM|id);
|
ui_sb_update_tip(SB_CDROM | id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -150,7 +142,7 @@ cdrom_mount(uint8_t id, char *fn)
|
|||||||
} else {
|
} else {
|
||||||
ui_sb_update_icon_state(SB_CDROM | id, 1);
|
ui_sb_update_icon_state(SB_CDROM | id, 1);
|
||||||
}
|
}
|
||||||
//media_menu_update_cdrom(id);
|
// media_menu_update_cdrom(id);
|
||||||
ui_sb_update_tip(SB_CDROM | id);
|
ui_sb_update_tip(SB_CDROM | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
@@ -167,12 +159,11 @@ mo_eject(uint8_t id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui_sb_update_icon_state(SB_MO | id, 1);
|
ui_sb_update_icon_state(SB_MO | id, 1);
|
||||||
//media_menu_update_mo(id);
|
// media_menu_update_mo(id);
|
||||||
ui_sb_update_tip(SB_MO | id);
|
ui_sb_update_tip(SB_MO | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mo_mount(uint8_t id, char *fn, uint8_t wp)
|
mo_mount(uint8_t id, char *fn, uint8_t wp)
|
||||||
{
|
{
|
||||||
@@ -184,13 +175,12 @@ mo_mount(uint8_t id, char *fn, uint8_t wp)
|
|||||||
mo_insert(dev);
|
mo_insert(dev);
|
||||||
|
|
||||||
ui_sb_update_icon_state(SB_MO | id, strlen(mo_drives[id].image_path) ? 0 : 1);
|
ui_sb_update_icon_state(SB_MO | id, strlen(mo_drives[id].image_path) ? 0 : 1);
|
||||||
//media_menu_update_mo(id);
|
// media_menu_update_mo(id);
|
||||||
ui_sb_update_tip(SB_MO | id);
|
ui_sb_update_tip(SB_MO | id);
|
||||||
|
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mo_reload(uint8_t id)
|
mo_reload(uint8_t id)
|
||||||
{
|
{
|
||||||
@@ -198,13 +188,13 @@ mo_reload(uint8_t id)
|
|||||||
|
|
||||||
mo_disk_reload(dev);
|
mo_disk_reload(dev);
|
||||||
if (strlen(mo_drives[id].image_path) == 0) {
|
if (strlen(mo_drives[id].image_path) == 0) {
|
||||||
ui_sb_update_icon_state(SB_MO|id, 1);
|
ui_sb_update_icon_state(SB_MO | id, 1);
|
||||||
} else {
|
} else {
|
||||||
ui_sb_update_icon_state(SB_MO|id, 0);
|
ui_sb_update_icon_state(SB_MO | id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//media_menu_update_mo(id);
|
// media_menu_update_mo(id);
|
||||||
ui_sb_update_tip(SB_MO|id);
|
ui_sb_update_tip(SB_MO | id);
|
||||||
|
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
@@ -221,12 +211,11 @@ zip_eject(uint8_t id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui_sb_update_icon_state(SB_ZIP | id, 1);
|
ui_sb_update_icon_state(SB_ZIP | id, 1);
|
||||||
//media_menu_update_zip(id);
|
// media_menu_update_zip(id);
|
||||||
ui_sb_update_tip(SB_ZIP | id);
|
ui_sb_update_tip(SB_ZIP | id);
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zip_mount(uint8_t id, char *fn, uint8_t wp)
|
zip_mount(uint8_t id, char *fn, uint8_t wp)
|
||||||
{
|
{
|
||||||
@@ -238,13 +227,12 @@ zip_mount(uint8_t id, char *fn, uint8_t wp)
|
|||||||
zip_insert(dev);
|
zip_insert(dev);
|
||||||
|
|
||||||
ui_sb_update_icon_state(SB_ZIP | id, strlen(zip_drives[id].image_path) ? 0 : 1);
|
ui_sb_update_icon_state(SB_ZIP | id, strlen(zip_drives[id].image_path) ? 0 : 1);
|
||||||
//media_menu_update_zip(id);
|
// media_menu_update_zip(id);
|
||||||
ui_sb_update_tip(SB_ZIP | id);
|
ui_sb_update_tip(SB_ZIP | id);
|
||||||
|
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zip_reload(uint8_t id)
|
zip_reload(uint8_t id)
|
||||||
{
|
{
|
||||||
@@ -252,13 +240,13 @@ zip_reload(uint8_t id)
|
|||||||
|
|
||||||
zip_disk_reload(dev);
|
zip_disk_reload(dev);
|
||||||
if (strlen(zip_drives[id].image_path) == 0) {
|
if (strlen(zip_drives[id].image_path) == 0) {
|
||||||
ui_sb_update_icon_state(SB_ZIP|id, 1);
|
ui_sb_update_icon_state(SB_ZIP | id, 1);
|
||||||
} else {
|
} else {
|
||||||
ui_sb_update_icon_state(SB_ZIP|id, 0);
|
ui_sb_update_icon_state(SB_ZIP | id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//media_menu_update_zip(id);
|
// media_menu_update_zip(id);
|
||||||
ui_sb_update_tip(SB_ZIP|id);
|
ui_sb_update_tip(SB_ZIP | id);
|
||||||
|
|
||||||
config_save();
|
config_save();
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,7 @@
|
|||||||
#define RENDERER_HARDWARE 2
|
#define RENDERER_HARDWARE 2
|
||||||
#define RENDERER_OPENGL 4
|
#define RENDERER_OPENGL 4
|
||||||
|
|
||||||
typedef struct sdl_blit_params
|
typedef struct sdl_blit_params {
|
||||||
{
|
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
} sdl_blit_params;
|
} sdl_blit_params;
|
||||||
extern sdl_blit_params params;
|
extern sdl_blit_params params;
|
||||||
@@ -35,9 +34,9 @@ static SDL_Texture *sdl_tex = NULL;
|
|||||||
int sdl_w = SCREEN_RES_X, sdl_h = SCREEN_RES_Y;
|
int sdl_w = SCREEN_RES_X, sdl_h = SCREEN_RES_Y;
|
||||||
static int sdl_fs, sdl_flags = -1;
|
static int sdl_fs, sdl_flags = -1;
|
||||||
static int cur_w, cur_h;
|
static int cur_w, cur_h;
|
||||||
static int cur_wx = 0, cur_wy = 0, cur_ww =0, cur_wh = 0;
|
static int cur_wx = 0, cur_wy = 0, cur_ww = 0, cur_wh = 0;
|
||||||
static volatile int sdl_enabled = 1;
|
static volatile int sdl_enabled = 1;
|
||||||
static SDL_mutex* sdl_mutex = NULL;
|
static SDL_mutex *sdl_mutex = NULL;
|
||||||
int mouse_capture;
|
int mouse_capture;
|
||||||
int title_set = 0;
|
int title_set = 0;
|
||||||
int resize_pending = 0;
|
int resize_pending = 0;
|
||||||
@@ -127,7 +126,6 @@ sdl_stretch(int *w, int *h, int *x, int *y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
|
sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
|
||||||
{
|
{
|
||||||
@@ -146,7 +144,7 @@ sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
|
|||||||
void ui_window_title_real();
|
void ui_window_title_real();
|
||||||
|
|
||||||
void
|
void
|
||||||
sdl_real_blit(SDL_Rect* r_src)
|
sdl_real_blit(SDL_Rect *r_src)
|
||||||
{
|
{
|
||||||
SDL_Rect r_dst;
|
SDL_Rect r_dst;
|
||||||
int ret, winx, winy;
|
int ret, winx, winy;
|
||||||
@@ -156,16 +154,12 @@ sdl_real_blit(SDL_Rect* r_src)
|
|||||||
r_dst = *r_src;
|
r_dst = *r_src;
|
||||||
r_dst.x = r_dst.y = 0;
|
r_dst.x = r_dst.y = 0;
|
||||||
|
|
||||||
if (sdl_fs)
|
if (sdl_fs) {
|
||||||
{
|
|
||||||
sdl_stretch(&r_dst.w, &r_dst.h, &r_dst.x, &r_dst.y);
|
sdl_stretch(&r_dst.w, &r_dst.h, &r_dst.x, &r_dst.y);
|
||||||
|
} else {
|
||||||
|
r_dst.w *= ((float) winx / (float) r_dst.w);
|
||||||
|
r_dst.h *= ((float) winy / (float) r_dst.h);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
r_dst.w *= ((float)winx / (float) r_dst.w);
|
|
||||||
r_dst.h *= ((float)winy / (float) r_dst.h);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ret = SDL_RenderCopy(sdl_render, sdl_tex, r_src, &r_dst);
|
ret = SDL_RenderCopy(sdl_render, sdl_tex, r_src, &r_dst);
|
||||||
if (ret)
|
if (ret)
|
||||||
@@ -191,9 +185,9 @@ sdl_blit(int x, int y, int w, int h)
|
|||||||
|
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
|
|
||||||
if (resize_pending)
|
if (resize_pending) {
|
||||||
{
|
if (!video_fullscreen)
|
||||||
if (!video_fullscreen) sdl_resize(resize_w, resize_h);
|
sdl_resize(resize_w, resize_h);
|
||||||
resize_pending = 0;
|
resize_pending = 0;
|
||||||
}
|
}
|
||||||
r_src.x = x;
|
r_src.x = x;
|
||||||
@@ -211,11 +205,9 @@ static void
|
|||||||
sdl_destroy_window(void)
|
sdl_destroy_window(void)
|
||||||
{
|
{
|
||||||
if (sdl_win != NULL) {
|
if (sdl_win != NULL) {
|
||||||
if (window_remember)
|
if (window_remember) {
|
||||||
{
|
|
||||||
SDL_GetWindowSize(sdl_win, &window_w, &window_h);
|
SDL_GetWindowSize(sdl_win, &window_w, &window_h);
|
||||||
if (strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0)
|
if (strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0) {
|
||||||
{
|
|
||||||
SDL_GetWindowPosition(sdl_win, &window_x, &window_y);
|
SDL_GetWindowPosition(sdl_win, &window_x, &window_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +216,6 @@ sdl_destroy_window(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sdl_destroy_texture(void)
|
sdl_destroy_texture(void)
|
||||||
{
|
{
|
||||||
@@ -285,8 +276,7 @@ sdl_select_best_hw_driver(void)
|
|||||||
int i;
|
int i;
|
||||||
SDL_RendererInfo renderInfo;
|
SDL_RendererInfo renderInfo;
|
||||||
|
|
||||||
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i)
|
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
|
||||||
{
|
|
||||||
SDL_GetRenderDriverInfo(i, &renderInfo);
|
SDL_GetRenderDriverInfo(i, &renderInfo);
|
||||||
if (renderInfo.flags & SDL_RENDERER_ACCELERATED) {
|
if (renderInfo.flags & SDL_RENDERER_ACCELERATED) {
|
||||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name);
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name);
|
||||||
@@ -308,7 +298,6 @@ sdl_reinit_texture()
|
|||||||
|
|
||||||
sdl_tex = SDL_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
|
sdl_tex = SDL_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
|
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -316,7 +305,7 @@ sdl_set_fs(int fs)
|
|||||||
{
|
{
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
SDL_SetWindowFullscreen(sdl_win, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(sdl_win, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
SDL_SetRelativeMouseMode((SDL_bool)mouse_capture);
|
SDL_SetRelativeMouseMode((SDL_bool) mouse_capture);
|
||||||
|
|
||||||
sdl_fs = fs;
|
sdl_fs = fs;
|
||||||
|
|
||||||
@@ -363,8 +352,7 @@ sdl_resize(int x, int y)
|
|||||||
void
|
void
|
||||||
sdl_reload(void)
|
sdl_reload(void)
|
||||||
{
|
{
|
||||||
if (sdl_flags & RENDERER_HARDWARE)
|
if (sdl_flags & RENDERER_HARDWARE) {
|
||||||
{
|
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
|
|
||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, video_filter_method ? "1" : "0");
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, video_filter_method ? "1" : "0");
|
||||||
@@ -375,7 +363,7 @@ sdl_reload(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
plat_vidapi(char* api)
|
plat_vidapi(char *api)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -393,29 +381,26 @@ sdl_init_common(int flags)
|
|||||||
/* Initialize the SDL system. */
|
/* Initialize the SDL system. */
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "SDL: initialization failed (%s)\n", SDL_GetError());
|
fprintf(stderr, "SDL: initialization failed (%s)\n", SDL_GetError());
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & RENDERER_HARDWARE) {
|
if (flags & RENDERER_HARDWARE) {
|
||||||
if (flags & RENDERER_OPENGL) {
|
if (flags & RENDERER_OPENGL) {
|
||||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "OpenGL");
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "OpenGL");
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
sdl_select_best_hw_driver();
|
sdl_select_best_hw_driver();
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_mutex = SDL_CreateMutex();
|
sdl_mutex = SDL_CreateMutex();
|
||||||
sdl_win = SDL_CreateWindow("86Box", strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_x : SDL_WINDOWPOS_CENTERED, strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_y : SDL_WINDOWPOS_CENTERED, scrnsz_x, scrnsz_y, SDL_WINDOW_OPENGL | (vid_resize & 1 ? SDL_WINDOW_RESIZABLE : 0));
|
sdl_win = SDL_CreateWindow("86Box", strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_x : SDL_WINDOWPOS_CENTERED, strncasecmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0 && window_remember ? window_y : SDL_WINDOWPOS_CENTERED, scrnsz_x, scrnsz_y, SDL_WINDOW_OPENGL | (vid_resize & 1 ? SDL_WINDOW_RESIZABLE : 0));
|
||||||
sdl_set_fs(video_fullscreen);
|
sdl_set_fs(video_fullscreen);
|
||||||
if (!(video_fullscreen & 1))
|
if (!(video_fullscreen & 1)) {
|
||||||
{
|
|
||||||
if (vid_resize & 2)
|
if (vid_resize & 2)
|
||||||
plat_resize(fixed_size_x, fixed_size_y);
|
plat_resize(fixed_size_x, fixed_size_y);
|
||||||
else
|
else
|
||||||
plat_resize(scrnsz_x, scrnsz_y);
|
plat_resize(scrnsz_x, scrnsz_y);
|
||||||
}
|
}
|
||||||
if ((vid_resize < 2) && window_remember)
|
if ((vid_resize < 2) && window_remember) {
|
||||||
{
|
|
||||||
SDL_SetWindowSize(sdl_win, window_w, window_h);
|
SDL_SetWindowSize(sdl_win, window_w, window_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +412,7 @@ sdl_init_common(int flags)
|
|||||||
|
|
||||||
sdl_enabled = 1;
|
sdl_enabled = 1;
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -436,37 +421,35 @@ sdl_inits()
|
|||||||
return sdl_init_common(0);
|
return sdl_init_common(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sdl_inith()
|
sdl_inith()
|
||||||
{
|
{
|
||||||
return sdl_init_common(RENDERER_HARDWARE);
|
return sdl_init_common(RENDERER_HARDWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sdl_initho()
|
sdl_initho()
|
||||||
{
|
{
|
||||||
return sdl_init_common(RENDERER_HARDWARE | RENDERER_OPENGL);
|
return sdl_init_common(RENDERER_HARDWARE | RENDERER_OPENGL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sdl_pause(void)
|
sdl_pause(void)
|
||||||
{
|
{
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
plat_mouse_capture(int on)
|
plat_mouse_capture(int on)
|
||||||
{
|
{
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
SDL_SetRelativeMouseMode((SDL_bool)on);
|
SDL_SetRelativeMouseMode((SDL_bool) on);
|
||||||
mouse_capture = on;
|
mouse_capture = on;
|
||||||
SDL_UnlockMutex(sdl_mutex);
|
SDL_UnlockMutex(sdl_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_resize(int w, int h)
|
void
|
||||||
|
plat_resize(int w, int h)
|
||||||
{
|
{
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
resize_w = w;
|
resize_w = w;
|
||||||
@@ -476,21 +459,20 @@ void plat_resize(int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wchar_t sdl_win_title[512] = { L'8', L'6', L'B', L'o', L'x', 0 };
|
wchar_t sdl_win_title[512] = { L'8', L'6', L'B', L'o', L'x', 0 };
|
||||||
SDL_mutex* titlemtx = NULL;
|
SDL_mutex *titlemtx = NULL;
|
||||||
|
|
||||||
void ui_window_title_real()
|
void
|
||||||
|
ui_window_title_real()
|
||||||
{
|
{
|
||||||
char* res;
|
char *res;
|
||||||
if (sizeof(wchar_t) == 1)
|
if (sizeof(wchar_t) == 1) {
|
||||||
{
|
SDL_SetWindowTitle(sdl_win, (char *) sdl_win_title);
|
||||||
SDL_SetWindowTitle(sdl_win, (char*)sdl_win_title);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res = SDL_iconv_string("UTF-8", sizeof(wchar_t) == 2 ? "UTF-16LE" : "UTF-32LE", (char*)sdl_win_title, wcslen(sdl_win_title) * sizeof(wchar_t) + sizeof(wchar_t));
|
res = SDL_iconv_string("UTF-8", sizeof(wchar_t) == 2 ? "UTF-16LE" : "UTF-32LE", (char *) sdl_win_title, wcslen(sdl_win_title) * sizeof(wchar_t) + sizeof(wchar_t));
|
||||||
if (res)
|
if (res) {
|
||||||
{
|
|
||||||
SDL_SetWindowTitle(sdl_win, res);
|
SDL_SetWindowTitle(sdl_win, res);
|
||||||
SDL_free((void*)res);
|
SDL_free((void *) res);
|
||||||
}
|
}
|
||||||
title_set = 0;
|
title_set = 0;
|
||||||
}
|
}
|
||||||
@@ -498,9 +480,11 @@ extern SDL_threadID eventthread;
|
|||||||
|
|
||||||
/* Only activate threading path on macOS, otherwise it will softlock Xorg.
|
/* Only activate threading path on macOS, otherwise it will softlock Xorg.
|
||||||
Wayland doesn't seem to have this issue. */
|
Wayland doesn't seem to have this issue. */
|
||||||
wchar_t* ui_window_title(wchar_t* str)
|
wchar_t *
|
||||||
|
ui_window_title(wchar_t *str)
|
||||||
{
|
{
|
||||||
if (!str) return sdl_win_title;
|
if (!str)
|
||||||
|
return sdl_win_title;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (eventthread == SDL_ThreadID())
|
if (eventthread == SDL_ThreadID())
|
||||||
#endif
|
#endif
|
||||||
@@ -518,10 +502,17 @@ wchar_t* ui_window_title(wchar_t* str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_init_monitor(int monitor_index) {}
|
void
|
||||||
void ui_deinit_monitor(int monitor_index) {}
|
ui_init_monitor(int monitor_index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void
|
||||||
|
ui_deinit_monitor(int monitor_index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void plat_resize_request(int w, int h, int monitor_index)
|
void
|
||||||
|
plat_resize_request(int w, int h, int monitor_index)
|
||||||
{
|
{
|
||||||
atomic_store((&doresize_monitors[monitor_index]), 1);
|
atomic_store((&doresize_monitors[monitor_index]), 1);
|
||||||
}
|
}
|
||||||
|
@@ -7,30 +7,23 @@
|
|||||||
#include <86box/plat.h>
|
#include <86box/plat.h>
|
||||||
#include <86box/thread.h>
|
#include <86box/thread.h>
|
||||||
|
|
||||||
|
typedef struct event_pthread_t {
|
||||||
typedef struct event_pthread_t
|
|
||||||
{
|
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
int state;
|
int state;
|
||||||
} event_pthread_t;
|
} event_pthread_t;
|
||||||
|
|
||||||
|
typedef struct thread_param {
|
||||||
typedef struct thread_param
|
void (*thread_rout)(void *);
|
||||||
{
|
void *param;
|
||||||
void (*thread_rout)(void*);
|
|
||||||
void * param;
|
|
||||||
} thread_param;
|
} thread_param;
|
||||||
|
|
||||||
|
typedef struct pt_mutex_t {
|
||||||
typedef struct pt_mutex_t
|
|
||||||
{
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} pt_mutex_t;
|
} pt_mutex_t;
|
||||||
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
thread_run_wrapper(thread_param* arg)
|
thread_run_wrapper(thread_param *arg)
|
||||||
{
|
{
|
||||||
thread_param localparam = *arg;
|
thread_param localparam = *arg;
|
||||||
free(arg);
|
free(arg);
|
||||||
@@ -38,7 +31,6 @@ thread_run_wrapper(thread_param* arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
thread_t *
|
thread_t *
|
||||||
thread_create(void (*thread_rout)(void *param), void *param)
|
thread_create(void (*thread_rout)(void *param), void *param)
|
||||||
{
|
{
|
||||||
@@ -47,19 +39,17 @@ thread_create(void (*thread_rout)(void *param), void *param)
|
|||||||
thrparam->thread_rout = thread_rout;
|
thrparam->thread_rout = thread_rout;
|
||||||
thrparam->param = param;
|
thrparam->param = param;
|
||||||
|
|
||||||
pthread_create(thread, NULL, (void* (*)(void*))thread_run_wrapper, thrparam);
|
pthread_create(thread, NULL, (void *(*) (void *) ) thread_run_wrapper, thrparam);
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_wait(thread_t *arg)
|
thread_wait(thread_t *arg)
|
||||||
{
|
{
|
||||||
return pthread_join(*(pthread_t*)(arg), NULL);
|
return pthread_join(*(pthread_t *) (arg), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event_t *
|
event_t *
|
||||||
thread_create_event()
|
thread_create_event()
|
||||||
{
|
{
|
||||||
@@ -69,14 +59,13 @@ thread_create_event()
|
|||||||
pthread_mutex_init(&event->mutex, NULL);
|
pthread_mutex_init(&event->mutex, NULL);
|
||||||
event->state = 0;
|
event->state = 0;
|
||||||
|
|
||||||
return (event_t *)event;
|
return (event_t *) event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
thread_set_event(event_t *handle)
|
thread_set_event(event_t *handle)
|
||||||
{
|
{
|
||||||
event_pthread_t *event = (event_pthread_t *)handle;
|
event_pthread_t *event = (event_pthread_t *) handle;
|
||||||
|
|
||||||
pthread_mutex_lock(&event->mutex);
|
pthread_mutex_lock(&event->mutex);
|
||||||
event->state = 1;
|
event->state = 1;
|
||||||
@@ -84,22 +73,20 @@ thread_set_event(event_t *handle)
|
|||||||
pthread_mutex_unlock(&event->mutex);
|
pthread_mutex_unlock(&event->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
thread_reset_event(event_t *handle)
|
thread_reset_event(event_t *handle)
|
||||||
{
|
{
|
||||||
event_pthread_t *event = (event_pthread_t *)handle;
|
event_pthread_t *event = (event_pthread_t *) handle;
|
||||||
|
|
||||||
pthread_mutex_lock(&event->mutex);
|
pthread_mutex_lock(&event->mutex);
|
||||||
event->state = 0;
|
event->state = 0;
|
||||||
pthread_mutex_unlock(&event->mutex);
|
pthread_mutex_unlock(&event->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_wait_event(event_t *handle, int timeout)
|
thread_wait_event(event_t *handle, int timeout)
|
||||||
{
|
{
|
||||||
event_pthread_t *event = (event_pthread_t *)handle;
|
event_pthread_t *event = (event_pthread_t *) handle;
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||||
@@ -121,11 +108,10 @@ thread_wait_event(event_t *handle, int timeout)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
thread_destroy_event(event_t *handle)
|
thread_destroy_event(event_t *handle)
|
||||||
{
|
{
|
||||||
event_pthread_t *event = (event_pthread_t *)handle;
|
event_pthread_t *event = (event_pthread_t *) handle;
|
||||||
|
|
||||||
pthread_cond_destroy(&event->cond);
|
pthread_cond_destroy(&event->cond);
|
||||||
pthread_mutex_destroy(&event->mutex);
|
pthread_mutex_destroy(&event->mutex);
|
||||||
@@ -133,7 +119,6 @@ thread_destroy_event(event_t *handle)
|
|||||||
free(event);
|
free(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mutex_t *
|
mutex_t *
|
||||||
thread_create_mutex(void)
|
thread_create_mutex(void)
|
||||||
{
|
{
|
||||||
@@ -144,46 +129,40 @@ thread_create_mutex(void)
|
|||||||
return mutex;
|
return mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_wait_mutex(mutex_t *_mutex)
|
thread_wait_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
if (_mutex == NULL)
|
if (_mutex == NULL)
|
||||||
return(0);
|
return (0);
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
|
||||||
|
|
||||||
return
|
return pthread_mutex_lock(&mutex->mutex) != 0;
|
||||||
pthread_mutex_lock(&mutex->mutex) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_test_mutex(mutex_t *_mutex)
|
thread_test_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
if (_mutex == NULL)
|
if (_mutex == NULL)
|
||||||
return(0);
|
return (0);
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
|
||||||
|
|
||||||
return
|
return pthread_mutex_trylock(&mutex->mutex) != 0;
|
||||||
pthread_mutex_trylock(&mutex->mutex) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_release_mutex(mutex_t *_mutex)
|
thread_release_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
if (_mutex == NULL)
|
if (_mutex == NULL)
|
||||||
return(0);
|
return (0);
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
|
||||||
|
|
||||||
return pthread_mutex_unlock(&mutex->mutex) != 0;
|
return pthread_mutex_unlock(&mutex->mutex) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
thread_close_mutex(mutex_t *_mutex)
|
thread_close_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
|
||||||
|
|
||||||
pthread_mutex_destroy(&mutex->mutex);
|
pthread_mutex_destroy(&mutex->mutex);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user