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>
|
|
|
|
#include <vector>
|
2016-09-13 00:40:34 +02:00
|
|
|
#include <stdio.h>
|
2015-05-13 18:47:23 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <asm/sigcontext.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include "sysconfig.h"
|
|
|
|
#include "sysdeps.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "autoconf.h"
|
|
|
|
#include "uae.h"
|
|
|
|
#include "options.h"
|
2016-12-10 11:40:41 +01:00
|
|
|
#include "threaddep/thread.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
#include "gui.h"
|
2017-01-29 12:04:05 +01:00
|
|
|
#include "include/memory.h"
|
2016-04-24 09:45:29 +00:00
|
|
|
#include "newcpu.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
#include "custom.h"
|
|
|
|
#include "xwin.h"
|
|
|
|
#include "drawing.h"
|
|
|
|
#include "inputdevice.h"
|
|
|
|
#include "keybuf.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "disk.h"
|
|
|
|
#include "savestate.h"
|
2015-10-11 14:23:51 +02:00
|
|
|
#include "traps.h"
|
2016-04-24 09:45:29 +00:00
|
|
|
#include "bsdsocket.h"
|
2016-07-10 13:48:11 +02:00
|
|
|
#include "blkdev.h"
|
2015-10-11 14:23:51 +02:00
|
|
|
#include "native2amiga.h"
|
2015-11-16 22:32:10 +01:00
|
|
|
#include "rtgmodes.h"
|
|
|
|
#include "uaeresource.h"
|
2016-04-24 09:45:29 +00:00
|
|
|
#include "rommgr.h"
|
2016-07-10 13:48:11 +02:00
|
|
|
#include "akiko.h"
|
2017-01-21 14:54:08 +01:00
|
|
|
#include "SDL.h"
|
2017-02-27 14:29:54 +01:00
|
|
|
#include "amiberry_rp9.h"
|
2017-02-27 15:54:52 +01:00
|
|
|
#include <map>
|
2017-02-28 13:21:37 +01:00
|
|
|
#include "scsidev.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
extern void signal_segv(int signum, siginfo_t* info, void* ptr);
|
|
|
|
extern void gui_force_rtarea_hdchange();
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
extern int loadconfig_old(struct uae_prefs* p, const char* orgpath);
|
|
|
|
extern void SetLastActiveConfig(const char* filename);
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
/* Keyboard */
|
2017-02-27 15:54:52 +01:00
|
|
|
map<int, int> customControlMap; // No SDLK_LAST. SDL2 migration guide suggests std::map
|
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-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-01-29 12:04:05 +01:00
|
|
|
extern "C" int main(int argc, char* argv[]);
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void reinit_amiga()
|
2015-10-11 14:23:51 +02:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
write_log("reinit_amiga() called\n");
|
|
|
|
DISK_free();
|
2016-07-10 13:48:11 +02:00
|
|
|
#ifdef CD32
|
2017-01-29 12:04:05 +01:00
|
|
|
akiko_free();
|
2016-07-10 13:48:11 +02:00
|
|
|
#endif
|
2015-10-11 14:23:51 +02:00
|
|
|
#ifdef FILESYS
|
2017-01-29 12:04:05 +01:00
|
|
|
filesys_cleanup();
|
|
|
|
hardfile_reset();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
|
|
|
#ifdef AUTOCONFIG
|
2016-04-24 09:45:29 +00:00
|
|
|
#if defined (BSDSOCKET)
|
2017-01-29 12:04:05 +01:00
|
|
|
bsdlib_reset();
|
2016-04-24 09:45:29 +00:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
expansion_cleanup();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
device_func_reset();
|
|
|
|
memory_cleanup();
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
currprefs = changed_prefs;
|
|
|
|
/* force sound settings change */
|
|
|
|
currprefs.produce_sound = 0;
|
2015-10-11 14:23:51 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
framecnt = 1;
|
2015-10-11 14:23:51 +02:00
|
|
|
#ifdef AUTOCONFIG
|
2017-01-29 12:04:05 +01:00
|
|
|
rtarea_setup();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FILESYS
|
2017-01-29 12:04:05 +01:00
|
|
|
rtarea_init();
|
|
|
|
uaeres_install();
|
|
|
|
hardfile_install();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
keybuf_init();
|
2015-10-11 14:23:51 +02:00
|
|
|
|
|
|
|
#ifdef AUTOCONFIG
|
2017-01-29 12:04:05 +01:00
|
|
|
expansion_init();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FILESYS
|
2017-01-29 12:04:05 +01:00
|
|
|
filesys_install();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
memory_init();
|
|
|
|
memory_reset();
|
2015-10-11 14:23:51 +02:00
|
|
|
|
|
|
|
#ifdef AUTOCONFIG
|
2016-04-24 09:45:29 +00:00
|
|
|
#if defined (BSDSOCKET)
|
2017-01-29 12:04:05 +01:00
|
|
|
bsdlib_install();
|
2016-04-24 09:45:29 +00:00
|
|
|
#endif
|
2017-01-29 12:04:05 +01:00
|
|
|
emulib_install();
|
|
|
|
native2amiga_install();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
custom_init(); /* Must come after memory_init */
|
|
|
|
DISK_init();
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
reset_frame_rate_hack();
|
|
|
|
init_m68k();
|
2015-10-11 14:23:51 +02:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void sleep_millis_main(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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void logging_init()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
2016-09-01 13:53:43 +02:00
|
|
|
static int started;
|
|
|
|
static int first;
|
|
|
|
char debugfilename[MAX_DPATH];
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2016-09-01 13:53:43 +02:00
|
|
|
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-01-29 12:04:05 +01:00
|
|
|
sprintf(debugfilename, "%s/amiberry_log.txt", start_path_data);
|
2016-09-01 13:53:43 +02:00
|
|
|
if(!debugfile)
|
|
|
|
debugfile = fopen(debugfilename, "wt");
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2016-09-01 13:53:43 +02:00
|
|
|
first++;
|
2017-01-29 12:04:05 +01:00
|
|
|
write_log ( "Amiberry Logfile\n\n");
|
2015-05-13 18:47:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void logging_cleanup()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
2016-09-01 13:53:43 +02:00
|
|
|
if(debugfile)
|
|
|
|
fclose(debugfile);
|
|
|
|
debugfile = 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void stripslashes(TCHAR* p)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +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
|
|
|
|
|
|
|
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-01-29 12:04:05 +01:00
|
|
|
void getpathpart(TCHAR* outpath, int size, const TCHAR* inpath)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
_tcscpy (outpath, inpath);
|
|
|
|
TCHAR* p = _tcsrchr (outpath, '/');
|
|
|
|
if (p)
|
|
|
|
p[0] = 0;
|
|
|
|
fixtrailing(outpath);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
2017-01-29 12:04:05 +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;
|
|
|
|
const TCHAR* p = _tcsrchr (path, '/');
|
|
|
|
if (p)
|
|
|
|
_tcscpy (out, p + 1);
|
|
|
|
else
|
|
|
|
_tcscpy (out, path);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
void target_run()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
|
|
|
void target_quit()
|
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-01-29 12:04:05 +01:00
|
|
|
p->rtgmem_type = 1;
|
|
|
|
if (p->z3fastmem_start != z3_start_adr)
|
|
|
|
p->z3fastmem_start = z3_start_adr;
|
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)
|
|
|
|
p->gfx_size.height == 256;
|
2017-01-29 12:04:05 +01:00
|
|
|
p->gfx_resolution = p->gfx_size.width > 600 ? 1 : 0;
|
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-02-27 14:29:54 +01:00
|
|
|
p->amiberry_customControls = 0;
|
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
|
|
|
|
p->scaling_method = -1; //Default is Auto
|
|
|
|
p->key_for_menu = SDLK_F12;
|
|
|
|
p->key_for_quit = 0;
|
|
|
|
p->button_for_menu = -1;
|
|
|
|
p->button_for_quit = -1;
|
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-02-28 13:21:37 +01:00
|
|
|
cfgfile_write(f, _T("gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
|
|
|
|
cfgfile_write(f, _T("kbd_led_num"), _T("%d"), p->kbd_led_num);
|
|
|
|
cfgfile_write(f, _T("kbd_led_scr"), _T("%d"), p->kbd_led_scr);
|
|
|
|
cfgfile_write(f, _T("scaling_method"), _T("%d"), p->scaling_method);
|
|
|
|
cfgfile_write(f, _T("key_for_menu"), _T("%d"), p->key_for_menu);
|
|
|
|
cfgfile_write(f, _T("key_for_quit"), _T("%d"), p->key_for_quit);
|
|
|
|
cfgfile_write(f, _T("button_for_menu"), _T("%d"), p->button_for_menu);
|
|
|
|
cfgfile_write(f, _T("button_for_quit"), _T("%d"), p->button_for_quit);
|
|
|
|
|
2017-02-27 14:29:54 +01:00
|
|
|
cfgfile_write(f, "amiberry.custom_controls", "%d", p->amiberry_customControls);
|
2017-02-27 15:54:52 +01:00
|
|
|
cfgfile_write(f, "amiberry.custom_up", "%d", customControlMap[VK_UP]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_down", "%d", customControlMap[VK_DOWN]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_left", "%d", customControlMap[VK_LEFT]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_right", "%d", customControlMap[VK_RIGHT]);
|
2017-02-28 13:21:37 +01:00
|
|
|
cfgfile_write(f, "amiberry.custom_a", "%d", customControlMap[VK_Green]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_b", "%d", customControlMap[VK_Blue]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_x", "%d", customControlMap[VK_Red]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_y", "%d", customControlMap[VK_Yellow]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_l", "%d", customControlMap[VK_LShoulder]);
|
|
|
|
cfgfile_write(f, "amiberry.custom_r", "%d", customControlMap[VK_RShoulder]);
|
2017-03-01 00:49:56 +01:00
|
|
|
cfgfile_write(f, "amiberry.custom_play", "%d", customControlMap[VK_Play]);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void target_restart()
|
2016-08-27 20:39:53 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
TCHAR* target_expand_environment(const TCHAR* path)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-02-28 13:21:37 +01:00
|
|
|
if (!path)
|
|
|
|
return nullptr;
|
2017-01-29 12:04:05 +01:00
|
|
|
return strdup(path);
|
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-02-28 13:21:37 +01:00
|
|
|
|
|
|
|
if (cfgfile_intval(option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
|
|
|
|
return 1;
|
|
|
|
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;
|
|
|
|
if (cfgfile_intval(option, value, "scaling_method", &p->scaling_method, 1))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_intval(option, value, "key_for_menu", &p->key_for_menu, 1))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_intval(option, value, "key_for_quit", &p->key_for_quit, 1))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_intval(option, value, "button_for_menu", &p->button_for_menu, 1))
|
|
|
|
return 1;
|
|
|
|
if (cfgfile_intval(option, value, "button_for_quit", &p->button_for_quit, 1))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
int result = cfgfile_intval(option, value, "custom_controls", &p->amiberry_customControls, 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_up", &customControlMap[VK_UP], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_down", &customControlMap[VK_DOWN], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_left", &customControlMap[VK_LEFT], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_right", &customControlMap[VK_RIGHT], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_a", &customControlMap[VK_Green], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_b", &customControlMap[VK_Blue], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_x", &customControlMap[VK_Red], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_y", &customControlMap[VK_Yellow], 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_l", &customControlMap[VK_LShoulder], 1)
|
2017-02-28 14:05:36 +01:00
|
|
|
|| cfgfile_intval(option, value, "custom_r", &customControlMap[VK_RShoulder], 1)
|
2017-03-01 00:49:56 +01:00
|
|
|
|| cfgfile_intval(option, value, "custom_play", &customControlMap[VK_Play], 1);
|
2017-01-29 12:04:05 +01:00
|
|
|
return result;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +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-01-29 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
void fetch_configurationpath(char* out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, config_path, size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
void fetch_rompath(char* out, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, rom_path, size);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
void fetch_rp9path(char* out, int size)
|
2016-04-25 17:12:37 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strncpy(out, rp9_path, size);
|
2016-04-25 17:12:37 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 01:20:30 +01:00
|
|
|
void fetch_statefilepath(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-01-29 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
int i;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
if (emulating && changed_prefs.cdslots[0].inuse)
|
|
|
|
gui_force_rtarea_hdchange();
|
|
|
|
|
|
|
|
discard_prefs(p, type);
|
|
|
|
default_prefs(p, 0);
|
|
|
|
|
|
|
|
const char* ptr = strstr(filename, ".rp9");
|
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
|
|
|
// Load rp9 config
|
|
|
|
result = rp9_parse_file(p, filename);
|
|
|
|
if (result)
|
|
|
|
extractFileName(filename, last_loaded_config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ptr = strstr(filename, ".uae");
|
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
|
|
|
int type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
|
|
|
|
result = cfgfile_load(p, filename, &type, 0, 1);
|
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
extractFileName(filename, last_loaded_config);
|
|
|
|
else
|
|
|
|
result = loadconfig_old(p, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
for (i = 0; i < p->nr_floppies; ++i)
|
|
|
|
{
|
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-01-29 12:04:05 +01:00
|
|
|
|
|
|
|
SetLastActiveConfig(filename);
|
|
|
|
|
|
|
|
if (count_HDs(p) > 0) // When loading a config with HDs, always do a hardreset
|
|
|
|
gui_force_rtarea_hdchange();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int check_configfile(char* file)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char tmp[MAX_PATH];
|
|
|
|
|
2017-01-29 13:24:39 +01:00
|
|
|
FILE* f = fopen(file, "rt");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(tmp, file);
|
|
|
|
char* ptr = strstr(tmp, ".uae");
|
|
|
|
if (ptr > nullptr)
|
|
|
|
{
|
|
|
|
*(ptr + 1) = '\0';
|
|
|
|
strcat(tmp, "conf");
|
|
|
|
f = fopen(tmp, "rt");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void extractFileName(const char* str, char* buffer)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
const char* p = str + strlen(str) - 1;
|
|
|
|
while (*p != '/' && p > str)
|
|
|
|
p--;
|
|
|
|
p++;
|
|
|
|
strcpy(buffer, p);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void extractPath(char* str, char* buffer)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
strcpy(buffer, str);
|
|
|
|
char* p = buffer + strlen(buffer) - 1;
|
|
|
|
while (*p != '/' && p > buffer)
|
|
|
|
p--;
|
|
|
|
p[1] = '\0';
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void removeFileExtension(char* filename)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char* p = filename + strlen(filename) - 1;
|
|
|
|
while (p > filename && *p != '.')
|
|
|
|
{
|
|
|
|
*p = '\0';
|
|
|
|
--p;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 13:24:39 +01:00
|
|
|
void ReadDirectory(const char* path, vector<string>* dirs, vector<string>* files)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
DIR* dir;
|
|
|
|
struct dirent* dent;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
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-01-29 13:24:39 +01:00
|
|
|
if (dirs != nullptr && dirs->size() > 0 && (*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-01-29 12:04:05 +01:00
|
|
|
std::sort(dirs->begin(), dirs->end());
|
2017-01-29 13:24:39 +01:00
|
|
|
if (files != nullptr)
|
2017-01-29 12:04:05 +01:00
|
|
|
std::sort(files->begin(), files->end());
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 13:24:39 +01:00
|
|
|
void saveAdfDir()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char path[MAX_DPATH];
|
|
|
|
int i;
|
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-01-29 13:24:39 +01:00
|
|
|
FILE* f = fopen(path, "w");
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
for (i = 0; i < lstAvailableROMs.size(); ++i)
|
|
|
|
{
|
|
|
|
snprintf(buffer, MAX_DPATH, "ROMName=%s\n", lstAvailableROMs[i]->Name);
|
|
|
|
fputs(buffer, f);
|
|
|
|
snprintf(buffer, MAX_DPATH, "ROMPath=%s\n", lstAvailableROMs[i]->Path);
|
|
|
|
fputs(buffer, f);
|
|
|
|
snprintf(buffer, MAX_DPATH, "ROMType=%d\n", lstAvailableROMs[i]->ROMType);
|
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "MRUDiskList=%d\n", lstMRUDiskList.size());
|
|
|
|
fputs(buffer, f);
|
|
|
|
for (i = 0; i < lstMRUDiskList.size(); ++i)
|
|
|
|
{
|
|
|
|
snprintf(buffer, MAX_DPATH, "Diskfile=%s\n", lstMRUDiskList[i].c_str());
|
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, MAX_DPATH, "MRUCDList=%d\n", lstMRUCDList.size());
|
|
|
|
fputs(buffer, f);
|
|
|
|
for (i = 0; i < lstMRUCDList.size(); ++i)
|
|
|
|
{
|
|
|
|
snprintf(buffer, MAX_DPATH, "CDfile=%s\n", lstMRUCDList[i].c_str());
|
|
|
|
fputs(buffer, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void get_string(FILE* f, char* dst, int size)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char buffer[MAX_PATH];
|
|
|
|
fgets(buffer, MAX_PATH, f);
|
|
|
|
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-01-29 13:24:39 +01:00
|
|
|
void loadAdfDir()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
char path[MAX_DPATH];
|
|
|
|
int i;
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
strcpy(currentDir, start_path_data);
|
|
|
|
snprintf(config_path, MAX_DPATH, "%s/conf/", start_path_data);
|
|
|
|
snprintf(rom_path, MAX_DPATH, "%s/kickstarts/", start_path_data);
|
|
|
|
snprintf(rp9_path, MAX_DPATH, "%s/rp9/", start_path_data);
|
|
|
|
|
|
|
|
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
|
2017-01-29 13:24:39 +01:00
|
|
|
FILE* f1 = fopen(path, "rt");
|
2017-01-29 12:04:05 +01:00
|
|
|
if (f1)
|
|
|
|
{
|
|
|
|
fscanf(f1, "path=");
|
|
|
|
get_string(f1, currentDir, sizeof(currentDir));
|
|
|
|
if (!feof(f1))
|
|
|
|
{
|
|
|
|
fscanf(f1, "config_path=");
|
|
|
|
get_string(f1, config_path, sizeof(config_path));
|
|
|
|
fscanf(f1, "rom_path=");
|
|
|
|
get_string(f1, rom_path, sizeof(rom_path));
|
|
|
|
|
|
|
|
int numROMs;
|
|
|
|
fscanf(f1, "ROMs=%d\n", &numROMs);
|
|
|
|
for (i = 0; i < numROMs; ++i)
|
|
|
|
{
|
|
|
|
AvailableROM* tmp;
|
|
|
|
tmp = new AvailableROM();
|
|
|
|
fscanf(f1, "ROMName=");
|
|
|
|
get_string(f1, tmp->Name, sizeof(tmp->Name));
|
|
|
|
fscanf(f1, "ROMPath=");
|
|
|
|
get_string(f1, tmp->Path, sizeof(tmp->Path));
|
|
|
|
fscanf(f1, "ROMType=%d\n", &(tmp->ROMType));
|
|
|
|
lstAvailableROMs.push_back(tmp);
|
|
|
|
}
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
lstMRUDiskList.clear();
|
|
|
|
int numDisks = 0;
|
|
|
|
char disk[MAX_PATH];
|
|
|
|
fscanf(f1, "MRUDiskList=%d\n", &numDisks);
|
|
|
|
for (i = 0; i < numDisks; ++i)
|
|
|
|
{
|
|
|
|
fscanf(f1, "Diskfile=");
|
|
|
|
get_string(f1, disk, sizeof(disk));
|
|
|
|
FILE * f = fopen(disk, "rb");
|
|
|
|
if (f != NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
lstMRUDiskList.push_back(disk);
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
lstMRUCDList.clear();
|
|
|
|
int numCD = 0;
|
|
|
|
char cd[MAX_PATH];
|
|
|
|
fscanf(f1, "MRUCDList=%d\n", &numCD);
|
|
|
|
for (i = 0; i < numCD; ++i)
|
|
|
|
{
|
|
|
|
fscanf(f1, "CDfile=");
|
|
|
|
get_string(f1, cd, sizeof(cd));
|
|
|
|
FILE * f = fopen(cd, "rb");
|
|
|
|
if (f != NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
lstMRUCDList.push_back(cd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f1);
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
void target_reset()
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
uae_u32 emulib_target_getcpurate(uae_u32 v, uae_u32* low)
|
2016-04-24 09:45:29 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
*low = 0;
|
|
|
|
if (v == 1)
|
|
|
|
{
|
|
|
|
*low = 1e+9; /* We have nano seconds */
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-29 13:24:39 +01:00
|
|
|
|
|
|
|
if (v == 2)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
|
|
|
int64_t time;
|
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
time = (int64_t(ts.tv_sec) * 1000000000) + ts.tv_nsec;
|
|
|
|
*low = uae_u32(time & 0xffffffff);
|
|
|
|
return uae_u32(time >> 32);
|
|
|
|
}
|
|
|
|
return 0;
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int main(int argc, char* argv[])
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
struct sigaction action;
|
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();
|
|
|
|
|
|
|
|
snprintf(savestate_fname, MAX_PATH, "%s/saves/default.ads", start_path_data);
|
|
|
|
logging_init();
|
|
|
|
|
|
|
|
memset(&action, 0, sizeof(action));
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
alloc_AmigaMem();
|
|
|
|
RescanROMs();
|
2017-02-28 01:20:30 +01:00
|
|
|
keyboard_settrans();
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2016-08-29 20:08:05 +02:00
|
|
|
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
|
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
|
|
|
#endif
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
real_main(argc, argv);
|
2016-11-30 22:25:43 +01:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
|
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
|
|
|
#endif
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
int handle_msgpump()
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
int got = 0;
|
|
|
|
SDL_Event rEvent;
|
|
|
|
int keycode;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
while (SDL_PollEvent(&rEvent))
|
|
|
|
{
|
|
|
|
got = 1;
|
2017-01-29 13:24:39 +01:00
|
|
|
const Uint8* keystate = SDL_GetKeyboardState(nullptr);
|
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-23 14:05:22 +01:00
|
|
|
case SDL_JOYBUTTONDOWN:
|
|
|
|
if (currprefs.button_for_menu != -1 && rEvent.jbutton.button == currprefs.button_for_menu)
|
|
|
|
inputdevice_add_inputcode(AKS_ENTERGUI, 1);
|
|
|
|
if (currprefs.button_for_quit != -1 && rEvent.jbutton.button == currprefs.button_for_quit)
|
|
|
|
inputdevice_add_inputcode(AKS_QUIT, 1);
|
|
|
|
break;
|
2017-01-29 12:04:05 +01:00
|
|
|
|
|
|
|
case SDL_KEYDOWN:
|
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-01-23 14:05:22 +01:00
|
|
|
{
|
|
|
|
uae_reset(0, 1);
|
|
|
|
break;
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-02-28 13:21:37 +01:00
|
|
|
switch (rEvent.key.keysym.sym)
|
2017-01-29 12:04:05 +01:00
|
|
|
{
|
2017-02-28 13:21:37 +01:00
|
|
|
case SDLK_NUMLOCKCLEAR:
|
2017-02-28 01:20:30 +01:00
|
|
|
if (currprefs.keyboard_leds[KBLED_NUMLOCKB] > 0)
|
|
|
|
{
|
|
|
|
//oldleds ^= KBLED_NUMLOCKM;
|
|
|
|
//ch = true;
|
|
|
|
}
|
|
|
|
break;
|
2017-02-28 13:21:37 +01:00
|
|
|
case SDLK_CAPSLOCK: // capslock
|
2017-02-28 01:20:30 +01:00
|
|
|
if (currprefs.keyboard_leds[KBLED_CAPSLOCKB] > 0)
|
|
|
|
{
|
|
|
|
//oldleds ^= KBLED_CAPSLOCKM;
|
|
|
|
//ch = true;
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
// Treat CAPSLOCK as a toggle. If on, set off and vice/versa
|
2017-01-23 14:05:22 +01:00
|
|
|
ioctl(0, KDGKBLED, &kbd_flags);
|
|
|
|
ioctl(0, KDGETLED, &kbd_led_status);
|
|
|
|
if ((kbd_flags & 07) & LED_CAP)
|
|
|
|
{
|
2017-01-29 12:04:05 +01:00
|
|
|
// On, so turn off
|
2017-01-23 14:05:22 +01:00
|
|
|
kbd_led_status &= ~LED_CAP;
|
|
|
|
kbd_flags &= ~LED_CAP;
|
|
|
|
inputdevice_do_keyboard(AK_CAPSLOCK, 0);
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
else
|
2017-01-23 14:05:22 +01:00
|
|
|
{
|
|
|
|
// 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-29 12:41:13 +01:00
|
|
|
|
2017-02-28 13:21:37 +01:00
|
|
|
case SDLK_SCROLLLOCK:
|
2017-02-28 01:20:30 +01:00
|
|
|
if (currprefs.keyboard_leds[KBLED_SCROLLLOCKB] > 0)
|
|
|
|
{
|
|
|
|
//oldleds ^= KBLED_SCROLLLOCKM;
|
|
|
|
//ch = true;
|
|
|
|
}
|
2017-01-29 12:41:13 +01:00
|
|
|
break;
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
default:
|
2017-02-27 15:54:52 +01:00
|
|
|
if (currprefs.amiberry_customControls)
|
|
|
|
{
|
|
|
|
keycode = customControlMap[rEvent.key.keysym.sym];
|
|
|
|
if (keycode < 0)
|
|
|
|
{
|
|
|
|
// Simulate mouse or joystick
|
|
|
|
SimulateMouseOrJoy(keycode, 1);
|
|
|
|
break;
|
|
|
|
}
|
2017-02-28 13:21:37 +01:00
|
|
|
if (keycode > 0)
|
2017-02-27 15:54:52 +01:00
|
|
|
{
|
|
|
|
// Send mapped key press
|
|
|
|
inputdevice_do_keyboard(keycode, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-02-28 01:20:30 +01:00
|
|
|
translate_amiberry_keys(rEvent.key.keysym.sym, 1);
|
2017-01-29 12:04:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYUP:
|
2017-02-27 15:54:52 +01:00
|
|
|
if (currprefs.amiberry_customControls)
|
|
|
|
{
|
|
|
|
keycode = customControlMap[rEvent.key.keysym.sym];
|
|
|
|
if (keycode < 0)
|
|
|
|
{
|
|
|
|
// Simulate mouse or joystick
|
|
|
|
SimulateMouseOrJoy(keycode, 0);
|
|
|
|
break;
|
|
|
|
}
|
2017-02-28 13:21:37 +01:00
|
|
|
if (keycode > 0)
|
2017-02-27 15:54:52 +01:00
|
|
|
{
|
|
|
|
// Send mapped key release
|
|
|
|
inputdevice_do_keyboard(keycode, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
2017-02-28 01:20:30 +01:00
|
|
|
translate_amiberry_keys(rEvent.key.keysym.sym, 0);
|
2017-01-29 12:04:05 +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)
|
|
|
|
{
|
|
|
|
if (rEvent.button.button == SDL_BUTTON_LEFT)
|
2017-02-28 23:05:10 +01:00
|
|
|
setmousebuttonstate(0, 0, 1);
|
|
|
|
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)
|
2017-02-28 23:05:10 +01:00
|
|
|
setmousebuttonstate(0, 0, 0);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int mouseScale = currprefs.input_joymouse_multiplier / 2;
|
|
|
|
x = rEvent.motion.xrel;
|
|
|
|
y = rEvent.motion.yrel;
|
2017-01-29 13:24:39 +01:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
setmousestate(0, 0, x * mouseScale, 0);
|
|
|
|
setmousestate(0, 1, y * mouseScale, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-02-28 23:24:43 +01:00
|
|
|
|
|
|
|
case SDL_MOUSEWHEEL:
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
|
|
|
int valY = rEvent.wheel.y;
|
|
|
|
int valX = rEvent.wheel.x;
|
|
|
|
setmousestate(0, 2, valY, 0);
|
|
|
|
setmousestate(0, 3, valX, 0);
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|