Commit 24dd5d9e authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

Keyboard/mouse event proc thunk creation moved out of if1632/thunk.c.

parent c44ab1f0
......@@ -2,7 +2,7 @@ name keyboard
type win16
1 pascal16 Inquire(ptr) KEYBOARD_Inquire
2 pascal16 Enable(segptr ptr) THUNK_KEYBOARD_Enable
2 pascal16 Enable(segptr ptr) WIN16_KEYBOARD_Enable
3 pascal16 Disable() KEYBOARD_Disable
4 pascal16 ToAscii(word word ptr ptr word) ToAscii16
5 pascal16 AnsiToOem(str ptr) AnsiToOem16
......
......@@ -2,7 +2,7 @@ name mouse
type win16
1 pascal16 Inquire(ptr) MOUSE_Inquire
2 pascal16 Enable(segptr) THUNK_MOUSE_Enable
2 pascal16 Enable(segptr) WIN16_MOUSE_Enable
3 pascal16 Disable() MOUSE_Disable
4 stub MOUSEGETINTVECT
5 stub GETSETMOUSEDATA
......
......@@ -24,6 +24,7 @@
#include "keyboard.h"
#include "mouse.h"
#include "message.h"
#include "module.h"
#include "debugtools.h"
#include "struct32.h"
#include "winerror.h"
......@@ -143,6 +144,20 @@ void WINAPI keybd_event( BYTE bVk, BYTE bScan,
}
/***********************************************************************
* WIN16_keybd_event (USER.289)
*/
void WINAPI WIN16_keybd_event( CONTEXT86 *context )
{
DWORD dwFlags = 0;
if (AH_reg(context) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
if (BH_reg(context) & 1 ) dwFlags |= KEYEVENTF_EXTENDEDKEY;
keybd_event( AL_reg(context), BL_reg(context),
dwFlags, MAKELONG(SI_reg(context), DI_reg(context)) );
}
/***********************************************************************
* mouse_event (USER32.584)
*/
void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
......@@ -238,6 +253,25 @@ void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
}
}
/***********************************************************************
* WIN16_mouse_event (USER.299)
*/
void WINAPI WIN16_mouse_event( CONTEXT86 *context )
{
mouse_event( AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), MAKELONG(SI_reg(context), DI_reg(context)) );
}
/***********************************************************************
* GetMouseEventProc (USER.337)
*/
FARPROC16 WINAPI GetMouseEventProc16(void)
{
HMODULE16 hmodule = GetModuleHandle16("USER");
return NE_GetEntryPoint( hmodule, NE_GetOrdinal( hmodule, "mouse_event" ));
}
/**********************************************************************
* EnableHardwareInput (USER.331)
*/
......
......@@ -19,7 +19,8 @@
#include "heap.h"
#include "keyboard.h"
#include "message.h"
#include "debugtools.h"
#include "callback.h"
#include "builtin16.h"
#include "debugtools.h"
#include "struct32.h"
#include "winerror.h"
......@@ -56,6 +57,8 @@ VOID WINAPI KEYBOARD_Enable( LPKEYBD_EVENT_PROC lpKeybEventProc,
{
static BOOL initDone = FALSE;
THUNK_Free( (FARPROC)DefKeybEventProc );
DefKeybEventProc = lpKeybEventProc;
pKeyStateTable = lpKeyState;
......@@ -66,11 +69,40 @@ VOID WINAPI KEYBOARD_Enable( LPKEYBD_EVENT_PROC lpKeybEventProc,
initDone = TRUE;
}
static VOID WINAPI KEYBOARD_CallKeybdEventProc( FARPROC16 proc,
BYTE bVk, BYTE bScan,
DWORD dwFlags, DWORD dwExtraInfo )
{
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
CS_reg(&context) = SELECTOROF( proc );
EIP_reg(&context) = OFFSETOF( proc );
AH_reg(&context) = (dwFlags & KEYEVENTF_KEYUP)? 0x80 : 0;
AL_reg(&context) = bVk;
BH_reg(&context) = (dwFlags & KEYEVENTF_EXTENDEDKEY)? 1 : 0;
BL_reg(&context) = bScan;
SI_reg(&context) = LOWORD( dwExtraInfo );
DI_reg(&context) = HIWORD( dwExtraInfo );
CallTo16RegisterShort( &context, 0 );
}
VOID WINAPI WIN16_KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
{
LPKEYBD_EVENT_PROC thunk =
(LPKEYBD_EVENT_PROC)THUNK_Alloc( proc, (RELAY)KEYBOARD_CallKeybdEventProc );
KEYBOARD_Enable( thunk, lpKeyState );
}
/***********************************************************************
* KEYBOARD_Disable (KEYBOARD.3)
*/
VOID WINAPI KEYBOARD_Disable(VOID)
{
THUNK_Free( (FARPROC)DefKeybEventProc );
DefKeybEventProc = NULL;
pKeyStateTable = NULL;
}
......
......@@ -5,7 +5,11 @@
*
*/
#include <string.h>
#include "debugtools.h"
#include "callback.h"
#include "builtin16.h"
#include "mouse.h"
#include "monitor.h"
#include "winuser.h"
......@@ -42,14 +46,43 @@ WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
*/
VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
{
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = lpMouseEventProc;
}
static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
DWORD dwFlags, DWORD dx, DWORD dy,
DWORD cButtons, DWORD dwExtraInfo )
{
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
CS_reg(&context) = SELECTOROF( proc );
EIP_reg(&context) = OFFSETOF( proc );
AX_reg(&context) = (WORD)dwFlags;
BX_reg(&context) = (WORD)dx;
CX_reg(&context) = (WORD)dy;
DX_reg(&context) = (WORD)cButtons;
SI_reg(&context) = LOWORD( dwExtraInfo );
DI_reg(&context) = HIWORD( dwExtraInfo );
CallTo16RegisterShort( &context, 0 );
}
VOID WINAPI WIN16_MOUSE_Enable( FARPROC16 proc )
{
LPMOUSE_EVENT_PROC thunk =
(LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
MOUSE_Enable( thunk );
}
/***********************************************************************
* MOUSE_Disable (MOUSE.3)
*/
VOID WINAPI MOUSE_Disable(VOID)
{
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment