source: trunk/src/dinput/oslibinput.cpp@ 1633

Last change on this file since 1633 was 1633, checked in by sandervl, 26 years ago

Creation of initial Wine Port (991031)

File size: 2.1 KB
Line 
1#define INCL_WIN
2#include <os2wrap.h>
3#include <win32type.h>
4#include <winconst.h>
5#include "oslibinput.h"
6#include <winkeyboard.h>
7
8RECTL desktopRectl = {0};
9ULONG ScreenWidth = 0;
10ULONG ScreenHeight = 0;
11
12//******************************************************************************
13//******************************************************************************
14void OSLibInit()
15{
16 WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
17 ScreenWidth = desktopRectl.xRight;
18 ScreenHeight = desktopRectl.yTop;
19}
20//******************************************************************************
21//******************************************************************************
22BOOL OSLibGetDIState(DWORD len, LPVOID ptr)
23{
24 BYTE PMKeyState[256];
25 BYTE *winkeybuf = (BYTE *)ptr;
26 APIRET rc;
27
28 rc = WinSetKeyboardStateTable( HWND_DESKTOP, (PBYTE)&PMKeyState, FALSE );
29
30 if(rc == TRUE && len==256)
31 {
32 KeyTranslatePMToWinBuf((BYTE *)&PMKeyState, (BYTE *)&ptr, len);
33 for(int i=0;i<256;i++) {
34 winkeybuf[i] &= 0x80; //only high bit
35 }
36 return TRUE;
37 }
38 return FALSE;
39}
40//******************************************************************************
41//******************************************************************************
42BOOL OSLibQueryMousePos(DWORD *rx, DWORD *ry, DWORD *state)
43{
44 POINTL point;
45 BOOL rc;
46
47 rc = WinQueryPointerPos(HWND_DESKTOP, &point);
48
49 *rx = point.x;
50 *ry = ScreenHeight - point.y;
51
52 *state = 0;
53 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
54 *state |= MK_LBUTTON_W;
55 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
56 *state |= MK_RBUTTON_W;
57 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
58 *state |= MK_MBUTTON_W;
59
60 return rc;
61}
62//******************************************************************************
63//******************************************************************************
64BOOL OSLibMoveCursor(DWORD x, DWORD y)
65{
66 y = ScreenHeight - y;
67
68 return WinSetPointerPos(HWND_DESKTOP, x, y);
69}
70//******************************************************************************
71//******************************************************************************
Note: See TracBrowser for help on using the repository browser.