[NTVDM]
[reactos.git] / reactos / subsystems / mvdm / ntvdm / ntvdm.c
index 54b868a..58f18bf 100644 (file)
@@ -176,6 +176,34 @@ static VOID ShowHideMousePointer(HANDLE ConOutHandle, BOOLEAN ShowPtr)
     }
 }
 
+static VOID EnableExtraHardware(HANDLE ConsoleInput)
+{
+    DWORD ConInMode;
+
+    if (GetConsoleMode(ConsoleInput, &ConInMode))
+    {
+#if 0
+        // GetNumberOfConsoleMouseButtons();
+        // GetSystemMetrics(SM_CMOUSEBUTTONS);
+        // GetSystemMetrics(SM_MOUSEPRESENT);
+        if (MousePresent)
+        {
+#endif
+            /* Support mouse input events if there is a mouse on the system */
+            ConInMode |= ENABLE_MOUSE_INPUT;
+#if 0
+        }
+        else
+        {
+            /* Do not support mouse input events if there is no mouse on the system */
+            ConInMode &= ~ENABLE_MOUSE_INPUT;
+        }
+#endif
+
+        SetConsoleMode(ConsoleInput, ConInMode);
+    }
+}
+
 /* PUBLIC FUNCTIONS ***********************************************************/
 
 VOID
@@ -232,14 +260,6 @@ ConsoleCtrlHandler(DWORD ControlType)
 {
     switch (ControlType)
     {
-        case CTRL_C_EVENT:
-        case CTRL_BREAK_EVENT:
-        {
-            /* HACK: Stop the VDM */
-            DPRINT1("Ctrl-C/Break: Stop the VDM\n");
-            EmulatorTerminate();
-            break;
-        }
         case CTRL_LAST_CLOSE_EVENT:
         {
             if (WaitForSingleObject(VdmTaskEvent, 0) == WAIT_TIMEOUT)
@@ -260,6 +280,7 @@ ConsoleCtrlHandler(DWORD ControlType)
 
             break;
         }
+
         default:
         {
             /* Stop the VDM if the user logs out or closes the console */
@@ -284,7 +305,7 @@ ConsoleCleanupUI(VOID)
     DestroyVdmMenu();
 }
 
-static BOOL
+BOOL
 ConsoleAttach(VOID)
 {
     /* Save the original input and output console modes */
@@ -297,13 +318,22 @@ ConsoleAttach(VOID)
         // return FALSE;
     }
 
+    /* Set the console input mode */
+    // FIXME: Activate ENABLE_WINDOW_INPUT when we will want to perform actions
+    // upon console window events (screen buffer resize, ...).
+    SetConsoleMode(ConsoleInput, 0 /* | ENABLE_WINDOW_INPUT */);
+    EnableExtraHardware(ConsoleInput);
+
+    /* Set the console output mode */
+    // SetConsoleMode(ConsoleOutput, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
+
     /* Initialize the UI */
     ConsoleInitUI();
 
     return TRUE;
 }
 
-static VOID
+VOID
 ConsoleDetach(VOID)
 {
     /* Restore the original input and output console modes */