Added config mode to restrict mouse to Apple's window

This commit is contained in:
tomch 2008-05-18 18:23:25 +00:00
parent 758d4ffbbe
commit 84ba1ad382
7 changed files with 85 additions and 50 deletions

View File

@ -105,7 +105,7 @@ STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION | WS_SYSMENU
CAPTION "Input"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
PUSHBUTTON "Paste from clipboard",IDC_PASTE_FROM_CLIPBOARD,5,163,75,14
PUSHBUTTON "Paste from clipboard",IDC_PASTE_FROM_CLIPBOARD,5,179,75,14
GROUPBOX "Joystick Control",IDC_STATIC,5,20,200,80
LTEXT "&Joystick1:",IDC_STATIC,12,33,40,8
COMBOBOX IDC_JOYSTICK0,52,31,100,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
@ -119,10 +119,12 @@ BEGIN
CONTROL "Spin1",IDC_SPIN_YTRIM,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNLEFT | UDS_AUTOBUDDY,161,69,10,14
CONTROL "Scroll Lock acts as toggle for full-speed CPU",IDC_SCROLLLOCK_TOGGLE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,114,166,10
LTEXT "(Shift+Insert during emulation)",IDC_STATIC,89,166,94,8
LTEXT "(Shift+Insert during emulation)",IDC_STATIC,89,182,94,8
CONTROL "Mouse interface in slot 4",IDC_MOUSE_IN_SLOT4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,128,106,10
CONTROL "Show crosshairs in window's frame",IDC_MOUSE_CROSSHAIR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,142,159,10
CONTROL "Restrict mouse to Apple window",IDC_MOUSE_RESTRICT_TO_WINDOW,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,156,159,10
END
IDD_PROPPAGE_SOUND DIALOGEX 0, 0, 210, 221

View File

@ -79,6 +79,7 @@
#define IDC_THE_FREEZES_F8_ROM_FW 1045
#define IDC_MOUSE_CROSSHAIR 1045
#define IDC_CLONETYPE 1046
#define IDC_MOUSE_RESTRICT_TO_WINDOW 1046
#define IDM_EXIT 40001
#define IDM_HELP 40002
#define IDM_ABOUT 40003

View File

@ -440,6 +440,8 @@ void LoadConfiguration ()
g_uMouseInSlot4 = dwTmp;
if(LOAD(TEXT(REGVALUE_MOUSE_CROSSHAIR), &dwTmp))
g_uMouseShowCrosshair = dwTmp;
if(LOAD(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), &dwTmp))
g_uMouseRestrictToWindow = dwTmp;
g_Slot4 = g_uMouseInSlot4 ? CT_MouseInterface : CT_Mockingboard;
//

View File

@ -72,7 +72,6 @@ enum AppMode_e
#define REGVALUE_SPKR_VOLUME "Speaker Volume"
#define REGVALUE_MB_VOLUME "Mockingboard Volume"
#define REGVALUE_SOUNDCARD_TYPE "Soundcard Type"
//#define REGVALUE_KEYB_BUFFER_ENABLE "Keyboard Buffer Enable"
#define REGVALUE_SAVESTATE_FILENAME "Save State Filename"
#define REGVALUE_SAVE_STATE_ON_EXIT "Save State On Exit"
#define REGVALUE_HDD_ENABLED "Harddisk Enable"
@ -83,6 +82,7 @@ enum AppMode_e
#define REGVALUE_SCROLLLOCK_TOGGLE "ScrollLock Toggle"
#define REGVALUE_MOUSE_IN_SLOT4 "Mouse in slot 4"
#define REGVALUE_MOUSE_CROSSHAIR "Mouse crosshair"
#define REGVALUE_MOUSE_RESTRICT_TO_WINDOW "Mouse restrict to window"
#define REGVALUE_THE_FREEZES_F8_ROM "The Freeze's F8 Rom"
#define REGVALUE_CLONETYPE "Clone Type"

View File

@ -78,7 +78,7 @@ static BOOL helpquit = 0;
static BOOL painting = 0;
static HFONT smallfont = (HFONT)0;
static HWND tooltipwindow = (HWND)0;
static BOOL usingcursor = 0;
static BOOL usingcursor = 0; // 1=AppleWin is using (hiding) the mouse-cursor
static int viewportx = VIEWPORTX; // Default to Normal (non-FullScreen) mode
static int viewporty = VIEWPORTY; // Default to Normal (non-FullScreen) mode
@ -86,7 +86,6 @@ static LPDIRECTDRAW directdraw = (LPDIRECTDRAW)0;
static LPDIRECTDRAWSURFACE surface = (LPDIRECTDRAWSURFACE)0;
static bool g_bShowingCursor = true;
static bool g_bOldShowingCursor = true; // Used during MODE_PAUSE
static bool g_bLastCursorInAppleViewport = false;
void DrawStatusArea (HDC passdc, BOOL drawflags);
@ -106,6 +105,33 @@ static void DrawCrosshairsMouse();
static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x=0, int y=0);
//===========================================================================
void FrameShowCursor(BOOL bShow)
{
int nCount;
if (bShow)
{
do
{
nCount = ShowCursor(bShow);
}
while(nCount < 0);
g_bShowingCursor = true;
}
else
{
do
{
nCount = ShowCursor(bShow);
}
while(nCount >= 0);
g_bShowingCursor = false;
}
}
//===========================================================================
void CreateGdiObjects () {
ZeroMemory(buttonbitmap,BUTTONS*sizeof(HBITMAP));
#define LOADBUTTONBITMAP(bitmapname) LoadImage(g_hInstance,bitmapname, \
@ -653,26 +679,21 @@ LRESULT CALLBACK FrameWndProc (
case MODE_RUNNING:
g_nAppMode = MODE_PAUSED;
SoundCore_SetFade(FADE_OUT);
g_bOldShowingCursor = g_bShowingCursor;
if (sg_Mouse.IsActiveAndEnabled() && !g_bShowingCursor)
{
int nCount = ShowCursor(1);
_ASSERT(nCount >= 0);
g_bShowingCursor = true;
FrameShowCursor(TRUE);
if (g_uMouseShowCrosshair) // Erase crosshairs if they are being drawn
DrawCrosshairs(0,0);
if (g_uMouseRestrictToWindow)
SetUsingCursor(true);
}
break;
case MODE_PAUSED:
g_nAppMode = MODE_RUNNING;
SoundCore_SetFade(FADE_IN);
if (sg_Mouse.IsActiveAndEnabled() && !g_bOldShowingCursor)
{
int nCount = ShowCursor(0);
_ASSERT(nCount < 0);
g_bShowingCursor = false;
}
// Don't call FrameShowCursor(FALSE) else ClipCursor() won't be called
break;
case MODE_STEPPING:
DebuggerInputConsoleChar( DEBUG_EXIT_KEY );
@ -737,7 +758,7 @@ LRESULT CALLBACK FrameWndProc (
DrawButton((HDC)0,buttonactive);
SetCapture(window);
}
else if (usingcursor)
else if (usingcursor && !sg_Mouse.IsActive())
{
if (wparam & (MK_CONTROL | MK_SHIFT))
{
@ -756,14 +777,18 @@ LRESULT CALLBACK FrameWndProc (
{
if (wparam & (MK_CONTROL | MK_SHIFT))
{
sg_Mouse.SetEnabled(false);
if (sg_Mouse.IsEnabled())
{
sg_Mouse.SetEnabled(false);
int nCount = ShowCursor(1);
_ASSERT(nCount >= 0);
g_bShowingCursor = true;
FrameShowCursor(TRUE);
if (g_uMouseShowCrosshair) // Erase crosshairs if they are being drawn
DrawCrosshairs(0,0);
if (g_uMouseShowCrosshair) // Erase crosshairs if they are being drawn
DrawCrosshairs(0,0);
if (g_uMouseRestrictToWindow)
SetUsingCursor(false);
}
}
else
{
@ -771,10 +796,8 @@ LRESULT CALLBACK FrameWndProc (
{
sg_Mouse.SetEnabled(true);
int nCount = ShowCursor(0);
_ASSERT(nCount < 0);
g_bShowingCursor = false;
// Don't call SetButton() when enabling
// Don't call FrameShowCursor(FALSE) else ClipCursor() won't be called
// Don't call SetButton() when 1st enabled (else get the confusing action of both enabling & an Apple mouse click)
}
else
{
@ -800,7 +823,7 @@ LRESULT CALLBACK FrameWndProc (
}
buttonactive = -1;
}
else if (usingcursor)
else if (usingcursor && !sg_Mouse.IsActive())
{
JoySetButton(BUTTON0, BUTTON_UP);
}
@ -843,6 +866,8 @@ LRESULT CALLBACK FrameWndProc (
if (g_bLastCursorInAppleViewport)
break;
// Outside Apple viewport
const int iAppleScreenMaxX = VIEWPORTCX-1;
const int iAppleScreenMaxY = VIEWPORTCY-1;
const int iBoundMinX = viewportx;
@ -871,6 +896,8 @@ LRESULT CALLBACK FrameWndProc (
if (g_bLastCursorInAppleViewport == false)
break;
// Inside Apple viewport
int iOutOfBoundsX=0, iOutOfBoundsY=0;
long dX,dY;
@ -1293,7 +1320,7 @@ void SetUsingCursor (BOOL newvalue) {
ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.left);
ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.right);
ClipCursor(&rect);
ShowCursor(0);
FrameShowCursor(FALSE);
POINT pt;
GetCursorPos(&pt);
ScreenToClient(g_hFrameWindow,&pt);
@ -1301,7 +1328,7 @@ void SetUsingCursor (BOOL newvalue) {
}
else {
DrawCrosshairs(0,0);
ShowCursor(1);
FrameShowCursor(TRUE);
ClipCursor(NULL);
ReleaseCapture();
}
@ -1580,6 +1607,9 @@ static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int
if (bOutsideAppleViewport)
{
if (g_uMouseRestrictToWindow)
return;
g_bLastCursorInAppleViewport = false;
if (!g_bShowingCursor)
@ -1587,11 +1617,10 @@ static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int
// Mouse leaving Apple screen area
FrameSetCursorPosByMousePos(0, 0, iOutOfBoundsX, iOutOfBoundsY, true);
#ifdef _DEBUG_SHOW_CURSOR
#else
int nCount = ShowCursor(1);
_ASSERT(nCount >= 0);
#endif
g_bShowingCursor = true;
#else
FrameShowCursor(TRUE);
#endif
}
}
else
@ -1603,11 +1632,15 @@ static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int
// Mouse entering Apple screen area
FrameSetCursorPosByMousePos(x, y, 0, 0, false);
#ifdef _DEBUG_SHOW_CURSOR
#else
int nCount = ShowCursor(0);
_ASSERT(nCount < 0);
#endif
g_bShowingCursor = false;
#else
FrameShowCursor(FALSE);
#endif
//
if (g_uMouseRestrictToWindow)
SetUsingCursor(true);
}
else
{

View File

@ -103,6 +103,7 @@ UINT g_nLastPage = PG_CONFIG;
UINT g_uScrollLockToggle = 0;
UINT g_uMouseInSlot4 = 0;
UINT g_uMouseShowCrosshair = 0;
UINT g_uMouseRestrictToWindow = 0;
//
@ -447,18 +448,16 @@ static BOOL CALLBACK ConfigDlgProc (HWND window,
static void InputDlg_OK(HWND window, UINT afterclose)
{
DWORD newjoytype0 = (DWORD)SendDlgItemMessage(window,IDC_JOYSTICK0,CB_GETCURSEL,0,0);
DWORD newjoytype1 = (DWORD)SendDlgItemMessage(window,IDC_JOYSTICK1,CB_GETCURSEL,0,0);
UINT uNewJoyType0 = SendDlgItemMessage(window,IDC_JOYSTICK0,CB_GETCURSEL,0,0);
UINT uNewJoyType1 = SendDlgItemMessage(window,IDC_JOYSTICK1,CB_GETCURSEL,0,0);
// bool bNewKeybBufferEnable = IsDlgButtonChecked(window, IDC_KEYB_BUFFER_ENABLE) ? true : false;
if (!JoySetEmulationType(window,g_nJoy0ChoiceTranlationTbl[newjoytype0],JN_JOYSTICK0))
if (!JoySetEmulationType(window, g_nJoy0ChoiceTranlationTbl[uNewJoyType0], JN_JOYSTICK0))
{
afterclose = 0;
return;
}
if (!JoySetEmulationType(window,g_nJoy1ChoiceTranlationTbl[newjoytype1],JN_JOYSTICK1))
if (!JoySetEmulationType(window, g_nJoy1ChoiceTranlationTbl[uNewJoyType1], JN_JOYSTICK1))
{
afterclose = 0;
return;
@ -468,8 +467,7 @@ static void InputDlg_OK(HWND window, UINT afterclose)
JoySetTrim((short)SendDlgItemMessage(window, IDC_SPIN_YTRIM, UDM_GETPOS, 0, 0), false);
g_uMouseShowCrosshair = IsDlgButtonChecked(window, IDC_MOUSE_CROSSHAIR) ? 1 : 0;
// KeybSetBufferMode(bNewKeybBufferEnable);
g_uMouseRestrictToWindow = IsDlgButtonChecked(window, IDC_MOUSE_RESTRICT_TO_WINDOW) ? 1 : 0;
SAVE(TEXT("Joystick 0 Emulation"),joytype[0]);
SAVE(TEXT("Joystick 1 Emulation"),joytype[1]);
@ -478,7 +476,7 @@ static void InputDlg_OK(HWND window, UINT afterclose)
SAVE(TEXT(REGVALUE_SCROLLLOCK_TOGGLE),g_uScrollLockToggle);
SAVE(TEXT(REGVALUE_MOUSE_IN_SLOT4),g_uMouseInSlot4);
SAVE(TEXT(REGVALUE_MOUSE_CROSSHAIR),g_uMouseShowCrosshair);
// SAVE(TEXT(REGVALUE_KEYB_BUFFER_ENABLE),KeybGetBufferMode() ? 1 : 0);
SAVE(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW),g_uMouseRestrictToWindow);
//
@ -607,9 +605,6 @@ static BOOL CALLBACK InputDlgProc (HWND window,
case IDC_PASTE_FROM_CLIPBOARD:
ClipboardInitiatePaste();
break;
// case IDC_KEYB_BUFFER_ENABLE:
// break;
}
break;
@ -629,8 +624,9 @@ static BOOL CALLBACK InputDlgProc (HWND window,
CheckDlgButton(window, IDC_SCROLLLOCK_TOGGLE, g_uScrollLockToggle ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(window, IDC_MOUSE_IN_SLOT4, g_uMouseInSlot4 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(window, IDC_MOUSE_CROSSHAIR, g_uMouseShowCrosshair ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(window, IDC_MOUSE_RESTRICT_TO_WINDOW, g_uMouseRestrictToWindow ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(window, IDC_MOUSE_CROSSHAIR), g_uMouseInSlot4 ? TRUE : FALSE);
// CheckDlgButton(window, IDC_KEYB_BUFFER_ENABLE, KeybGetBufferMode() ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(window, IDC_MOUSE_RESTRICT_TO_WINDOW), g_uMouseInSlot4 ? TRUE : FALSE);
}
}

View File

@ -10,5 +10,6 @@ void get_tfe_enabled(int *tfe_enabled);
extern UINT g_uScrollLockToggle;
extern UINT g_uMouseInSlot4;
extern UINT g_uMouseShowCrosshair;
extern UINT g_uMouseRestrictToWindow;
extern UINT g_uTheFreezesF8Rom;
extern DWORD g_uCloneType;