Login  •  Register


The time is now: Wed Jun 19, 2013 11:15 pm

Emaculation wiki  •  Delete all board cookies



Post new topic  Reply to topic Page 1 of 1 [ 5 posts ]
Print view Previous topic  |  Next topic
Author Message
PostPosted: Fri Jun 22, 2012 6:31 am 
Offline
Master Emulator
User avatar

Joined: Tue Aug 14, 2007 4:32 pm
Posts: 383
Location: People's Republic of China
Image
Image
I know this hack is dirty and this will only work when emulated system instead of the whole Sheepshaver program hangs..
Code:
--- /d/sss/BasiliskII/src/sdl/video_sdl.cpp   Sat Jan 14 23:45:18 2012
+++ video_sdl.cpp   Fri Jun 22 14:09:57 2012
@@ -88,6 +88,7 @@ static int display_type = DISPLAY_WINDOW
 // Constants
 #ifdef WIN32
 const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes";
+const unsigned int fquit = 432;
 #else
 const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes";
 #endif
@@ -244,7 +245,19 @@ static LRESULT CALLBACK windows_message_
             SysMediaArrived();
       }
       return 0;
-
+   break;
+   case WM_SYSCOMMAND:
+      if(wParam == fquit)
+      {
+         int rt;
+         rt = MessageBox(hwnd, "Do you really want to Force Quit Sheepshaver?",
+         "Sheepshaver", MB_ICONWARNING|MB_OKCANCEL);
+         if(rt == IDOK)
+         {
+            printf("Force quitting...\n");
+            QuitEmulator();
+         }
+      }
    default:
       if (sdl_window_proc)
          return CallWindowProc(sdl_window_proc, hwnd, msg, wParam, lParam);
@@ -1089,6 +1102,12 @@ bool SDL_monitor_desc::video_open(void)
    HWND the_window = GetMainWindowHandle();
    sdl_window_proc = (WNDPROC)GetWindowLongPtr(the_window, GWLP_WNDPROC);
    SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)windows_message_handler);
+   
+   HMENU smenu = GetSystemMenu(the_window, 0);
+   unsigned int fp=fquit;
+   if (smenu)
+      AppendMenu(smenu, MF_STRING, (UINT_PTR)fp, "&Force Quit");
+      
 #endif
 
    // Initialize VideoRefresh function


Top
 Profile  
Post a reply  
PostPosted: Fri Jun 22, 2012 12:26 pm 
Offline
Site Admin
User avatar

Joined: Mon May 20, 2002 4:37 am
Posts: 3125
Location: Canada
Nice addition. Did you know that there is actually a hotkey that forces SheepShaver to quit:

[Control + Alt]hold + Escape[tap a few times]

UberFoX discovered that when he was working on his mouse-grab hotkey.


Top
 Profile  
Post a reply  
PostPosted: Fri Jun 22, 2012 12:47 pm 
Offline
Master Emulator
User avatar

Joined: Tue Aug 14, 2007 4:32 pm
Posts: 383
Location: People's Republic of China
I didn't look at the keyboard code...
Now the confirmation when "emergency quit" hotkey (It's in fact Ctrl+Esc, however Windows itself use it as a substitute to the Windows key so only Ctrl+Alt+Esc will work) down is also added.

Code:
--- /d/video_sdl.cpp   Sat Jan 14 23:45:18 2012
+++ video_sdl.cpp   Fri Jun 22 20:52:05 2012
@@ -88,6 +88,7 @@ static int display_type = DISPLAY_WINDOW
 // Constants
 #ifdef WIN32
 const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes";
+const unsigned int fquit = 432;
 #else
 const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes";
 #endif
@@ -244,7 +245,19 @@ static LRESULT CALLBACK windows_message_
             SysMediaArrived();
       }
       return 0;
-
+   break;
+   case WM_SYSCOMMAND:
+      if(wParam == fquit)
+      {
+         int rt;
+         rt = MessageBox(hwnd, "Do you really want to Force Quit Sheepshaver?",
+         "Sheepshaver", MB_ICONWARNING|MB_OKCANCEL);
+         if(rt == IDOK)
+         {
+            printf("Force quitting...\n");
+            quit_full_screen = true; emerg_quit = true;
+         }
+      }
    default:
       if (sdl_window_proc)
          return CallWindowProc(sdl_window_proc, hwnd, msg, wParam, lParam);
@@ -1089,6 +1102,12 @@ bool SDL_monitor_desc::video_open(void)
    HWND the_window = GetMainWindowHandle();
    sdl_window_proc = (WNDPROC)GetWindowLongPtr(the_window, GWLP_WNDPROC);
    SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)windows_message_handler);
+   
+   HMENU smenu = GetSystemMenu(the_window, 0);
+   unsigned int fp=fquit;
+   if (smenu)
+      AppendMenu(smenu, MF_STRING, (UINT_PTR)fp, "&Force Quit");
+      
 #endif
 
    // Initialize VideoRefresh function
@@ -1701,7 +1720,23 @@ static int kc_decode(SDL_keysym const &
    case SDLK_LEFT: return 0x3b;
    case SDLK_RIGHT: return 0x3c;
 
-   case SDLK_ESCAPE: if (is_ctrl_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
+   case SDLK_ESCAPE: if (is_ctrl_down(ks))
+   {
+      if (!key_down)
+      {
+#ifdef WIN32
+         HWND the_window = GetMainWindowHandle();
+         if ( MessageBox(the_window, "Do you really want to Force Quit Sheepshaver?",
+         "Sheepshaver", MB_ICONWARNING|MB_OKCANCEL) == IDOK )
+#endif
+         {
+            printf ("Force quitting on hotkey down...\n");
+            quit_full_screen = true; emerg_quit = true;
+         }
+      }
+      return -2;
+   }
+   else return 0x35;
 
    case SDLK_F1: if (is_ctrl_down(ks)) {if (!key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
    case SDLK_F2: return 0x78;


Last edited by yksoft1 on Fri Jun 22, 2012 12:56 pm, edited 1 time in total.


Top
 Profile  
Post a reply  
PostPosted: Fri Jun 22, 2012 12:53 pm 
Offline
Site Admin
User avatar

Joined: Mon May 20, 2002 4:37 am
Posts: 3125
Location: Canada
You could post a build with that feature and I'll try it out... or maybe you could send it in? There's a lot of activity going on with SheepShaver development this month.

Meanwhile, since you didn't know about the hotkey, maybe you didn't see UberFoX's thread where it was first mentioned:

viewtopic.php?f=20&t=7604

Check it out... a nice improvement for SheepShaver for Windows!


Top
 Profile  
Post a reply  
PostPosted: Fri Jun 22, 2012 1:01 pm 
Offline
Master Emulator
User avatar

Joined: Tue Aug 14, 2007 4:32 pm
Posts: 383
Location: People's Republic of China
My patch is still based on the CVS code and not the git code.. I don't know will this patch work under the newest git code.

Sheepshaver for Windows with window menu Force Quit item and Force Quit hotkey confirmation, based on the latest and last CVS snapshot:
http://www.mediafire.com/file/2eydxr124wr1stb/ssn2.zip

offtopic: How did Uberfox's patch fix the busy mouse grab bug? This sort of bugfix need to be merged into the main source tree for its severity.


Top
 Profile  
Post a reply  
Display posts from previous:  Sort by  
Post new topic  Reply to topic Page 1 of 1 [ 5 posts ]


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
 

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group