mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
- Moved Raw Input processing into a seperate method of FInputDevice so that
all the devices can share the same setup code. SVN r1664 (trunk)
This commit is contained in:
parent
870508c64a
commit
deff9cfb12
5 changed files with 191 additions and 177 deletions
|
@ -1,4 +1,11 @@
|
||||||
June 9, 2009 (Changes by Graf Zahl)
|
June 10, 2009
|
||||||
|
- Moved Raw Input processing into a seperate method of FInputDevice so that
|
||||||
|
all the devices can share the same setup code.
|
||||||
|
|
||||||
|
June 9, 2009
|
||||||
|
- Removed F16 mapping for SDL, because I guess it's not present in SDL 1.2.
|
||||||
|
|
||||||
|
June 9, 2009 (Changes by Graf Zahl)
|
||||||
- Added Gez's Skulltag feature patch, including:
|
- Added Gez's Skulltag feature patch, including:
|
||||||
* BUMPSPECIAL flag: actors with this flag will run their special if collided on by a player
|
* BUMPSPECIAL flag: actors with this flag will run their special if collided on by a player
|
||||||
* WEAPON.NOAUTOAIM flag, though it is restricted to attacks that spawn a missile (it will
|
* WEAPON.NOAUTOAIM flag, though it is restricted to attacks that spawn a missile (it will
|
||||||
|
|
|
@ -71,6 +71,10 @@
|
||||||
// w32api does not #define the PBT_ macros in winuser.h like the PSDK does
|
// w32api does not #define the PBT_ macros in winuser.h like the PSDK does
|
||||||
#include <pbt.h>
|
#include <pbt.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GET_RAWINPUT_CODE_WPARAM
|
||||||
|
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define USE_WINDOWS_DWORD
|
#define USE_WINDOWS_DWORD
|
||||||
#include "c_dispatch.h"
|
#include "c_dispatch.h"
|
||||||
|
@ -460,6 +464,32 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
LRESULT result;
|
LRESULT result;
|
||||||
|
|
||||||
|
if (message == WM_INPUT)
|
||||||
|
{
|
||||||
|
if (MyGetRawInputData != NULL)
|
||||||
|
{
|
||||||
|
UINT size;
|
||||||
|
|
||||||
|
if (!MyGetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) &&
|
||||||
|
size != 0)
|
||||||
|
{
|
||||||
|
BYTE *buffer = (BYTE *)alloca(size);
|
||||||
|
if (MyGetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)) == size)
|
||||||
|
{
|
||||||
|
int code = GET_RAWINPUT_CODE_WPARAM(wParam);
|
||||||
|
if (Keyboard == NULL || !Keyboard->ProcessRawInput((RAWINPUT *)buffer, code))
|
||||||
|
{
|
||||||
|
if (Mouse != NULL)
|
||||||
|
{
|
||||||
|
Mouse->ProcessRawInput((RAWINPUT *)buffer, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
if (CallHook(Keyboard, hWnd, message, wParam, lParam, &result))
|
if (CallHook(Keyboard, hWnd, message, wParam, lParam, &result))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
@ -1338,6 +1368,34 @@ FInputDevice::~FInputDevice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FInputDevice :: ProcessInput
|
||||||
|
//
|
||||||
|
// Gives subclasses an opportunity to do input handling that doesn't involve
|
||||||
|
// window messages.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FInputDevice::ProcessInput()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FInputDevice :: ProcessRawInput
|
||||||
|
//
|
||||||
|
// Gives subclasses a chance to handle WM_INPUT messages. This is not part
|
||||||
|
// of WndProcHook so that we only need to fill the RAWINPUT buffer once
|
||||||
|
// per message and be sure it gets cleaned up properly.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
bool FInputDevice::ProcessRawInput(RAWINPUT *raw, int code)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FInputDevice :: WndProcHook
|
// FInputDevice :: WndProcHook
|
||||||
|
|
|
@ -62,7 +62,8 @@ class FInputDevice
|
||||||
public:
|
public:
|
||||||
virtual ~FInputDevice() = 0;
|
virtual ~FInputDevice() = 0;
|
||||||
virtual bool GetDevice() = 0;
|
virtual bool GetDevice() = 0;
|
||||||
virtual void ProcessInput() = 0;
|
virtual void ProcessInput();
|
||||||
|
virtual bool ProcessRawInput(RAWINPUT *raw, int code);
|
||||||
virtual bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
virtual bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
|
|
||||||
#define DINPUT_BUFFERSIZE 32
|
#define DINPUT_BUFFERSIZE 32
|
||||||
|
|
||||||
// Hi, w32api!
|
|
||||||
#ifndef GET_RAWINPUT_CODE_WPARAM
|
|
||||||
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TYPES -------------------------------------------------------------------
|
// TYPES -------------------------------------------------------------------
|
||||||
|
|
||||||
class FDInputKeyboard : public FKeyboard
|
class FDInputKeyboard : public FKeyboard
|
||||||
|
@ -36,7 +31,6 @@ public:
|
||||||
|
|
||||||
bool GetDevice();
|
bool GetDevice();
|
||||||
void ProcessInput();
|
void ProcessInput();
|
||||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LPDIRECTINPUTDEVICE8 Device;
|
LPDIRECTINPUTDEVICE8 Device;
|
||||||
|
@ -49,8 +43,7 @@ public:
|
||||||
~FRawKeyboard();
|
~FRawKeyboard();
|
||||||
|
|
||||||
bool GetDevice();
|
bool GetDevice();
|
||||||
void ProcessInput();
|
bool ProcessRawInput(RAWINPUT *rawinput, int code);
|
||||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
USHORT E1Prefix;
|
USHORT E1Prefix;
|
||||||
|
@ -377,16 +370,8 @@ void FDInputKeyboard::ProcessInput()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
/**************************************************************************/
|
||||||
//
|
/**************************************************************************/
|
||||||
// FDInputKeyboard :: WndProcHook
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
bool FDInputKeyboard::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -447,17 +432,7 @@ bool FRawKeyboard::GetDevice()
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FRawKeyboard :: ProcessInput
|
// FRawKeyboard :: ProcessRawInput
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FRawKeyboard::ProcessInput()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// FRawKeyboard :: WndProcHook
|
|
||||||
//
|
//
|
||||||
// Convert scan codes to DirectInput key codes. For the most part, this is
|
// Convert scan codes to DirectInput key codes. For the most part, this is
|
||||||
// straight forward: Scan codes without any prefix are passed unmodified.
|
// straight forward: Scan codes without any prefix are passed unmodified.
|
||||||
|
@ -476,102 +451,88 @@ void FRawKeyboard::ProcessInput()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool FRawKeyboard::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
|
bool FRawKeyboard::ProcessRawInput(RAWINPUT *raw, int code)
|
||||||
{
|
{
|
||||||
if (message != WM_INPUT)
|
if (raw->header.dwType != RIM_TYPEKEYBOARD)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BYTE buffer[40];
|
int keycode = raw->data.keyboard.MakeCode;
|
||||||
UINT size = sizeof(buffer);
|
if (keycode == 0 && (raw->data.keyboard.Flags & RI_KEY_E0))
|
||||||
int keycode;
|
{ // Even if the make code is 0, we might still be able to extract a
|
||||||
|
// useful key from the message.
|
||||||
|
if (raw->data.keyboard.VKey >= VK_BROWSER_BACK && raw->data.keyboard.VKey <= VK_LAUNCH_APP2)
|
||||||
|
{
|
||||||
|
static const BYTE MediaKeys[VK_LAUNCH_APP2 - VK_BROWSER_BACK + 1] =
|
||||||
|
{
|
||||||
|
DIK_WEBBACK, DIK_WEBFORWARD, DIK_WEBREFRESH, DIK_WEBSTOP,
|
||||||
|
DIK_WEBSEARCH, DIK_WEBFAVORITES, DIK_WEBHOME,
|
||||||
|
|
||||||
if (MyGetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)) > 0)
|
DIK_MUTE, DIK_VOLUMEDOWN, DIK_VOLUMEUP,
|
||||||
|
DIK_NEXTTRACK, DIK_PREVTRACK, DIK_MEDIASTOP, DIK_PLAYPAUSE,
|
||||||
|
|
||||||
|
DIK_MAIL, DIK_MEDIASELECT, DIK_MYCOMPUTER, DIK_CALCULATOR
|
||||||
|
};
|
||||||
|
keycode = MediaKeys[raw->data.keyboard.VKey - VK_BROWSER_BACK];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (keycode < 1 || keycode > 0xFF)
|
||||||
{
|
{
|
||||||
RAWINPUT *raw = (RAWINPUT *)buffer;
|
return false;
|
||||||
if (raw->header.dwType != RIM_TYPEKEYBOARD)
|
}
|
||||||
{
|
if (raw->data.keyboard.Flags & RI_KEY_E1)
|
||||||
|
{
|
||||||
|
E1Prefix = raw->data.keyboard.MakeCode;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (raw->data.keyboard.Flags & RI_KEY_E0)
|
||||||
|
{
|
||||||
|
if (keycode == DIK_LSHIFT || keycode == DIK_RSHIFT)
|
||||||
|
{ // Ignore fake shifts.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
keycode |= 0x80;
|
||||||
keycode = raw->data.keyboard.MakeCode;
|
}
|
||||||
if (keycode == 0 && (raw->data.keyboard.Flags & RI_KEY_E0))
|
// The sequence for an unshifted pause is E1 1D 45 (E1 Prefix +
|
||||||
{ // Even if the make code is 0, we might still be able to extract a
|
// Control + Num Lock).
|
||||||
// useful key from the message.
|
if (E1Prefix)
|
||||||
if (raw->data.keyboard.VKey >= VK_BROWSER_BACK && raw->data.keyboard.VKey <= VK_LAUNCH_APP2)
|
{
|
||||||
{
|
if (E1Prefix == 0x1D && keycode == DIK_NUMLOCK)
|
||||||
static const BYTE MediaKeys[VK_LAUNCH_APP2 - VK_BROWSER_BACK + 1] =
|
|
||||||
{
|
|
||||||
DIK_WEBBACK, DIK_WEBFORWARD, DIK_WEBREFRESH, DIK_WEBSTOP,
|
|
||||||
DIK_WEBSEARCH, DIK_WEBFAVORITES, DIK_WEBHOME,
|
|
||||||
|
|
||||||
DIK_MUTE, DIK_VOLUMEDOWN, DIK_VOLUMEUP,
|
|
||||||
DIK_NEXTTRACK, DIK_PREVTRACK, DIK_MEDIASTOP, DIK_PLAYPAUSE,
|
|
||||||
|
|
||||||
DIK_MAIL, DIK_MEDIASELECT, DIK_MYCOMPUTER, DIK_CALCULATOR
|
|
||||||
};
|
|
||||||
keycode = MediaKeys[raw->data.keyboard.VKey - VK_BROWSER_BACK];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (keycode < 1 || keycode > 0xFF)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (raw->data.keyboard.Flags & RI_KEY_E1)
|
|
||||||
{
|
|
||||||
E1Prefix = raw->data.keyboard.MakeCode;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (raw->data.keyboard.Flags & RI_KEY_E0)
|
|
||||||
{
|
|
||||||
if (keycode == DIK_LSHIFT || keycode == DIK_RSHIFT)
|
|
||||||
{ // Ignore fake shifts.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
keycode |= 0x80;
|
|
||||||
}
|
|
||||||
// The sequence for an unshifted pause is E1 1D 45 (E1 Prefix +
|
|
||||||
// Control + Num Lock).
|
|
||||||
if (E1Prefix)
|
|
||||||
{
|
|
||||||
if (E1Prefix == 0x1D && keycode == DIK_NUMLOCK)
|
|
||||||
{
|
|
||||||
keycode = DIK_PAUSE;
|
|
||||||
E1Prefix = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
E1Prefix = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If you press Ctrl+Pause, the keyboard sends the Break make code
|
|
||||||
// E0 46 instead of the Pause make code.
|
|
||||||
if (keycode == 0xC6)
|
|
||||||
{
|
{
|
||||||
keycode = DIK_PAUSE;
|
keycode = DIK_PAUSE;
|
||||||
|
E1Prefix = 0;
|
||||||
}
|
}
|
||||||
// If you press Ctrl+PrtScn (to get SysRq), the keyboard sends
|
else
|
||||||
// the make code E0 37. If you press PrtScn without any modifiers,
|
|
||||||
// it sends E0 2A E0 37. And if you press Alt+PrtScn, it sends 54
|
|
||||||
// (which is undefined in the charts I can find.)
|
|
||||||
if (keycode == 0x54)
|
|
||||||
{
|
{
|
||||||
keycode = DIK_SYSRQ;
|
E1Prefix = 0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// If you press any keys in the island between the main keyboard
|
|
||||||
// and the numeric keypad with Num Lock turned on, they generate
|
|
||||||
// a fake shift before their actual codes. They do not generate this
|
|
||||||
// fake shift if Num Lock is off. We unconditionally discard fake
|
|
||||||
// shifts above, so we don't need to do anything special for these,
|
|
||||||
// since they are also prefixed by E0 so we can tell them apart from
|
|
||||||
// their keypad counterparts.
|
|
||||||
|
|
||||||
// Okay, we're done translating the keycode. Post it (or ignore it.)
|
|
||||||
PostKeyEvent(keycode, !(raw->data.keyboard.Flags & RI_KEY_BREAK),
|
|
||||||
GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT);
|
|
||||||
}
|
}
|
||||||
return false;
|
// If you press Ctrl+Pause, the keyboard sends the Break make code
|
||||||
|
// E0 46 instead of the Pause make code.
|
||||||
|
if (keycode == 0xC6)
|
||||||
|
{
|
||||||
|
keycode = DIK_PAUSE;
|
||||||
|
}
|
||||||
|
// If you press Ctrl+PrtScn (to get SysRq), the keyboard sends
|
||||||
|
// the make code E0 37. If you press PrtScn without any modifiers,
|
||||||
|
// it sends E0 2A E0 37. And if you press Alt+PrtScn, it sends 54
|
||||||
|
// (which is undefined in the charts I can find.)
|
||||||
|
if (keycode == 0x54)
|
||||||
|
{
|
||||||
|
keycode = DIK_SYSRQ;
|
||||||
|
}
|
||||||
|
// If you press any keys in the island between the main keyboard
|
||||||
|
// and the numeric keypad with Num Lock turned on, they generate
|
||||||
|
// a fake shift before their actual codes. They do not generate this
|
||||||
|
// fake shift if Num Lock is off. We unconditionally discard fake
|
||||||
|
// shifts above, so we don't need to do anything special for these,
|
||||||
|
// since they are also prefixed by E0 so we can tell them apart from
|
||||||
|
// their keypad counterparts.
|
||||||
|
|
||||||
|
// Okay, we're done translating the keycode. Post it (or ignore it.)
|
||||||
|
PostKeyEvent(keycode, !(raw->data.keyboard.Flags & RI_KEY_BREAK), code == RIM_INPUT);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
~FRawMouse();
|
~FRawMouse();
|
||||||
|
|
||||||
bool GetDevice();
|
bool GetDevice();
|
||||||
void ProcessInput();
|
bool ProcessRawInput(RAWINPUT *rawinput, int code);
|
||||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||||
void Grab();
|
void Grab();
|
||||||
void Ungrab();
|
void Ungrab();
|
||||||
|
@ -492,25 +492,12 @@ bool FRawMouse::GetDevice()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// FRawMouse :: ProcessInput
|
|
||||||
//
|
|
||||||
// All input comes through WM_INPUT messages, so nothing to do here.
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FRawMouse::ProcessInput()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FRawMouse :: Grab
|
// FRawMouse :: Grab
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
extern BOOL AppActive;
|
|
||||||
void FRawMouse::Grab()
|
void FRawMouse::Grab()
|
||||||
{
|
{
|
||||||
if (!Grabbed)
|
if (!Grabbed)
|
||||||
|
@ -561,6 +548,49 @@ void FRawMouse::Ungrab()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FRawMouse :: ProcessRawInput
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
bool FRawMouse::ProcessRawInput(RAWINPUT *raw, int code)
|
||||||
|
{
|
||||||
|
if (!Grabbed || raw->header.dwType != RIM_TYPEMOUSE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check buttons. The up and down motions are stored in the usButtonFlags field.
|
||||||
|
// The ulRawButtons field, unfortunately, is device-dependant, and may well
|
||||||
|
// not contain any data at all. This means it is apparently impossible
|
||||||
|
// to read more than five mouse buttons with Windows, because RI_MOUSE_WHEEL
|
||||||
|
// gets in the way when trying to extrapolate to more than five.
|
||||||
|
for (int i = 0, mask = 1; i < 5; ++i)
|
||||||
|
{
|
||||||
|
if (raw->data.mouse.usButtonFlags & mask) // button down
|
||||||
|
{
|
||||||
|
PostButtonEvent(i, true);
|
||||||
|
}
|
||||||
|
mask <<= 1;
|
||||||
|
if (raw->data.mouse.usButtonFlags & mask) // button up
|
||||||
|
{
|
||||||
|
PostButtonEvent(i, false);
|
||||||
|
}
|
||||||
|
mask <<= 1;
|
||||||
|
}
|
||||||
|
if (raw->data.mouse.usButtonFlags & RI_MOUSE_WHEEL)
|
||||||
|
{
|
||||||
|
WheelMoved(0, (SHORT)raw->data.mouse.usButtonData);
|
||||||
|
}
|
||||||
|
else if (raw->data.mouse.usButtonFlags & 0x800) // horizontal mouse wheel
|
||||||
|
{
|
||||||
|
WheelMoved(1, (SHORT)raw->data.mouse.usButtonData);
|
||||||
|
}
|
||||||
|
PostMouseMove(m_noprescale ? raw->data.mouse.lLastX : raw->data.mouse.lLastX<<2,
|
||||||
|
-raw->data.mouse.lLastY);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FRawMouse :: WndProcHook
|
// FRawMouse :: WndProcHook
|
||||||
|
@ -573,55 +603,7 @@ bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (message == WM_INPUT)
|
if (message == WM_SYSCOMMAND)
|
||||||
{
|
|
||||||
BYTE buffer[sizeof(RAWINPUT)];
|
|
||||||
UINT size = sizeof(buffer);
|
|
||||||
int i;
|
|
||||||
USHORT mask;
|
|
||||||
UINT gridret;
|
|
||||||
|
|
||||||
gridret = MyGetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER));
|
|
||||||
if (gridret != (UINT)-1 && gridret > 0)
|
|
||||||
{
|
|
||||||
RAWINPUT *raw = (RAWINPUT *)buffer;
|
|
||||||
if (raw->header.dwType != RIM_TYPEMOUSE)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check buttons. The up and down motions are stored in the usButtonFlags field.
|
|
||||||
// The ulRawButtons field, unfortunately, is device-dependant, and may well
|
|
||||||
// not contain any data at all. This means it is apparently impossible
|
|
||||||
// to read more than five mouse buttons with Windows, because RI_MOUSE_WHEEL
|
|
||||||
// gets in the way when trying to extrapolate to more than five.
|
|
||||||
for (i = 0, mask = 1; i < 5; ++i)
|
|
||||||
{
|
|
||||||
if (raw->data.mouse.usButtonFlags & mask) // button down
|
|
||||||
{
|
|
||||||
PostButtonEvent(i, true);
|
|
||||||
}
|
|
||||||
mask <<= 1;
|
|
||||||
if (raw->data.mouse.usButtonFlags & mask) // button up
|
|
||||||
{
|
|
||||||
PostButtonEvent(i, false);
|
|
||||||
}
|
|
||||||
mask <<= 1;
|
|
||||||
}
|
|
||||||
if (raw->data.mouse.usButtonFlags & RI_MOUSE_WHEEL)
|
|
||||||
{
|
|
||||||
WheelMoved(0, (SHORT)raw->data.mouse.usButtonData);
|
|
||||||
}
|
|
||||||
else if (raw->data.mouse.usButtonFlags & 0x800) // horizontal mouse wheel
|
|
||||||
{
|
|
||||||
WheelMoved(1, (SHORT)raw->data.mouse.usButtonData);
|
|
||||||
}
|
|
||||||
PostMouseMove(m_noprescale ? raw->data.mouse.lLastX : raw->data.mouse.lLastX<<2,
|
|
||||||
-raw->data.mouse.lLastY);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (message == WM_SYSCOMMAND)
|
|
||||||
{
|
{
|
||||||
wParam &= 0xFFF0;
|
wParam &= 0xFFF0;
|
||||||
if (wParam == SC_MOVE || wParam == SC_SIZE)
|
if (wParam == SC_MOVE || wParam == SC_SIZE)
|
||||||
|
@ -632,6 +614,9 @@ bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// CreateDInputMouse
|
// CreateDInputMouse
|
||||||
|
@ -1128,6 +1113,9 @@ void FWin32Mouse::CenterMouse(int curx, int cury)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// I_StartupMouse
|
// I_StartupMouse
|
||||||
|
@ -1195,4 +1183,3 @@ void I_StartupMouse ()
|
||||||
NativeMouse = true;
|
NativeMouse = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue