2015-05-13 18:47:23 +00:00
|
|
|
/*
|
|
|
|
* UAE - The Un*x Amiga Emulator
|
|
|
|
*
|
2017-02-27 14:29:54 +01:00
|
|
|
* Amiberry interface
|
2015-05-13 18:47:23 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
2017-12-04 15:49:40 +01:00
|
|
|
#include <iostream>
|
2015-05-13 18:47:23 +00:00
|
|
|
#include <vector>
|
2017-12-27 15:08:50 +01:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdarg>
|
2015-05-13 18:47:23 +00:00
|
|
|
#include <asm/sigcontext.h>
|
2017-12-27 15:08:50 +01:00
|
|
|
#include <csignal>
|
2017-12-04 15:49:40 +01:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#ifndef ANDROID
|
|
|
|
#include <execinfo.h>
|
|
|
|
#endif
|
2015-05-13 18:47:23 +00:00
|
|
|
#include "sysconfig.h"
|
|
|
|
#include "sysdeps.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "uae.h"
|
|
|
|
#include "options.h"
|
2018-01-20 18:14:12 +01:00
|
|
|
#include "custom.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
#include "inputdevice.h"
|
|
|
|
#include "disk.h"
|
|
|
|
#include "savestate.h"
|
2016-04-24 09:45:29 +00:00
|
|
|
#include "rommgr.h"
|
2017-12-04 15:49:40 +01:00
|
|
|
#include "zfile.h"
|
|
|
|
#include <SDL.h>
|
2018-01-20 18:14:12 +01:00
|
|
|
#include "amiberry_rp9.h"
|
|
|
|
#include "machdep/rpt.h"
|
|
|
|
|
|
|
|
#include "threaddep/thread.h"
|
|
|
|
#include "include/memory.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "rtgmodes.h"
|
|
|
|
#include "gfxboard.h"
|
|
|
|
#include "amiberry_gfx.h"
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef USE_SDL2
|
2017-02-27 15:54:52 +01:00
|
|
|
#include <map>
|
2017-12-04 15:49:40 +01:00
|
|
|
#endif
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef WITH_LOGGING
|
|
|
|
extern FILE *debugfile;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int quickstart_start = 1;
|
|
|
|
int quickstart_model = 0;
|
|
|
|
int quickstart_conf = 0;
|
|
|
|
bool host_poweroff = false;
|
2018-02-07 22:43:17 +01:00
|
|
|
bool read_config_descriptions = true;
|
2017-03-30 21:21:31 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
extern void signal_segv(int signum, siginfo_t* info, void* ptr);
|
2017-12-04 15:49:40 +01:00
|
|
|
extern void signal_buserror(int signum, siginfo_t* info, void* ptr);
|
|
|
|
extern void signal_term(int signum, siginfo_t* info, void* ptr);
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
extern void SetLastActiveConfig(const char* filename);
|
2017-03-01 14:08:11 +01:00
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
char start_path_data[MAX_DPATH];
|
|
|
|
char currentDir[MAX_DPATH];
|
2016-09-13 00:40:34 +02:00
|
|
|
|
2016-09-01 13:53:43 +02:00
|
|
|
#include <linux/kd.h>
|
|
|
|
#include <sys/ioctl.h>
|
2016-11-30 22:30:52 +01:00
|
|
|
unsigned char kbd_led_status;
|
2016-09-01 13:53:43 +02:00
|
|
|
char kbd_flags;
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
static char config_path[MAX_DPATH];
|
|
|
|
static char rom_path[MAX_DPATH];
|
2016-04-25 17:12:37 +00:00
|
|
|
static char rp9_path[MAX_DPATH];
|
2017-12-04 15:49:40 +01:00
|
|
|
static char controllers_path[MAX_DPATH];
|
|
|
|
static char retroarch_file[MAX_DPATH];
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
char last_loaded_config[MAX_DPATH] = {'\0'};
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2016-11-30 22:25:43 +01:00
|
|
|
int max_uae_width;
|
|
|
|
int max_uae_height;
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
extern "C" int main(int argc, char* argv[]);
|
2015-10-11 14:23:51 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void sleep_millis(int ms)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
usleep(ms * 1000);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2018-01-20 18:14:12 +01:00
|
|
|
int sleep_millis_main(int ms)
|
|
|
|
{
|
|
|
|
unsigned long start = read_processor_time();
|
|
|
|
usleep(ms * 1000);
|
|
|
|
idletime += read_processor_time() - start;
|
|
|
|
return 0;
|
|
|
|
}
|
2017-12-04 15:49:40 +01:00
|
|
|
|
|
|
|
void logging_init(void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
2017-12-04 15:49:40 +01:00
|
|
|
static int started;
|
|
|
|
static int first;
|
|
|
|
char debugfilename[MAX_DPATH];
|
|
|
|
|
|
|
|
if (first > 1) {
|
|
|
|
write_log ("***** RESTART *****\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (first == 1) {
|
|
|
|
if (debugfile)
|
|
|
|
fclose (debugfile);
|
|
|
|
debugfile = 0;
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
sprintf(debugfilename, "%s/amiberry_log.txt", start_path_data);
|
|
|
|
if (!debugfile)
|
|
|
|
debugfile = fopen(debugfilename, "wt");
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
first++;
|
|
|
|
write_log("AMIBERRY Logfile\n\n");
|
2015-05-13 18:47:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void logging_cleanup(void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
2017-12-04 15:49:40 +01:00
|
|
|
if (debugfile)
|
|
|
|
fclose(debugfile);
|
|
|
|
debugfile = 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void stripslashes(TCHAR *p)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
while (_tcslen(p) > 0 && (p[_tcslen(p) - 1] == '\\' || p[_tcslen(p) - 1] == '/'))
|
|
|
|
p[_tcslen(p) - 1] = 0;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fixtrailing(TCHAR *p)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
if (_tcslen(p) == 0)
|
|
|
|
return;
|
|
|
|
if (p[_tcslen(p) - 1] == '/' || p[_tcslen(p) - 1] == '\\')
|
|
|
|
return;
|
|
|
|
_tcscat(p, "/");
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void getpathpart(TCHAR *outpath, int size, const TCHAR *inpath)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
_tcscpy(outpath, inpath);
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto p = _tcsrchr(outpath, '/');
|
2017-01-29 12:04:05 +01:00
|
|
|
if (p)
|
|
|
|
p[0] = 0;
|
|
|
|
fixtrailing(outpath);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void getfilepart(TCHAR *out, int size, const TCHAR *path)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
out[0] = 0;
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto p = _tcsrchr(path, '/');
|
2017-01-29 12:04:05 +01:00
|
|
|
if (p)
|
2017-12-04 15:49:40 +01:00
|
|
|
_tcscpy(out, p + 1);
|
2017-01-29 12:04:05 +01:00
|
|
|
else
|
2017-12-04 15:49:40 +01:00
|
|
|
_tcscpy(out, path);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
uae_u8 *target_load_keyfile(struct uae_prefs *p, const char *path, int *sizep, char *name)
|
2015-10-11 14:23:51 +02:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
return nullptr;
|
2015-10-11 14:23:51 +02:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void target_run(void)
|
|
|
|
{
|
|
|
|
// Reset counter for access violations
|
|
|
|
init_max_signals();
|
|
|
|
}
|
|
|
|
|
|
|
|
void target_quit(void)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-13 14:43:50 +01:00
|
|
|
void fix_apmodes(struct uae_prefs *p)
|
2015-09-09 21:49:41 +02:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
if (p->ntscmode)
|
|
|
|
{
|
|
|
|
p->gfx_apmode[0].gfx_refreshrate = 60;
|
|
|
|
p->gfx_apmode[1].gfx_refreshrate = 60;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p->gfx_apmode[0].gfx_refreshrate = 50;
|
|
|
|
p->gfx_apmode[1].gfx_refreshrate = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixup_prefs_dimensions(p);
|
2015-09-09 21:49:41 +02:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void target_fixup_options(struct uae_prefs* p)
|
2015-09-09 21:49:41 +02:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
p->rtgboards[0].rtgmem_type = GFXBOARD_UAE_Z3;
|
|
|
|
|
2018-03-05 21:03:25 +01:00
|
|
|
if (z3_base_adr == Z3BASE_REAL) {
|
2017-12-04 15:49:40 +01:00
|
|
|
// map Z3 memory at real address (0x40000000)
|
|
|
|
p->z3_mapping_mode = Z3MAPPING_REAL;
|
2018-03-05 21:03:25 +01:00
|
|
|
p->z3autoconfig_start = z3_base_adr;
|
2017-12-04 15:49:40 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// map Z3 memory at UAE address (0x10000000)
|
|
|
|
p->z3_mapping_mode = Z3MAPPING_UAE;
|
2018-03-05 21:03:25 +01:00
|
|
|
p->z3autoconfig_start = z3_base_adr;
|
2017-12-04 15:49:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (p->cs_cd32cd && p->cs_cd32nvram && (p->cs_compatible == CP_GENERIC || p->cs_compatible == 0)) {
|
|
|
|
// Old config without cs_compatible, but other cd32-flags
|
|
|
|
p->cs_compatible = CP_CD32;
|
|
|
|
built_in_chipset_prefs(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->cs_cd32cd && p->cartfile[0]) {
|
|
|
|
p->cs_cd32fmv = true;
|
|
|
|
}
|
2016-04-24 09:45:29 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
|
2017-02-28 01:20:30 +01:00
|
|
|
if (p->gfx_size.width == 0)
|
|
|
|
p->gfx_size.width = 640;
|
|
|
|
if (p->gfx_size.height == 0)
|
2017-12-22 20:54:27 +01:00
|
|
|
p->gfx_size.height = 256;
|
2017-01-29 12:04:05 +01:00
|
|
|
p->gfx_resolution = p->gfx_size.width > 600 ? 1 : 0;
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2018-01-03 00:48:54 +01:00
|
|
|
if (p->gfx_vresolution && !can_have_linedouble)
|
|
|
|
p->gfx_vresolution = 0;
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
if (p->cachesize > 0)
|
|
|
|
p->fpu_no_unimplemented = false;
|
|
|
|
else
|
|
|
|
p->fpu_no_unimplemented = true;
|
|
|
|
|
|
|
|
fix_apmodes(p);
|
2015-09-09 21:49:41 +02:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void target_default_options(struct uae_prefs* p, int type)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
p->fast_copper = 0;
|
2018-04-02 16:42:43 +02:00
|
|
|
p->compfpu = false;
|
2017-01-29 12:04:05 +01:00
|
|
|
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
|
2017-02-28 13:21:37 +01:00
|
|
|
|
|
|
|
p->kbd_led_num = -1; // No status on numlock
|
|
|
|
p->kbd_led_scr = -1; // No status on scrollock
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2017-12-25 00:15:51 +01:00
|
|
|
p->vertical_offset = OFFSET_Y_ADJUST;
|
2018-01-02 20:17:32 +01:00
|
|
|
p->gfx_correct_aspect = 1; // Default is Enabled
|
2017-02-28 13:21:37 +01:00
|
|
|
p->scaling_method = -1; //Default is Auto
|
2018-01-24 22:03:42 +01:00
|
|
|
p->gfx_vresolution = 0; // Disabled by default due to big performance hit under SDL2
|
2017-12-04 15:49:40 +01:00
|
|
|
|
|
|
|
_tcscpy(p->open_gui, "F12");
|
|
|
|
_tcscpy(p->quit_amiberry, "");
|
2018-01-27 22:25:46 +01:00
|
|
|
_tcscpy(p->action_replay, "Pause");
|
|
|
|
_tcscpy(p->fullscreen_toggle, "");
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2018-02-08 11:05:16 +01:00
|
|
|
p->input_analog_remap = false;
|
|
|
|
|
2017-12-22 20:54:27 +01:00
|
|
|
p->use_retroarch_quit = true;
|
|
|
|
p->use_retroarch_menu = true;
|
|
|
|
p->use_retroarch_reset = false;
|
2017-12-04 15:49:40 +01:00
|
|
|
|
|
|
|
#ifdef ANDROIDSDL
|
|
|
|
p->onScreen = 1;
|
|
|
|
p->onScreen_textinput = 1;
|
|
|
|
p->onScreen_dpad = 1;
|
|
|
|
p->onScreen_button1 = 1;
|
|
|
|
p->onScreen_button2 = 1;
|
|
|
|
p->onScreen_button3 = 1;
|
|
|
|
p->onScreen_button4 = 1;
|
|
|
|
p->onScreen_button5 = 0;
|
|
|
|
p->onScreen_button6 = 0;
|
|
|
|
p->custom_position = 0;
|
|
|
|
p->pos_x_textinput = 0;
|
|
|
|
p->pos_y_textinput = 0;
|
|
|
|
p->pos_x_dpad = 4;
|
|
|
|
p->pos_y_dpad = 215;
|
|
|
|
p->pos_x_button1 = 430;
|
|
|
|
p->pos_y_button1 = 286;
|
|
|
|
p->pos_x_button2 = 378;
|
|
|
|
p->pos_y_button2 = 286;
|
|
|
|
p->pos_x_button3 = 430;
|
|
|
|
p->pos_y_button3 = 214;
|
|
|
|
p->pos_x_button4 = 378;
|
|
|
|
p->pos_y_button4 = 214;
|
|
|
|
p->pos_x_button5 = 430;
|
|
|
|
p->pos_y_button5 = 142;
|
|
|
|
p->pos_x_button6 = 378;
|
|
|
|
p->pos_y_button6 = 142;
|
|
|
|
p->extfilter = 1;
|
|
|
|
p->quickSwitch = 0;
|
|
|
|
p->floatingJoystick = 0;
|
|
|
|
p->disableMenuVKeyb = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
p->cr[CHIPSET_REFRESH_PAL].locked = true;
|
|
|
|
p->cr[CHIPSET_REFRESH_PAL].vsync = 1;
|
|
|
|
|
|
|
|
p->cr[CHIPSET_REFRESH_NTSC].locked = true;
|
|
|
|
p->cr[CHIPSET_REFRESH_NTSC].vsync = 1;
|
|
|
|
|
|
|
|
p->cr[0].index = 0;
|
|
|
|
p->cr[0].horiz = -1;
|
|
|
|
p->cr[0].vert = -1;
|
|
|
|
p->cr[0].lace = -1;
|
|
|
|
p->cr[0].resolution = 0;
|
|
|
|
p->cr[0].vsync = -1;
|
|
|
|
p->cr[0].rate = 60.0;
|
|
|
|
p->cr[0].ntsc = 1;
|
|
|
|
p->cr[0].locked = true;
|
|
|
|
p->cr[0].rtg = true;
|
|
|
|
_tcscpy(p->cr[0].label, _T("RTG"));
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void target_save_options(struct zfile* f, struct uae_prefs* p)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-25 00:15:51 +01:00
|
|
|
cfgfile_write(f, "amiberry.vertical_offset", "%d", p->vertical_offset - OFFSET_Y_ADJUST);
|
2018-01-10 15:34:36 +01:00
|
|
|
cfgfile_write(f, "amiberry.hide_idle_led", "%d", p->hide_idle_led);
|
2017-12-22 20:54:27 +01:00
|
|
|
cfgfile_write(f, _T("amiberry.gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
|
2017-12-04 15:49:40 +01:00
|
|
|
cfgfile_write(f, _T("amiberry.kbd_led_num"), _T("%d"), p->kbd_led_num);
|
|
|
|
cfgfile_write(f, _T("amiberry.kbd_led_scr"), _T("%d"), p->kbd_led_scr);
|
|
|
|
cfgfile_write(f, _T("amiberry.scaling_method"), _T("%d"), p->scaling_method);
|
2017-02-28 13:21:37 +01:00
|
|
|
|
2017-12-22 21:24:51 +01:00
|
|
|
cfgfile_dwrite_str(f, _T("amiberry.open_gui"), p->open_gui);
|
|
|
|
cfgfile_dwrite_str(f, _T("amiberry.quit_amiberry"), p->quit_amiberry);
|
2018-01-27 22:25:46 +01:00
|
|
|
cfgfile_dwrite_str(f, _T("amiberry.action_replay"), p->action_replay);
|
|
|
|
cfgfile_dwrite_str(f, _T("amiberry.fullscreen_toggle"), p->fullscreen_toggle);
|
2018-02-03 21:30:52 +01:00
|
|
|
cfgfile_write_bool(f, _T("amiberry.use_analogue_remap"), p->input_analog_remap);
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2017-12-22 20:54:27 +01:00
|
|
|
cfgfile_write_bool(f, _T("amiberry.use_retroarch_quit"), p->use_retroarch_quit);
|
|
|
|
cfgfile_write_bool(f, _T("amiberry.use_retroarch_menu"), p->use_retroarch_menu);
|
|
|
|
cfgfile_write_bool(f, _T("amiberry.use_retroarch_reset"), p->use_retroarch_reset);
|
2017-12-04 15:49:40 +01:00
|
|
|
|
|
|
|
#ifdef ANDROIDSDL
|
2017-12-22 20:54:27 +01:00
|
|
|
cfgfile_write(f, "amiberry.onscreen", "%d", p->onScreen);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_textinput", "%d", p->onScreen_textinput);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_dpad", "%d", p->onScreen_dpad);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button1", "%d", p->onScreen_button1);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button2", "%d", p->onScreen_button2);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button3", "%d", p->onScreen_button3);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button4", "%d", p->onScreen_button4);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button5", "%d", p->onScreen_button5);
|
|
|
|
cfgfile_write(f, "amiberry.onscreen_button6", "%d", p->onScreen_button6);
|
|
|
|
cfgfile_write(f, "amiberry.custom_position", "%d", p->custom_position);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_textinput", "%d", p->pos_x_textinput);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_textinput", "%d", p->pos_y_textinput);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_dpad", "%d", p->pos_x_dpad);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_dpad", "%d", p->pos_y_dpad);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button1", "%d", p->pos_x_button1);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button1", "%d", p->pos_y_button1);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button2", "%d", p->pos_x_button2);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button2", "%d", p->pos_y_button2);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button3", "%d", p->pos_x_button3);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button3", "%d", p->pos_y_button3);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button4", "%d", p->pos_x_button4);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button4", "%d", p->pos_y_button4);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button5", "%d", p->pos_x_button5);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button5", "%d", p->pos_y_button5);
|
|
|
|
cfgfile_write(f, "amiberry.pos_x_button6", "%d", p->pos_x_button6);
|
|
|
|
cfgfile_write(f, "amiberry.pos_y_button6", "%d", p->pos_y_button6);
|
|
|
|
cfgfile_write(f, "amiberry.floating_joystick", "%d", p->floatingJoystick);
|
|
|
|
cfgfile_write(f, "amiberry.disable_menu_vkeyb", "%d", p->disableMenuVKeyb);
|
2017-12-04 15:49:40 +01:00
|
|
|
#endif
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void target_restart(void)
|
2016-08-27 20:39:53 +02:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
emulating = 0;
|
|
|
|
gui_restart();
|
2016-08-27 20:39:53 +02:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
TCHAR *target_expand_environment(const TCHAR *path, TCHAR *out, int maxlen)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
if (out == nullptr)
|
|
|
|
return strdup(path);
|
2017-12-26 14:04:41 +01:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
_tcscpy(out, path);
|
|
|
|
return out;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int target_parse_option(struct uae_prefs* p, const char* option, const char* value)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef ANDROIDSDL
|
|
|
|
|| cfgfile_intval(option, value, "onscreen", &p->onScreen, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_textinput", &p->onScreen_textinput, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_dpad", &p->onScreen_dpad, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button1", &p->onScreen_button1, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button2", &p->onScreen_button2, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button3", &p->onScreen_button3, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button4", &p->onScreen_button4, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button5", &p->onScreen_button5, 1)
|
|
|
|
|| cfgfile_intval(option, value, "onscreen_button6", &p->onScreen_button6, 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_position", &p->custom_position, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_textinput", &p->pos_x_textinput, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_textinput", &p->pos_y_textinput, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_dpad", &p->pos_x_dpad, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_dpad", &p->pos_y_dpad, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button1", &p->pos_x_button1, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button1", &p->pos_y_button1, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button2", &p->pos_x_button2, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button2", &p->pos_y_button2, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button3", &p->pos_x_button3, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button3", &p->pos_y_button3, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button4", &p->pos_x_button4, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button4", &p->pos_y_button4, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button5", &p->pos_x_button5, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button5", &p->pos_y_button5, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_x_button6", &p->pos_x_button6, 1)
|
|
|
|
|| cfgfile_intval(option, value, "pos_y_button6", &p->pos_y_button6, 1)
|
|
|
|
|| cfgfile_intval(option, value, "floating_joystick", &p->floatingJoystick, 1)
|
|
|
|
|| cfgfile_intval(option, value, "disable_menu_vkeyb", &p->disableMenuVKeyb, 1)
|
|
|
|
#endif
|
2017-02-28 13:21:37 +01:00
|
|
|
|
2017-12-22 20:54:27 +01:00
|
|
|
if (cfgfile_yesno(option, value, _T("use_retroarch_quit"), &p->use_retroarch_quit))
|
2017-12-04 15:49:40 +01:00
|
|
|
return 1;
|
2017-12-22 20:54:27 +01:00
|
|
|
if (cfgfile_yesno(option, value, _T("use_retroarch_menu"), &p->use_retroarch_menu))
|
2017-02-28 13:21:37 +01:00
|
|
|
return 1;
|
2017-12-22 20:54:27 +01:00
|
|
|
if (cfgfile_yesno(option, value, _T("use_retroarch_reset"), &p->use_retroarch_reset))
|
2017-12-04 15:49:40 +01:00
|
|
|
return 1;
|
2018-02-03 21:30:52 +01:00
|
|
|
if (cfgfile_yesno(option, value, _T("use_analogue_remap"), &p->input_analog_remap))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
2017-02-28 13:21:37 +01:00
|
|
|
if (cfgfile_intval(option, value, "kbd_led_num", &p->kbd_led_num, 1))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_intval(option, value, "kbd_led_scr", &p->kbd_led_scr, 1))
|
|
|
|
return 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2017-12-25 00:15:51 +01:00
|
|
|
if (cfgfile_intval(option, value, "vertical_offset", &p->vertical_offset, 1))
|
|
|
|
{
|
|
|
|
p->vertical_offset += OFFSET_Y_ADJUST;
|
|
|
|
return 1;
|
|
|
|
}
|
2018-01-10 15:34:36 +01:00
|
|
|
if (cfgfile_intval(option, value, "hide_idle_led", &p->hide_idle_led, 1))
|
|
|
|
return 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
if (cfgfile_intval(option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
|
2017-02-28 13:21:37 +01:00
|
|
|
return 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
if (cfgfile_intval(option, value, "scaling_method", &p->scaling_method, 1))
|
2017-02-28 13:21:37 +01:00
|
|
|
return 1;
|
2018-01-03 22:07:57 +01:00
|
|
|
if (cfgfile_string(option, value, "open_gui", p->open_gui, sizeof p->open_gui))
|
2017-02-28 13:21:37 +01:00
|
|
|
return 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
if (cfgfile_string(option, value, "quit_amiberry", p->quit_amiberry, sizeof p->quit_amiberry))
|
2017-02-28 13:21:37 +01:00
|
|
|
return 1;
|
2018-01-27 22:25:46 +01:00
|
|
|
if (cfgfile_string(option, value, "action_replay", p->action_replay, sizeof p->action_replay))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_string(option, value, "fullscreen_toggle", p->fullscreen_toggle, sizeof p->fullscreen_toggle))
|
|
|
|
return 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
return 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_datapath(char *out, int size)
|
2016-07-10 13:48:11 +02:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/", size);
|
2016-07-10 13:48:11 +02:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_saveimagepath(char *out, int size, int dir)
|
2015-10-11 14:23:51 +02:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/savestates/", size);
|
2015-10-11 14:23:51 +02:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_configurationpath(char *out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2018-01-03 22:07:57 +01:00
|
|
|
fixtrailing(config_path);
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, config_path, size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void set_configurationpath(char *newpath)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(config_path, newpath, MAX_DPATH);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_controllerspath(char* out, int size)
|
|
|
|
{
|
2018-01-03 22:07:57 +01:00
|
|
|
fixtrailing(controllers_path);
|
2017-12-04 15:49:40 +01:00
|
|
|
strncpy(out, controllers_path, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_controllerspath(char* newpath)
|
|
|
|
{
|
|
|
|
strncpy(controllers_path, newpath, MAX_DPATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fetch_retroarchfile(char* out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, retroarch_file, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_retroarchfile(char* newpath)
|
|
|
|
{
|
|
|
|
strncpy(retroarch_file, newpath, MAX_DPATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void fetch_rompath(char* out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2018-01-03 22:07:57 +01:00
|
|
|
fixtrailing(rom_path);
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, rom_path, size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void set_rompath(char *newpath)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(rom_path, newpath, MAX_DPATH);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
|
|
|
|
void fetch_rp9path(char *out, int size)
|
2016-04-25 17:12:37 +00:00
|
|
|
{
|
2018-01-03 22:07:57 +01:00
|
|
|
fixtrailing(rp9_path);
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, rp9_path, size);
|
2016-04-25 17:12:37 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_savestatepath(char *out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/savestates/", size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void fetch_screenshotpath(char *out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/screenshots/", size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int target_cfgfile_load(struct uae_prefs* p, const char* filename, int type, int isdefault)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
auto result = 0;
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
write_log(_T("target_cfgfile_load(): load file %s\n"), filename);
|
2017-01-29 12:04:05 +01:00
|
|
|
|
|
|
|
discard_prefs(p, type);
|
2017-03-30 21:21:31 +02:00
|
|
|
default_prefs(p, true, 0);
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-16 21:53:01 +01:00
|
|
|
const char* ptr = strstr(const_cast<char *>(filename), ".rp9");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
|
|
|
// Load rp9 config
|
|
|
|
result = rp9_parse_file(p, filename);
|
|
|
|
if (result)
|
|
|
|
extractFileName(filename, last_loaded_config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-16 21:53:01 +01:00
|
|
|
ptr = strstr(const_cast<char *>(filename), ".uae");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
2017-12-26 00:13:23 +01:00
|
|
|
auto config_type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
|
|
|
|
result = cfgfile_load(p, filename, &config_type, 0, 1);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
extractFileName(filename, last_loaded_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
2017-12-26 00:13:23 +01:00
|
|
|
for (auto i = 0; i < p->nr_floppies; ++i)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-01-29 13:24:39 +01:00
|
|
|
if (!DISK_validate_filename(p, p->floppyslots[i].df, 0, nullptr, nullptr, nullptr))
|
2017-01-29 12:04:05 +01:00
|
|
|
p->floppyslots[i].df[0] = 0;
|
|
|
|
disk_insert(i, p->floppyslots[i].df);
|
|
|
|
if (strlen(p->floppyslots[i].df) > 0)
|
|
|
|
AddFileToDiskList(p->floppyslots[i].df, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isdefault)
|
2017-01-29 13:24:39 +01:00
|
|
|
inputdevice_updateconfig(nullptr, p);
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef WITH_LOGGING
|
|
|
|
p->leds_on_screen = true;
|
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
SetLastActiveConfig(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
int check_configfile(char *file)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-16 21:53:01 +01:00
|
|
|
char tmp[MAX_DPATH];
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
auto f = fopen(file, "rte");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-12-16 21:53:01 +01:00
|
|
|
strncpy(tmp, file, MAX_DPATH);
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto ptr = strstr(tmp, ".uae");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
|
|
|
*(ptr + 1) = '\0';
|
2017-12-16 21:53:01 +01:00
|
|
|
strncat(tmp, "conf", MAX_DPATH);
|
2017-12-21 11:19:52 +01:00
|
|
|
f = fopen(tmp, "rte");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void extractFileName(const char * str, char *buffer)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
auto p = str + strlen(str) - 1;
|
2017-01-29 12:04:05 +01:00
|
|
|
while (*p != '/' && p > str)
|
|
|
|
p--;
|
|
|
|
p++;
|
2017-12-16 21:53:01 +01:00
|
|
|
strncpy(buffer, p, MAX_DPATH);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void extractPath(char *str, char *buffer)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-16 21:53:01 +01:00
|
|
|
strncpy(buffer, str, MAX_DPATH);
|
2017-12-21 11:19:52 +01:00
|
|
|
auto p = buffer + strlen(buffer) - 1;
|
2017-01-29 12:04:05 +01:00
|
|
|
while (*p != '/' && p > buffer)
|
|
|
|
p--;
|
|
|
|
p[1] = '\0';
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void removeFileExtension(char *filename)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
auto p = filename + strlen(filename) - 1;
|
2017-01-29 12:04:05 +01:00
|
|
|
while (p > filename && *p != '.')
|
|
|
|
{
|
|
|
|
*p = '\0';
|
|
|
|
--p;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void ReadDirectory(const char *path, std::vector<std::string> *dirs, std::vector<std::string> *files)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
struct dirent *dent;
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-01-29 13:24:39 +01:00
|
|
|
if (dirs != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
dirs->clear();
|
2017-01-29 13:24:39 +01:00
|
|
|
if (files != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
files->clear();
|
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto dir = opendir(path);
|
2017-01-29 13:24:39 +01:00
|
|
|
if (dir != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-01-29 13:24:39 +01:00
|
|
|
while ((dent = readdir(dir)) != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
|
|
|
if (dent->d_type == DT_DIR)
|
|
|
|
{
|
2017-01-29 13:24:39 +01:00
|
|
|
if (dirs != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
dirs->push_back(dent->d_name);
|
|
|
|
}
|
2017-01-29 13:24:39 +01:00
|
|
|
else if (files != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
files->push_back(dent->d_name);
|
|
|
|
}
|
2017-12-21 11:19:52 +01:00
|
|
|
if (dirs != nullptr && !dirs->empty() && (*dirs)[0] == ".")
|
2017-01-29 12:04:05 +01:00
|
|
|
dirs->erase(dirs->begin());
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
|
2017-01-29 13:24:39 +01:00
|
|
|
if (dirs != nullptr)
|
2017-12-04 15:49:40 +01:00
|
|
|
sort(dirs->begin(), dirs->end());
|
2017-01-29 13:24:39 +01:00
|
|
|
if (files != nullptr)
|
2017-12-04 15:49:40 +01:00
|
|
|
sort(files->begin(), files->end());
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void saveAdfDir(void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char path[MAX_DPATH];
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto f = fopen(path, "we");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char buffer[MAX_DPATH];
|
|
|
|
snprintf(buffer, MAX_DPATH, "path=%s\n", currentDir);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "config_path=%s\n", config_path);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "controllers_path=%s\n", controllers_path);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "retroarch_config=%s\n", retroarch_file);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "rom_path=%s\n", rom_path);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "ROMs=%d\n", lstAvailableROMs.size());
|
|
|
|
fputs(buffer, f);
|
2018-01-03 21:49:41 +01:00
|
|
|
for (auto & lstAvailableROM : lstAvailableROMs)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "ROMName=%s\n", lstAvailableROM->Name);
|
2017-01-29 12:04:05 +01:00
|
|
|
fputs(buffer, f);
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "ROMPath=%s\n", lstAvailableROM->Path);
|
2017-01-29 12:04:05 +01:00
|
|
|
fputs(buffer, f);
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "ROMType=%d\n", lstAvailableROM->ROMType);
|
2017-01-29 12:04:05 +01:00
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "MRUDiskList=%d\n", lstMRUDiskList.size());
|
|
|
|
fputs(buffer, f);
|
2018-01-03 21:49:41 +01:00
|
|
|
for (auto & i : lstMRUDiskList)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "Diskfile=%s\n", i.c_str());
|
2017-01-29 12:04:05 +01:00
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "MRUCDList=%d\n", lstMRUCDList.size());
|
|
|
|
fputs(buffer, f);
|
2018-01-03 21:49:41 +01:00
|
|
|
for (auto & i : lstMRUCDList)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "CDfile=%s\n", i.c_str());
|
2017-01-29 12:04:05 +01:00
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "Quickstart=%d\n", quickstart_start);
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
2018-02-07 22:43:17 +01:00
|
|
|
snprintf(buffer, MAX_DPATH, "read_config_descriptions=%s\n", read_config_descriptions ? "yes" : "no");
|
|
|
|
fputs(buffer, f);
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
fclose(f);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void get_string(FILE *f, char *dst, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-16 21:53:01 +01:00
|
|
|
char buffer[MAX_DPATH];
|
|
|
|
fgets(buffer, MAX_DPATH, f);
|
2017-01-29 12:04:05 +01:00
|
|
|
int i = strlen(buffer);
|
|
|
|
while (i > 0 && (buffer[i - 1] == '\t' || buffer[i - 1] == ' '
|
|
|
|
|| buffer[i - 1] == '\r' || buffer[i - 1] == '\n'))
|
|
|
|
buffer[--i] = '\0';
|
|
|
|
strncpy(dst, buffer, size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
static void trimwsa(char *s)
|
|
|
|
{
|
|
|
|
/* Delete trailing whitespace. */
|
|
|
|
int len = strlen(s);
|
|
|
|
while (len > 0 && strcspn(s + len - 1, "\t \r\n") == 0)
|
|
|
|
s[--len] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadAdfDir(void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char path[MAX_DPATH];
|
|
|
|
int i;
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef ANDROID
|
|
|
|
strncpy(currentDir, getenv("SDCARD"), MAX_DPATH);
|
|
|
|
#else
|
|
|
|
strncpy(currentDir, start_path_data, MAX_DPATH);
|
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
snprintf(config_path, MAX_DPATH, "%s/conf/", start_path_data);
|
2017-12-04 15:49:40 +01:00
|
|
|
snprintf(controllers_path, MAX_DPATH, "%s/controllers/", start_path_data);
|
|
|
|
snprintf(retroarch_file, MAX_DPATH, "%s/conf/retroarch.cfg", start_path_data);
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
char afepath[MAX_DPATH];
|
|
|
|
snprintf(afepath, MAX_DPATH, "%s/Android/data/com.cloanto.amigaforever.essentials/files/rom/", getenv("SDCARD"));
|
|
|
|
DIR *afedir = opendir(afepath);
|
|
|
|
if (afedir) {
|
|
|
|
snprintf(rom_path, MAX_DPATH, "%s", afepath);
|
|
|
|
closedir(afedir);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
snprintf(rom_path, MAX_DPATH, "%s/kickstarts/", start_path_data);
|
|
|
|
#else
|
2017-01-29 12:04:05 +01:00
|
|
|
snprintf(rom_path, MAX_DPATH, "%s/kickstarts/", start_path_data);
|
2017-12-04 15:49:40 +01:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
snprintf(rp9_path, MAX_DPATH, "%s/rp9/", start_path_data);
|
|
|
|
|
|
|
|
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
|
2018-02-07 22:43:17 +01:00
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
const auto fh = zfile_fopen(path, _T("r"), ZFD_NORMAL);
|
2017-12-04 15:49:40 +01:00
|
|
|
if (fh) {
|
|
|
|
char linea[CONFIG_BLEN];
|
|
|
|
TCHAR option[CONFIG_BLEN], value[CONFIG_BLEN];
|
|
|
|
int numROMs, numDisks, numCDs;
|
2017-12-21 11:19:52 +01:00
|
|
|
auto romType = -1;
|
2017-12-16 21:53:01 +01:00
|
|
|
char romName[MAX_DPATH] = { '\0' };
|
|
|
|
char romPath[MAX_DPATH] = { '\0' };
|
|
|
|
char tmpFile[MAX_DPATH];
|
2017-12-04 15:49:40 +01:00
|
|
|
|
2018-01-03 21:49:41 +01:00
|
|
|
while (zfile_fgetsa(linea, sizeof linea, fh) != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
trimwsa(linea);
|
|
|
|
if (strlen(linea) > 0) {
|
|
|
|
if (!cfgfile_separate_linea(path, linea, option, value))
|
|
|
|
continue;
|
|
|
|
|
2018-01-03 21:49:41 +01:00
|
|
|
if (cfgfile_string(option, value, "ROMName", romName, sizeof romName)
|
|
|
|
|| cfgfile_string(option, value, "ROMPath", romPath, sizeof romPath)
|
2017-12-04 15:49:40 +01:00
|
|
|
|| cfgfile_intval(option, value, "ROMType", &romType, 1)) {
|
|
|
|
if (strlen(romName) > 0 && strlen(romPath) > 0 && romType != -1) {
|
2017-12-21 11:19:52 +01:00
|
|
|
auto tmp = new AvailableROM();
|
2018-01-03 21:49:41 +01:00
|
|
|
strncpy(tmp->Name, romName, sizeof tmp->Name);
|
|
|
|
strncpy(tmp->Path, romPath, sizeof tmp->Path);
|
2017-12-04 15:49:40 +01:00
|
|
|
tmp->ROMType = romType;
|
2018-01-03 21:49:41 +01:00
|
|
|
lstAvailableROMs.emplace_back(tmp);
|
|
|
|
strncpy(romName, "", sizeof romName);
|
|
|
|
strncpy(romPath, "", sizeof romPath);
|
2017-12-04 15:49:40 +01:00
|
|
|
romType = -1;
|
|
|
|
}
|
|
|
|
}
|
2018-01-03 21:49:41 +01:00
|
|
|
else if (cfgfile_string(option, value, "Diskfile", tmpFile, sizeof tmpFile))
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
auto f = fopen(tmpFile, "rbe");
|
2017-12-04 15:49:40 +01:00
|
|
|
if (f != nullptr)
|
|
|
|
{
|
|
|
|
fclose(f);
|
2017-12-21 11:19:52 +01:00
|
|
|
lstMRUDiskList.emplace_back(tmpFile);
|
2017-12-04 15:49:40 +01:00
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
2018-01-03 21:49:41 +01:00
|
|
|
else if (cfgfile_string(option, value, "CDfile", tmpFile, sizeof tmpFile))
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-12-22 20:54:27 +01:00
|
|
|
FILE* f = fopen(tmpFile, "rbe");
|
2017-12-04 15:49:40 +01:00
|
|
|
if (f != nullptr)
|
|
|
|
{
|
|
|
|
fclose(f);
|
2017-12-21 11:19:52 +01:00
|
|
|
lstMRUCDList.emplace_back(tmpFile);
|
2017-12-04 15:49:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-01-03 21:49:41 +01:00
|
|
|
cfgfile_string(option, value, "path", currentDir, sizeof currentDir);
|
|
|
|
cfgfile_string(option, value, "config_path", config_path, sizeof config_path);
|
|
|
|
cfgfile_string(option, value, "controllers_path", controllers_path, sizeof controllers_path);
|
|
|
|
cfgfile_string(option, value, "retroarch_config", retroarch_file, sizeof retroarch_file);
|
|
|
|
cfgfile_string(option, value, "rom_path", rom_path, sizeof rom_path);
|
2017-12-04 15:49:40 +01:00
|
|
|
cfgfile_intval(option, value, "ROMs", &numROMs, 1);
|
|
|
|
cfgfile_intval(option, value, "MRUDiskList", &numDisks, 1);
|
|
|
|
cfgfile_intval(option, value, "MRUCDList", &numCDs, 1);
|
|
|
|
cfgfile_intval(option, value, "Quickstart", &quickstart_start, 1);
|
2018-02-07 22:43:17 +01:00
|
|
|
cfgfile_yesno(option, value, "read_config_descriptions", &read_config_descriptions);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-04 15:49:40 +01:00
|
|
|
zfile_fclose(fh);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
void target_addtorecent(const TCHAR *name, int t)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void target_reset(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool target_can_autoswitchdevice(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uae_u32 emulib_target_getcpurate(uae_u32 v, uae_u32 *low)
|
|
|
|
{
|
|
|
|
*low = 0;
|
|
|
|
if (v == 1) {
|
2017-01-29 12:04:05 +01:00
|
|
|
*low = 1e+9; /* We have nano seconds */
|
|
|
|
return 0;
|
|
|
|
}
|
2017-12-04 15:49:40 +01:00
|
|
|
if (v == 2) {
|
2017-12-21 11:19:52 +01:00
|
|
|
struct timespec ts{};
|
2017-01-29 12:04:05 +01:00
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
2017-12-21 11:19:52 +01:00
|
|
|
const int64_t time = int64_t(ts.tv_sec) * 1000000000 + ts.tv_nsec;
|
2017-12-27 15:08:50 +01:00
|
|
|
*low = uae_u32(time & 0xffffffff);
|
|
|
|
return uae_u32(time >> 32);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 14:48:11 +01:00
|
|
|
void target_shutdown(void)
|
2017-12-04 15:49:40 +01:00
|
|
|
{
|
|
|
|
system("sudo poweroff");
|
|
|
|
}
|
2017-12-13 14:43:50 +01:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int main(int argc, char* argv[])
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
struct sigaction action{};
|
2017-12-13 14:43:50 +01:00
|
|
|
|
2017-01-23 14:13:43 +01:00
|
|
|
max_uae_width = 1920;
|
|
|
|
max_uae_height = 1080;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
// Get startup path
|
|
|
|
getcwd(start_path_data, MAX_DPATH);
|
|
|
|
loadAdfDir();
|
|
|
|
rp9_init();
|
|
|
|
|
2018-01-03 21:49:41 +01:00
|
|
|
snprintf(savestate_fname, sizeof savestate_fname, "%s/savestates/default.ads", start_path_data);
|
2017-01-29 12:04:05 +01:00
|
|
|
logging_init();
|
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
memset(&action, 0, sizeof action);
|
2017-01-29 12:04:05 +01:00
|
|
|
action.sa_sigaction = signal_segv;
|
|
|
|
action.sa_flags = SA_SIGINFO;
|
2017-01-29 13:24:39 +01:00
|
|
|
if (sigaction(SIGSEGV, &action, nullptr) < 0)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGSEGV).\n");
|
|
|
|
abort();
|
|
|
|
}
|
2017-01-29 13:24:39 +01:00
|
|
|
if (sigaction(SIGILL, &action, nullptr) < 0)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGILL).\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
memset(&action, 0, sizeof action);
|
2017-12-04 15:49:40 +01:00
|
|
|
action.sa_sigaction = signal_buserror;
|
|
|
|
action.sa_flags = SA_SIGINFO;
|
|
|
|
if (sigaction(SIGBUS, &action, nullptr) < 0)
|
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGBUS).\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2017-12-21 11:19:52 +01:00
|
|
|
memset(&action, 0, sizeof action);
|
2017-12-04 15:49:40 +01:00
|
|
|
action.sa_sigaction = signal_term;
|
|
|
|
action.sa_flags = SA_SIGINFO;
|
|
|
|
if (sigaction(SIGTERM, &action, nullptr) < 0)
|
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGTERM).\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
alloc_AmigaMem();
|
|
|
|
RescanROMs();
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
// set capslock state based upon current "real" state
|
2016-09-13 22:46:06 +02:00
|
|
|
ioctl(0, KDGKBLED, &kbd_flags);
|
|
|
|
ioctl(0, KDGETLED, &kbd_led_status);
|
2017-03-01 13:23:32 +01:00
|
|
|
if (kbd_flags & 07 & LED_CAP)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
|
|
|
// record capslock pressed
|
|
|
|
kbd_led_status |= LED_CAP;
|
|
|
|
inputdevice_do_keyboard(AK_CAPSLOCK, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// record capslock as not pressed
|
|
|
|
kbd_led_status &= ~LED_CAP;
|
|
|
|
inputdevice_do_keyboard(AK_CAPSLOCK, 0);
|
|
|
|
}
|
2016-09-13 22:46:06 +02:00
|
|
|
ioctl(0, KDSETLED, kbd_led_status);
|
2016-08-29 20:08:05 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
real_main(argc, argv);
|
2016-11-30 22:25:43 +01:00
|
|
|
|
2016-09-14 23:02:32 +02:00
|
|
|
// restore keyboard LEDs to normal state
|
|
|
|
ioctl(0, KDSETLED, 0xFF);
|
2016-11-30 22:25:43 +01:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
ClearAvailableROMList();
|
|
|
|
romlist_clear();
|
|
|
|
free_keyring();
|
|
|
|
free_AmigaMem();
|
|
|
|
lstMRUDiskList.clear();
|
|
|
|
lstMRUCDList.clear();
|
|
|
|
rp9_cleanup();
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
logging_cleanup();
|
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
if(host_poweroff)
|
|
|
|
target_shutdown();
|
2017-01-29 12:04:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2018-02-09 17:54:59 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
SDLKey GetKeyFromName(const char *name)
|
|
|
|
{
|
|
|
|
if (!name || !*name) {
|
|
|
|
return SDLK_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int key = SDLK_FIRST; key < SDLK_LAST; key++)
|
|
|
|
{
|
|
|
|
if (!SDL_GetKeyName(SDLKey(key)))
|
|
|
|
continue;
|
|
|
|
if (SDL_strcasecmp(name, SDL_GetKeyName(SDLKey(key))) == 0)
|
|
|
|
{
|
|
|
|
return SDLKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SDLK_UNKNOWN;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int handle_msgpump()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-12-21 11:19:52 +01:00
|
|
|
auto got = 0;
|
2017-01-29 12:04:05 +01:00
|
|
|
SDL_Event rEvent;
|
2017-12-17 12:58:57 +01:00
|
|
|
|
2017-12-26 00:13:23 +01:00
|
|
|
// Default Enter GUI key is F12
|
|
|
|
int enter_gui_key = SDLK_F12;
|
|
|
|
if (strncmp(currprefs.open_gui, "", 1) != 0)
|
|
|
|
{
|
|
|
|
// If we have a value in the config, we use that instead
|
|
|
|
// SDL2-only for now
|
2018-02-09 17:54:59 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
enter_gui_key = GetKeyFromName(currprefs.open_gui);
|
|
|
|
#elif USE_SDL2
|
2017-12-26 00:13:23 +01:00
|
|
|
enter_gui_key = SDL_GetKeyFromName(currprefs.open_gui);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't set a default value for Quitting
|
|
|
|
int quit_key = 0;
|
|
|
|
if (strncmp(currprefs.quit_amiberry, "", 1) != 0)
|
|
|
|
{
|
|
|
|
// If we have a value in the config, we use that instead
|
2018-02-09 17:54:59 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
quit_key = GetKeyFromName(currprefs.quit_amiberry);
|
|
|
|
#elif USE_SDL2
|
2017-12-26 00:13:23 +01:00
|
|
|
quit_key = SDL_GetKeyFromName(currprefs.quit_amiberry);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-01-27 22:25:46 +01:00
|
|
|
// The default value for Action Replay is Pause/Break
|
|
|
|
int action_replay_button = SDLK_PAUSE;
|
|
|
|
if (strncmp(currprefs.action_replay, "", 1) != 0)
|
|
|
|
{
|
2018-02-09 17:54:59 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
action_replay_button = GetKeyFromName(currprefs.action_replay);
|
|
|
|
#elif USE_SDL2
|
2018-01-27 22:25:46 +01:00
|
|
|
action_replay_button = SDL_GetKeyFromName(currprefs.action_replay);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// No default value for Full Screen toggle
|
|
|
|
int fullscreen_key = 0;
|
|
|
|
if (strncmp(currprefs.fullscreen_toggle, "", 1) != 0)
|
|
|
|
{
|
2018-02-09 17:54:59 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
fullscreen_key = GetKeyFromName(currprefs.fullscreen_toggle);
|
|
|
|
#elif USE_SDL2
|
2018-01-27 22:25:46 +01:00
|
|
|
fullscreen_key = SDL_GetKeyFromName(currprefs.fullscreen_toggle);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
while (SDL_PollEvent(&rEvent))
|
|
|
|
{
|
|
|
|
got = 1;
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
Uint8* keystate = SDL_GetKeyState(nullptr);
|
2017-12-26 00:13:23 +01:00
|
|
|
#elif USE_SDL2
|
2017-01-29 13:24:39 +01:00
|
|
|
const Uint8* keystate = SDL_GetKeyboardState(nullptr);
|
2017-12-04 15:49:40 +01:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
switch (rEvent.type)
|
|
|
|
{
|
|
|
|
case SDL_QUIT:
|
|
|
|
uae_quit();
|
|
|
|
break;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_KEYDOWN:
|
2018-01-30 01:08:23 +01:00
|
|
|
#ifdef USE_SDL2
|
|
|
|
if (rEvent.key.repeat == 0)
|
2017-12-26 00:13:23 +01:00
|
|
|
{
|
2018-01-30 01:08:23 +01:00
|
|
|
#endif
|
|
|
|
// If the Enter GUI key was pressed, handle it
|
|
|
|
if (enter_gui_key && rEvent.key.keysym.sym == enter_gui_key)
|
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_ENTERGUI, 1, nullptr);
|
|
|
|
break;
|
|
|
|
}
|
2017-12-26 00:13:23 +01:00
|
|
|
|
2018-01-30 01:08:23 +01:00
|
|
|
// If the Quit emulator key was pressed, handle it
|
|
|
|
if (quit_key && rEvent.key.keysym.sym == quit_key)
|
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_QUIT, 1, nullptr);
|
|
|
|
break;
|
|
|
|
}
|
2018-01-27 22:25:46 +01:00
|
|
|
|
2018-01-30 01:08:23 +01:00
|
|
|
if (action_replay_button && rEvent.key.keysym.sym == action_replay_button)
|
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_FREEZEBUTTON, 1, nullptr);
|
|
|
|
break;
|
|
|
|
}
|
2018-01-27 22:25:46 +01:00
|
|
|
|
2018-01-30 01:08:23 +01:00
|
|
|
if (fullscreen_key && rEvent.key.keysym.sym == fullscreen_key)
|
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_TOGGLEWINDOWEDFULLSCREEN, 1, nullptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef USE_SDL2
|
|
|
|
}
|
|
|
|
#endif
|
2017-12-26 00:13:23 +01:00
|
|
|
// If the reset combination was pressed, handle it
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
// Strangely in FBCON left window is seen as left alt ??
|
2017-12-26 00:13:23 +01:00
|
|
|
if (keyboard_type == 2) // KEYCODE_FBCON
|
|
|
|
{
|
2018-02-10 00:47:18 +01:00
|
|
|
if (keystate[SDLK_LCTRL] && (keystate[SDLK_LSUPER] || keystate[SDLK_LALT]) && (keystate[SDLK_RSUPER] || keystate[SDLK_MENU]))
|
2017-12-26 00:13:23 +01:00
|
|
|
{
|
|
|
|
uae_reset(0, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (keystate[SDLK_LCTRL] && keystate[SDLK_LSUPER] && (keystate[SDLK_RSUPER] || keystate[SDLK_MENU]))
|
|
|
|
#elif USE_SDL2
|
2017-02-28 01:20:30 +01:00
|
|
|
if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_APPLICATION]))
|
2017-12-04 15:49:40 +01:00
|
|
|
#endif
|
2017-01-23 14:05:22 +01:00
|
|
|
{
|
|
|
|
uae_reset(0, 1);
|
|
|
|
break;
|
|
|
|
}
|
2017-12-26 00:13:23 +01:00
|
|
|
|
2017-12-04 15:49:40 +01:00
|
|
|
#ifdef USE_SDL1
|
|
|
|
// fix Caps Lock keypress shown as SDLK_UNKNOWN (scancode = 58)
|
|
|
|
if (rEvent.key.keysym.scancode == 58 && rEvent.key.keysym.sym == SDLK_UNKNOWN)
|
|
|
|
rEvent.key.keysym.sym = SDLK_CAPSLOCK;
|
|
|
|
#endif
|
2018-01-30 01:08:23 +01:00
|
|
|
#ifdef USE_SDL2
|
|
|
|
if (rEvent.key.repeat == 0)
|
2017-12-04 15:49:40 +01:00
|
|
|
{
|
2018-01-30 01:08:23 +01:00
|
|
|
#endif
|
|
|
|
if (rEvent.key.keysym.sym == SDLK_CAPSLOCK)
|
2017-01-23 14:05:22 +01:00
|
|
|
{
|
2018-01-30 01:08:23 +01:00
|
|
|
// Treat CAPSLOCK as a toggle. If on, set off and vice/versa
|
|
|
|
ioctl(0, KDGKBLED, &kbd_flags);
|
|
|
|
ioctl(0, KDGETLED, &kbd_led_status);
|
|
|
|
if (kbd_flags & 07 & LED_CAP)
|
|
|
|
{
|
|
|
|
// On, so turn off
|
|
|
|
kbd_led_status &= ~LED_CAP;
|
|
|
|
kbd_flags &= ~LED_CAP;
|
|
|
|
inputdevice_do_keyboard(AK_CAPSLOCK, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Off, so turn on
|
|
|
|
kbd_led_status |= LED_CAP;
|
|
|
|
kbd_flags |= LED_CAP;
|
|
|
|
inputdevice_do_keyboard(AK_CAPSLOCK, 1);
|
|
|
|
}
|
|
|
|
ioctl(0, KDSETLED, kbd_led_status);
|
|
|
|
ioctl(0, KDSKBLED, kbd_flags);
|
|
|
|
break;
|
2017-01-23 14:05:22 +01:00
|
|
|
}
|
2018-01-30 01:08:23 +01:00
|
|
|
|
|
|
|
// Handle all other keys
|
2017-12-26 00:13:23 +01:00
|
|
|
#ifdef USE_SDL1
|
2018-01-27 22:25:46 +01:00
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
2017-12-26 00:13:23 +01:00
|
|
|
#elif USE_SDL2
|
2018-01-27 22:25:46 +01:00
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
|
|
|
}
|
2018-01-30 01:08:23 +01:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
2018-01-30 01:08:23 +01:00
|
|
|
#ifdef USE_SDL2
|
2018-01-27 22:25:46 +01:00
|
|
|
if (rEvent.key.repeat == 0)
|
|
|
|
{
|
2018-01-30 01:08:23 +01:00
|
|
|
#endif
|
2017-12-26 00:13:23 +01:00
|
|
|
#ifdef USE_SDL1
|
2018-01-27 22:25:46 +01:00
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
2017-12-26 00:13:23 +01:00
|
|
|
#elif USE_SDL2
|
2018-01-27 22:25:46 +01:00
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
|
|
|
}
|
2018-01-30 01:08:23 +01:00
|
|
|
#endif
|
2017-12-04 15:49:40 +01:00
|
|
|
break;
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
2018-01-03 14:21:14 +01:00
|
|
|
if (rEvent.button.button == SDL_BUTTON_LEFT)
|
|
|
|
setmousebuttonstate(0, 0, 1);
|
2017-02-28 23:05:10 +01:00
|
|
|
if (rEvent.button.button == SDL_BUTTON_RIGHT)
|
2017-01-29 12:04:05 +01:00
|
|
|
setmousebuttonstate(0, 1, 1);
|
2017-02-28 23:05:10 +01:00
|
|
|
if (rEvent.button.button == SDL_BUTTON_MIDDLE)
|
2017-02-28 16:05:32 +01:00
|
|
|
setmousebuttonstate(0, 2, 1);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
|
|
|
if (rEvent.button.button == SDL_BUTTON_LEFT)
|
2018-01-03 14:21:14 +01:00
|
|
|
setmousebuttonstate(0, 0, 0);
|
2017-02-28 23:05:10 +01:00
|
|
|
if (rEvent.button.button == SDL_BUTTON_RIGHT)
|
2017-01-29 12:04:05 +01:00
|
|
|
setmousebuttonstate(0, 1, 0);
|
2017-02-28 23:05:10 +01:00
|
|
|
if (rEvent.button.button == SDL_BUTTON_MIDDLE)
|
2017-02-28 16:05:32 +01:00
|
|
|
setmousebuttonstate(0, 2, 0);
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
if (currprefs.input_tablet == TABLET_OFF)
|
|
|
|
{
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
2017-12-26 00:13:23 +01:00
|
|
|
const auto mouseScale = currprefs.input_joymouse_multiplier / 2;
|
|
|
|
const auto x = rEvent.motion.xrel;
|
|
|
|
const auto y = rEvent.motion.yrel;
|
2017-12-27 15:08:50 +01:00
|
|
|
#if defined (ANDROIDSDL)
|
2018-01-30 01:08:23 +01:00
|
|
|
if (rEvent.motion.x == 0 && x > -4)
|
|
|
|
x = -4;
|
|
|
|
if (rEvent.motion.y == 0 && y > -4)
|
|
|
|
y = -4;
|
|
|
|
if (rEvent.motion.x == currprefs.gfx_size.width - 1 && x < 4)
|
|
|
|
x = 4;
|
|
|
|
if (rEvent.motion.y == currprefs.gfx_size.height - 1 && y < 4)
|
|
|
|
y = 4;
|
2017-12-27 15:08:50 +01:00
|
|
|
#endif //ANDROIDSDL
|
2017-01-29 12:04:05 +01:00
|
|
|
setmousestate(0, 0, x * mouseScale, 0);
|
|
|
|
setmousestate(0, 1, y * mouseScale, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-12-26 00:13:23 +01:00
|
|
|
|
2017-12-05 11:11:01 +01:00
|
|
|
#ifdef USE_SDL2
|
2017-02-28 23:24:43 +01:00
|
|
|
case SDL_MOUSEWHEEL:
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
2017-12-04 15:49:40 +01:00
|
|
|
const int valY = rEvent.wheel.y;
|
|
|
|
const int valX = rEvent.wheel.x;
|
2017-02-28 23:24:43 +01:00
|
|
|
setmousestate(0, 2, valY, 0);
|
|
|
|
setmousestate(0, 3, valX, 0);
|
|
|
|
}
|
|
|
|
break;
|
2017-12-05 11:11:01 +01:00
|
|
|
#endif
|
2017-12-26 00:13:23 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2017-01-29 12:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return got;
|
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
static uaecptr clipboard_data;
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void amiga_clipboard_die()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void amiga_clipboard_init()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void amiga_clipboard_task_start(uaecptr data)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
clipboard_data = data;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
uae_u32 amiga_clipboard_proc_start()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
return clipboard_data;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void amiga_clipboard_got_data(uaecptr data, uae_u32 size, uae_u32 actual)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int amiga_clipboard_want_data()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
return 0;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void clipboard_vsync()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
}
|