2015-05-13 18:47:23 +00:00
|
|
|
/*
|
|
|
|
* UAE - The Un*x Amiga Emulator
|
|
|
|
*
|
|
|
|
* Pandora interface
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2016-04-25 17:12:37 +00:00
|
|
|
#include "pandora_rp9.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
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
static int delayed_mousebutton = 0;
|
|
|
|
static int doStylusRightClick;
|
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 */
|
2016-12-10 13:23:58 +01:00
|
|
|
//int customControlMap[SDLK_LAST];
|
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-05-14 18:57:55 +00:00
|
|
|
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
|
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;
|
2016-05-14 18:57:55 +00:00
|
|
|
#endif
|
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;
|
|
|
|
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-01-29 12:04:05 +01:00
|
|
|
p->pandora_horizontal_offset = 0;
|
|
|
|
p->pandora_vertical_offset = 0;
|
|
|
|
p->pandora_hide_idle_led = 0;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
p->pandora_tapDelay = 10;
|
|
|
|
p->pandora_customControls = 0;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
// memset(customControlMap, 0, sizeof(customControlMap));
|
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-01-23 14:13:43 +01:00
|
|
|
cfgfile_write(f, "pandora.cpu_speed", "%d", p->pandora_cpu_speed);
|
|
|
|
cfgfile_write(f, "pandora.hide_idle_led", "%d", p->pandora_hide_idle_led);
|
|
|
|
cfgfile_write(f, "pandora.tap_delay", "%d", p->pandora_tapDelay);
|
|
|
|
cfgfile_write(f, "pandora.custom_controls", "%d", p->pandora_customControls);
|
2017-01-29 12:04:05 +01:00
|
|
|
// cfgfile_write(f, "pandora.custom_up", "%d", customControlMap[VK_UP]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_down", "%d", customControlMap[VK_DOWN]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_left", "%d", customControlMap[VK_LEFT]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_right", "%d", customControlMap[VK_RIGHT]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_a", "%d", customControlMap[VK_A]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_b", "%d", customControlMap[VK_B]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_x", "%d", customControlMap[VK_X]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_y", "%d", customControlMap[VK_Y]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_l", "%d", customControlMap[VK_L]);
|
|
|
|
// cfgfile_write(f, "pandora.custom_r", "%d", customControlMap[VK_R]);
|
2017-01-23 14:13:43 +01:00
|
|
|
cfgfile_write(f, "pandora.move_x", "%d", p->pandora_horizontal_offset);
|
|
|
|
cfgfile_write(f, "pandora.move_y", "%d", p->pandora_vertical_offset);
|
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-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-01-23 14:13:43 +01:00
|
|
|
int result = (cfgfile_intval(option, value, "cpu_speed", &p->pandora_cpu_speed, 1)
|
2017-01-29 12:04:05 +01:00
|
|
|
|| cfgfile_intval(option, value, "hide_idle_led", &p->pandora_hide_idle_led, 1)
|
|
|
|
|| cfgfile_intval(option, value, "tap_delay", &p->pandora_tapDelay, 1)
|
|
|
|
|| cfgfile_intval(option, value, "custom_controls", &p->pandora_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_A], 1)
|
|
|
|
// || cfgfile_intval(option, value, "custom_b", &customControlMap[VK_B], 1)
|
|
|
|
// || cfgfile_intval(option, value, "custom_x", &customControlMap[VK_X], 1)
|
|
|
|
// || cfgfile_intval(option, value, "custom_y", &customControlMap[VK_Y], 1)
|
|
|
|
// || cfgfile_intval(option, value, "custom_l", &customControlMap[VK_L], 1)
|
|
|
|
// || cfgfile_intval(option, value, "custom_r", &customControlMap[VK_R], 1)
|
|
|
|
|| cfgfile_intval(option, value, "move_x", &p->pandora_horizontal_offset, 1)
|
|
|
|
|| cfgfile_intval(option, value, "move_y", &p->pandora_vertical_offset, 1)
|
|
|
|
);
|
|
|
|
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-01-29 12:04:05 +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-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)
|
|
|
|
{
|
|
|
|
if (!DISK_validate_filename(p, p->floppyslots[i].df, 0, NULL, NULL, NULL))
|
|
|
|
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)
|
|
|
|
inputdevice_updateconfig(NULL, p);
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
FILE * f = fopen(file, "rt");
|
|
|
|
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 12:04:05 +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-01-29 12:04:05 +01:00
|
|
|
DIR* dir;
|
|
|
|
struct dirent* dent;
|
|
|
|
|
|
|
|
if (dirs != NULL)
|
|
|
|
dirs->clear();
|
|
|
|
if (files != NULL)
|
|
|
|
files->clear();
|
|
|
|
|
|
|
|
dir = opendir(path);
|
|
|
|
if (dir != NULL)
|
|
|
|
{
|
|
|
|
while ((dent = readdir(dir)) != NULL)
|
|
|
|
{
|
|
|
|
if (dent->d_type == DT_DIR)
|
|
|
|
{
|
|
|
|
if (dirs != NULL)
|
|
|
|
dirs->push_back(dent->d_name);
|
|
|
|
}
|
|
|
|
else if (files != NULL)
|
|
|
|
files->push_back(dent->d_name);
|
|
|
|
}
|
|
|
|
if (dirs != NULL && dirs->size() > 0 && (*dirs)[0] == ".")
|
|
|
|
dirs->erase(dirs->begin());
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dirs != NULL)
|
|
|
|
std::sort(dirs->begin(), dirs->end());
|
|
|
|
if (files != NULL)
|
|
|
|
std::sort(files->begin(), files->end());
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void saveAdfDir(void)
|
|
|
|
{
|
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);
|
|
|
|
FILE * f = fopen(path, "w");
|
|
|
|
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);
|
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void loadAdfDir(void)
|
|
|
|
{
|
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);
|
|
|
|
FILE * f1 = fopen(path, "rt");
|
|
|
|
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-23 20:35:38 +01:00
|
|
|
//int currVSyncRate = 0;
|
|
|
|
//bool SetVSyncRate(int hz)
|
|
|
|
//{
|
|
|
|
// char cmd[64];
|
|
|
|
//
|
|
|
|
// if(currVSyncRate != hz)
|
|
|
|
// {
|
|
|
|
// snprintf((char*)cmd, 64, "sudo /usr/pandora/scripts/op_lcdrate.sh %d", hz);
|
|
|
|
// system(cmd);
|
|
|
|
// currVSyncRate = hz;
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// return false;
|
|
|
|
//}
|
2016-08-27 20:39:53 +02: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;
|
|
|
|
}
|
|
|
|
else if (v == 2)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
if (sigaction(SIGSEGV, &action, NULL) < 0)
|
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGSEGV).\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
if (sigaction(SIGILL, &action, NULL) < 0)
|
|
|
|
{
|
|
|
|
printf("Failed to set signal handler (SIGILL).\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
alloc_AmigaMem();
|
|
|
|
RescanROMs();
|
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-01-29 12:04:05 +01:00
|
|
|
if ((kbd_flags & 07) & LED_CAP)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
int modifier;
|
2016-11-30 22:25:43 +01:00
|
|
|
int handled = 0;
|
|
|
|
int i;
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
if (delayed_mousebutton)
|
|
|
|
{
|
|
|
|
--delayed_mousebutton;
|
|
|
|
if (delayed_mousebutton == 0)
|
|
|
|
setmousebuttonstate(0, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (SDL_PollEvent(&rEvent))
|
|
|
|
{
|
|
|
|
got = 1;
|
|
|
|
const Uint8* keystate = SDL_GetKeyboardState(NULL);
|
|
|
|
|
|
|
|
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:
|
|
|
|
// Menu button or key pressed
|
|
|
|
if (currprefs.key_for_menu != 0 && rEvent.key.keysym.scancode == currprefs.key_for_menu)
|
2017-01-23 14:05:22 +01:00
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_ENTERGUI, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (currprefs.key_for_quit != 0 && rEvent.key.keysym.sym == currprefs.key_for_quit)
|
|
|
|
{
|
|
|
|
inputdevice_add_inputcode(AKS_QUIT, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_MENU]))
|
|
|
|
{
|
|
|
|
uae_reset(0, 1);
|
|
|
|
break;
|
|
|
|
}
|
2017-01-29 12:04:05 +01:00
|
|
|
|
|
|
|
switch (rEvent.key.keysym.scancode)
|
|
|
|
{
|
2017-01-23 14:05:22 +01:00
|
|
|
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_SCANCODE_CAPSLOCK: // capslock
|
|
|
|
// 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;
|
|
|
|
#endif
|
2016-09-01 13:53:43 +02:00
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_SCANCODE_LSHIFT: // Shift key
|
2017-01-29 12:41:13 +01:00
|
|
|
inputdevice_do_keyboard(AK_RSH, 1);
|
|
|
|
break;
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_SCANCODE_RSHIFT:
|
|
|
|
inputdevice_do_keyboard(AK_LSH, 1);
|
|
|
|
break;
|
|
|
|
|
2017-01-29 12:41:13 +01:00
|
|
|
case SDL_SCANCODE_RGUI:
|
|
|
|
case SDL_SCANCODE_MENU:
|
|
|
|
inputdevice_do_keyboard(AK_RAMI, 1);
|
|
|
|
break;
|
|
|
|
case SDL_SCANCODE_LGUI:
|
|
|
|
inputdevice_do_keyboard(AK_LAMI, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_SCANCODE_LALT:
|
|
|
|
inputdevice_do_keyboard(AK_LALT, 1);
|
|
|
|
break;
|
|
|
|
case SDL_SCANCODE_RALT:
|
|
|
|
inputdevice_do_keyboard(AK_RALT, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_SCANCODE_LCTRL:
|
|
|
|
case SDL_SCANCODE_RCTRL:
|
|
|
|
inputdevice_do_keyboard(AK_CTRL, 1);
|
|
|
|
break;
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
// case VK_L: // Left shoulder button
|
|
|
|
// case VK_R: // Right shoulder button
|
|
|
|
// if(currprefs.input_tablet > TABLET_OFF)
|
|
|
|
// {
|
|
|
|
// // Holding left or right shoulder button -> stylus does right mousebutton
|
|
|
|
// doStylusRightClick = 1;
|
|
|
|
// }
|
|
|
|
// Fall through...
|
|
|
|
|
|
|
|
default:
|
|
|
|
// if (currprefs.pandora_customControls)
|
|
|
|
// {
|
|
|
|
//// keycode = customControlMap[rEvent.key.keysym.sym];
|
|
|
|
// if (keycode < 0)
|
|
|
|
// {
|
|
|
|
// // Simulate mouse or joystick
|
|
|
|
// SimulateMouseOrJoy(keycode, 1);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// else if (keycode > 0)
|
|
|
|
// {
|
|
|
|
// // Send mapped key press
|
|
|
|
// inputdevice_do_keyboard(keycode, 1);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
modifier = rEvent.key.keysym.mod;
|
|
|
|
|
|
|
|
// keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier);
|
|
|
|
// if(keycode)
|
|
|
|
// {
|
|
|
|
// if(modifier == KMOD_SHIFT)
|
|
|
|
// inputdevice_do_keyboard(AK_LSH, 1);
|
|
|
|
// else
|
|
|
|
// inputdevice_do_keyboard(AK_LSH, 0);
|
|
|
|
//
|
|
|
|
// inputdevice_do_keyboard(keycode, 1);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
|
|
|
// }
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYUP:
|
|
|
|
switch (rEvent.key.keysym.scancode)
|
|
|
|
{
|
|
|
|
case SDL_SCANCODE_LSHIFT: // Shift key
|
2017-01-29 12:41:13 +01:00
|
|
|
inputdevice_do_keyboard(AK_RSH, 0);
|
|
|
|
break;
|
2017-01-29 12:04:05 +01:00
|
|
|
case SDL_SCANCODE_RSHIFT:
|
|
|
|
inputdevice_do_keyboard(AK_LSH, 0);
|
|
|
|
break;
|
|
|
|
|
2017-01-29 12:41:13 +01:00
|
|
|
case SDL_SCANCODE_RGUI:
|
|
|
|
case SDL_SCANCODE_MENU:
|
|
|
|
inputdevice_do_keyboard(AK_RAMI, 0);
|
|
|
|
break;
|
|
|
|
case SDL_SCANCODE_LGUI:
|
|
|
|
inputdevice_do_keyboard(AK_LAMI, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_SCANCODE_LALT:
|
|
|
|
inputdevice_do_keyboard(AK_LALT, 0);
|
|
|
|
break;
|
|
|
|
case SDL_SCANCODE_RALT:
|
|
|
|
inputdevice_do_keyboard(AK_RALT, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_SCANCODE_LCTRL:
|
|
|
|
case SDL_SCANCODE_RCTRL:
|
|
|
|
inputdevice_do_keyboard(AK_CTRL, 0);
|
|
|
|
break;
|
|
|
|
|
2017-01-29 12:04:05 +01:00
|
|
|
// case VK_L: // Left shoulder button
|
|
|
|
// case VK_R: // Right shoulder button
|
|
|
|
// if(currprefs.input_tablet > TABLET_OFF)
|
|
|
|
// {
|
|
|
|
// // Release left or right shoulder button -> stylus does left mousebutton
|
|
|
|
// doStylusRightClick = 0;
|
|
|
|
// }
|
|
|
|
// Fall through...
|
|
|
|
|
|
|
|
default:
|
|
|
|
// if (currprefs.pandora_customControls)
|
|
|
|
// {
|
|
|
|
//// keycode = customControlMap[rEvent.key.keysym.sym];
|
|
|
|
// if (keycode < 0)
|
|
|
|
// {
|
|
|
|
// // Simulate mouse or joystick
|
|
|
|
// SimulateMouseOrJoy(keycode, 0);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// else if (keycode > 0)
|
|
|
|
// {
|
|
|
|
// // Send mapped key release
|
|
|
|
// inputdevice_do_keyboard(keycode, 0);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
modifier = rEvent.key.keysym.mod;
|
|
|
|
// keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier);
|
|
|
|
// if(keycode)
|
|
|
|
// {
|
|
|
|
// inputdevice_do_keyboard(keycode, 0);
|
|
|
|
// if(modifier == KMOD_SHIFT)
|
|
|
|
// inputdevice_do_keyboard(AK_LSH, 0);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
|
|
|
// }
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (currprefs.input_tablet > TABLET_OFF && !doStylusRightClick)
|
|
|
|
{
|
|
|
|
// Delay mousebutton, we need new position first...
|
|
|
|
delayed_mousebutton = currprefs.pandora_tapDelay << 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setmousebuttonstate(0, doStylusRightClick, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rEvent.button.button == SDL_BUTTON_RIGHT)
|
|
|
|
setmousebuttonstate(0, 1, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
|
|
|
{
|
|
|
|
if (rEvent.button.button == SDL_BUTTON_LEFT)
|
|
|
|
{
|
|
|
|
setmousebuttonstate(0, doStylusRightClick, 0);
|
|
|
|
}
|
|
|
|
else if (rEvent.button.button == SDL_BUTTON_RIGHT)
|
|
|
|
setmousebuttonstate(0, 1, 0);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
//#ifdef PANDORA_SPECIFIC
|
|
|
|
// 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;
|
|
|
|
//#endif
|
|
|
|
setmousestate(0, 0, x * mouseScale, 0);
|
|
|
|
setmousestate(0, 1, y * mouseScale, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|