Author: aandrejevic
Date: Sat Sep 13 15:32:07 2014
New Revision: 64133
URL:
http://svn.reactos.org/svn/reactos?rev=64133&view=rev
Log:
[NTVDM]
Implement mouse buttons and cursor positioning.
Modified:
trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c
trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h
trunk/reactos/subsystems/ntvdm/hardware/ps2.c
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c [iso-8859-1] Sat Sep 13
15:32:07 2014
@@ -151,6 +151,63 @@
break;
}
+ /* Return Position And Button Status */
+ case 0x03:
+ {
+ setBX(DriverState.ButtonState);
+ setCX(DriverState.Position.X);
+ setDX(DriverState.Position.Y);
+
+ break;
+ }
+
+ /* Position Mouse Cursor */
+ case 0x04:
+ {
+ POINT Point;
+
+ Point.x = getCX();
+ Point.y = getDX();
+
+ ClientToScreen(GetConsoleWindow(), &Point);
+ SetCursorPos(Point.x, Point.y);
+
+ break;
+ }
+
+ /* Return Button Press Data */
+ case 0x05:
+ {
+ WORD Button = getBX();
+
+ setAX(DriverState.ButtonState);
+ setBX(DriverState.PressCount[Button]);
+ setCX(DriverState.LastPress[Button].X);
+ setDX(DriverState.LastPress[Button].Y);
+
+ /* Reset the counter */
+ DriverState.PressCount[Button] = 0;
+
+ break;
+ }
+
+ /* Return Button Release Data */
+ case 0x06:
+ {
+ WORD Button = getBX();
+
+ setAX(DriverState.ButtonState);
+ setBX(DriverState.ReleaseCount[Button]);
+ setCX(DriverState.LastRelease[Button].X);
+ setDX(DriverState.LastRelease[Button].Y);
+
+ /* Reset the counter */
+ DriverState.ReleaseCount[Button] = 0;
+
+ break;
+
+ }
+
/* Define Graphics Cursor */
case 0x09:
{
@@ -203,6 +260,9 @@
/* Disable Mouse Driver */
case 0x1F:
{
+ setES(0x0000);
+ setBX(0x0000);
+
DriverEnabled = FALSE;
break;
}
@@ -233,6 +293,34 @@
}
}
+VOID MouseBiosUpdateButtons(WORD ButtonState)
+{
+ WORD i;
+
+ if (!DriverEnabled) return;
+
+ for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
+ {
+ BOOLEAN OldState = (DriverState.ButtonState >> i) & 1;
+ BOOLEAN NewState = (ButtonState >> i) & 1;
+
+ if (NewState > OldState)
+ {
+ /* Mouse press */
+ DriverState.PressCount[i]++;
+ DriverState.LastPress[i] = DriverState.Position;
+ }
+ else if (NewState < OldState)
+ {
+ /* Mouse release */
+ DriverState.ReleaseCount[i]++;
+ DriverState.LastRelease[i] = DriverState.Position;
+ }
+ }
+
+ DriverState.ButtonState = ButtonState;
+}
+
BOOLEAN MouseBios32Initialize(VOID)
{
/* Clear the state */
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h [iso-8859-1] Sat Sep 13
15:32:07 2014
@@ -17,11 +17,24 @@
#define BIOS_MOUSE_INTERRUPT 0x33
+enum
+{
+ MOUSE_BUTTON_LEFT,
+ MOUSE_BUTTON_RIGHT,
+ MOUSE_BUTTON_MIDDLE,
+ NUM_MOUSE_BUTTONS
+};
+
typedef struct _MOUSE_DRIVER_STATE
{
SHORT ShowCount;
COORD Position;
WORD Character;
+ WORD ButtonState;
+ WORD PressCount[NUM_MOUSE_BUTTONS];
+ COORD LastPress[NUM_MOUSE_BUTTONS];
+ WORD ReleaseCount[NUM_MOUSE_BUTTONS];
+ COORD LastRelease[NUM_MOUSE_BUTTONS];
struct
{
@@ -40,6 +53,7 @@
/* FUNCTIONS ******************************************************************/
VOID MouseBiosUpdatePosition(PCOORD NewPosition);
+VOID MouseBiosUpdateButtons(WORD ButtonStatus);
BOOLEAN MouseBios32Initialize(VOID);
VOID MouseBios32Cleanup(VOID);
Modified: trunk/reactos/subsystems/ntvdm/hardware/ps2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/ps2.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/ps2.c [iso-8859-1] Sat Sep 13 15:32:07 2014
@@ -310,6 +310,7 @@
{
/* Notify the BIOS driver */
MouseBiosUpdatePosition(&InputRecord->Event.MouseEvent.dwMousePosition);
+
MouseBiosUpdateButtons(LOWORD(InputRecord->Event.MouseEvent.dwButtonState));
// TODO: PS/2, other stuff