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

Last change on this file since 2364 was 2188, checked in by hugh, 26 years ago

Added CRTL and SHIFT state in Query Mounse pos and anded wit 0x8000

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