mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[NTVDM]
Implement mouse buttons and cursor positioning. svn path=/trunk/; revision=64133
This commit is contained in:
parent
63143d1ab6
commit
d15e766663
3 changed files with 103 additions and 0 deletions
|
@ -151,6 +151,63 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
|
|||
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 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
|
|||
/* Disable Mouse Driver */
|
||||
case 0x1F:
|
||||
{
|
||||
setES(0x0000);
|
||||
setBX(0x0000);
|
||||
|
||||
DriverEnabled = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -233,6 +293,34 @@ VOID MouseBiosUpdatePosition(PCOORD NewPosition)
|
|||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
|
|
|
@ -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 @@ typedef struct _MOUSE_DRIVER_STATE
|
|||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID MouseBiosUpdatePosition(PCOORD NewPosition);
|
||||
VOID MouseBiosUpdateButtons(WORD ButtonStatus);
|
||||
BOOLEAN MouseBios32Initialize(VOID);
|
||||
VOID MouseBios32Cleanup(VOID);
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ VOID PS2Dispatch(PINPUT_RECORD InputRecord)
|
|||
{
|
||||
/* Notify the BIOS driver */
|
||||
MouseBiosUpdatePosition(&InputRecord->Event.MouseEvent.dwMousePosition);
|
||||
MouseBiosUpdateButtons(LOWORD(InputRecord->Event.MouseEvent.dwButtonState));
|
||||
|
||||
// TODO: PS/2, other stuff
|
||||
|
||||
|
|
Loading…
Reference in a new issue