--- uae/src/inputdevice.c 2018/04/24 17:14:14 1.1.1.2 +++ uae/src/inputdevice.c 2018/04/24 17:18:20 1.1.1.4 @@ -21,11 +21,7 @@ #include "sysconfig.h" #include "sysdeps.h" -#include "config.h" #include "options.h" -#include "keyboard.h" -#include "inputdevice.h" -#include "keybuf.h" #include "custom.h" #include "xwin.h" #include "drawing.h" @@ -38,6 +34,11 @@ #include "gui.h" #include "disk.h" #include "audio.h" +#include "autoconf.h" +#include "traps.h" +#include "keyboard.h" +#include "inputdevice.h" +#include "keybuf.h" #include "savestate.h" #define DIR_LEFT 1 @@ -79,6 +80,7 @@ struct inputevent { #define AM_AF 32 /* supports autofire */ #define AM_INFO 64 /* information data for gui */ #define AM_DUMMY 128 /* placeholder */ +#define AM_AUTO 256 /* forces autofire */ #define AM_K (AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT|AM_AF) /* generic button/switch */ /* event flags */ @@ -86,7 +88,7 @@ struct inputevent { #define DEFEVENT(A, B, C, D, E, F) {#A, B, C, D, E, F }, struct inputevent events[] = { -{0, 0, AM_K,0,0,0}, +{0, 0, AM_K, 0, 0, 0}, #include "inputevents.def" {0, 0, 0, 0, 0, 0} }; @@ -105,6 +107,8 @@ static struct uae_input_device2 mice2[MA static uae_u8 mouse_settings_reset[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; static uae_u8 joystick_settings_reset[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; +static struct inputdevice_functions idev[3]; + static int isdevice (struct uae_input_device *id) { int i, j; @@ -320,8 +324,10 @@ static int getnum (char **pp) char *p = *pp; int v = atol (p); - while (*p != 0 && *p !='.' && *p != ',') p++; - if (*p == '.' || *p == ',') p++; + while (*p != 0 && *p !='.' && *p != ',') + p++; + if (*p == '.' || *p == ',') + p++; *pp = p; return v; } @@ -334,8 +340,10 @@ static char *getstring (char **pp) if (*p == 0) return 0; i = 0; - while (*p != 0 && *p !='.' && *p != ',') str[i++] = *p++; - if (*p == '.' || *p == ',') p++; + while (*p != 0 && *p !='.' && *p != ',') + str[i++] = *p++; + if (*p == '.' || *p == ',') + p++; str[i] = 0; *pp = p; return str; @@ -514,12 +522,44 @@ void read_inputdevice_config (struct uae static int ievent_alive = 0; static int lastmx, lastmy; +static void mousehack_setpos (int mousexpos, int mouseypos) +{ + uae_u8 *p; + if (!uae_boot_rom) + return; + p = rtarea + get_long (RTAREA_BASE + 40) + 12; + p[0] = mousexpos >> 8; + p[1] = mousexpos; + p[2] = mouseypos >> 8; + p[3] = mouseypos; + //write_log ("%dx%d\n", mousexpos, mouseypos); +} + +static void new_mousehack_helper (void) +{ + int mousexpos, mouseypos; + + if (!mousehack_allowed ()) + return; +#ifdef PICASSO96 + if (picasso_on) { + mousexpos = lastmx - picasso96_state.XOffset; + mouseypos = lastmy - picasso96_state.YOffset; + } else +#endif + { + mouseypos = coord_native_to_amiga_y (lastmy) << 1; + mousexpos = coord_native_to_amiga_x (lastmx); + } + mousehack_setpos (mousexpos, mouseypos); +} + int mousehack_alive (void) { return ievent_alive > 0; } -uae_u32 mousehack_helper (void) +uae_u32 mousehack_helper (TrapContext *dummy) { int mousexpos, mouseypos; @@ -538,7 +578,7 @@ uae_u32 mousehack_helper (void) switch (m68k_dreg (regs, 0)) { case 0: - return ievent_alive ? -1 : needmousehack (); + return ievent_alive ? -1 : (1 || !uae_boot_rom) && needmousehack (); case 1: ievent_alive = 10; if (!mousehack_allowed ()) @@ -683,7 +723,7 @@ void JOYTEST (uae_u16 v) mouse_frame_y[0] = mouse_y[0]; mouse_frame_x[1] = mouse_x[1]; mouse_frame_y[1] = mouse_y[1]; -// write_log ("%d:%04.4X %p\n",vpos,v,m68k_getpc()); +// write_log ("%d:%04.4X %p\n",vpos,v,m68k_getpc ()); } static uae_u8 parconvert (uae_u8 v, int jd, int shift) @@ -814,7 +854,7 @@ static uae_u16 handle_joystick_potgor (u potgor &= ~p9dat; /* shift at zero == return zero */ if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2)))) potgor &= ~p9dat; - //write_log ("%d:%04.4X %08.8X\n", cd32_shifter[i], potgor, m68k_getpc()); + //write_log ("%d:%04.4X %08.8X\n", cd32_shifter[i], potgor, m68k_getpc ()); } else { if (getbuttonstate (i, JOYBUTTON_3)) potgor &= ~p5dat; @@ -895,7 +935,7 @@ void POTGO (uae_u16 v) { int i; - //write_log ("W:%d: %04.4X %p\n", vpos, v, m68k_getpc()); + //write_log ("W:%d: %04.4X %p\n", vpos, v, m68k_getpc ()); #ifdef DONGLE_DEBUG if (notinrom ()) write_log ("POTGO %04.4X %s\n", v, debuginfo(0)); @@ -927,7 +967,7 @@ void POTGO (uae_u16 v) uae_u16 POTGOR (void) { uae_u16 v = handle_joystick_potgor (potgo_value) & 0x5500; - //write_log("R:%d:%04.4X %d %p\n", vpos, v, cd32_shifter[1], m68k_getpc()); + //write_log ("R:%d:%04.4X %d %p\n", vpos, v, cd32_shifter[1], m68k_getpc ()); return v; } @@ -1006,7 +1046,7 @@ void inputdevice_do_keyboard (int code, uae_reset (r); } record_key ((uae_u8)((key << 1) | (key >> 7))); - //write_log("Amiga key %02.2X %d\n", key & 0x7f, key >> 7); + //write_log ("Amiga key %02.2X %d\n", key & 0x7f, key >> 7); return; } inputdevice_add_inputcode (code, state); @@ -1184,6 +1224,9 @@ void inputdevice_handle_inputcode (void) } break; #endif + case AKS_SWITCHINTERPOL: + switch_audio_interpol (); + break; } } @@ -1195,7 +1238,7 @@ void handle_input_event (int nr, int sta 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); @@ -1348,11 +1391,16 @@ static void setbuttonstateall (struct ua if (button >= ID_BUTTON_TOTAL) return; for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) { + struct inputevent *ie; + event = id->eventid[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]]; custom = id->custom[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]]; if (event <= 0 && custom == NULL) continue; autofire = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_AUTOFIRE) ? 1 : 0; + ie = events + event; + if (ie->allow_mask & AM_AUTO) + autofire = 1; if (state < 0) { handle_input_event (event, 1, 1, 0); queue_input_event (event, 0, 1, 1, 0); /* send release event next frame */ @@ -1548,7 +1596,7 @@ static void compatibility_mode (struct u used[joy] = 1; 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].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_FIRE_BUTTON_AF; #ifdef CD32 if (cd32_enabled) setcd32 (joy, 1); @@ -1563,7 +1611,7 @@ static void compatibility_mode (struct u 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].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_FIRE_BUTTON_AF; joysticks[joy].enabled = 1; } @@ -1739,8 +1787,6 @@ int inputdevice_translatekeycode (int ke return 0; } -static struct inputdevice_functions idev[3]; - void inputdevice_init (void) { idev[IDTYPE_JOYSTICK] = inputdevicefunc_joystick; @@ -2258,7 +2304,7 @@ void setmousestate (int mouse, int axis, *oldm_p = *mouse_p; *mouse_p += data; d = (*mouse_p - *oldm_p) * currprefs.input_mouse_speed / 100.0; - printf (" offs %f\n", d); + /* printf (" offs %f\n", d); */ } else { d = data - (int)(*oldm_p); *oldm_p = data; @@ -2278,6 +2324,7 @@ void setmousestate (int mouse, int axis, } for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0); + new_mousehack_helper(); } #if 0