2015-05-13 18:47:23 +00:00
|
|
|
/*
|
|
|
|
* UAE - The Un*x Amiga Emulator
|
|
|
|
*
|
|
|
|
* Pandora interface
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <asm/sigcontext.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <execinfo.h>
|
|
|
|
#include "sysconfig.h"
|
|
|
|
#include "sysdeps.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "autoconf.h"
|
|
|
|
#include "uae.h"
|
|
|
|
#include "options.h"
|
2015-10-11 14:23:51 +02:00
|
|
|
#include "td-sdl/thread.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
#include "gui.h"
|
|
|
|
#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 "joystick.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"
|
2015-05-13 18:47:23 +00:00
|
|
|
#include <SDL.h>
|
2016-04-25 17:12:37 +00:00
|
|
|
#include "pandora_rp9.h"
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
/*
|
|
|
|
#define DBG_MAX_THREADS 128
|
|
|
|
uae_thread_id running_threads[DBG_MAX_THREADS];
|
|
|
|
char running_threads_name[DBG_MAX_THREADS][64];
|
|
|
|
|
|
|
|
void dbg_add_thread(uae_thread_id id, const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i<DBG_MAX_THREADS; ++i)
|
|
|
|
{
|
|
|
|
if(running_threads[i] == 0)
|
|
|
|
{
|
|
|
|
running_threads[i] = id;
|
|
|
|
if(name != NULL)
|
|
|
|
strncpy(running_threads_name[i], name, 64);
|
|
|
|
else
|
|
|
|
strncpy(running_threads_name[i], "<empty>", 64);
|
|
|
|
write_log("dbg_add_thread: id = %d, name = %s, pos = %d\n", id, running_threads_name[i], i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
write_log("dbg_add_thread: no more free entries\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void dbg_rem_thread(uae_thread_id id)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i<DBG_MAX_THREADS; ++i)
|
|
|
|
{
|
|
|
|
if(running_threads[i] == id)
|
|
|
|
{
|
|
|
|
write_log("dbg_rem_thread: id = %d, name = %s, pos = %d\n", id, running_threads_name[i], i);
|
|
|
|
running_threads[i] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dbg_list_threads(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i<DBG_MAX_THREADS; ++i)
|
|
|
|
{
|
|
|
|
if(running_threads[i] != 0)
|
|
|
|
{
|
|
|
|
write_log("dbg_list_threads: id = %d, name = %s, pos = %d\n", running_threads[i], running_threads_name[i], i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
extern void signal_segv(int signum, siginfo_t* info, void*ptr);
|
2016-04-24 09:45:29 +00:00
|
|
|
extern void gui_force_rtarea_hdchange(void);
|
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
|
|
|
|
2015-05-17 07:52:43 +00: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-07-10 13:48:11 +02:00
|
|
|
int customControlMap[SDLK_LAST];
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
char start_path_data[MAX_DPATH];
|
|
|
|
char currentDir[MAX_DPATH];
|
2016-05-14 18:57:55 +00:00
|
|
|
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
|
|
|
|
static int capslock = 0;
|
|
|
|
#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];
|
2015-05-13 18:47:23 +00:00
|
|
|
char last_loaded_config[MAX_DPATH] = { '\0' };
|
|
|
|
|
|
|
|
static bool cpuSpeedChanged = false;
|
|
|
|
static int lastCpuSpeed = 600;
|
2016-06-25 09:23:49 +00:00
|
|
|
int defaultCpuSpeed = 600;
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" int main( int argc, char *argv[] );
|
|
|
|
|
|
|
|
|
2015-10-11 14:23:51 +02:00
|
|
|
void reinit_amiga(void)
|
|
|
|
{
|
|
|
|
write_log("reinit_amiga() called\n");
|
|
|
|
DISK_free ();
|
2016-07-10 13:48:11 +02:00
|
|
|
#ifdef CD32
|
|
|
|
akiko_free ();
|
|
|
|
#endif
|
2015-10-11 14:23:51 +02:00
|
|
|
#ifdef FILESYS
|
|
|
|
filesys_cleanup ();
|
2016-04-24 09:45:29 +00:00
|
|
|
hardfile_reset();
|
2015-10-11 14:23:51 +02:00
|
|
|
#endif
|
|
|
|
#ifdef AUTOCONFIG
|
2016-04-24 09:45:29 +00:00
|
|
|
#if defined (BSDSOCKET)
|
|
|
|
bsdlib_reset();
|
|
|
|
#endif
|
2015-10-11 14:23:51 +02:00
|
|
|
expansion_cleanup ();
|
|
|
|
#endif
|
2016-07-10 13:48:11 +02:00
|
|
|
device_func_reset ();
|
2016-04-24 09:45:29 +00:00
|
|
|
memory_cleanup ();
|
2015-10-11 14:23:51 +02:00
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
/* At this point, there might run some threads from bsdsocket.*/
|
|
|
|
// write_log("Threads in reinit_amiga():\n");
|
|
|
|
// dbg_list_threads();
|
|
|
|
|
2015-10-11 14:23:51 +02:00
|
|
|
currprefs = changed_prefs;
|
|
|
|
/* force sound settings change */
|
|
|
|
currprefs.produce_sound = 0;
|
|
|
|
|
|
|
|
framecnt = 1;
|
|
|
|
#ifdef AUTOCONFIG
|
|
|
|
rtarea_setup ();
|
|
|
|
#endif
|
|
|
|
#ifdef FILESYS
|
|
|
|
rtarea_init ();
|
2015-11-16 22:32:10 +01:00
|
|
|
uaeres_install ();
|
2015-10-11 14:23:51 +02:00
|
|
|
hardfile_install();
|
|
|
|
#endif
|
2016-04-24 09:45:29 +00:00
|
|
|
keybuf_init();
|
2015-10-11 14:23:51 +02:00
|
|
|
|
|
|
|
#ifdef AUTOCONFIG
|
|
|
|
expansion_init ();
|
|
|
|
#endif
|
|
|
|
#ifdef FILESYS
|
|
|
|
filesys_install ();
|
|
|
|
#endif
|
|
|
|
memory_init ();
|
|
|
|
memory_reset ();
|
|
|
|
|
|
|
|
#ifdef AUTOCONFIG
|
2016-04-24 09:45:29 +00:00
|
|
|
#if defined (BSDSOCKET)
|
|
|
|
bsdlib_install ();
|
|
|
|
#endif
|
2015-10-11 14:23:51 +02:00
|
|
|
emulib_install ();
|
|
|
|
native2amiga_install ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
custom_init (); /* Must come after memory_init */
|
|
|
|
DISK_init ();
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
reset_frame_rate_hack ();
|
2015-10-11 14:23:51 +02:00
|
|
|
init_m68k();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
void sleep_millis (int ms)
|
|
|
|
{
|
|
|
|
usleep(ms * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sleep_millis_busy (int ms)
|
|
|
|
{
|
|
|
|
usleep(ms * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void logging_init( void )
|
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
sprintf(debugfilename, "%s/uae4arm_log.txt", start_path_data);
|
2015-05-13 18:47:23 +00:00
|
|
|
if(!debugfile)
|
|
|
|
debugfile = fopen(debugfilename, "wt");
|
|
|
|
|
|
|
|
first++;
|
2016-04-24 09:45:29 +00:00
|
|
|
write_log ( "UAE4ARM Logfile\n\n");
|
2015-05-13 18:47:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging_cleanup( void )
|
|
|
|
{
|
|
|
|
#ifdef WITH_LOGGING
|
|
|
|
if(debugfile)
|
|
|
|
fclose(debugfile);
|
|
|
|
debugfile = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
void stripslashes (TCHAR *p)
|
|
|
|
{
|
|
|
|
while (_tcslen (p) > 0 && (p[_tcslen (p) - 1] == '\\' || p[_tcslen (p) - 1] == '/'))
|
|
|
|
p[_tcslen (p) - 1] = 0;
|
|
|
|
}
|
|
|
|
void fixtrailing (TCHAR *p)
|
|
|
|
{
|
|
|
|
if (_tcslen(p) == 0)
|
|
|
|
return;
|
|
|
|
if (p[_tcslen(p) - 1] == '/' || p[_tcslen(p) - 1] == '\\')
|
|
|
|
return;
|
|
|
|
_tcscat(p, "/");
|
|
|
|
}
|
|
|
|
|
|
|
|
void getpathpart (TCHAR *outpath, int size, const TCHAR *inpath)
|
|
|
|
{
|
|
|
|
_tcscpy (outpath, inpath);
|
|
|
|
TCHAR *p = _tcsrchr (outpath, '/');
|
|
|
|
if (p)
|
|
|
|
p[0] = 0;
|
|
|
|
fixtrailing (outpath);
|
|
|
|
}
|
|
|
|
void getfilepart (TCHAR *out, int size, const TCHAR *path)
|
|
|
|
{
|
|
|
|
out[0] = 0;
|
|
|
|
const TCHAR *p = _tcsrchr (path, '/');
|
|
|
|
if (p)
|
|
|
|
_tcscpy (out, p + 1);
|
|
|
|
else
|
|
|
|
_tcscpy (out, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uae_u8 *target_load_keyfile (struct uae_prefs *p, const char *path, int *sizep, char *name)
|
2015-10-11 14:23:51 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
void target_run (void)
|
|
|
|
{
|
|
|
|
}
|
2015-09-09 21:49:41 +02:00
|
|
|
void target_quit (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void target_fixup_options (struct uae_prefs *p)
|
|
|
|
{
|
2016-04-24 09:45:29 +00:00
|
|
|
p->rtgmem_type = 1;
|
|
|
|
gfxmem_start = rtg_start_adr;
|
|
|
|
if (p->z3fastmem_start != z3_start_adr)
|
|
|
|
p->z3fastmem_start = z3_start_adr;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
void target_default_options (struct uae_prefs *p, int type)
|
|
|
|
{
|
|
|
|
p->pandora_horizontal_offset = 0;
|
|
|
|
p->pandora_vertical_offset = 0;
|
2016-06-25 09:23:49 +00:00
|
|
|
p->pandora_cpu_speed = defaultCpuSpeed;
|
|
|
|
p->pandora_hide_idle_led = 0;
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
p->pandora_tapDelay = 10;
|
2016-07-10 13:48:11 +02:00
|
|
|
p->pandora_customControls = 0;
|
|
|
|
|
|
|
|
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
|
2015-11-16 22:32:10 +01:00
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
memset(customControlMap, 0, sizeof(customControlMap));
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void target_save_options (struct zfile *f, struct uae_prefs *p)
|
|
|
|
{
|
2016-04-24 09:45:29 +00:00
|
|
|
cfgfile_write (f, "pandora.cpu_speed", "%d", p->pandora_cpu_speed);
|
2016-06-25 09:23:49 +00:00
|
|
|
cfgfile_write (f, "pandora.hide_idle_led", "%d", p->pandora_hide_idle_led);
|
2016-04-24 09:45:29 +00:00
|
|
|
cfgfile_write (f, "pandora.tap_delay", "%d", p->pandora_tapDelay);
|
|
|
|
cfgfile_write (f, "pandora.custom_controls", "%d", p->pandora_customControls);
|
2016-07-10 13:48:11 +02:00
|
|
|
cfgfile_write (f, "pandora.custom_up", "%d", customControlMap[SDLK_UP]);
|
|
|
|
cfgfile_write (f, "pandora.custom_down", "%d", customControlMap[SDLK_DOWN]);
|
|
|
|
cfgfile_write (f, "pandora.custom_left", "%d", customControlMap[SDLK_LEFT]);
|
|
|
|
cfgfile_write (f, "pandora.custom_right", "%d", customControlMap[SDLK_RIGHT]);
|
|
|
|
cfgfile_write (f, "pandora.custom_a", "%d", customControlMap[SDLK_HOME]);
|
|
|
|
cfgfile_write (f, "pandora.custom_b", "%d", customControlMap[SDLK_END]);
|
|
|
|
cfgfile_write (f, "pandora.custom_x", "%d", customControlMap[SDLK_PAGEDOWN]);
|
|
|
|
cfgfile_write (f, "pandora.custom_y", "%d", customControlMap[SDLK_PAGEUP]);
|
|
|
|
cfgfile_write (f, "pandora.custom_l", "%d", customControlMap[SDLK_RSHIFT]);
|
|
|
|
cfgfile_write (f, "pandora.custom_r", "%d", customControlMap[SDLK_RCTRL]);
|
2016-04-24 09:45:29 +00:00
|
|
|
cfgfile_write (f, "pandora.move_x", "%d", p->pandora_horizontal_offset);
|
|
|
|
cfgfile_write (f, "pandora.move_y", "%d", p->pandora_vertical_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TCHAR *target_expand_environment (const TCHAR *path)
|
|
|
|
{
|
|
|
|
return strdup(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
int target_parse_option (struct uae_prefs *p, const char *option, const char *value)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2015-10-11 14:23:51 +02:00
|
|
|
int result = (cfgfile_intval (option, value, "cpu_speed", &p->pandora_cpu_speed, 1)
|
2016-06-25 09:23:49 +00:00
|
|
|
|| cfgfile_intval (option, value, "hide_idle_led", &p->pandora_hide_idle_led, 1)
|
2015-05-13 18:47:23 +00:00
|
|
|
|| cfgfile_intval (option, value, "tap_delay", &p->pandora_tapDelay, 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_controls", &p->pandora_customControls, 1)
|
2016-07-10 13:48:11 +02:00
|
|
|
|| cfgfile_intval (option, value, "custom_up", &customControlMap[SDLK_UP], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_down", &customControlMap[SDLK_DOWN], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_left", &customControlMap[SDLK_LEFT], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_right", &customControlMap[SDLK_RIGHT], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_a", &customControlMap[SDLK_HOME], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_b", &customControlMap[SDLK_END], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_x", &customControlMap[SDLK_PAGEDOWN], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_y", &customControlMap[SDLK_PAGEUP], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_l", &customControlMap[SDLK_RSHIFT], 1)
|
|
|
|
|| cfgfile_intval (option, value, "custom_r", &customControlMap[SDLK_RCTRL], 1)
|
2015-05-13 18:47:23 +00:00
|
|
|
|| cfgfile_intval (option, value, "move_x", &p->pandora_horizontal_offset, 1)
|
|
|
|
|| cfgfile_intval (option, value, "move_y", &p->pandora_vertical_offset, 1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
void fetch_datapath (char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-11 14:23:51 +02:00
|
|
|
void fetch_saveimagepath (char *out, int size, int dir)
|
|
|
|
{
|
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/savestates/", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
void fetch_configurationpath (char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, config_path, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_configurationpath(char *newpath)
|
|
|
|
{
|
|
|
|
strncpy(config_path, newpath, MAX_DPATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fetch_rompath (char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, rom_path, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_rompath(char *newpath)
|
|
|
|
{
|
|
|
|
strncpy(rom_path, newpath, MAX_DPATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-25 17:12:37 +00:00
|
|
|
void fetch_rp9path (char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, rp9_path, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
void fetch_savestatepath(char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/savestates/", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fetch_screenshotpath(char *out, int size)
|
|
|
|
{
|
|
|
|
strncpy(out, start_path_data, size);
|
|
|
|
strncat(out, "/screenshots/", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
int target_cfgfile_load (struct uae_prefs *p, const char *filename, int type, int isdefault)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2015-09-09 21:49:41 +02:00
|
|
|
int i;
|
2015-05-13 18:47:23 +00:00
|
|
|
int result = 0;
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
if(emulating && changed_prefs.cdslots[0].inuse)
|
|
|
|
gui_force_rtarea_hdchange();
|
|
|
|
|
2015-10-11 14:23:51 +02:00
|
|
|
discard_prefs(p, type);
|
2016-07-10 13:48:11 +02:00
|
|
|
default_prefs(p, 0);
|
2015-10-11 14:23:51 +02:00
|
|
|
|
2016-04-25 17:12:37 +00:00
|
|
|
char *ptr = strstr(filename, ".rp9");
|
2015-05-13 18:47:23 +00:00
|
|
|
if(ptr > 0)
|
|
|
|
{
|
2016-04-25 17:12:37 +00:00
|
|
|
// Load rp9 config
|
|
|
|
result = rp9_parse_file(p, filename);
|
|
|
|
if(result)
|
|
|
|
extractFileName(filename, last_loaded_config);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2015-05-17 07:52:43 +00:00
|
|
|
else
|
2016-04-25 17:12:37 +00:00
|
|
|
{
|
|
|
|
ptr = strstr(filename, ".uae");
|
|
|
|
if(ptr > 0)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
if(result)
|
|
|
|
{
|
2015-10-11 14:23:51 +02:00
|
|
|
for(i=0; i < p->nr_floppies; ++i)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-04-24 09:45:29 +00:00
|
|
|
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);
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
if(!isdefault)
|
|
|
|
inputdevice_updateconfig (p);
|
2016-04-24 09:45:29 +00:00
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
SetLastActiveConfig(filename);
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
if(count_HDs(p) > 0) // When loading a config with HDs, always do a hardreset
|
|
|
|
gui_force_rtarea_hdchange();
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int check_configfile(char *file)
|
|
|
|
{
|
|
|
|
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 > 0)
|
|
|
|
{
|
|
|
|
*(ptr + 1) = '\0';
|
|
|
|
strcat(tmp, "conf");
|
|
|
|
f = fopen(tmp, "rt");
|
|
|
|
if(f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void extractFileName(const char * str,char *buffer)
|
|
|
|
{
|
|
|
|
const char *p=str+strlen(str)-1;
|
|
|
|
while(*p != '/' && p > str)
|
|
|
|
p--;
|
|
|
|
p++;
|
|
|
|
strcpy(buffer,p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void extractPath(char *str, char *buffer)
|
|
|
|
{
|
|
|
|
strcpy(buffer, str);
|
|
|
|
char *p = buffer + strlen(buffer) - 1;
|
|
|
|
while(*p != '/' && p > buffer)
|
|
|
|
p--;
|
|
|
|
p[1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void removeFileExtension(char *filename)
|
|
|
|
{
|
|
|
|
char *p = filename + strlen(filename) - 1;
|
|
|
|
while(p > filename && *p != '.')
|
|
|
|
{
|
|
|
|
*p = '\0';
|
|
|
|
--p;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ReadDirectory(const char *path, std::vector<std::string> *dirs, std::vector<std::string> *files)
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void saveAdfDir(void)
|
|
|
|
{
|
|
|
|
char path[MAX_DPATH];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void get_string(FILE *f, char *dst, int size)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loadAdfDir(void)
|
|
|
|
{
|
|
|
|
char path[MAX_DPATH];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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);
|
2016-04-25 17:12:37 +00:00
|
|
|
snprintf(rp9_path, MAX_DPATH, "%s/rp9/", start_path_data);
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
2016-04-25 17:12:37 +00:00
|
|
|
FILE *f = fopen(disk, "rb");
|
|
|
|
if(f != NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
lstMRUDiskList.push_back(disk);
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2016-07-10 13:48:11 +02: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);
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
fclose(f1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setCpuSpeed()
|
|
|
|
{
|
2016-07-10 13:48:11 +02:00
|
|
|
#ifdef PANDORA_SPECIFIC
|
2016-04-03 10:15:26 +00:00
|
|
|
char speedCmd[128];
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed;
|
|
|
|
|
|
|
|
if(currprefs.pandora_cpu_speed != lastCpuSpeed)
|
|
|
|
{
|
|
|
|
snprintf((char*)speedCmd, 128, "unset DISPLAY; echo y | sudo -n /usr/pandora/scripts/op_cpuspeed.sh %d", currprefs.pandora_cpu_speed);
|
|
|
|
system(speedCmd);
|
|
|
|
lastCpuSpeed = currprefs.pandora_cpu_speed;
|
|
|
|
cpuSpeedChanged = true;
|
|
|
|
}
|
|
|
|
if(changed_prefs.ntscmode != currprefs.ntscmode)
|
|
|
|
{
|
|
|
|
if(changed_prefs.ntscmode)
|
|
|
|
system("sudo /usr/pandora/scripts/op_lcdrate.sh 60");
|
|
|
|
else
|
|
|
|
system("sudo /usr/pandora/scripts/op_lcdrate.sh 50");
|
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
#else
|
|
|
|
return;
|
|
|
|
#endif
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
|
|
|
|
|
2016-06-25 09:23:49 +00:00
|
|
|
int getDefaultCpuSpeed(void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-06-25 09:23:49 +00:00
|
|
|
#ifdef PANDORA_SPECIFIC
|
|
|
|
int speed = 600;
|
|
|
|
FILE* f = fopen ("/etc/pandora/conf/cpu.conf", "rt");
|
|
|
|
if(f)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-06-25 09:23:49 +00:00
|
|
|
char line[128];
|
|
|
|
for(int i=0; i<6; ++i)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-06-25 09:23:49 +00:00
|
|
|
fscanf(f, "%s\n", &line);
|
|
|
|
if(strncmp(line, "default:", 8) == 0)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-06-25 09:23:49 +00:00
|
|
|
int value = 0;
|
|
|
|
sscanf(line, "default:%d", &value);
|
|
|
|
if(value > 500 && value < 1200)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-06-25 09:23:49 +00:00
|
|
|
speed = value;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-25 09:23:49 +00:00
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
return speed;
|
|
|
|
#else
|
2016-07-10 13:48:11 +02:00
|
|
|
return 0;
|
2016-06-25 09:23:49 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void resetCpuSpeed(void)
|
|
|
|
{
|
|
|
|
#ifdef PANDORA_SPECIFIC
|
|
|
|
if(cpuSpeedChanged)
|
|
|
|
{
|
|
|
|
lastCpuSpeed = defaultCpuSpeed - 10;
|
|
|
|
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed = defaultCpuSpeed;
|
|
|
|
setCpuSpeed();
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2016-06-25 09:23:49 +00:00
|
|
|
#else
|
|
|
|
return;
|
|
|
|
#endif
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
void target_reset (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
|
|
|
|
{
|
|
|
|
*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;
|
|
|
|
}
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct sigaction action;
|
|
|
|
|
2016-06-25 09:23:49 +00:00
|
|
|
defaultCpuSpeed = getDefaultCpuSpeed();
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
// Get startup path
|
|
|
|
getcwd(start_path_data, MAX_DPATH);
|
|
|
|
loadAdfDir();
|
2016-04-25 17:12:37 +00:00
|
|
|
rp9_init();
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2015-11-16 22:32:10 +01:00
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
alloc_AmigaMem();
|
2015-10-11 14:23:51 +02:00
|
|
|
RescanROMs();
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2016-07-20 23:48:35 +02:00
|
|
|
//keyboard_settrans();
|
2015-05-13 18:47:23 +00:00
|
|
|
real_main (argc, argv);
|
2016-04-24 09:45:29 +00:00
|
|
|
|
|
|
|
ClearAvailableROMList();
|
2016-04-25 17:12:37 +00:00
|
|
|
romlist_clear();
|
2016-04-24 09:45:29 +00:00
|
|
|
free_keyring();
|
2015-05-13 18:47:23 +00:00
|
|
|
free_AmigaMem();
|
2016-04-24 09:45:29 +00:00
|
|
|
lstMRUDiskList.clear();
|
2016-07-10 13:48:11 +02:00
|
|
|
lstMRUCDList.clear();
|
2016-04-25 17:12:37 +00:00
|
|
|
rp9_cleanup();
|
2015-05-13 18:47:23 +00:00
|
|
|
|
|
|
|
logging_cleanup();
|
2016-06-25 09:23:49 +00:00
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
// printf("Threads at exit:\n");
|
|
|
|
// dbg_list_threads();
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
int handle_msgpump (void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
2016-07-10 13:48:11 +02:00
|
|
|
int got = 0;
|
2015-05-13 18:47:23 +00:00
|
|
|
SDL_Event rEvent;
|
2016-07-10 13:48:11 +02:00
|
|
|
int keycode;
|
|
|
|
int modifier;
|
|
|
|
|
|
|
|
if(delayed_mousebutton) {
|
|
|
|
--delayed_mousebutton;
|
|
|
|
if(delayed_mousebutton == 0)
|
|
|
|
setmousebuttonstate (0, 0, 1);
|
2016-04-24 09:45:29 +00:00
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
|
|
|
|
while (SDL_PollEvent(&rEvent)) {
|
|
|
|
got = 1;
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
switch (rEvent.type)
|
|
|
|
{
|
|
|
|
case SDL_QUIT:
|
|
|
|
uae_quit();
|
|
|
|
break;
|
2016-07-10 13:48:11 +02:00
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
case SDL_KEYDOWN:
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
if(rEvent.key.keysym.sym == currprefs.key_for_menu)
|
|
|
|
inputdevice_add_inputcode (AKS_ENTERGUI, 1);
|
|
|
|
switch(rEvent.key.keysym.sym)
|
|
|
|
{
|
2015-05-13 18:47:23 +00:00
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
case SDLK_LSHIFT: // Shift key
|
|
|
|
inputdevice_do_keyboard(AK_LSH, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_RSHIFT: // Left shoulder button
|
|
|
|
case SDLK_RCTRL: // 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 {
|
2016-08-01 18:58:01 +02:00
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
|
|
|
|
|
2016-07-10 13:48:11 +02:00
|
|
|
}
|
|
|
|
break;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYUP:
|
|
|
|
switch(rEvent.key.keysym.sym)
|
|
|
|
{
|
|
|
|
|
|
|
|
case SDLK_LSHIFT: // Shift key
|
|
|
|
inputdevice_do_keyboard(AK_LSH, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_RSHIFT: // Left shoulder button
|
|
|
|
case SDLK_RCTRL: // 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 {
|
2016-08-01 18:58:01 +02:00
|
|
|
if (keyboard_type == KEYCODE_UNK)
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
|
|
|
|
else
|
|
|
|
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
|
2016-07-10 13:48:11 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-05-13 18:47:23 +00:00
|
|
|
case SDL_MOUSEMOTION:
|
2016-04-24 09:45:29 +00:00
|
|
|
if(currprefs.input_tablet == TABLET_OFF) {
|
2016-07-10 13:48:11 +02:00
|
|
|
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;
|
2016-04-03 10:15:26 +00:00
|
|
|
#ifdef PANDORA_SPECIFIC
|
2016-07-10 13:48:11 +02: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;
|
2016-01-10 11:11:26 +01:00
|
|
|
#endif
|
2016-07-10 13:48:11 +02:00
|
|
|
setmousestate(0, 0, x * mouseScale, 0);
|
|
|
|
setmousestate(0, 1, y * mouseScale, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
2016-07-10 13:48:11 +02:00
|
|
|
}
|
|
|
|
return got;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handle_events (void)
|
|
|
|
{
|
|
|
|
/* Handle GUI events */
|
|
|
|
gui_handle_events ();
|
2015-05-13 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2016-04-24 09:45:29 +00:00
|
|
|
|
|
|
|
static uaecptr clipboard_data;
|
|
|
|
|
|
|
|
void amiga_clipboard_die (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_clipboard_init (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_clipboard_task_start (uaecptr data)
|
|
|
|
{
|
|
|
|
clipboard_data = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
uae_u32 amiga_clipboard_proc_start (void)
|
|
|
|
{
|
|
|
|
return clipboard_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_clipboard_want_data (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void clipboard_vsync (void)
|
2015-05-13 18:47:23 +00:00
|
|
|
{
|
|
|
|
}
|