Mouse capture/release improvements
This commit is contained in:
parent
c8c10a713a
commit
d42608b546
3 changed files with 114 additions and 61 deletions
|
@ -4054,9 +4054,9 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s)
|
|||
case AKS_WARP:
|
||||
warpmode(newstate);
|
||||
break;
|
||||
//case AKS_INHIBITSCREEN:
|
||||
// toggle_inhibit_frame(monid, IHF_SCROLLLOCK);
|
||||
// break;
|
||||
case AKS_INHIBITSCREEN:
|
||||
toggle_inhibit_frame(IHF_SCROLLLOCK);
|
||||
break;
|
||||
//case AKS_STATEREWIND:
|
||||
// savestate_dorewind(-2);
|
||||
// break;
|
||||
|
|
|
@ -189,6 +189,7 @@ bool resumepaused(int priority)
|
|||
if (pausemouseactive)
|
||||
{
|
||||
pausemouseactive = 0;
|
||||
setmouseactive(isfullscreen() > 0 ? 1 : -1);
|
||||
}
|
||||
pause_emulation = 0;
|
||||
setsystime();
|
||||
|
@ -204,6 +205,10 @@ bool setpaused(int priority)
|
|||
devices_pause();
|
||||
setsoundpaused();
|
||||
pausemouseactive = 1;
|
||||
if (isfullscreen() <= 0) {
|
||||
pausemouseactive = mouseactive;
|
||||
setmouseactive(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1476,19 +1481,16 @@ static void amiberry_inactive(int minimized)
|
|||
if (minimized) {
|
||||
inputdevice_unacquire();
|
||||
setpaused(1);
|
||||
setsoundpaused();
|
||||
sound_closed = -1;
|
||||
}
|
||||
else if (mouseactive) {
|
||||
inputdevice_unacquire();
|
||||
setpaused(2);
|
||||
setsoundpaused();
|
||||
sound_closed = -1;
|
||||
}
|
||||
else {
|
||||
inputdevice_unacquire();
|
||||
setpaused(2);
|
||||
setsoundpaused();
|
||||
sound_closed = -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -1512,6 +1514,67 @@ static void amiberry_active(int minimized)
|
|||
//clipboard_active(1);
|
||||
}
|
||||
|
||||
static void setmouseactive2(int active, bool allowpause)
|
||||
{
|
||||
if (active == 0)
|
||||
set_mouse_grab(false);
|
||||
if (mouseactive == active && active >= 0)
|
||||
return;
|
||||
|
||||
if (active == 1 && !(currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC)) {
|
||||
set_mouse_grab(true);
|
||||
}
|
||||
|
||||
if (active < 0)
|
||||
active = 1;
|
||||
|
||||
mouseactive = active ? 1 : 0;
|
||||
|
||||
recapture = 0;
|
||||
|
||||
if (isfullscreen() <= 0 && (currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC) && currprefs.input_tablet > 0) {
|
||||
if (mousehack_alive())
|
||||
return;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
inputdevice_acquire(TRUE);
|
||||
resumepaused(2);
|
||||
if (sound_closed < 0)
|
||||
resumesoundpaused();
|
||||
}
|
||||
else {
|
||||
inputdevice_acquire(FALSE);
|
||||
inputdevice_releasebuttons();
|
||||
setpaused(2);
|
||||
sound_closed = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void setmouseactive(int active)
|
||||
{
|
||||
if (active > 1)
|
||||
SDL_RaiseWindow(sdl_window);
|
||||
setmouseactive2(active, true);
|
||||
}
|
||||
|
||||
void enablecapture()
|
||||
{
|
||||
if (pause_emulation > 2)
|
||||
return;
|
||||
setmouseactive(1);
|
||||
if (sound_closed < 0) {
|
||||
resumesoundpaused();
|
||||
sound_closed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void disablecapture()
|
||||
{
|
||||
setmouseactive(0);
|
||||
focus = 0;
|
||||
}
|
||||
|
||||
int handle_msgpump()
|
||||
{
|
||||
auto gotEvent = 0;
|
||||
|
@ -1531,6 +1594,9 @@ int handle_msgpump()
|
|||
setminimized();
|
||||
amiberry_inactive(minimized);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
set_mouse_grab(false);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
uae_quit();
|
||||
break;
|
||||
|
@ -1708,34 +1774,36 @@ int handle_msgpump()
|
|||
|
||||
case SDL_FINGERMOTION:
|
||||
//TODO this doesn't work yet
|
||||
mouseScale = currprefs.input_joymouse_multiplier / 2;
|
||||
x = event.motion.xrel;
|
||||
y = event.motion.yrel;
|
||||
setmousestate(0, 0, x* mouseScale, 0);
|
||||
setmousestate(0, 1, y* mouseScale, 0);
|
||||
setmousestate(0, 0, event.motion.xrel, 0);
|
||||
setmousestate(0, 1, event.motion.yrel, 0);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
if (currprefs.input_tablet == TABLET_OFF)
|
||||
if (recapture && isfullscreen() <= 0) {
|
||||
enablecapture();
|
||||
}
|
||||
|
||||
if (currprefs.input_tablet >= TABLET_MOUSEHACK)
|
||||
{
|
||||
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
||||
{
|
||||
mouseScale = currprefs.input_joymouse_multiplier / 2;
|
||||
x = event.motion.xrel;
|
||||
y = event.motion.yrel;
|
||||
/* absolute */
|
||||
setmousestate(0, 0, event.motion.x, 1);
|
||||
setmousestate(0, 1, event.motion.y, 1);
|
||||
}
|
||||
else if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)
|
||||
{
|
||||
/* relative */
|
||||
#if defined (ANDROID)
|
||||
if (event.motion.x == 0 && x > -4)
|
||||
x = -4;
|
||||
if (event.motion.y == 0 && y > -4)
|
||||
y = -4;
|
||||
if (event.motion.x == currprefs.gfx_monitor.gfx_size.width - 1 && x < 4)
|
||||
x = 4;
|
||||
if (event.motion.y == currprefs.gfx_monitor.gfx_size.height - 1 && y < 4)
|
||||
y = 4;
|
||||
if (event.motion.x == 0 && x > -4)
|
||||
x = -4;
|
||||
if (event.motion.y == 0 && y > -4)
|
||||
y = -4;
|
||||
if (event.motion.x == currprefs.gfx_monitor.gfx_size.width - 1 && x < 4)
|
||||
x = 4;
|
||||
if (event.motion.y == currprefs.gfx_monitor.gfx_size.height - 1 && y < 4)
|
||||
y = 4;
|
||||
#endif //ANDROID
|
||||
setmousestate(0, 0, x * mouseScale, 0);
|
||||
setmousestate(0, 1, y * mouseScale, 0);
|
||||
}
|
||||
setmousestate(0, 0, event.motion.xrel, 0);
|
||||
setmousestate(0, 1, event.motion.yrel, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1791,6 +1859,9 @@ bool handle_events()
|
|||
amiberry_active(minimized);
|
||||
unsetminimized();
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
set_mouse_grab(false);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
uae_quit();
|
||||
break;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <guisan.hpp>
|
||||
#include <guisan/sdl.hpp>
|
||||
|
@ -139,7 +138,7 @@ void ClearAvailableROMList()
|
|||
{
|
||||
while (!lstAvailableROMs.empty())
|
||||
{
|
||||
const auto tmp = lstAvailableROMs[0];
|
||||
auto* const tmp = lstAvailableROMs[0];
|
||||
lstAvailableROMs.erase(lstAvailableROMs.begin());
|
||||
delete tmp;
|
||||
}
|
||||
|
@ -148,7 +147,7 @@ void ClearAvailableROMList()
|
|||
static void addrom(struct romdata* rd, const char* path)
|
||||
{
|
||||
char tmpName[MAX_DPATH];
|
||||
const auto tmp = new AvailableROM();
|
||||
auto* const tmp = new AvailableROM();
|
||||
getromname(rd, tmpName);
|
||||
strncpy(tmp->Name, tmpName, MAX_DPATH - 1);
|
||||
if (path != nullptr)
|
||||
|
@ -191,7 +190,7 @@ static struct romdata* scan_single_rom_2(struct zfile* f)
|
|||
{
|
||||
zfile_fseek(f, 0, SEEK_SET);
|
||||
}
|
||||
uae_u8* rombuf = xcalloc(uae_u8, size);
|
||||
auto* rombuf = xcalloc(uae_u8, size);
|
||||
if (!rombuf)
|
||||
return nullptr;
|
||||
zfile_fread(rombuf, 1, size, f);
|
||||
|
@ -222,7 +221,7 @@ static int isromext(char* path)
|
|||
{
|
||||
if (!path)
|
||||
return 0;
|
||||
auto ext = strrchr(path, '.');
|
||||
auto* ext = strrchr(path, '.');
|
||||
if (!ext)
|
||||
return 0;
|
||||
ext++;
|
||||
|
@ -240,11 +239,11 @@ static int isromext(char* path)
|
|||
|
||||
static int scan_rom_2(struct zfile* f, void* dummy)
|
||||
{
|
||||
const auto path = zfile_getname(f);
|
||||
auto* const path = zfile_getname(f);
|
||||
|
||||
if (!isromext(path))
|
||||
return 0;
|
||||
const auto rd = scan_single_rom_2(f);
|
||||
auto* const rd = scan_single_rom_2(f);
|
||||
if (rd)
|
||||
addrom(rd, path);
|
||||
return 0;
|
||||
|
@ -286,7 +285,7 @@ void RescanROMs()
|
|||
|
||||
auto id = 1;
|
||||
for (;;) {
|
||||
auto rd = getromdatabyid(id);
|
||||
auto* rd = getromdatabyid(id);
|
||||
if (!rd)
|
||||
break;
|
||||
if (rd->crc32 == 0xffffffff && strncmp(rd->model, "AROS", 4) == 0)
|
||||
|
@ -302,13 +301,12 @@ static void ClearConfigFileList()
|
|||
{
|
||||
while (!ConfigFilesList.empty())
|
||||
{
|
||||
const auto tmp = ConfigFilesList[0];
|
||||
auto* const tmp = ConfigFilesList[0];
|
||||
ConfigFilesList.erase(ConfigFilesList.begin());
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReadConfigFileList(void)
|
||||
{
|
||||
char path[MAX_DPATH];
|
||||
|
@ -372,16 +370,6 @@ static void clearallkeys (void)
|
|||
inputdevice_updateconfig (NULL, &changed_prefs);
|
||||
}
|
||||
|
||||
void setmouseactive(int active)
|
||||
{
|
||||
if (active) {
|
||||
inputdevice_acquire(TRUE);
|
||||
} else {
|
||||
inputdevice_acquire (FALSE);
|
||||
inputdevice_releasebuttons();
|
||||
}
|
||||
}
|
||||
|
||||
static void prefs_to_gui()
|
||||
{
|
||||
/* filesys hack */
|
||||
|
@ -389,7 +377,6 @@ static void prefs_to_gui()
|
|||
memcpy(&changed_prefs.mountconfig, &currprefs.mountconfig, MOUNT_CONFIG_SIZE * sizeof(struct uaedev_config_info));
|
||||
}
|
||||
|
||||
|
||||
static void gui_to_prefs(void)
|
||||
{
|
||||
/* filesys hack */
|
||||
|
@ -398,7 +385,6 @@ static void gui_to_prefs(void)
|
|||
fixup_prefs(&changed_prefs, true);
|
||||
}
|
||||
|
||||
|
||||
static void after_leave_gui()
|
||||
{
|
||||
// Check if we have to set or clear autofire
|
||||
|
@ -420,7 +406,6 @@ static void after_leave_gui()
|
|||
inputdevice_config_change_test();
|
||||
}
|
||||
|
||||
|
||||
int gui_init()
|
||||
{
|
||||
emulating = 0;
|
||||
|
@ -454,13 +439,11 @@ void gui_exit()
|
|||
ClearAvailableROMList();
|
||||
}
|
||||
|
||||
|
||||
void gui_purge_events()
|
||||
{
|
||||
keybuf_init();
|
||||
}
|
||||
|
||||
|
||||
int gui_update()
|
||||
{
|
||||
char tmp[MAX_DPATH];
|
||||
|
@ -499,7 +482,6 @@ int gui_update()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void gui_display(int shortcut)
|
||||
{
|
||||
if (quit_program != 0)
|
||||
|
@ -769,8 +751,8 @@ bool DevicenameExists(const char* name)
|
|||
{
|
||||
for (auto i = 0; i < MAX_HD_DEVICES; ++i)
|
||||
{
|
||||
auto uci = &changed_prefs.mountconfig[i];
|
||||
const auto ci = &uci->ci;
|
||||
auto* uci = &changed_prefs.mountconfig[i];
|
||||
auto* const ci = &uci->ci;
|
||||
|
||||
if (ci->devname[0])
|
||||
{
|
||||
|
@ -813,7 +795,7 @@ int tweakbootpri(int bp, int ab, int dnm)
|
|||
bool hardfile_testrdb(const TCHAR* filename)
|
||||
{
|
||||
auto isrdb = false;
|
||||
auto f = zfile_fopen(filename, _T("rb"), ZFD_NORMAL);
|
||||
auto* f = zfile_fopen(filename, _T("rb"), ZFD_NORMAL);
|
||||
uae_u8 tmp[8];
|
||||
|
||||
if (!f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue