Minor cleanups dealing with plat, keyboard and mouse.
This commit is contained in:
@@ -580,5 +580,11 @@ keyboard_isfsexit(void)
|
|||||||
int
|
int
|
||||||
keyboard_ismsexit(void)
|
keyboard_ismsexit(void)
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
/* Windows: F8+F12 */
|
||||||
return( recv_key[0x42] && recv_key[0x58] );
|
return( recv_key[0x42] && recv_key[0x58] );
|
||||||
|
#else
|
||||||
|
/* Linux: CTRL+END */
|
||||||
|
return( (recv_key[0x1D] || recv_key[0x9D]) && recv_key[0xCF] );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,5 +43,9 @@ extern void keyboard_input(int down, uint16_t scan);
|
|||||||
extern int keyboard_isfsexit(void);
|
extern int keyboard_isfsexit(void);
|
||||||
extern int keyboard_ismsexit(void);
|
extern int keyboard_ismsexit(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /*EMU_KEYBOARD_H*/
|
#endif /*EMU_KEYBOARD_H*/
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Common driver module for MOUSE devices.
|
* Common driver module for MOUSE devices.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse.c 1.0.11 2017/10/22
|
* Version: @(#)mouse.c 1.0.12 2017/10/24
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
|
|
||||||
int mouse_type = 0;
|
int mouse_type = 0;
|
||||||
int mouse_capture;
|
|
||||||
int mouse_x,
|
int mouse_x,
|
||||||
mouse_y,
|
mouse_y,
|
||||||
mouse_z,
|
mouse_z,
|
||||||
@@ -71,7 +70,6 @@ mouse_emu_init(void)
|
|||||||
/* Initialize local data. */
|
/* Initialize local data. */
|
||||||
mouse_x = mouse_y = mouse_z = 0;
|
mouse_x = mouse_y = mouse_z = 0;
|
||||||
mouse_buttons = 0x00;
|
mouse_buttons = 0x00;
|
||||||
mouse_capture = 0;
|
|
||||||
|
|
||||||
cur_mouse = mouse_list[mouse_type];
|
cur_mouse = mouse_list[mouse_type];
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
*
|
*
|
||||||
* Definitions for the MOUSE driver.
|
* Definitions for the MOUSE driver.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse.h 1.0.5 2017/10/22
|
* Version: @(#)mouse.h 1.0.6 2017/10/24
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2008-2017 Sarah Walker.
|
* Copyright 2008-2017 Sarah Walker.
|
||||||
* Copyright 2016-2017 Miran Grca.
|
* Copyright 2016,2017 Miran Grca.
|
||||||
*/
|
*/
|
||||||
#ifndef EMU_MOUSE_H
|
#ifndef EMU_MOUSE_H
|
||||||
# define EMU_MOUSE_H
|
# define EMU_MOUSE_H
|
||||||
@@ -53,7 +53,6 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
extern int mouse_type;
|
extern int mouse_type;
|
||||||
extern int mouse_capture;
|
|
||||||
extern int mouse_x, mouse_y, mouse_z;
|
extern int mouse_x, mouse_y, mouse_z;
|
||||||
extern int mouse_buttons;
|
extern int mouse_buttons;
|
||||||
|
|
||||||
|
|||||||
8
src/pc.c
8
src/pc.c
@@ -774,13 +774,7 @@ pc_close(thread_t *ptr)
|
|||||||
|
|
||||||
config_save();
|
config_save();
|
||||||
|
|
||||||
#if 0
|
plat_mouse_capture(0);
|
||||||
//FIXME: need to move this to Plat. */
|
|
||||||
if (mouse_capture) {
|
|
||||||
ClipCursor(&oldclip);
|
|
||||||
ShowCursor(TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0; i<CDROM_NUM; i++)
|
for (i=0; i<CDROM_NUM; i++)
|
||||||
cdrom_drives[i].handler->exit(i);
|
cdrom_drives[i].handler->exit(i);
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ extern "C" {
|
|||||||
GLOBAL int dopause, /* system is paused */
|
GLOBAL int dopause, /* system is paused */
|
||||||
doresize, /* screen resize requested */
|
doresize, /* screen resize requested */
|
||||||
quited, /* system exit requested */
|
quited, /* system exit requested */
|
||||||
leave_fullscreen_flag; /* windowed-mode requested */
|
leave_fullscreen_flag, /* windowed-mode requested */
|
||||||
|
mouse_capture; /* mouse is captured in app */
|
||||||
GLOBAL uint64_t timer_freq;
|
GLOBAL uint64_t timer_freq;
|
||||||
GLOBAL int infocus;
|
GLOBAL int infocus;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ extern uint64_t plat_timer_read(void);
|
|||||||
extern uint32_t plat_get_ticks(void);
|
extern uint32_t plat_get_ticks(void);
|
||||||
extern void plat_delay_ms(uint32_t count);
|
extern void plat_delay_ms(uint32_t count);
|
||||||
extern void plat_pause(int p);
|
extern void plat_pause(int p);
|
||||||
|
extern void plat_mouse_capture(int on);
|
||||||
extern int plat_vidapi(char *name);
|
extern int plat_vidapi(char *name);
|
||||||
extern char *plat_vidapi_name(int api);
|
extern char *plat_vidapi_name(int api);
|
||||||
extern int plat_setvid(int api);
|
extern int plat_setvid(int api);
|
||||||
|
|||||||
@@ -132,17 +132,6 @@ win_menu_update(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
releasemouse(void)
|
|
||||||
{
|
|
||||||
if (mouse_capture) {
|
|
||||||
ClipCursor(&oldclip);
|
|
||||||
ShowCursor(TRUE);
|
|
||||||
mouse_capture = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
video_toggle_option(HMENU h, int *val, int id)
|
video_toggle_option(HMENU h, int *val, int id)
|
||||||
{
|
{
|
||||||
@@ -606,7 +595,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
infocus = 0;
|
infocus = 0;
|
||||||
releasemouse();
|
plat_mouse_capture(0);
|
||||||
if (video_fullscreen)
|
if (video_fullscreen)
|
||||||
leave_fullscreen_flag = 1;
|
leave_fullscreen_flag = 1;
|
||||||
if (hook_enabled) {
|
if (hook_enabled) {
|
||||||
@@ -616,22 +605,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
if (!mouse_capture && !video_fullscreen) {
|
if (! video_fullscreen)
|
||||||
GetClipCursor(&oldclip);
|
plat_mouse_capture(1);
|
||||||
GetWindowRect(hwndRender, &rect);
|
|
||||||
|
|
||||||
ClipCursor(&rect);
|
|
||||||
mouse_capture = 1;
|
|
||||||
while (1) {
|
|
||||||
if (ShowCursor(FALSE) < 0) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
if (!(mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON)) {
|
if (!(mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON))
|
||||||
releasemouse();
|
plat_mouse_capture(0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ENTERMENULOOP:
|
case WM_ENTERMENULOOP:
|
||||||
@@ -1085,9 +1065,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mouse_capture && keyboard_ismsexit()) {
|
if (mouse_capture && keyboard_ismsexit()) {
|
||||||
ClipCursor(&oldclip);
|
/* Release the in-app mouse. */
|
||||||
ShowCursor(TRUE);
|
plat_mouse_capture(0);
|
||||||
mouse_capture = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_fullscreen && keyboard_isfsexit()) {
|
if (video_fullscreen && keyboard_isfsexit()) {
|
||||||
@@ -1098,10 +1077,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
|
|||||||
|
|
||||||
timeEndPeriod(1);
|
timeEndPeriod(1);
|
||||||
|
|
||||||
if (mouse_capture) {
|
if (mouse_capture)
|
||||||
ClipCursor(&oldclip);
|
plat_mouse_capture(0);
|
||||||
ShowCursor(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
UnregisterClass(SUB_CLASS_NAME, hinstance);
|
UnregisterClass(SUB_CLASS_NAME, hinstance);
|
||||||
UnregisterClass(CLASS_NAME, hinstance);
|
UnregisterClass(CLASS_NAME, hinstance);
|
||||||
@@ -1174,7 +1151,10 @@ do_start(void)
|
|||||||
timer_freq = qpc.QuadPart;
|
timer_freq = qpc.QuadPart;
|
||||||
pclog("Main timer precision: %llu\n", timer_freq);
|
pclog("Main timer precision: %llu\n", timer_freq);
|
||||||
|
|
||||||
atexit(releasemouse);
|
#if 0
|
||||||
|
/* We should have an application-wide at_exit catcher. */
|
||||||
|
atexit(plat_mouse_capture);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Start the emulator, really. */
|
/* Start the emulator, really. */
|
||||||
thMain = thread_create(pc_thread, &quited);
|
thMain = thread_create(pc_thread, &quited);
|
||||||
@@ -1391,3 +1371,28 @@ plat_get_string_from_string(char *str)
|
|||||||
{
|
{
|
||||||
return(plat_get_string(atoi(str)));
|
return(plat_get_string(atoi(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
plat_mouse_capture(int on)
|
||||||
|
{
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
|
if (on && !mouse_capture) {
|
||||||
|
/* Enable the in-app mouse. */
|
||||||
|
GetClipCursor(&oldclip);
|
||||||
|
GetWindowRect(hwndRender, &rect);
|
||||||
|
ClipCursor(&rect);
|
||||||
|
while (1) {
|
||||||
|
if (ShowCursor(FALSE) < 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mouse_capture = 1;
|
||||||
|
} else if (!on && mouse_capture) {
|
||||||
|
/* Disable the in-app mouse. */
|
||||||
|
ClipCursor(&oldclip);
|
||||||
|
ShowCursor(TRUE);
|
||||||
|
|
||||||
|
mouse_capture = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user