"68000", "68000", "68010", "68010", "68ec020", "68020", "68ec020/68881", "68020/68881",
"68040", "68040", "xxxxx", "xxxxx", "68060", "68060", 0
};
-static const char *portmode[] = { "joy0", "joy1", "mouse", "kbd1", "kbd2", "kbd3", 0 };
static const char *colormode1[] = { "8bit", "15bit", "16bit", "8bit_dither", "4bit_dither", "32bit", 0 };
static const char *colormode2[] = { "8", "15", "16", "8d", "4d", "32", 0 };
static const char *soundmode1[] = { "none", "interrupts", "normal", "exact", 0 };
if (p->override_dga_address)
cfgfile_write (f, "override_dga_address=0x%08x\n", p->override_dga_address);
- cfgfile_write (f, "joyport0=%s\n", portmode[p->jport0]);
- cfgfile_write (f, "joyport1=%s\n", portmode[p->jport1]);
+ for (i = 0; i < 2; i++) {
+ int v = i == 0 ? p->jport0 : p->jport1;
+ char tmp1[100], tmp2[50];
+ if (v < JSEM_JOYS)
+ sprintf (tmp2, "kbd%d", v);
+ else if (v < JSEM_MICE)
+ sprintf (tmp2, "joy%d", v - JSEM_JOYS);
+ else
+ sprintf (tmp2, "mouse%d", v - JSEM_MICE);
+ sprintf (tmp1, "joyport%d=%s\n", i, tmp2);
+ cfgfile_write (f, tmp1);
+ }
cfgfile_write (f, "bsdsocket_emu=%s\n", p->socket_emu ? "true" : "false");
|| cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode2, 0)
|| cfgfile_strval (option, value, "sound_interpol", &p->sound_interpol, interpolmode, 0)
|| cfgfile_strval (option, value, "sound_filter", &p->sound_filter, soundfiltermode, 0)
- || cfgfile_strval (option, value, "joyport0", &p->jport0, portmode, 0)
- || cfgfile_strval (option, value, "joyport1", &p->jport1, portmode, 0)
|| cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode1, 1)
|| cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode2, 1)
|| cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode3, 0)
return 1;
}
+ if (strcmp (option, "joyport0") == 0 || strcmp (option, "joyport1") == 0) {
+ int port = strcmp (option, "joyport0") == 0 ? 0 : 1;
+ int start = -1;
+ int kbdl = 0;
+ char *pp = 0;
+ if (strncmp (value, "kbd", 3) == 0) {
+ start = JSEM_KBDLAYOUT;
+ pp = value + 3;
+ kbdl = 1;
+ } else if (strncmp (value, "joy", 3) == 0) {
+ start = JSEM_JOYS;
+ pp = value + 3;
+ } else if (strncmp (value, "mouse", 5) == 0) {
+ start = JSEM_MICE;
+ pp = value + 5;
+ }
+ if (pp) {
+ start += atol (pp);
+ if (kbdl && start > 0)
+ start--;
+ if (port)
+ p->jport1 = start;
+ else
+ p->jport0 = start;
+ }
+ return 1;
+ }
+
if (cfgfile_string (option, value, "statefile", tmpbuf, sizeof (tmpbuf))) {
savestate_state = STATE_DORESTORE;
strcpy (savestate_fname, tmpbuf);
#endif
ciahsync++;
if (ciahsync >= (currprefs.ntscmode ? MAXVPOS_NTSC : MAXVPOS_PAL) * MAXHPOS_PAL / maxhpos) { /* not so perfect.. */
+ if (ciahsync != 312) {
+ static int warned = 0;
+ if (!warned)
+ gui_message("ciahsync may be messed up! check logs!");
+ warned = 1;
+ write_log ("ciahsync=%d! %d %d", ciahsync, currprefs.ntscmode, maxhpos);
+ }
CIA_vsync_handler ();
ciahsync = 0;
}
}
}
-/*
- * This _should_ be no issue for us, but let's rather use a guaranteed
- * thread safe function if we have one.
- * This used to be broken in glibc versions <= 2.0.1 (I think). I hope
- * no one is using this these days.
- * Michael Krause says it's also broken in libc5. ARRRGHHHHHH!!!!
- */
-#if 0 && defined HAVE_READDIR_R
-
-static struct dirent *my_readdir (DIR *dirstream, struct dirent *space)
-{
- struct dirent *loc;
- if (readdir_r (dirstream, space, &loc) == 0) {
- /* Success */
- return loc;
- }
- return 0;
-}
-
-#else
-#define my_readdir(dirstream, space) readdir(dirstream)
-#endif
-
uaecptr filesys_initcode;
static uae_u32 fsdevname, filesys_configdev;
if (uip[i].volname != 0) {
fprintf (f, "filesystem2=%s,%s:%s:%s,%d\n", uip[i].readonly ? "ro" : "rw",
uip[i].devname ? uip[i].devname : "", uip[i].volname, str, uip[i].bootpri);
+#if 0
fprintf (f, "filesystem=%s,%s:%s\n", uip[i].readonly ? "ro" : "rw",
uip[i].volname, str);
+#endif
} else {
fprintf (f, "hardfile2=%s,%s:%s,%d,%d,%d,%d,%d,%s\n",
uip[i].readonly ? "ro" : "rw",
uip[i].devname ? uip[i].devname : "", str,
uip[i].hf.secspertrack, uip[i].hf.surfaces, uip[i].hf.reservedblocks, uip[i].hf.blocksize,
uip[i].bootpri,uip[i].filesysdir ? uip[i].filesysdir : "");
+#if 0
fprintf (f, "hardfile=%s,%d,%d,%d,%d,%s\n",
uip[i].readonly ? "ro" : "rw", uip[i].hf.secspertrack,
uip[i].hf.surfaces, uip[i].hf.reservedblocks, uip[i].hf.blocksize, str);
+#endif
}
xfree (str);
}
struct key *next;
a_inode *aino;
uae_u32 uniq;
- int fd;
+ void *fd;
off_t file_pos;
int dosmode;
int createmode;
aino->comment = 0;
aino->has_dbentry = 0;
- fsdb_fill_file_attrs (aino);
+ if (!fsdb_fill_file_attrs (aino)) {
+ xfree (aino);
+ return 0;
+ }
if (aino->dir)
fsdb_clean_dir (aino);
}
c->aname = get_aname (unit, base, rel);
c->comment = 0;
c->has_dbentry = 0;
- fsdb_fill_file_attrs (c);
+ if (!fsdb_fill_file_attrs (c)) {
+ xfree (c);
+ *err = ERROR_NO_FREE_STORE;
+ return 0;
+ }
if (c->dir)
fsdb_clean_dir (c);
}
}
if (k->fd >= 0)
- close (k->fd);
+ my_close (k->fd);
xfree(k);
}
{
Key *k = (Key *) xmalloc(sizeof(Key));
k->uniq = ++unit->key_uniq;
- k->fd = -1;
+ k->fd = NULL;
k->file_pos = 0;
k->next = unit->keys;
unit->keys = k;
static void populate_directory (Unit *unit, a_inode *base)
{
- DIR *d = opendir (base->nname);
+ void *d = my_opendir (base->nname);
a_inode *aino;
if (!d)
TRACE(("Populating directory, child %p, locked_children %d\n",
base->child, base->locked_children));
for (;;) {
- struct dirent *de;
+ char fn[MAX_DPATH];
+ int ok;
uae_u32 err;
/* Find next file that belongs to the Amiga fs (skipping things
like "..", "." etc. */
do {
- de = my_readdir (d, &de_space);
- } while (de && fsdb_name_invalid (de->d_name));
- if (! de)
+ ok = my_readdir (d, fn);
+ } while (ok && fsdb_name_invalid (fn));
+ if (!ok)
break;
/* This calls init_child_aino, which will notice that the parent is
being ExNext()ed, and it will increment the locked counts. */
- aino = lookup_child_aino_for_exnext (unit, base, de->d_name, &err);
+ aino = lookup_child_aino_for_exnext (unit, base, fn, &err);
}
- closedir (d);
+ my_closedir (d);
}
static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info)
uaecptr name = GET_PCK_ARG3 (packet) << 2;
a_inode *aino;
Key *k;
- int fd;
+ void *fd;
uae_u32 err;
mode_t openmode;
int aino_created = 0;
| (create ? O_CREAT : 0)
| (create == 2 ? O_TRUNC : 0));
- fd = open (aino->nname, openmode | O_BINARY, 0777);
+ fd = my_open (aino->nname, openmode | O_BINARY);
- if (fd < 0) {
+ if (fd == NULL) {
if (aino_created)
delete_aino (unit, aino);
PUT_PCK_RES1 (packet, DOS_FALSE);
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
a_inode *aino;
Key *k;
- int fd;
+ void *fd;
mode_t openmode;
int mode;
if (unit->ui.readonly)
openmode = O_RDONLY;
- fd = open (aino->nname, openmode | O_BINARY, 0777);
+ fd = my_open (aino->nname, openmode | O_BINARY);
if (fd < 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
* Try to detect a LoadSeg() */
if (k->file_pos == 0 && size >= 4) {
unsigned char buf[4];
- off_t currpos = lseek(k->fd, 0, SEEK_CUR);
- read(k->fd, buf, 4);
- lseek(k->fd, currpos, SEEK_SET);
+ off_t currpos = my_lseek (k->fd, 0, SEEK_CUR);
+ my_read (k->fd, buf, 4);
+ my_lseek (k->fd, currpos, SEEK_SET);
if (buf[0] == 0 && buf[1] == 0 && buf[2] == 3 && buf[3] == 0xF3)
possible_loadseg();
}
if (valid_address (addr, size)) {
uae_u8 *realpt;
realpt = get_real_address (addr);
- actual = read(k->fd, realpt, size);
+ actual = my_read (k->fd, realpt, size);
if (actual == 0) {
PUT_PCK_RES1 (packet, 0);
write_log ("unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size);
/* ugh this is inefficient but easy */
- old = lseek (k->fd, 0, SEEK_CUR);
- filesize = lseek (k->fd, 0, SEEK_END);
- lseek (k->fd, old, SEEK_SET);
+ old = my_lseek (k->fd, 0, SEEK_CUR);
+ filesize = my_lseek (k->fd, 0, SEEK_END);
+ my_lseek (k->fd, old, SEEK_SET);
if (size > filesize)
size = filesize;
PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
return;
}
- actual = read(k->fd, buf, size);
+ actual = my_read (k->fd, buf, size);
if (actual < 0) {
PUT_PCK_RES1 (packet, 0);
for (i = 0; i < size; i++)
buf[i] = get_byte(addr + i);
- PUT_PCK_RES1 (packet, write(k->fd, buf, size));
+ PUT_PCK_RES1 (packet, my_write (k->fd, buf, size));
if (GET_PCK_RES1 (packet) != size)
PUT_PCK_RES2 (packet, dos_errno ());
if (GET_PCK_RES1 (packet) >= 0)
TRACE(("ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode));
- old = lseek (k->fd, 0, SEEK_CUR);
+ old = my_lseek (k->fd, 0, SEEK_CUR);
{
uae_s32 temppos;
- long filesize = lseek (k->fd, 0, SEEK_END);
- lseek (k->fd, old, SEEK_SET);
+ long filesize = my_lseek (k->fd, 0, SEEK_END);
+ my_lseek (k->fd, old, SEEK_SET);
if (whence == SEEK_CUR) temppos = old + pos;
if (whence == SEEK_SET) temppos = pos;
return;
}
}
- res = lseek (k->fd, pos, whence);
+ res = my_lseek (k->fd, pos, whence);
if (-1 == res) {
PUT_PCK_RES1 (packet, res);
return;
}
- if (mkdir (aino->nname, 0777) == -1) {
+ if (my_mkdir (aino->nname) == -1) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, dos_errno());
return;
}
/* Write one then truncate: that should give the right size in all cases. */
- offset = lseek (k->fd, offset, whence);
- write (k->fd, /* whatever */(char *)&k1, 1);
+ offset = my_lseek (k->fd, offset, whence);
+ my_write (k->fd, /* whatever */(char *)&k1, 1);
if (k->file_pos > offset)
k->file_pos = offset;
- lseek (k->fd, k->file_pos, SEEK_SET);
+ my_lseek (k->fd, k->file_pos, SEEK_SET);
/* Brian: no bug here; the file _must_ be one byte too large after writing
The write is supposed to guarantee that the file can't be smaller than
the requested size, the truncate guarantees that it can't be larger.
If we were to write one byte earlier we'd clobber file data. */
- if (truncate (k->aino->nname, offset) == -1) {
+ if (my_truncate (k->aino->nname, offset) == -1) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, dos_errno ());
return;
if (a->dir) {
/* This should take care of removing the fsdb if no files remain. */
fsdb_dir_writeback (a);
- if (rmdir (a->nname) == -1) {
+ if (my_rmdir (a->nname) == -1) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, dos_errno());
return;
}
} else {
- if (unlink (a->nname) == -1) {
+ if (my_unlink (a->nname) == -1) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, dos_errno());
return;
knext = k1->next;
if (k1->aino == a1 && k1->fd >= 0) {
wehavekeys++;
- close (k1->fd);
+ my_close (k1->fd);
write_log ("handle %d freed\n", k1->fd);
}
}
mode |= O_BINARY;
if (ret == -1) {
/* rename still failed, restore fd */
- k1->fd = open (a1->nname, mode, 0777);
+ k1->fd = my_open (a1->nname, mode);
write_log ("restoring old handle '%s' %d\n", a1->nname, k1->dosmode);
} else {
/* transfer fd to new name */
k1->aino = a2;
- k1->fd = open (a2->nname, mode, 0777);
+ k1->fd = my_open (a2->nname, mode);
write_log ("restoring new handle '%s' %d\n", a2->nname, k1->dosmode);
}
if (k1->fd < 0) {
write_log ("relocking failed '%s' -> '%s'\n", a1->nname, a2->nname);
free_key (unit, k1);
} else {
- lseek (k1->fd, k1->file_pos, SEEK_SET);
+ my_lseek (k1->fd, k1->file_pos, SEEK_SET);
}
}
}
char *fsdb_search_dir (const char *dirname, char *rel)
{
char *p = 0;
- struct dirent *de;
- DIR *dir = opendir (dirname);
+ int de;
+ void *dir = my_opendir (dirname);
+ char fn[MAX_DPATH];
/* This really shouldn't happen... */
if (! dir)
return 0;
- while (p == 0 && (de = readdir (dir)) != 0) {
- if (strcmp (de->d_name, rel) == 0)
+ while (p == 0 && (de = my_readdir (dir, fn)) != 0) {
+ if (strcmp (fn, rel) == 0)
p = rel;
- else if (strcasecmp (de->d_name, rel) == 0)
- p = my_strdup (de->d_name);
+ else if (strcasecmp (fn, rel) == 0)
+ p = my_strdup (fn);
}
- closedir (dir);
+ my_closedir (dir);
return p;
}
pos1 += sizeof buf;
}
fclose (f);
- truncate (n, pos1);
+ my_truncate (n, pos1);
free (n);
}
BLOCKS FROMSIZE-byte blocks, rounding away from zero.
TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
-static long
-adjust_blocks (blocks, fromsize, tosize)
- long blocks;
- int fromsize, tosize;
+static long adjust_blocks (long blocks, int fromsize, int tosize)
{
if (tosize <= 0)
abort ();
#include "sysdeps.h"
#include "od-win32/posixemu.h"
#include <windows.h>
-int
-get_fs_usage (path, disk, fsp)
- const char *path;
- const char *disk;
- struct fs_usage *fsp;
+int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
- char buf1[1024];
char buf2[1024];
DWORD SectorsPerCluster;
DWORD BytesPerSector;
DWORD NumberOfFreeClusters;
DWORD TotalNumberOfClusters;
- fname_atow (path, buf1, sizeof buf1);
-
- GetFullPathName (buf1, sizeof buf2, buf2, NULL);
+ GetFullPathName (path, sizeof buf2, buf2, NULL);
buf2[3] = 0;
extern int fsdb_set_file_attrs (a_inode *, int);
extern int fsdb_mode_representable_p (const a_inode *);
extern char *fsdb_create_unique_nname (a_inode *base, const char *);
+
+extern void *my_opendir (const char*);
+extern void my_closedir (void*);
+extern int my_readdir (void*, char*);
+
+extern int my_rmdir (const char*);
+extern int my_mkdir (const char*);
+extern int my_unlink (const char*);
+
+extern void *my_open (const char*, int);
+extern void my_close (void*);
+extern unsigned int my_lseek (void*, unsigned int, int);
+extern unsigned int my_read (void*, void*, unsigned int);
+extern unsigned int my_write (void*, void*, unsigned int);
+extern int my_truncate (const char *name, long int len);
+
+
extern void inputdevice_add_inputcode (int code);
extern void inputdevice_handle_inputcode (void);
+
+#define JSEM_KBDLAYOUT 0
+#define JSEM_JOYS 100
+#define JSEM_MICE 200
+#define JSEM_END 300
+#define JSEM_DECODEVAL(port,p) ((port) == 0 ? (p)->jport0 : (p)->jport1)
+#define JSEM_ISNUMPAD(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT)
+#define JSEM_ISCURSOR(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 1)
+#define JSEM_ISSOMEWHEREELSE(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 2)
+extern int compatibility_device[2];
+
+extern int jsem_isjoy (int port, struct uae_prefs *p);
+extern int jsem_ismouse (int port, struct uae_prefs *p);
+extern int jsem_iskbdjoy (int port, struct uae_prefs *p);
extern void check_prefs_changed_audio (void);
extern int check_prefs_changed_gfx (void);
-#define JSEM_DECODEVAL(n,v) ((n) == 0 ? (v)->jport0 : (v)->jport1)
-/* Determine how port n is configured */
-#define JSEM_ISJOY0(n,v) (JSEM_DECODEVAL(n,v) == 0)
-#define JSEM_ISJOY1(n,v) (JSEM_DECODEVAL(n,v) == 1)
-#define JSEM_ISMOUSE(n,v) (JSEM_DECODEVAL(n,v) == 2)
-#define JSEM_ISNUMPAD(n,v) (JSEM_DECODEVAL(n,v) == 3)
-#define JSEM_ISCURSOR(n,v) (JSEM_DECODEVAL(n,v) == 4)
-#define JSEM_ISSOMEWHEREELSE(n,v) (JSEM_DECODEVAL(n,v) == 5)
-extern const char *gameport_state (int n);
-
extern struct uae_prefs currprefs, changed_prefs;
extern void machdep_init (void);
if (nr <= 0) return;
ie = &events[nr];
- //write_log("'%s' %d %d\n", ie->name, state, max);
+// write_log("'%s' %d %d\n", ie->name, state, max);
if (autofire) {
if (state)
queue_input_event (nr, state, max, currprefs.input_autofire_framecnt, 1);
if (button >= ID_BUTTON_TOTAL)
return;
for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
- event = id->eventid[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 0 : 1][i]];
+ event = id->eventid[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]];
if (event <= 0)
continue;
- autofire = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 0 : 1][i]] & ID_FLAG_AUTOFIRE) ? 1 : 0;
+ autofire = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_AUTOFIRE) ? 1 : 0;
if (state < 0) {
handle_input_event (event, 1, 1, 0);
queue_input_event (event, 0, 1, 1, 0); /* send release event next frame */
}
}
+int compatibility_device[2];
static void compatibility_mode (struct uae_prefs *prefs)
{
int joy, i;
+ int used[4] = { 0, 0, 0, 0};
+ compatibility_device[0] = -1;
+ compatibility_device[1] = -1;
for (i = 0; i < MAX_INPUT_DEVICES; i++) {
memset (&mice[i], 0, sizeof (*mice));
memset (&joysticks[i], 0, sizeof (*joysticks));
}
- /* mouse compatibility code */
- if (JSEM_ISMOUSE (0, prefs)) {
- mice[0].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE1_HORIZ;
- mice[0].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE1_VERT;
- mice[0].eventid[ID_AXIS_OFFSET + 2][0] = INPUTEVENT_MOUSE1_WHEEL;
- mice[0].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
- mice[0].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
- mice[0].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
- mice[0].enabled = 1;
- } else if (JSEM_ISMOUSE (1, prefs)) {
- mice[0].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE2_HORIZ;
- mice[0].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE2_VERT;
- mice[0].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
- mice[0].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
- mice[0].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
- mice[0].enabled = 1;
- }
-
- /* joystick 2 compatibility code */
- joy = -1;
- if (JSEM_ISJOY0 (1, prefs))
- joy = 0;
- else if (JSEM_ISJOY1 (1, prefs))
- joy = 1;
+ if ((joy = jsem_ismouse (0, prefs)) >= 0) {
+ mice[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE1_HORIZ;
+ mice[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE1_VERT;
+ mice[joy].eventid[ID_AXIS_OFFSET + 2][0] = INPUTEVENT_MOUSE1_WHEEL;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 3][0] = INPUTEVENT_KEY_ALT_LEFT;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 3][1] = INPUTEVENT_KEY_CURSOR_LEFT;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 4][0] = INPUTEVENT_KEY_ALT_LEFT;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 4][1] = INPUTEVENT_KEY_CURSOR_RIGHT;
+ mice[joy].enabled = 1;
+ }
+ if ((joy = jsem_ismouse (1, prefs)) >= 0) {
+ mice[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE2_HORIZ;
+ mice[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE2_VERT;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
+ mice[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
+ mice[joy].enabled = 1;
+ }
+
+ joy = jsem_isjoy (1, prefs);
if (joy >= 0) {
joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY2_HORIZ;
joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY2_VERT;
+ used[joy] = 1;
#ifdef CD32
if (cd32_enabled) {
joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
#endif
joysticks[joy].enabled = 1;
}
- if (JSEM_ISNUMPAD (1, prefs) || JSEM_ISCURSOR (1, prefs) || JSEM_ISSOMEWHEREELSE (1, prefs)) {
- joysticks[3].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY2_HORIZ;
- joysticks[3].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY2_VERT;
- joysticks[3].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
- joysticks[3].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
- joysticks[3].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
- joysticks[3].enabled = 1;
- }
-
-
- /* joystick 1 compatibility code */
- joy = -1;
- if (JSEM_ISJOY0 (0, prefs))
- joy = 0;
- else if (JSEM_ISJOY1 (0, prefs))
- joy = 1;
+
+ joy = jsem_isjoy (0, prefs);
if (joy >= 0) {
+ used[joy] = 1;
joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY1_HORIZ;
joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY1_VERT;
joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
joysticks[joy].enabled = 1;
}
+
+ for (joy = 0; used[joy]; joy++);
if (JSEM_ISNUMPAD (0, prefs) || JSEM_ISCURSOR (0, prefs) || JSEM_ISSOMEWHEREELSE (0, prefs)) {
- joysticks[2].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY1_HORIZ;
- joysticks[2].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY1_VERT;
- joysticks[2].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
- joysticks[2].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
- joysticks[2].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
- joysticks[2].enabled = 1;
+ joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY1_HORIZ;
+ joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY1_VERT;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
+ joysticks[joy].enabled = 1;
+ used[joy] = 1;
+ compatibility_device[0] = joy;
+ }
+ for (joy = 0; used[joy]; joy++);
+ if (JSEM_ISNUMPAD (1, prefs) || JSEM_ISCURSOR (1, prefs) || JSEM_ISSOMEWHEREELSE (1, prefs)) {
+ joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY2_HORIZ;
+ joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY2_VERT;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
+ joysticks[joy].enabled = 1;
+ used[joy] = 1;
+ compatibility_device[1] = joy;
}
}
while (na->extra[j][0] >= 0) {
if (na->extra[j][0] == scancode) {
for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {/* send key release events in reverse order */
- int autofire = (na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] & ID_FLAG_AUTOFIRE) ? 1 : 0;
+ int autofire = (na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] & ID_FLAG_AUTOFIRE) ? 1 : 0;
int event = na->eventid[j][sublevdir[state == 0 ? 1 : 0][k]];
handle_input_event (event, state, 1, autofire);
//write_log ("'%s' %d ('%s') %d\n", na->name, event, events[event].name, state);
else
pause_emulation = mode;
}
+
+int jsem_isjoy (int port, struct uae_prefs *p)
+{
+ int v = JSEM_DECODEVAL (port, p);
+ if (v < JSEM_JOYS)
+ return -1;
+ v -= JSEM_JOYS;
+ if (v >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ return -1;
+ return v;
+}
+int jsem_ismouse (int port, struct uae_prefs *p)
+{
+ int v = JSEM_DECODEVAL (port, p);
+ if (v < JSEM_MICE)
+ return -1;
+ v -= JSEM_MICE;
+ if (v >= inputdevice_get_device_total (IDTYPE_MOUSE))
+ return -1;
+ return v;
+}
+int jsem_iskbdjoy (int port, struct uae_prefs *p)
+{
+ int v = JSEM_DECODEVAL (port, p);
+ if (v < JSEM_KBDLAYOUT)
+ return -1;
+ v -= JSEM_KBDLAYOUT;
+ if (v >= 3)
+ return -1;
+ return v;
+}
+
+
+
+extern int jsem_ismouse (int v, struct uae_prefs*);
+extern int jsem_iskbd (int v, struct uae_prefs*);
{
int *fake = fakestate[nr];
- nr += 2;
+ nr = compatibility_device[nr];
setjoystickstate (nr, 0, fake[1] ? -100 : (fake[2] ? 100 : 0), 100);
setjoystickstate (nr, 1, fake[0] ? -100 : (fake[3] ? 100 : 0), 100);
setjoybuttonstate (nr, 0, fake[4]);
strcpy (restart_config, cfgfile);
}
-const char *gameport_state (int nr)
-{
- if (JSEM_ISJOY0 (nr, &currprefs) && inputdevice_get_device_total (IDTYPE_JOYSTICK) > 0)
- return "using joystick #0";
- else if (JSEM_ISJOY1 (nr, &currprefs) && inputdevice_get_device_total (IDTYPE_JOYSTICK) > 1)
- return "using joystick #1";
- else if (JSEM_ISMOUSE (nr, &currprefs))
- return "using mouse";
- else if (JSEM_ISNUMPAD (nr, &currprefs))
- return "using numeric pad as joystick";
- else if (JSEM_ISCURSOR (nr, &currprefs))
- return "using cursor keys as joystick";
- else if (JSEM_ISSOMEWHEREELSE (nr, &currprefs))
- return "using T/F/H/B/Alt as joystick";
-
- return "not connected";
-}
-
#ifndef DONT_PARSE_CMDLINE
void usage (void)
* Copyright 2002 - 2004 Toni Wilen
*/
-#define _WIN32_WINNT 0x501 /* make RAWINPUT available */
+#define _WIN32_WINNT 0x501 /* enable RAWINPUT support */
#define DI_DEBUG
//#define DI_DEBUG2
static int dd_inited, mouse_inited, keyboard_inited, joystick_inited;
static int stopoutput;
static HANDLE kbhandle = INVALID_HANDLE_VALUE;
-static int oldleds, oldusedleds, newleds;
+static int oldleds, oldusedleds, newleds, usbledmode, oldusbleds;
static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber;
static int normalkb, superkb, rawkb;
num_mouse++;
did->name = my_strdup ("Windows mouse");
did->sortname = my_strdup ("Windows mouse");
- did->buttons = 3;
- did->axles = 3;
+ did->buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
+ if (did->buttons > 5)
+ did->buttons = 5; /* no non-direcinput support for >5 buttons */
+ if (did->buttons > 3 && !os_winnt)
+ did->buttons = 3; /* Windows 98/ME support max 3 non-DI buttons */
+ did->axles = GetSystemMetrics (SM_MOUSEWHEELPRESENT) ? 3 : 2;
did->axistype[0] = 1;
did->axissort[0] = 0;
did->axisname[0] = my_strdup ("X-Axis");
did->axistype[1] = 1;
did->axissort[1] = 1;
did->axisname[1] = my_strdup ("Y-Axis");
- did->axistype[2] = 1;
- did->axissort[2] = 2;
- did->axisname[2] = my_strdup ("Wheel");
- for (j = 0; j < 3; j++) {
+ if (did->axles > 2) {
+ did->axistype[2] = 1;
+ did->axissort[2] = 2;
+ did->axisname[2] = my_strdup ("Wheel");
+ }
+ for (j = 0; j < did->buttons; j++) {
did->buttonsort[j] = j;
sprintf (tmp, "Button %d", j + 1);
did->buttonname[j] = my_strdup (tmp);
{
int i, j;
struct didata ddtmp;
+
+ /* rename duplicate names */
+ for (i = 0; i < num; i++) {
+ for (j = i + 1; j < num; j++) {
+ if (!strcmp (dd[i].name, dd[j].name)) {
+ int cnt = 1;
+ char tmp[MAX_DPATH], tmp2[MAX_DPATH];
+ strcpy (tmp2, dd[i].name);
+ for (j = i; j < num; j++) {
+ if (!strcmp (tmp2, dd[j].name)) {
+ sprintf (tmp, "%s [%d]", dd[j].name, cnt++);
+ xfree (dd[j].name);
+ dd[j].name = my_strdup (tmp);
+ }
+ }
+ break;
+ }
+ }
+ }
+
for (i = 0; i < num; i++) {
dd[i].type = type;
for (j = i + 1; j < num; j++) {
}
}
}
- j = 1;
- for (i = 0; i < num; i++) {
- if (dd[i].rawinput) {
- char *ntmp = dd[i].name;
- char tmp[200];
- sprintf (tmp, "%s %d", ntmp, j);
- dd[i].name = my_strdup (tmp);
- free (ntmp);
- j++;
- }
- }
}
static void sortobjects (struct didata *did, int *mappings, int *sort, char **names, int *types, int num)
static uae_u32 get_leds (void)
{
uae_u32 led = 0;
- if (os_winnt && kbhandle != INVALID_HANDLE_VALUE) {
+
+ GetKeyboardState (ledkeystate);
+ if (ledkeystate[VK_NUMLOCK] & 1)
+ led |= KBLED_NUMLOCK;
+ if (ledkeystate[VK_CAPITAL] & 1)
+ led |= KBLED_CAPSLOCK;
+ if (ledkeystate[VK_SCROLL] & 1)
+ led |= KBLED_SCROLLLOCK;
+
+ if (usbledmode && os_winnt) {
+ oldusbleds = led;
+ } else if (!usbledmode && os_winnt && kbhandle != INVALID_HANDLE_VALUE) {
#ifdef WINDDK
KEYBOARD_INDICATOR_PARAMETERS InputBuffer;
KEYBOARD_INDICATOR_PARAMETERS OutputBuffer;
if (!DeviceIoControl(kbhandle, IOCTL_KEYBOARD_QUERY_INDICATORS,
&InputBuffer, DataLength, &OutputBuffer, DataLength, &ReturnedLength, NULL))
return 0;
+ led = 0;
if (OutputBuffer.LedFlags & KEYBOARD_NUM_LOCK_ON) led |= KBLED_NUMLOCK;
if (OutputBuffer.LedFlags & KEYBOARD_CAPS_LOCK_ON) led |= KBLED_CAPSLOCK;
if (OutputBuffer.LedFlags & KEYBOARD_SCROLL_LOCK_ON) led |= KBLED_SCROLLLOCK;
#endif
- } else if (!os_winnt) {
- GetKeyboardState (ledkeystate);
- if (ledkeystate[VK_NUMLOCK] & 1) led |= KBLED_NUMLOCK;
- if (ledkeystate[VK_CAPITAL] & 1) led |= KBLED_CAPSLOCK;
- if (ledkeystate[VK_SCROLL] & 1) led |= KBLED_SCROLLLOCK;
}
return led;
}
static void set_leds (uae_u32 led)
{
- if (os_winnt && kbhandle != INVALID_HANDLE_VALUE) {
+ if (os_winnt && usbledmode) {
+ if((oldusbleds & KBLED_NUMLOCK) != (led & KBLED_NUMLOCK)) {
+ keybd_event (VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event (VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+ }
+ if((oldusbleds & KBLED_CAPSLOCK) != (led & KBLED_CAPSLOCK)) {
+ keybd_event (VK_CAPITAL, 0, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event (VK_CAPITAL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+ }
+ if((oldusbleds & KBLED_SCROLLLOCK) != (led & KBLED_SCROLLLOCK)) {
+ keybd_event (VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event (VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+ }
+ oldusbleds = led;
+ } else if (os_winnt && kbhandle != INVALID_HANDLE_VALUE) {
#ifdef WINDDK
KEYBOARD_INDICATOR_PARAMETERS InputBuffer;
ULONG DataLength = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
ULONG ReturnedLength;
memset (&InputBuffer, 0, sizeof (InputBuffer));
- if (led & KBLED_NUMLOCK) InputBuffer.LedFlags |= KEYBOARD_NUM_LOCK_ON;
- if (led & KBLED_CAPSLOCK) InputBuffer.LedFlags |= KEYBOARD_CAPS_LOCK_ON;
- if (led & KBLED_SCROLLLOCK) InputBuffer.LedFlags |= KEYBOARD_SCROLL_LOCK_ON;
+ if (led & KBLED_NUMLOCK)
+ InputBuffer.LedFlags |= KEYBOARD_NUM_LOCK_ON;
+ if (led & KBLED_CAPSLOCK)
+ InputBuffer.LedFlags |= KEYBOARD_CAPS_LOCK_ON;
+ if (led & KBLED_SCROLLLOCK)
+ InputBuffer.LedFlags |= KEYBOARD_SCROLL_LOCK_ON;
if (!DeviceIoControl(kbhandle, IOCTL_KEYBOARD_SET_INDICATORS,
&InputBuffer, DataLength, NULL, 0, &ReturnedLength, NULL))
write_log ("kbleds: DeviceIoControl() failed %d\n", GetLastError());
for (i = 0; i < 3; i++) {
if (currprefs.keyboard_leds[i] == num + 1) {
newleds &= ~(1 << i);
- if (state) newleds |= (1 << i);
+ if (state)
+ newleds |= (1 << i);
}
}
}
LPDIRECTINPUTDEVICE8 lpdi = di_keyboard[num].lpdi;
unacquire (lpdi, "keyboard");
- setcoop (lpdi, mode, "keyboard");
- kb_do_refresh = ~0;
-#ifdef WINDDK
if (currprefs.keyboard_leds_in_use) {
+#ifdef WINDDK
if (os_winnt) {
if (DefineDosDevice (DDD_RAW_TARGET_PATH, "Kbd","\\Device\\KeyboardClass0")) {
kbhandle = CreateFile("\\\\.\\Kbd", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
- if (kbhandle == INVALID_HANDLE_VALUE)
+ if (kbhandle == INVALID_HANDLE_VALUE) {
write_log ("kbled: CreateFile failed, error %d\n", GetLastError());
+ usbledmode = 1;
+ }
} else {
+ usbledmode = 1;
write_log ("kbled: DefineDosDevice failed, error %d\n", GetLastError());
}
}
+#else
+ usbledmode = 1;
+#endif
oldleds = get_leds ();
if (oldusedleds < 0)
oldusedleds = newleds = oldleds;
set_leds (oldusedleds);
}
-#endif
+
+ setcoop (lpdi, mode, "keyboard");
+ kb_do_refresh = ~0;
di_keyboard[num].acquired = -1;
if (acquire (lpdi, "keyboard")) {
if (di_keyboard[num].superdevice)
}
release_keys ();
-#ifdef WINDDK
if (currprefs.keyboard_leds_in_use && oldusedleds >= 0) {
- set_leds (oldleds);
+ if (!usbledmode)
+ set_leds (oldleds);
oldusedleds = oldleds;
+#ifdef WINDDK
if (kbhandle != INVALID_HANDLE_VALUE) {
CloseHandle(kbhandle);
DefineDosDevice (DDD_REMOVE_DEFINITION, "Kbd", NULL);
kbhandle = INVALID_HANDLE_VALUE;
}
- }
#endif
+ usbledmode = 0;
+ }
}
struct inputdevice_functions inputdevicefunc_keyboard = {
return di_joystick[joy].name;
}
-static int isjoy (int pcport, int amigaport)
-{
- if (pcport == 0)
- return JSEM_ISJOY0 (amigaport, &currprefs);
- else
- return JSEM_ISJOY1 (amigaport, &currprefs);
-}
-
static void read_joystick (void)
{
DIDEVICEOBJECTDATA didod[DI_BUFFER];
if (!lpdi)
continue;
if (currprefs.input_selected_setting == 0) {
+ if (jsem_isjoy (0, &currprefs) != i && jsem_isjoy (1, &currprefs) != i)
+ continue;
+#if 0
if (i >= 2)
break;
if (isjoy (i, 0)) {
continue;
} else
continue;
+#endif
}
elements = DI_BUFFER;
hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof (DIDEVICEOBJECTDATA), didod, &elements, 0);
uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+ if (port == 0) { /* map back and forward to ALT+LCUR and ALT+RCUR */
+ uid[i].eventid[ID_BUTTON_OFFSET + 3][0] = INPUTEVENT_KEY_ALT_LEFT;
+ uid[i].eventid[ID_BUTTON_OFFSET + 3][1] = INPUTEVENT_KEY_CURSOR_LEFT;
+ uid[i].eventid[ID_BUTTON_OFFSET + 4][0] = INPUTEVENT_KEY_ALT_LEFT;
+ uid[i].eventid[ID_BUTTON_OFFSET + 4][1] = INPUTEVENT_KEY_CURSOR_RIGHT;
+ }
}
uid[0].enabled = 1;
}
if( ddrval == DD_OK ) {
result = 1;
} else {
- if (ddrval != 0x887601cc)
+ if (ddrval == DDERR_SURFACELOST) {
+ static int recurse;
+ IDirectDrawSurface7_Restore (DirectDrawState.primary.surface);
+ if (!recurse) {
+ recurse++;
+ DirectDraw_Flip (wait);
+ recurse--;
+ }
+ } else
write_log("FLIP: DirectDrawSurface_Flip() failed with %s\n", DXError (ddrval));
}
return result;
for (;;) {
char *p = build_nname (base->nname, tmp);
- if (access (p, R_OK) < 0 && errno == ENOENT) {
+ if (!fsdb_exists (p)) {
write_log ("unique name: %s\n", p);
return p;
}
- free (p);
-
+ xfree (p);
/* tmpnam isn't reentrant and I don't really want to hack configure
* right now to see whether tmpnam_r is available... */
for (i = 0; i < 8; i++) {
}
}
}
+
+int my_mkdir (const char *name)
+{
+ return CreateDirectory (name, NULL) == 0 ? -1 : 0;
+}
+
+int my_rmdir (const char *name)
+{
+ return RemoveDirectory (name) == 0 ? -1 : 0;
+}
+
+int my_unlink (const char *name)
+{
+ return DeleteFile (name) == 0 ? -1 : 0;
+}
+
+struct my_opendirs {
+ HANDLE *h;
+ WIN32_FIND_DATA fd;
+ int first;
+};
+
+void *my_opendir (const char *name)
+{
+ struct my_opendirs *mod;
+ char tmp[MAX_DPATH];
+
+ strcpy (tmp, name);
+ strcat (tmp, "\\*.*");
+ mod = xmalloc (sizeof (struct my_opendirs));
+ if (!mod)
+ return NULL;
+ mod->h = FindFirstFile(tmp, &mod->fd);
+ if (mod->h == INVALID_HANDLE_VALUE) {
+ xfree (mod);
+ return NULL;
+ }
+ mod->first = 1;
+ return mod;
+}
+
+void my_closedir (void *d)
+{
+ struct my_opendirs *mod = d;
+ FindClose (mod->h);
+ xfree (mod);
+}
+
+int my_readdir (void *d, char *name)
+{
+ struct my_opendirs *mod = d;
+ if (mod->first) {
+ strcpy (name, mod->fd.cFileName);
+ mod->first = 0;
+ return 1;
+ }
+ if (!FindNextFile (mod->h, &mod->fd))
+ return 0;
+ strcpy (name, mod->fd.cFileName);
+ return 1;
+}
+
+struct my_opens {
+ HANDLE *h;
+};
+
+void my_close (void *d)
+{
+ struct my_opens *mos = d;
+ CloseHandle (mos->h);
+ xfree (mos);
+}
+
+unsigned int my_lseek (void *d, unsigned int offset, int whence)
+{
+ struct my_opens *mos = d;
+ return SetFilePointer (mos->h, offset, NULL,
+ whence == SEEK_SET ? FILE_BEGIN : (whence == SEEK_END ? FILE_END : FILE_CURRENT));
+}
+
+unsigned int my_read (void *d, void *b, unsigned int size)
+{
+ struct my_opens *mos = d;
+ DWORD read = 0;
+ ReadFile (mos->h, b, size, &read, NULL);
+ return read;
+}
+
+unsigned int my_write (void *d, void *b, unsigned int size)
+{
+ struct my_opens *mos = d;
+ DWORD written = 0;
+ WriteFile (mos->h, b, size, &written, NULL);
+ return written;
+}
+
+void *my_open (const char *name, int flags)
+{
+ struct my_opens *mos;
+ HANDLE h;
+ DWORD DesiredAccess = GENERIC_READ | GENERIC_WRITE;
+ DWORD ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ DWORD CreationDisposition = OPEN_EXISTING;
+ DWORD FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
+
+ mos = xmalloc (sizeof (struct my_opens));
+ if (!mos)
+ return NULL;
+ if (flags & O_TRUNC)
+ CreationDisposition = TRUNCATE_EXISTING;
+ if (flags & O_CREAT)
+ CreationDisposition = CREATE_ALWAYS;
+ if (flags & O_WRONLY)
+ DesiredAccess = GENERIC_WRITE;
+ if (flags & O_RDONLY)
+ DesiredAccess = GENERIC_READ;
+ if (flags & O_RDWR)
+ DesiredAccess = GENERIC_READ | GENERIC_WRITE;
+ h = CreateFile (name, DesiredAccess, ShareMode, NULL, CreationDisposition, FlagsAndAttributes, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ xfree (mos);
+ return 0;
+ }
+ mos->h = h;
+ return mos;
+}
+
+int my_truncate (const char *name, long int len)
+{
+ HANDLE hFile;
+ BOOL bResult = FALSE;
+ int result = -1;
+
+ if ((hFile = CreateFile (name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
+ {
+ if (SetFilePointer (hFile, len, NULL, FILE_BEGIN) == (DWORD)len) {
+ if (SetEndOfFile (hFile) == TRUE)
+ result = 0;
+ } else {
+ write_log ("SetFilePointer() failure for %s to posn %d\n", name, len);
+ }
+ CloseHandle( hFile );
+ } else {
+ write_log ("CreateFile() failed to open %s\n", name);
+ }
+ return result;
+}
+
\ No newline at end of file
screenshot (endpressed() ? 1 : 0);
break;
case DIK_PAUSE:
+ write_log("DIK_PAUSE\n");
if (endpressed ())
code = AKS_WARP;
else
break;
case DIK_PRIOR:
#ifdef ACTION_REPLAY
- code = AKS_FREEZEBUTTON;
+ if (armodel)
+ code = AKS_FREEZEBUTTON;
#endif
break;
case DIK_NEXT:
#define secs_per_day ( 24 * 60 * 60 )
#define diff ( (8 * 365 + 2) * secs_per_day )
-void get_time(time_t t, long* days, long* mins, long* ticks)
+static void get_time(time_t t, long* days, long* mins, long* ticks)
{
/* time_t is secs since 1-1-1970 */
/* days since 1-1-1978 */
*ticks = t * 50;
}
-/* stdioemu, posixemu, mallocemu, and various file system helper routines */
-static DWORD lasterror;
-
-static int isillegal (unsigned char *str)
-{
- int result = 0;
- unsigned char a = *str, b = str[1], c = str[2];
-
- if (a >= 'a' && a <= 'z')
- a &= ~' ';
- if (b >= 'a' && b <= 'z')
- b &= ~' ';
- if (c >= 'a' && c <= 'z')
- c &= ~' ';
-
- result = ( (a == 'A' && b == 'U' && c == 'X') ||
- (a == 'C' && b == 'O' && c == 'N') ||
- (a == 'P' && b == 'R' && c == 'N') ||
- (a == 'N' && b == 'U' && c == 'L') );
-
- return result;
-}
-
-static int checkspace (char *str, char s, char d)
-{
- char *ptr = str;
-
- while (*ptr && *ptr == s)
- ptr++;
-
- if (!*ptr || *ptr == '/' || *ptr == '\\') {
- while (str < ptr)
- *(str++) = d;
- return 0;
- }
- return 1;
-}
-
-/* This is sick and incomplete... in the meantime, I have discovered six new illegal file name formats
- * M$ sucks! */
-void fname_atow (const char *src, char *dst, int size)
-{
- char *lastslash = dst, *strt = dst, *posn = NULL, *temp = NULL;
- int i, j;
-
- temp = xmalloc( size );
-
- while (size-- > 0) {
- if (!(*dst = *src++))
- break;
-
- if (*dst == '~' || *dst == '|' || *dst == '*' || *dst == '?') {
- if (size > 2) {
- sprintf (dst, "~%02x", *dst);
- size -= 2;
- dst += 2;
- }
- } else if (*dst == '/') {
- if (checkspace (lastslash, ' ', (char)0xa0) && (dst - lastslash == 3 || (dst - lastslash > 3 && lastslash[3] == '.')) && isillegal (lastslash)) {
- i = dst - lastslash - 3;
- dst++;
- for (j = i + 1; j--; dst--)
- *dst = dst[-1];
- *(dst++) = (char)0xa0;
- dst += i;
- size--;
- } else if (*lastslash == '.' && (dst - lastslash == 1 || (lastslash[1] == '.' && dst - lastslash == 2)) && size) {
- *(dst++) = (char)0xa0;
- size--;
- }
- *dst = '\\';
- lastslash = dst + 1;
- }
- dst++;
- }
-
- if (checkspace (lastslash, ' ', (char)0xa0) && (dst - lastslash == 3 || (dst - lastslash > 3 && lastslash[3] == '.')) && isillegal (lastslash) && size > 1) {
- i = dst - lastslash - 3;
- dst++;
- for (j = i + 1; j--; dst--)
- *dst = dst[-1];
- *(dst++) = (char)0xa0;
- } else if (!strcmp (lastslash, ".") || !strcmp (lastslash, ".."))
- strcat (lastslash, "\xa0");
-
- /* Major kludge, because I can't find the problem... */
- if( ( posn = strstr( strt, "..\xA0\\" ) ) == strt && temp)
- {
- strcpy( temp, "..\\" );
- strcat( temp, strt + 4 );
- strcpy( strt, temp );
- }
-
- /* Another major kludge, for the MUI installation... */
- if( *strt == ' ' ) /* first char as a space is illegal in Windoze */
- {
- sprintf( temp, "~%02x%s", ' ', strt+1 );
- strcpy( strt, temp );
- }
-
- free (temp);
-}
-
-static int hextol (char a)
-{
- if (a >= '0' && a <= '9')
- return a - '0';
- if (a >= 'a' && a <= 'f')
- return a - 'a' + 10;
- if (a >= 'A' && a <= 'F')
- return a - 'A' + 10;
- return 2;
-}
-
-/* Win32 file name restrictions suck... */
-void fname_wtoa (unsigned char *ptr)
-{
- unsigned char *lastslash = ptr;
-
- while (*ptr) {
- if (*ptr == '~') {
- *ptr = hextol (ptr[1]) * 16 + hextol (ptr[2]);
- strcpy (ptr + 1, ptr + 3);
- } else if (*ptr == '\\') {
- if (checkspace (lastslash, ' ', (char)0xa0) && ptr - lastslash > 3 && lastslash[3] == 0xa0 && isillegal (lastslash)) {
- ptr--;
- strcpy (lastslash + 3, lastslash + 4);
- }
- *ptr = '/';
- lastslash = ptr + 1;
- }
- ptr++;
- }
-
- if (checkspace (lastslash, ' ', (char)0xa0) && ptr - lastslash > 3 && lastslash[3] == 0xa0 && isillegal (lastslash))
- strcpy (lastslash + 3, lastslash + 4);
-}
-
-#ifndef HAVE_TRUNCATE
-int truncate (const char *name, long int len)
-{
- HANDLE hFile;
- BOOL bResult = FALSE;
- int result = -1;
-
-#if 0
- char buf[1024];
-
- fname_atow(name,buf,sizeof buf);
-
- if( ( hFile = CreateFile( buf, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
- {
- if( SetFilePointer( hFile, len, NULL, FILE_BEGIN ) == (DWORD)len )
- {
- if( SetEndOfFile( hFile ) == TRUE )
- result = 0;
- }
- else
- {
- write_log( "SetFilePointer() failure for %s to posn %d\n", buf, len );
- }
- CloseHandle( hFile );
- }
- else
- {
- write_log( "CreateFile() failed to open %s\n", buf );
- }
-#else
- if( ( hFile = CreateFile( name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
- {
- if( SetFilePointer( hFile, len, NULL, FILE_BEGIN ) == (DWORD)len )
- {
- if( SetEndOfFile( hFile ) == TRUE )
- result = 0;
- }
- else
- {
- write_log( "SetFilePointer() failure for %s to posn %d\n", name, len );
- }
- CloseHandle( hFile );
- }
- else
- {
- write_log( "CreateFile() failed to open %s\n", name );
- }
-#endif
- if( result == -1 )
- lasterror = GetLastError();
- return result;
-}
-#endif
-
-DIR {
- WIN32_FIND_DATA finddata;
- HANDLE hDir;
- int getnext;
-};
-
-DIR *posixemu_opendir(const char *path)
+static DWORD getattr(const char *name, LPFILETIME lpft, size_t *size)
{
- char buf[1024];
- DIR *dir;
+ HANDLE hFind;
+ WIN32_FIND_DATA fd;
- if (!(dir = (DIR *)GlobalAlloc(GPTR,sizeof(DIR))))
- {
- lasterror = GetLastError();
- return 0;
- }
-#if 0
- fname_atow(path,buf,sizeof buf-4);
-#else
- strcpy( buf, path );
-#endif
- strcat(buf,"\\*");
-
- if ((dir->hDir = FindFirstFile(buf,&dir->finddata)) == INVALID_HANDLE_VALUE)
- {
- lasterror = GetLastError();
- GlobalFree(dir);
- return 0;
+ if ((hFind = FindFirstFile(name,&fd)) == INVALID_HANDLE_VALUE) {
+ fd.dwFileAttributes = GetFileAttributes(name);
+ return fd.dwFileAttributes;
}
- return dir;
-}
+ FindClose(hFind);
-struct dirent *posixemu_readdir(DIR *dir)
-{
- if (dir->getnext)
- {
- if (!FindNextFile(dir->hDir,&dir->finddata))
- {
- lasterror = GetLastError();
- return 0;
- }
- }
- dir->getnext = TRUE;
+ if (lpft) *lpft = fd.ftLastWriteTime;
+ if (size) *size = fd.nFileSizeLow;
- fname_wtoa(dir->finddata.cFileName);
- return (struct dirent *)dir->finddata.cFileName;
-}
-
-void posixemu_closedir(DIR *dir)
-{
- FindClose(dir->hDir);
- GlobalFree(dir);
-}
-
-static int w32fopendel(char *name, char *mode, int delflag)
-{
- HANDLE hFile;
-
- if ((hFile = CreateFile(name,
- mode[1] == '+' ? GENERIC_READ | GENERIC_WRITE : GENERIC_READ, // ouch :)
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- delflag ? FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE : FILE_ATTRIBUTE_NORMAL,
- NULL)) == INVALID_HANDLE_VALUE)
- {
- lasterror = GetLastError();
- hFile = 0;
- }
-
- return (int)hFile; /* return handle */
-}
-
-DWORD getattr(const char *name, LPFILETIME lpft, size_t *size)
-{
- HANDLE hFind;
- WIN32_FIND_DATA fd;
-
- if ((hFind = FindFirstFile(name,&fd)) == INVALID_HANDLE_VALUE)
- {
- lasterror = GetLastError();
-
- fd.dwFileAttributes = GetFileAttributes(name);
-
- return fd.dwFileAttributes;
- }
-
- FindClose(hFind);
-
- if (lpft) *lpft = fd.ftLastWriteTime;
- if (size) *size = fd.nFileSizeLow;
-
- return fd.dwFileAttributes;
+ return fd.dwFileAttributes;
}
int isspecialdrive(const char *name)
DWORD attr;
FILETIME ft, lft;
- if ((attr = getattr(name,&ft,(size_t*)&statbuf->st_size)) == (DWORD)~0)
- {
- lasterror = GetLastError();
+ if ((attr = getattr(name,&ft,(size_t*)&statbuf->st_size)) == (DWORD)~0) {
return -1;
- }
- else
- {
+ } else {
statbuf->st_mode = (attr & FILE_ATTRIBUTE_READONLY) ? FILEFLAG_READ : FILEFLAG_READ | FILEFLAG_WRITE;
if (attr & FILE_ATTRIBUTE_ARCHIVE) statbuf->st_mode |= FILEFLAG_ARCHIVE;
if (attr & FILE_ATTRIBUTE_DIRECTORY) statbuf->st_mode |= FILEFLAG_DIR;
if (!(mode & FILEFLAG_WRITE)) attr |= FILE_ATTRIBUTE_READONLY;
if (mode & FILEFLAG_ARCHIVE) attr |= FILE_ATTRIBUTE_ARCHIVE;
if (SetFileAttributes(name,attr)) return 1;
- lasterror = GetLastError();
return -1;
}
-void tmToSystemTime( struct tm *tmtime, LPSYSTEMTIME systime )
+static void tmToSystemTime( struct tm *tmtime, LPSYSTEMTIME systime )
{
if( tmtime == NULL )
{
FILETIME LocalFileTime, FileTime;
HANDLE hFile;
int success;
- if ((hFile = CreateFile(name, GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)) == INVALID_HANDLE_VALUE)
- {
- lasterror = GetLastError();
+ if ((hFile = CreateFile(name, GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)) == INVALID_HANDLE_VALUE) {
return 0;
}
FileTime = LocalFileTime;
}
- if (!(success = SetFileTime(hFile,&FileTime,&FileTime,&FileTime))) lasterror = GetLastError();
+ success = SetFileTime(hFile,&FileTime,&FileTime,&FileTime);
CloseHandle(hFile);
return success;
return result;
}
-#if 1
/* pthread Win32 emulation */
void sem_init (HANDLE * event, int manual_reset, int initial_state)
{
return result;
}
-#endif
-
void set_thread_priority (int pri)
{
}
#define IDC_PRINTERLIST 1025
#define IDC_CHIPMEM 1026
#define IDC_CREATELOGFILE 1026
+#define IDC_PORT0_JOYS 1026
#define IDC_FASTMEM 1027
#define IDC_SHOWLEDS 1027
+#define IDC_PORT1_JOYS 1027
#define IDC_SLOWMEM 1030
#define IDC_PARALLEL 1033
#define IDC_JULIAN 1040
#define IDC_SAVEIMAGE2 1287
#define IDC_PROWIZARD 1288
#define IDC_SAVEIMAGE3 1288
-#define IDC_PORT0_JOY0 1300
-#define IDC_PORT0_JOY1 1301
-#define IDC_PORT0_MOUSE 1302
+#define IDC_PORT0_JOYSC 1302
#define IDC_PORT0_KBDA 1303
#define IDC_PORT0_KBDB 1304
#define IDC_PORT0_KBDC 1305
-#define IDC_PORT1_JOY0 1306
-#define IDC_PORT1_JOY1 1307
-#define IDC_PORT1_MOUSE 1308
+#define IDC_PORT1_JOYSC 1308
#define IDC_PORT1_KBDA 1309
#define IDC_PORT1_KBDB 1310
#define IDC_PORT1_KBDC 1311
#define IDC_DF1QQ 1680
#define IDC_CONFIGAUTO 1682
#define IDC_DF0TEXTQ 1683
-#define IDC_CONFIGAUTO2 1683
#define IDC_CONFIGNOLINK 1683
#define IDC_DF0WPQ 1684
#define IDC_EJECT0Q 1685
WS_TABSTOP,146,206,48,10
END
-IDD_PORTS DIALOGEX 0, 0, 300, 202
+IDD_PORTS DIALOGEX 0, 0, 300, 194
STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
- GROUPBOX "Serial and Parallel",IDC_SERPARFRAME,7,3,284,45
+ GROUPBOX "Serial and Parallel",IDC_SERPARFRAME,4,2,291,46
RTEXT "Serial:",IDC_STATIC,20,15,25,15,SS_CENTERIMAGE
COMBOBOX IDC_SERIAL,50,15,95,65,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
RTEXT "Printer:",IDC_STATIC,155,15,25,15,SS_CENTERIMAGE
COMBOBOX IDC_PRINTERLIST,185,15,95,134,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
- GROUPBOX "MIDI",IDC_MIDIFRAME,7,51,284,36
+ PUSHBUTTON "Flush print job",IDC_FLUSHPRINTER,199,31,58,12
+ GROUPBOX "MIDI",IDC_MIDIFRAME,4,50,292,36
RTEXT "Out:",IDC_MIDI,10,64,34,15,SS_CENTERIMAGE
COMBOBOX IDC_MIDIOUTLIST,50,64,95,130,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
RTEXT "In:",IDC_MIDI2,150,64,29,15,SS_CENTERIMAGE
COMBOBOX IDC_MIDIINLIST,185,64,95,134,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Amiga Mouse Port 0",IDC_PORT0,7,92,116,106
- CONTROL "PC Joystick 0",IDC_PORT0_JOY0,"Button",
- BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,20,104,90,10
- CONTROL "PC Joystick 1",IDC_PORT0_JOY1,"Button",
- BS_AUTORADIOBUTTON | WS_TABSTOP,20,118,90,10
- CONTROL "PC Mouse",IDC_PORT0_MOUSE,"Button",BS_AUTORADIOBUTTON |
- WS_TABSTOP,20,133,90,11
+ GROUPBOX "Amiga Mouse/Joystick Port 0",IDC_PORT0,4,92,141,78
+ CONTROL "",IDC_PORT0_JOYSC,"Button",BS_AUTORADIOBUTTON |
+ WS_GROUP | WS_TABSTOP,10,107,9,11
CONTROL "Keyboard Layout ""A"" []Numeric keypad, 0 and 5 = fire",
IDC_PORT0_KBDA,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 20,149,90,10
+ 10,127,90,10
CONTROL "Keyboard Layout ""B"" []Cursor keys, right CTRL = fire",
IDC_PORT0_KBDB,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 20,164,90,10
+ 10,142,90,10
CONTROL "Keyboard Layout ""C"" []T = up, B = down, F = left, H = right, left ALT = fire",
IDC_PORT0_KBDC,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 20,179,90,10
- GROUPBOX "Amiga Mouse Port 1",IDC_PORT1,175,92,115,105
- CONTROL "PC Joystick 0",IDC_PORT1_JOY0,"Button",
- BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,190,104,90,10
- CONTROL "PC Joystick 1",IDC_PORT1_JOY1,"Button",
- BS_AUTORADIOBUTTON | WS_TABSTOP,190,118,90,10
- CONTROL "PC Mouse",IDC_PORT1_MOUSE,"Button",BS_AUTORADIOBUTTON |
- WS_TABSTOP,190,133,90,11
+ 10,156,90,10
+ COMBOBOX IDC_PORT0_JOYS,23,106,117,130,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Amiga Joystick/Mouse Port 1",IDC_PORT1,150,92,146,78
+ CONTROL "",IDC_PORT1_JOYSC,"Button",BS_AUTORADIOBUTTON |
+ WS_GROUP | WS_TABSTOP,155,107,9,11
CONTROL "Keyboard Layout ""A"" []Numeric keypad, 0 and 5 = fire",
IDC_PORT1_KBDA,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 190,149,90,10
+ 155,127,90,10
CONTROL "Keyboard Layout ""B"" []Cursor keys, right CTRL = fire",
IDC_PORT1_KBDB,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 190,164,90,10
+ 155,142,90,10
CONTROL "Keyboard Layout ""C"" []T = up, B = down, F = left, H = right, left ALT = fire",
IDC_PORT1_KBDC,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
- 190,179,90,10
- PUSHBUTTON "<-swap->",IDC_SWAP,130,132,40,14
- PUSHBUTTON "Flush print job",IDC_FLUSHPRINTER,199,31,58,12
+ 155,156,90,10
+ COMBOBOX IDC_PORT1_JOYS,168,106,123,130,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Swap ports",IDC_SWAP,119,176,54,14
END
IDD_CONTRIBUTORS DIALOGEX 0, 0, 411, 242
SS_CENTERIMAGE
GROUPBOX "Compatibility vs required CPU power ",
IDC_QUICKSTART_COMPA,3,56,294,33
+ GROUPBOX "Mode",IDC_STATIC,190,211,107,27,BS_LEFT
END
#include <stdarg.h>
#include <signal.h>
+#define _WIN32_WINNT 0x501 /* XButtons */
+
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#endif
}
+static void handleXbutton (WPARAM wParam, int updown)
+{
+ int b = GET_XBUTTON_WPARAM (wParam);
+ int num = (b & XBUTTON1) ? 3 : (b & XBUTTON2) ? 4 : -1;
+ if (num >= 0)
+ setmousebuttonstate (dinput_winmouse(), num, updown);
+}
+
static long FAR PASCAL AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int ignorenextactivateapp;
if (hMainWnd == 0)
hMainWnd = hWnd;
- switch( message )
+ switch (message)
{
case WM_SIZE:
{
winuae_inactive (hWnd, minimized);
}
return 0;
+ } else if (LOWORD (wParam) == WA_INACTIVE) {
+ minimized = 1;
+ if (ignorenextactivateapp > 0)
+ ignorenextactivateapp--;
+ } else if (!minimized && LOWORD (wParam) != WA_INACTIVE) {
+ winuae_active (hWnd, minimized);
+ if (ignorenextactivateapp > 0)
+ ignorenextactivateapp--;
+ return 0;
}
+ break;
case WM_ACTIVATEAPP:
if (!wParam) {
+ if (gui_active && isfullscreen())
+ exit_gui (0);
setmouseactive (0);
} else {
if (!ignorenextactivateapp && isfullscreen () && is3dmode ()) {
WIN32GFX_DisplayChangeRequested ();
- ignorenextactivateapp = 2;
+ ignorenextactivateapp = 3;
}
if (gui_active && isfullscreen())
exit_gui (0);
if (dinput_winmouse () > 0)
setmousebuttonstate (dinput_winmouse(), 2, 1);
return 0;
+ case WM_XBUTTONUP:
+ if (dinput_winmouse () > 0) {
+ handleXbutton (wParam, 0);
+ return TRUE;
+ }
+ return 0;
+ case WM_XBUTTONDOWN:
+ case WM_XBUTTONDBLCLK:
+ if (dinput_winmouse () > 0) {
+ handleXbutton (wParam, 1);
+ return TRUE;
+ }
+ return 0;
case WM_MOUSEWHEEL:
if (dinput_winmouse () > 0)
setmousestate (dinput_winmouse(), 2, ((short)HIWORD(wParam)), 0);
extern int manual_palette_refresh_needed;
extern int mouseactive, focus;
#define WINUAEBETA 1
-#define WINUAEBETASTR " Beta 10b"
+#define WINUAEBETASTR " Beta 11"
extern void my_kbd_handler (int, int, int);
extern void clearallkeys(void);
return 0;
}
-
systray (hMainWnd, FALSE);
if (hMainWnd != hAmigaWnd) {
ShowWindow (hMainWnd, SW_SHOWNORMAL);
HARDDISK_ID = -1, PORTS_ID = -1, INPUT_ID = -1, MISC1_ID = -1, MISC2_ID = -1, AVIOUTPUT_ID = -1,
PATHS_ID = -1, QUICKSTART_ID = -1, ABOUT_ID = -1;
static HWND pages[MAX_C_PAGES];
-static HWND guiDlg, ToolTipHWND;
+static HWND guiDlg, panelDlg, ToolTipHWND;
void exit_gui (int ok)
{
static char comports[MAX_SERIALS][8];
static int joy0idc[] = {
- IDC_PORT0_JOY0, IDC_PORT0_JOY1, IDC_PORT0_MOUSE, IDC_PORT0_KBDA, IDC_PORT0_KBDB, IDC_PORT0_KBDC
+ IDC_PORT0_JOYSC, IDC_PORT0_KBDA, IDC_PORT0_KBDB, IDC_PORT0_KBDC,
+ IDC_PORT0_JOYS, -1
};
static int joy1idc[] = {
- IDC_PORT1_JOY0, IDC_PORT1_JOY1, IDC_PORT1_MOUSE, IDC_PORT1_KBDA, IDC_PORT1_KBDB, IDC_PORT1_KBDC
+ IDC_PORT1_JOYSC, IDC_PORT1_KBDA, IDC_PORT1_KBDB, IDC_PORT1_KBDC,
+ IDC_PORT1_JOYS, -1
};
+static int joy0previous = -1, joy1previous = -1;
static BOOL bNoMidiIn = FALSE;
int i, v;
v = workprefs.input_selected_setting > 0 ? FALSE : TRUE;
- for( i = 0; i < 6; i++ )
- {
- EnableWindow( GetDlgItem( hDlg, joy0idc[i] ), v );
- EnableWindow( GetDlgItem( hDlg, joy1idc[i] ), v );
+ for (i = 0; joy0idc[i] >= 0; i++) {
+ EnableWindow (GetDlgItem (hDlg, joy0idc[i]), v);
+ EnableWindow (GetDlgItem (hDlg, joy1idc[i]), v);
}
EnableWindow (GetDlgItem (hDlg, IDC_SWAP), v);
#if !defined (SERIAL_PORT)
#endif
}
-static void UpdatePortRadioButtons( HWND hDlg )
+static void updatejoyport (HWND hDlg)
{
- int which_button1, which_button2;
+ int i, j, v;
- enable_for_portsdlg( hDlg );
- which_button1 = joy0idc[workprefs.jport0];
- if (CheckRadioButton (hDlg, IDC_PORT0_JOY0, IDC_PORT0_KBDC, which_button1) == 0)
- which_button1 = 0;
- else
- {
- EnableWindow( GetDlgItem( hDlg, joy1idc[workprefs.jport0] ), FALSE );
- }
- which_button2 = joy1idc[workprefs.jport1];
- if( workprefs.jport1 == workprefs.jport0 )
- {
- if( which_button2 == IDC_PORT1_KBDC )
- which_button2 = IDC_PORT1_KBDB;
- else
- which_button2++;
- }
- if (CheckRadioButton (hDlg, IDC_PORT1_JOY0, IDC_PORT1_KBDC, which_button2) == 0)
- which_button2 = 0;
- else
- {
- EnableWindow( GetDlgItem( hDlg, joy0idc[ workprefs.jport1 ] ), FALSE );
+ enable_for_portsdlg (hDlg);
+ for (i = 0; i < 2; i++) {
+ int *idcs1 = i == 0 ? joy0idc : joy1idc;
+ int *idcs2 = i == 0 ? joy1idc : joy0idc;
+ v = jsem_iskbdjoy (i, &workprefs);
+ if (v < 0)
+ v = 0;
+ else
+ v++;
+ CheckRadioButton (hDlg, idcs1[0], idcs1[3], idcs1[v]);
+ for (j = 1; j < 4; j++)
+ EnableWindow (GetDlgItem (hDlg, idcs2[j]), workprefs.input_selected_setting == 0 && j != v);
}
-}
+
+ if (joy0previous < 0)
+ joy0previous = inputdevice_get_device_total (IDTYPE_JOYSTICK);
+ if (joy1previous < 0)
+ joy1previous = 0;
+ for (i = 0; i < 2; i++) {
+ int idx = i == 0 ? joy0previous : joy1previous;
+ int id1 = i == 0 ? IDC_PORT0_JOYS : IDC_PORT1_JOYS;
+ int id2 = i == 0 ? IDC_PORT0_JOYSC : IDC_PORT1_JOYSC;
+ int v = i == 0 ? workprefs.jport0 : workprefs.jport1;
+ SendDlgItemMessage (hDlg, id1, CB_RESETCONTENT, 0, 0L);
+ SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)"");
+ for (j = 0; j < inputdevice_get_device_total (IDTYPE_JOYSTICK); j++)
+ SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_JOYSTICK, j));
+ for (j = 0; j < inputdevice_get_device_total (IDTYPE_MOUSE); j++)
+ SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_MOUSE, j));
+ if (v >= JSEM_MICE)
+ idx = inputdevice_get_device_total (IDTYPE_JOYSTICK) + (v - JSEM_MICE) + 1;
+ else if (v >= JSEM_JOYS)
+ idx = v - JSEM_JOYS + 1;
+ SendDlgItemMessage (hDlg, id1, CB_SETCURSEL, idx, 0);
+ }
+}
+
+static void fixjport (int *port, int v)
+{
+ int vv = *port;
+ if (vv != v)
+ return;
+ if (vv >= JSEM_JOYS && vv < JSEM_MICE) {
+ vv -= JSEM_JOYS;
+ vv++;
+ if (vv >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ vv = 0;
+ vv += JSEM_JOYS;
+ }
+ if (vv >= JSEM_MICE && vv < JSEM_END) {
+ vv -= JSEM_MICE;
+ vv++;
+ if (vv >= inputdevice_get_device_total (IDTYPE_MOUSE))
+ vv = 0;
+ vv += JSEM_MICE;
+ }
+ *port = vv;
+}
static void values_from_portsdlg (HWND hDlg)
{
- int item;
+ int item, i, j, lastside = 0, changed = 0;
char tmp[256];
- /* 0 - joystick 0
- * 1 - joystick 1
- * 2 - mouse
- * 3 - numpad
- * 4 - cursor keys
- * 5 - elsewhere
- */
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY0)) {
- workprefs.jport0 = 0;
- }
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY1)) {
- workprefs.jport0 = 1;
- }
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_MOUSE))
- workprefs.jport0 = 2;
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDA))
- workprefs.jport0 = 3;
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDB))
- workprefs.jport0 = 4;
- if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDC))
- workprefs.jport0 = 5;
-
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY0)) {
- workprefs.jport1 = 0;
- }
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY1)) {
- workprefs.jport1 = 1;
- }
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_MOUSE))
- workprefs.jport1 = 2;
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDA))
- workprefs.jport1 = 3;
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDB))
- workprefs.jport1 = 4;
- if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDC))
- workprefs.jport1 = 5;
+
+ for (i = 0; i < 2; i++) {
+ int *idcs = i == 0 ? joy0idc : joy1idc;
+ int *port = i == 0 ? &workprefs.jport0 : &workprefs.jport1;
+ int prevport = *port;
+ int *joyprev = i == 0 ? &joy0previous : &joy1previous;
+ int v = SendDlgItemMessage (hDlg, idcs[4], CB_GETCURSEL, 0, 0L);
+ if (v != CB_ERR)
+ *joyprev = v;
+ for (j = 0; j < 4; j++) {
+ if (IsDlgButtonChecked (hDlg, idcs[j])) {
+ if (j > 0) {
+ *port = JSEM_KBDLAYOUT + j - 1;
+ } else {
+ if (v != CB_ERR && v > 0) {
+ *joyprev = v;
+ v--;
+ if (v >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ *port = JSEM_MICE + v - inputdevice_get_device_total (IDTYPE_JOYSTICK);
+ else
+ *port = JSEM_JOYS + v;
+ }
+ }
+ }
+ }
+ if (*port != prevport) {
+ lastside = i;
+ changed = 1;
+ }
+ }
+ if (changed) {
+ if (lastside)
+ fixjport (&workprefs.jport0, workprefs.jport1);
+ else
+ fixjport (&workprefs.jport1, workprefs.jport0);
+ }
item = SendDlgItemMessage( hDlg, IDC_PRINTERLIST, CB_GETCURSEL, 0, 0L );
if( item != CB_ERR )
pages[PORTS_ID] = hDlg;
currentpage = PORTS_ID;
init_portsdlg( hDlg );
- enable_for_portsdlg( hDlg );
- values_to_portsdlg ( hDlg);
- UpdatePortRadioButtons( hDlg );
+ enable_for_portsdlg (hDlg);
+ values_to_portsdlg (hDlg);
+ updatejoyport (hDlg);
break;
case WM_USER:
recursive++;
- enable_for_portsdlg( hDlg );
- UpdatePortRadioButtons( hDlg );
+ enable_for_portsdlg (hDlg);
+ updatejoyport (hDlg);
recursive--;
return TRUE;
if (recursive > 0)
break;
recursive++;
- if( wParam == IDC_SWAP ) {
+ if (wParam == IDC_SWAP) {
temp = workprefs.jport0;
workprefs.jport0 = workprefs.jport1;
workprefs.jport1 = temp;
- UpdatePortRadioButtons( hDlg );
+ temp = joy0previous;
+ joy0previous = joy1previous;
+ joy1previous = temp;
+ updatejoyport (hDlg);
} else if (wParam == IDC_FLUSHPRINTER) {
if (isprinter ()) {
flushprinter ();
}
} else {
values_from_portsdlg (hDlg);
- UpdatePortRadioButtons( hDlg );
+ updatejoyport (hDlg);
}
inputdevice_updateconfig (&workprefs);
inputdevice_config_change ();
const char *help;
};
-static HWND panelhwnd;
+static int GetPanelRect (HWND hDlg, RECT *r)
+{
+ RECT rect;
+ if (!GetWindowRect (guiDlg, &rect))
+ return 0;
+ if (!GetWindowRect (hDlg, r))
+ return 0;
+ r->top -= rect.top;
+ r->left -= rect.left;
+ r->right -= rect.left;
+ r->bottom -= rect.top;
+ return 1;
+}
+
static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam)
{
TOOLINFO ti;
static HWND updatePanel (HWND hDlg, int id)
{
- static HWND chwnd, hwndTT;
+ static HWND hwndTT;
RECT r1c, r1w, r2c, r2w, r3c, r3w;
int w, h, pw, ph, x , y;
EnableWindow (GetDlgItem (guiDlg, IDC_RESETAMIGA), full_property_sheet ? FALSE : TRUE);
EnableWindow (GetDlgItem (guiDlg, IDOK), TRUE);
- if (chwnd != NULL) {
- ShowWindow (chwnd, FALSE);
- DestroyWindow (chwnd);
- chwnd = NULL;
+ if (panelDlg != NULL) {
+ ShowWindow (panelDlg, FALSE);
+ DestroyWindow (panelDlg);
+ panelDlg = NULL;
}
if (ToolTipHWND != NULL) {
DestroyWindow (ToolTipHWND);
GetClientRect (hDlg, &r2c);
gui_width = r2c.right;
gui_height = r2c.bottom;
- chwnd = CreateDialogParam (hUIDLL ? hUIDLL : hInst, ppage[id].pp.pszTemplate, hDlg, ppage[id].pp.pfnDlgProc, id);
+ panelDlg = CreateDialogParam (hUIDLL ? hUIDLL : hInst, ppage[id].pp.pszTemplate, hDlg, ppage[id].pp.pfnDlgProc, id);
GetWindowRect (hDlg, &r3w);
- GetClientRect (chwnd, &r3c);
+ GetClientRect (panelDlg, &r3c);
x = r1w.left - r2w.left;
y = r1w.top - r2w.top;
w = r3c.right - r3c.left + 1;
h = r3c.bottom - r3c.top + 1;
pw = r1w.right - r1w.left + 1;
ph = r1w.bottom - r1w.top + 1;
- SetWindowPos (chwnd, HWND_TOP, 0, 0, 0, 0,
+ SetWindowPos (panelDlg, HWND_TOP, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER);
- GetWindowRect (chwnd, &r3w);
- GetClientRect (chwnd, &r3c);
+ GetWindowRect (panelDlg, &r3w);
+ GetClientRect (panelDlg, &r3c);
x -= r3w.left - r2w.left - 1;
y -= r3w.top - r2w.top - 1;
- SetWindowPos (chwnd, HWND_TOP, x + (pw - w) / 2, y + (ph - h) / 2, 0, 0,
+ SetWindowPos (panelDlg, HWND_TOP, x + (pw - w) / 2, y + (ph - h) / 2, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER);
- ShowWindow (chwnd, TRUE);
+ ShowWindow (panelDlg, TRUE);
EnableWindow (GetDlgItem (hDlg, IDHELP), pHtmlHelp && ppage[currentpage].help ? TRUE : FALSE);
ToolTipHWND = CreateWindowEx (WS_EX_TOPMOST,
TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_BALLOON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- chwnd, NULL, hInst, NULL);
+ panelDlg, NULL, hInst, NULL);
SetWindowPos (ToolTipHWND, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
#if 0
#endif
SendMessage(ToolTipHWND, TTM_SETDELAYTIME, (WPARAM)TTDT_AUTOPOP, (LPARAM)MAKELONG(20000, 0));
SendMessage(ToolTipHWND, TTM_SETMAXTIPWIDTH, 0, 400);
- EnumChildWindows (chwnd, &childenumproc, (LPARAM)NULL);
- SendMessage (chwnd, WM_NULL, 0, 0);
+ EnumChildWindows (panelDlg, &childenumproc, (LPARAM)NULL);
+ SendMessage (panelDlg, WM_NULL, 0, 0);
- return chwnd;
+ return panelDlg;
}
static HTREEITEM CreateFolderNode (HWND TVhDlg, int nameid, HTREEITEM parent, int nodeid, int sub)
int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage)
{
- int cnt, i, drv, list;
+ int cnt, i, drv, firstdrv, list;
char file[MAX_DPATH];
+ int dfxtext[] = { IDC_DF0TEXT, IDC_DF0TEXTQ, IDC_DF1TEXT, IDC_DF1TEXTQ, IDC_DF2TEXT, -1, IDC_DF3TEXT, -1 };
POINT pt;
+ RECT r;
int ret = 0;
DragQueryPoint (hd, &pt);
+ pt.y += GetSystemMetrics (SM_CYMENU) + GetSystemMetrics (SM_CYBORDER);
cnt = DragQueryFile (hd, 0xffffffff, NULL, 0);
if (!cnt)
return 0;
drv = 0;
+ if (currentpage == FLOPPY_ID || currentpage == QUICKSTART_ID) {
+ for (i = 0; i < 4; i++) {
+ int id = dfxtext[i * 2 + (currentpage == QUICKSTART_ID ? 1 : 0)];
+ if (workprefs.dfxtype[i] >= 0 && id >= 0) {
+ if (GetPanelRect (GetDlgItem (panelDlg, id), &r)) {
+ if (PtInRect (&r, pt)) {
+ drv = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+ firstdrv = drv;
for (i = 0; i < cnt; i++) {
struct zfile *z;
DragQueryFile (hd, i, file, sizeof (file));
} else {
strcpy (workprefs.df[drv], file);
disk_insert (drv, file);
- if (drv < 3 && workprefs.dfxtype[drv + 1] >= 0)
- drv++;
+ drv++;
+ if (drv >= (currentpage == QUICKSTART_ID ? 2 : 4))
+ drv = 0;
+ if (workprefs.dfxtype[drv] < 0)
+ drv = 0;
+ if (drv == firstdrv)
+ i = cnt;
}
break;
case ZFILE_ROM: