LRESULT DefRawInputProc(
PRAWINPUT *paRawInput,
INT nInput,
UINT cbSizeHeader
);
// Windows Raw Input API support demo, (c) FiveTech Software
#include "FiveWin.ch"
#define WM_INPUT 0x00FF
function Main()
local oWnd1 := TMyWindow():New(), oWnd2 := TMyWindow():New()
oWnd1:SetText( "Mouse 1" )
oWnd2:SetText( "Mouse 2" )
oWnd1:hMouse = GetRawMouse( 1 ) // Use mouse 1 only
oWnd2:hMouse = GetRawMouse( 2 ) // Use mouse 2 only
RegisterRawInputDevices( oWnd1:hWnd )
RegisterRawInputDevices( oWnd2:hWnd )
WndTop( oWnd2:hWnd, 350 )
oWnd2:Show()
oWnd2:bLClicked = { || MsgInfo( "mouse 2 click" ) }
ACTIVATE WINDOW oWnd1 ;
ON CLICK MsgInfo( "mouse 1 click" )
return nil
CLASS TMyWindow FROM TWindow
CLASSDATA lRegistered
DATA hMouse // handle of the mouse to use
DATA lProcessMouse INIT .F.
METHOD HandleEvent( nMsg, nWParam, nLParam )
ENDCLASS
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow
local nButtons
if nMsg == WM_INPUT
::SetText( Str( RawGetHandle( nLParam ) ) )
::lProcessMouse = RawIsMouse( nLParam ) .and. RawGetHandle( nLParam ) == ::hMouse
return DefRawInputProc( nLParam )
endif
if nMsg == WM_LBUTTONDOWN .and. ! ::lProcessMouse
return nil
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#define RIDEV_NOLEGACY 0x00000030
#define RIDEV_INPUTSINK 0x00000100
#define RID_INPUT 0x10000003
#define RID_HEADER 0x10000005
#define RIDI_DEVICENAME 0x20000007
#define RIDI_DEVICEINFO 0x2000000b
#define RIM_TYPEMOUSE 0
#define RIM_TYPEKEYBOARD 1
#define RIM_TYPEHID 2
#define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001 // Left Button changed to down.
#define RI_MOUSE_LEFT_BUTTON_UP 0x0002 // Left Button changed to up.
#define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004 // Right Button changed to down.
#define RI_MOUSE_RIGHT_BUTTON_UP 0x0008 // Right Button changed to up.
#define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010 // Middle Button changed to down.
#define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020 // Middle Button changed to up.
typedef struct tagRAWINPUTDEVICE
{
USHORT usUsagePage;
USHORT usUsage;
DWORD dwFlags;
HWND hwndTarget;
} RAWINPUTDEVICE, * PRAWINPUTDEVICE, * LPRAWINPUTDEVICE;
typedef BOOL WINAPI ( * PREGISTERRAWINPUTDEVICES ) (
PRAWINPUTDEVICE pRawInputDevices,
UINT uiNumDevices,
UINT cbSize
);
typedef struct tagRAWINPUTHEADER {
DWORD dwType;
DWORD dwSize;
HANDLE hDevice;
WPARAM wParam;
} RAWINPUTHEADER, * PRAWINPUTHEADER;
typedef struct tagRAWMOUSE {
USHORT usFlags;
union {
ULONG ulButtons;
struct {
USHORT usButtonFlags;
USHORT usButtonData;
};
};
ULONG ulRawButtons;
LONG lLastX;
LONG lLastY;
ULONG ulExtraInformation;
} RAWMOUSE, * PRAWMOUSE, * LPRAWMOUSE;
typedef struct tagRAWKEYBOARD {
USHORT MakeCode;
USHORT Flags;
USHORT Reserved;
USHORT VKey;
UINT Message;
ULONG ExtraInformation;
} RAWKEYBOARD, *PRAWKEYBOARD, *LPRAWKEYBOARD;
typedef struct tagRAWHID {
DWORD dwSizeHid;
DWORD dwCount;
BYTE bRawData;
} RAWHID, **LPRAWHID;
typedef struct tagRAWINPUT {
RAWINPUTHEADER header;
union {
RAWMOUSE mouse;
RAWKEYBOARD keyboard;
RAWHID hid;
} data;
} RAWINPUT, * PRAWINPUT, * LPRAWINPUT;
typedef UINT WINAPI ( * PGETRAWINPUTDATA ) (
LPRAWINPUT hRawInput,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize,
UINT cbSizeHeader
);
typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, * PRAWINPUTDEVICELIST;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICELIST ) (
PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices,
UINT cbSize
);
typedef struct tagRID_DEVICE_INFO_MOUSE {
DWORD dwId;
DWORD dwNumberOfButtons;
DWORD dwSampleRate;
BOOL fHasHorizontalWheel;
} RID_DEVICE_INFO_MOUSE, * PRID_DEVICE_INFO_MOUSE;
typedef struct tagRID_DEVICE_INFO_KEYBOARD {
DWORD dwType;
DWORD dwSubType;
DWORD dwKeyboardMode;
DWORD dwNumberOfFunctionKeys;
DWORD dwNumberOfIndicators;
DWORD dwNumberOfKeysTotal;
} RID_DEVICE_INFO_KEYBOARD, * PRID_DEVICE_INFO_KEYBOARD;
typedef struct tagRID_DEVICE_INFO_HID {
DWORD dwVendorId;
DWORD dwProductId;
DWORD dwVersionNumber;
USHORT usUsagePage;
USHORT usUsage;
} RID_DEVICE_INFO_HID, * PRID_DEVICE_INFO_HID;
typedef struct tagRID_DEVICE_INFO {
DWORD cbSize;
DWORD dwType;
union {
RID_DEVICE_INFO_MOUSE mouse;
RID_DEVICE_INFO_KEYBOARD keyboard;
RID_DEVICE_INFO_HID hid;
};
} RID_DEVICE_INFO, * PRID_DEVICE_INFO, * LPRID_DEVICE_INFO;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICEINFO ) (
HANDLE hDevice,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize
);
typedef LRESULT WINAPI ( * PDEFRAWINPUTPROC ) (
PRAWINPUT * paRawInput,
INT nInput,
UINT cbSizeHeader
);
static PREGISTERRAWINPUTDEVICES pRegisterRawInputDevices;
static PGETRAWINPUTDEVICELIST pGetRawInputDeviceList;
static PGETRAWINPUTDEVICEINFO pGetRawInputDeviceInfo;
static PGETRAWINPUTDATA pGetRawInputData;
static PDEFRAWINPUTPROC pDefRawInputProc;
static void RawInit( void )
{
static BOOL bInit = FALSE;
if( ! bInit )
{
HINSTANCE hUser32 = LoadLibrary( "user32.dll" );
pRegisterRawInputDevices = ( PREGISTERRAWINPUTDEVICES ) GetProcAddress( hUser32, "RegisterRawInputDevices" );
pGetRawInputDeviceList = ( PGETRAWINPUTDEVICELIST ) GetProcAddress( hUser32, "GetRawInputDeviceList" );
pGetRawInputDeviceInfo = ( PGETRAWINPUTDEVICEINFO ) GetProcAddress( hUser32, "GetRawInputDeviceInfoA" );
pGetRawInputData = ( PGETRAWINPUTDATA ) GetProcAddress( hUser32, "GetRawInputData" );
pDefRawInputProc = ( PDEFRAWINPUTPROC ) GetProcAddress( hUser32, "DefRawInputProc" );
FreeLibrary( hUser32 );
bInit = TRUE;
}
}
HB_FUNC( REGISTERRAWINPUTDEVICES )
{
RAWINPUTDEVICE rid[ 2 ];
RawInit();
rid[ 0 ].usUsagePage = 0x01;
rid[ 0 ].usUsage = 0x02; // Mouse
rid[ 0 ].dwFlags = RIDEV_INPUTSINK; // RIDEV_NOLEGACY;
rid[ 0 ].hwndTarget = ( HWND ) hb_parnl( 1 );
rid[ 1 ].usUsagePage = 0x01;
rid[ 1 ].usUsage = 0x06; // Keyboard
rid[ 1 ].dwFlags = RIDEV_INPUTSINK;
rid[ 1 ].hwndTarget = ( HWND ) hb_parnl( 1 );
hb_retl( pRegisterRawInputDevices( rid, 2, sizeof( RAWINPUTDEVICE ) ) );
}
HB_FUNC( GETRAWINPUTDATA )
{
UINT dwSize;
LPBYTE lpb;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) lpb );
}
HB_FUNC( GETRAWINPUTDEVICELIST )
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
hb_reta( nDevices );
for( ui = 0; ui < nDevices; ui++ )
{
char name[ 512 ];
UINT uiSize = 511;
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICENAME, ( void * ) name, &uiSize );
hb_storclen( name, uiSize, -1, ui + 1 );
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSE ) // nMouse --> hDevice
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
UINT uiMouses = 0;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
UINT uiMouse = hb_parnl( 1 );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
{
if( ++uiMouses == uiMouse )
{
hb_retnl( ( unsigned long ) pRawInputDeviceList[ ui ].hDevice );
hb_xfree( ( void * ) pRawInputDeviceList );
return;
}
}
}
hb_retnl( 0 );
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSES ) // --> nMouses
{
UINT nDevices, uiMouses = 0;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
uiMouses++;
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
hb_retnl( --uiMouses ); // Windows reports an extra mouse (?)
}
HB_FUNC( RAWISMOUSE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retl( ( ( PRAWINPUT ) lpb )->header.dwType == RIM_TYPEMOUSE );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWGETHANDLE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->header.hDevice );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWBUTTONS )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->data.mouse.usButtonFlags );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( DEFRAWINPUTPROC )
{
LPRAWINPUT pri = ( LPRAWINPUT ) hb_parnl( 1 );
RawInit();
hb_retnl( ( unsigned long ) pDefRawInputProc( &pri, 1, sizeof( RAWINPUTHEADER ) ) );
}
#pragma ENDDUMP
// Windows Raw Input API support demo, (c) FiveTech Software
#include "FiveWin.ch"
#define WM_INPUT 0x00FF
function Main()
local oWnd := TMyWindow():New()
oWnd:SetText( "Raw API test" )
oWnd:SetMenu( BuildMenu( oWnd ) )
oWnd:hMouse = GetRawMouse( 1 )
RegisterRawInputDevices( oWnd:hWnd )
SET MESSAGE OF oWnd TO "Click on the window to test it" 2007
ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "mouse click" )
return nil
function BuildMenu( oWnd )
local oMenu, oMit1, oMit2, oMit3
MENU oMenu
MENUITEM "Select Mouse"
MENU
MENUITEM oMit1 PROMPT "Mouse 1" CHECKED ACTION ( oWnd:hMouse := GetRawMouse( 1 ), oMit1:SetCheck( .T. ), oMit2:SetCheck( .F. ), oMit3:SetCheck( .F. ) )
MENUITEM oMit2 PROMPT "Mouse 2" ACTION ( oWnd:hMouse := GetRawMouse( 2 ), oMit1:SetCheck( .F. ), oMit2:SetCheck( .T. ), oMit3:SetCheck( .F. ) )
MENUITEM oMit3 PROMPT "Mouse 3" ACTION ( oWnd:hMouse := GetRawMouse( 3 ), oMit1:SetCheck( .F. ), oMit2:SetCheck( .F. ), oMit3:SetCheck( .T. ) )
SEPARATOR
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
ENDMENU
return oMenu
CLASS TMyWindow FROM TWindow
CLASSDATA lRegistered
DATA hMouse // handle of the mouse to use
DATA lProcessMouse INIT .F.
METHOD HandleEvent( nMsg, nWParam, nLParam )
ENDCLASS
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow
local nButtons
if nMsg == WM_INPUT
::lProcessMouse = RawIsMouse( nLParam ) .and. RawGetHandle( nLParam ) == ::hMouse
endif
if nMsg == WM_LBUTTONDOWN .and. ! ::lProcessMouse
return nil
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#define RIDEV_NOLEGACY 0x00000030
#define RIDEV_INPUTSINK 0x00000100
#define RID_INPUT 0x10000003
#define RID_HEADER 0x10000005
#define RIDI_DEVICENAME 0x20000007
#define RIDI_DEVICEINFO 0x2000000b
#define RIM_TYPEMOUSE 0
#define RIM_TYPEKEYBOARD 1
#define RIM_TYPEHID 2
#define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001 // Left Button changed to down.
#define RI_MOUSE_LEFT_BUTTON_UP 0x0002 // Left Button changed to up.
#define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004 // Right Button changed to down.
#define RI_MOUSE_RIGHT_BUTTON_UP 0x0008 // Right Button changed to up.
#define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010 // Middle Button changed to down.
#define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020 // Middle Button changed to up.
typedef struct tagRAWINPUTDEVICE
{
USHORT usUsagePage;
USHORT usUsage;
DWORD dwFlags;
HWND hwndTarget;
} RAWINPUTDEVICE, * PRAWINPUTDEVICE, * LPRAWINPUTDEVICE;
typedef BOOL WINAPI ( * PREGISTERRAWINPUTDEVICES ) (
PRAWINPUTDEVICE pRawInputDevices,
UINT uiNumDevices,
UINT cbSize
);
typedef struct tagRAWINPUTHEADER {
DWORD dwType;
DWORD dwSize;
HANDLE hDevice;
WPARAM wParam;
} RAWINPUTHEADER, * PRAWINPUTHEADER;
typedef struct tagRAWMOUSE {
USHORT usFlags;
union {
ULONG ulButtons;
struct {
USHORT usButtonFlags;
USHORT usButtonData;
};
};
ULONG ulRawButtons;
LONG lLastX;
LONG lLastY;
ULONG ulExtraInformation;
} RAWMOUSE, * PRAWMOUSE, * LPRAWMOUSE;
typedef struct tagRAWKEYBOARD {
USHORT MakeCode;
USHORT Flags;
USHORT Reserved;
USHORT VKey;
UINT Message;
ULONG ExtraInformation;
} RAWKEYBOARD, *PRAWKEYBOARD, *LPRAWKEYBOARD;
typedef struct tagRAWHID {
DWORD dwSizeHid;
DWORD dwCount;
BYTE bRawData;
} RAWHID, **LPRAWHID;
typedef struct tagRAWINPUT {
RAWINPUTHEADER header;
union {
RAWMOUSE mouse;
RAWKEYBOARD keyboard;
RAWHID hid;
} data;
} RAWINPUT, * PRAWINPUT, * LPRAWINPUT;
typedef UINT WINAPI ( * PGETRAWINPUTDATA ) (
LPRAWINPUT hRawInput,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize,
UINT cbSizeHeader
);
typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, * PRAWINPUTDEVICELIST;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICELIST ) (
PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices,
UINT cbSize
);
typedef struct tagRID_DEVICE_INFO_MOUSE {
DWORD dwId;
DWORD dwNumberOfButtons;
DWORD dwSampleRate;
BOOL fHasHorizontalWheel;
} RID_DEVICE_INFO_MOUSE, * PRID_DEVICE_INFO_MOUSE;
typedef struct tagRID_DEVICE_INFO_KEYBOARD {
DWORD dwType;
DWORD dwSubType;
DWORD dwKeyboardMode;
DWORD dwNumberOfFunctionKeys;
DWORD dwNumberOfIndicators;
DWORD dwNumberOfKeysTotal;
} RID_DEVICE_INFO_KEYBOARD, * PRID_DEVICE_INFO_KEYBOARD;
typedef struct tagRID_DEVICE_INFO_HID {
DWORD dwVendorId;
DWORD dwProductId;
DWORD dwVersionNumber;
USHORT usUsagePage;
USHORT usUsage;
} RID_DEVICE_INFO_HID, * PRID_DEVICE_INFO_HID;
typedef struct tagRID_DEVICE_INFO {
DWORD cbSize;
DWORD dwType;
union {
RID_DEVICE_INFO_MOUSE mouse;
RID_DEVICE_INFO_KEYBOARD keyboard;
RID_DEVICE_INFO_HID hid;
};
} RID_DEVICE_INFO, * PRID_DEVICE_INFO, * LPRID_DEVICE_INFO;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICEINFO ) (
HANDLE hDevice,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize
);
typedef LRESULT WINAPI ( * PDEFRAWINPUTPROC ) (
PRAWINPUT * paRawInput,
INT nInput,
UINT cbSizeHeader
);
static PREGISTERRAWINPUTDEVICES pRegisterRawInputDevices;
static PGETRAWINPUTDEVICELIST pGetRawInputDeviceList;
static PGETRAWINPUTDEVICEINFO pGetRawInputDeviceInfo;
static PGETRAWINPUTDATA pGetRawInputData;
static PDEFRAWINPUTPROC pDefRawInputProc;
static void RawInit( void )
{
static BOOL bInit = FALSE;
if( ! bInit )
{
HINSTANCE hUser32 = LoadLibrary( "user32.dll" );
pRegisterRawInputDevices = ( PREGISTERRAWINPUTDEVICES ) GetProcAddress( hUser32, "RegisterRawInputDevices" );
pGetRawInputDeviceList = ( PGETRAWINPUTDEVICELIST ) GetProcAddress( hUser32, "GetRawInputDeviceList" );
pGetRawInputDeviceInfo = ( PGETRAWINPUTDEVICEINFO ) GetProcAddress( hUser32, "GetRawInputDeviceInfoA" );
pGetRawInputData = ( PGETRAWINPUTDATA ) GetProcAddress( hUser32, "GetRawInputData" );
pDefRawInputProc = ( PDEFRAWINPUTPROC ) GetProcAddress( hUser32, "DefRawInputProc" );
FreeLibrary( hUser32 );
bInit = TRUE;
}
}
HB_FUNC( REGISTERRAWINPUTDEVICES )
{
RAWINPUTDEVICE rid[ 2 ];
RawInit();
rid[ 0 ].usUsagePage = 0x01;
rid[ 0 ].usUsage = 0x02; // Mouse
rid[ 0 ].dwFlags = RIDEV_INPUTSINK; // RIDEV_NOLEGACY;
rid[ 0 ].hwndTarget = ( HWND ) hb_parnl( 1 );
rid[ 1 ].usUsagePage = 0x01;
rid[ 1 ].usUsage = 0x06; // Keyboard
rid[ 1 ].dwFlags = RIDEV_INPUTSINK;
rid[ 1 ].hwndTarget = ( HWND ) hb_parnl( 1 );
hb_retl( pRegisterRawInputDevices( rid, 2, sizeof( RAWINPUTDEVICE ) ) );
}
HB_FUNC( GETRAWINPUTDATA )
{
UINT dwSize;
LPBYTE lpb;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) lpb );
}
HB_FUNC( GETRAWINPUTDEVICELIST )
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
hb_reta( nDevices );
for( ui = 0; ui < nDevices; ui++ )
{
char name[ 512 ];
UINT uiSize = 511;
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICENAME, ( void * ) name, &uiSize );
hb_storclen( name, uiSize, -1, ui + 1 );
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSE ) // nMouse --> hDevice
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
UINT uiMouses = 0;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
UINT uiMouse = hb_parnl( 1 );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
{
if( ++uiMouses == uiMouse )
{
hb_retnl( ( unsigned long ) pRawInputDeviceList[ ui ].hDevice );
hb_xfree( ( void * ) pRawInputDeviceList );
return;
}
}
}
hb_retnl( 0 );
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSES ) // --> nMouses
{
UINT nDevices, uiMouses = 0;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
uiMouses++;
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
hb_retnl( --uiMouses ); // Windows reports an extra mouse (?)
}
HB_FUNC( RAWISMOUSE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retl( ( ( PRAWINPUT ) lpb )->header.dwType == RIM_TYPEMOUSE );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWGETHANDLE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->header.hDevice );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWBUTTONS )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->data.mouse.usButtonFlags );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( DEFRAWINPUTPROC )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
pDefRawInputProc( ( LPRAWINPUT * ) &lpb, 1, sizeof( RAWINPUTHEADER ) );
hb_xfree( ( void * ) lpb );
}
#pragma ENDDUMP
// Windows Raw Input API support demo, (c) FiveTech Software
#include "FiveWin.ch"
#define WM_INPUT 0x00FF
#define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001 // Left Button changed to down.
#define RI_MOUSE_LEFT_BUTTON_UP 0x0002 // Left Button changed to up.
#define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004 // Right Button changed to down.
#define RI_MOUSE_RIGHT_BUTTON_UP 0x0008 // Right Button changed to up.
#define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010 // Middle Button changed to down.
#define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020 // Middle Button changed to up.
function Main()
local oWnd := TMyWindow():New()
oWnd:SetText( "Raw API test" )
oWnd:SetMenu( BuildMenu( oWnd ) )
oWnd:hMouse = GetRawMouse( 1 ) // First mouse is not valid
RegisterRawInputDevices( oWnd:hWnd )
SET MESSAGE OF oWnd TO "Click on the window to test it" 2007
ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "mouse click" )
return nil
function BuildMenu( oWnd )
local oMenu, oMit1, oMit2, oMit3
MENU oMenu
MENUITEM "Select Mouse"
MENU
MENUITEM oMit1 PROMPT "Mouse 1" CHECKED ACTION ( oWnd:hMouse := GetRawMouse( 1 ), oMit1:SetCheck( .T. ), oMit2:SetCheck( .F. ), oMit3:SetCheck( .F. ) )
MENUITEM oMit2 PROMPT "Mouse 2" ACTION ( oWnd:hMouse := GetRawMouse( 2 ), oMit1:SetCheck( .F. ), oMit2:SetCheck( .T. ), oMit3:SetCheck( .F. ) )
MENUITEM oMit3 PROMPT "Mouse 3" ACTION ( oWnd:hMouse := GetRawMouse( 3 ), oMit1:SetCheck( .F. ), oMit2:SetCheck( .F. ), oMit3:SetCheck( .T. ) )
SEPARATOR
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
ENDMENU
return oMenu
CLASS TMyWindow FROM TWindow
CLASSDATA lRegistered
DATA hMouse // handle of the mouse to use
DATA lProcessMouse INIT .F.
METHOD HandleEvent( nMsg, nWParam, nLParam )
ENDCLASS
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow
local nButtons
if nMsg == WM_INPUT
// ::lProcessMouse = RawIsMouse( nLParam ) .and. RawGetHandle( nLParam ) == ::hMouse
if RawIsMouse( nLParam ) .and. RawGetHandle( nLParam ) == ::hMouse
nButtons = RawButtons( nLParam )
do case
case nAnd( nButtons, RI_MOUSE_LEFT_BUTTON_DOWN ) == RI_MOUSE_LEFT_BUTTON_DOWN
MsgInfo( "Left button down" )
endcase
endif
endif
if nMsg == WM_LBUTTONDOWN .and. ! ::lProcessMouse
return nil
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#define RIDEV_NOLEGACY 0x00000030
#define RIDEV_INPUTSINK 0x00000100
#define RID_INPUT 0x10000003
#define RID_HEADER 0x10000005
#define RIDI_DEVICENAME 0x20000007
#define RIDI_DEVICEINFO 0x2000000b
#define RIM_TYPEMOUSE 0
#define RIM_TYPEKEYBOARD 1
#define RIM_TYPEHID 2
#define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001 // Left Button changed to down.
#define RI_MOUSE_LEFT_BUTTON_UP 0x0002 // Left Button changed to up.
#define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004 // Right Button changed to down.
#define RI_MOUSE_RIGHT_BUTTON_UP 0x0008 // Right Button changed to up.
#define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010 // Middle Button changed to down.
#define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020 // Middle Button changed to up.
typedef struct tagRAWINPUTDEVICE
{
USHORT usUsagePage;
USHORT usUsage;
DWORD dwFlags;
HWND hwndTarget;
} RAWINPUTDEVICE, * PRAWINPUTDEVICE, * LPRAWINPUTDEVICE;
typedef BOOL WINAPI ( * PREGISTERRAWINPUTDEVICES ) (
PRAWINPUTDEVICE pRawInputDevices,
UINT uiNumDevices,
UINT cbSize
);
typedef struct tagRAWINPUTHEADER {
DWORD dwType;
DWORD dwSize;
HANDLE hDevice;
WPARAM wParam;
} RAWINPUTHEADER, * PRAWINPUTHEADER;
typedef struct tagRAWMOUSE {
USHORT usFlags;
union {
ULONG ulButtons;
struct {
USHORT usButtonFlags;
USHORT usButtonData;
};
};
ULONG ulRawButtons;
LONG lLastX;
LONG lLastY;
ULONG ulExtraInformation;
} RAWMOUSE, * PRAWMOUSE, * LPRAWMOUSE;
typedef struct tagRAWKEYBOARD {
USHORT MakeCode;
USHORT Flags;
USHORT Reserved;
USHORT VKey;
UINT Message;
ULONG ExtraInformation;
} RAWKEYBOARD, *PRAWKEYBOARD, *LPRAWKEYBOARD;
typedef struct tagRAWHID {
DWORD dwSizeHid;
DWORD dwCount;
BYTE bRawData;
} RAWHID, **LPRAWHID;
typedef struct tagRAWINPUT {
RAWINPUTHEADER header;
union {
RAWMOUSE mouse;
RAWKEYBOARD keyboard;
RAWHID hid;
} data;
} RAWINPUT, * PRAWINPUT, * LPRAWINPUT;
typedef UINT WINAPI ( * PGETRAWINPUTDATA ) (
LPRAWINPUT hRawInput,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize,
UINT cbSizeHeader
);
typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, * PRAWINPUTDEVICELIST;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICELIST ) (
PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices,
UINT cbSize
);
typedef struct tagRID_DEVICE_INFO_MOUSE {
DWORD dwId;
DWORD dwNumberOfButtons;
DWORD dwSampleRate;
BOOL fHasHorizontalWheel;
} RID_DEVICE_INFO_MOUSE, * PRID_DEVICE_INFO_MOUSE;
typedef struct tagRID_DEVICE_INFO_KEYBOARD {
DWORD dwType;
DWORD dwSubType;
DWORD dwKeyboardMode;
DWORD dwNumberOfFunctionKeys;
DWORD dwNumberOfIndicators;
DWORD dwNumberOfKeysTotal;
} RID_DEVICE_INFO_KEYBOARD, * PRID_DEVICE_INFO_KEYBOARD;
typedef struct tagRID_DEVICE_INFO_HID {
DWORD dwVendorId;
DWORD dwProductId;
DWORD dwVersionNumber;
USHORT usUsagePage;
USHORT usUsage;
} RID_DEVICE_INFO_HID, * PRID_DEVICE_INFO_HID;
typedef struct tagRID_DEVICE_INFO {
DWORD cbSize;
DWORD dwType;
union {
RID_DEVICE_INFO_MOUSE mouse;
RID_DEVICE_INFO_KEYBOARD keyboard;
RID_DEVICE_INFO_HID hid;
};
} RID_DEVICE_INFO, * PRID_DEVICE_INFO, * LPRID_DEVICE_INFO;
typedef UINT WINAPI ( * PGETRAWINPUTDEVICEINFO ) (
HANDLE hDevice,
UINT uiCommand,
LPVOID pData,
PUINT pcbSize
);
typedef LRESULT WINAPI ( * PDEFRAWINPUTPROC ) (
PRAWINPUT * paRawInput,
INT nInput,
UINT cbSizeHeader
);
static PREGISTERRAWINPUTDEVICES pRegisterRawInputDevices;
static PGETRAWINPUTDEVICELIST pGetRawInputDeviceList;
static PGETRAWINPUTDEVICEINFO pGetRawInputDeviceInfo;
static PGETRAWINPUTDATA pGetRawInputData;
static PDEFRAWINPUTPROC pDefRawInputProc;
static void RawInit( void )
{
static BOOL bInit = FALSE;
if( ! bInit )
{
HINSTANCE hUser32 = LoadLibrary( "user32.dll" );
pRegisterRawInputDevices = ( PREGISTERRAWINPUTDEVICES ) GetProcAddress( hUser32, "RegisterRawInputDevices" );
pGetRawInputDeviceList = ( PGETRAWINPUTDEVICELIST ) GetProcAddress( hUser32, "GetRawInputDeviceList" );
pGetRawInputDeviceInfo = ( PGETRAWINPUTDEVICEINFO ) GetProcAddress( hUser32, "GetRawInputDeviceInfoA" );
pGetRawInputData = ( PGETRAWINPUTDATA ) GetProcAddress( hUser32, "GetRawInputData" );
pDefRawInputProc = ( PDEFRAWINPUTPROC ) GetProcAddress( hUser32, "DefRawInputProc" );
FreeLibrary( hUser32 );
bInit = TRUE;
}
}
HB_FUNC( REGISTERRAWINPUTDEVICES )
{
RAWINPUTDEVICE rid[ 2 ];
RawInit();
rid[ 0 ].usUsagePage = 0x01;
rid[ 0 ].usUsage = 0x02; // Mouse
rid[ 0 ].dwFlags = RIDEV_INPUTSINK; // RIDEV_NOLEGACY;
rid[ 0 ].hwndTarget = ( HWND ) hb_parnl( 1 );
rid[ 1 ].usUsagePage = 0x01;
rid[ 1 ].usUsage = 0x06; // Keyboard
rid[ 1 ].dwFlags = RIDEV_INPUTSINK;
rid[ 1 ].hwndTarget = ( HWND ) hb_parnl( 1 );
hb_retl( pRegisterRawInputDevices( rid, 2, sizeof( RAWINPUTDEVICE ) ) );
}
HB_FUNC( GETRAWINPUTDATA )
{
UINT dwSize;
LPBYTE lpb;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) lpb );
}
HB_FUNC( GETRAWINPUTDEVICELIST )
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
hb_reta( nDevices );
for( ui = 0; ui < nDevices; ui++ )
{
char name[ 512 ];
UINT uiSize = 511;
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICENAME, ( void * ) name, &uiSize );
hb_storclen( name, uiSize, -1, ui + 1 );
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSE ) // nMouse --> hDevice
{
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
UINT uiMouses = 0;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
UINT uiMouse = hb_parnl( 1 );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
{
if( ++uiMouses == uiMouse )
{
hb_retnl( ( unsigned long ) pRawInputDeviceList[ ui ].hDevice );
hb_xfree( ( void * ) pRawInputDeviceList );
return;
}
}
}
hb_retnl( 0 );
hb_xfree( ( void * ) pRawInputDeviceList );
}
}
HB_FUNC( GETRAWMOUSES ) // --> nMouses
{
UINT nDevices, uiMouses = 0;
PRAWINPUTDEVICELIST pRawInputDeviceList;
RawInit();
pGetRawInputDeviceList( NULL, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
if( nDevices )
{
UINT ui;
pRawInputDeviceList = ( PRAWINPUTDEVICELIST ) hb_xgrab( sizeof( RAWINPUTDEVICELIST ) * nDevices );
pGetRawInputDeviceList( pRawInputDeviceList, &nDevices, sizeof( RAWINPUTDEVICELIST ) );
for( ui = 0; ui < nDevices; ui++ )
{
RID_DEVICE_INFO rdi;
UINT uiSize = sizeof( RID_DEVICE_INFO );
rdi.cbSize = sizeof( RID_DEVICE_INFO );
pGetRawInputDeviceInfo( pRawInputDeviceList[ ui ].hDevice, RIDI_DEVICEINFO, ( void * ) &rdi, &uiSize );
if( rdi.dwType == RIM_TYPEMOUSE )
uiMouses++;
}
hb_xfree( ( void * ) pRawInputDeviceList );
}
hb_retnl( --uiMouses ); // Windows reports an extra mouse (?)
}
HB_FUNC( RAWISMOUSE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retl( ( ( PRAWINPUT ) lpb )->header.dwType == RIM_TYPEMOUSE );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWGETHANDLE )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->header.hDevice );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( RAWBUTTONS )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
hb_retnl( ( unsigned long ) ( ( PRAWINPUT ) lpb )->data.mouse.usButtonFlags );
hb_xfree( ( void * ) lpb );
}
HB_FUNC( DEFRAWINPUTPROC )
{
LPBYTE lpb;
UINT dwSize;
RawInit();
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, NULL, &dwSize,
sizeof( RAWINPUTHEADER ) );
lpb = ( LPBYTE ) hb_xgrab( dwSize );
pGetRawInputData( ( LPRAWINPUT ) hb_parnl( 1 ), RID_INPUT, lpb, &dwSize,
sizeof( RAWINPUTHEADER ) );
pDefRawInputProc( ( LPRAWINPUT * ) &lpb, 1, sizeof( RAWINPUTHEADER ) );
hb_xfree( ( void * ) lpb );
}
#pragma ENDDUMP
if ::hWnd == GetFocus() .and. RawIsMouse( nLParam ) .and. RawGetHandle( nLParam ) == ::hMouse
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 84 guests