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:
|
||||
* 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
|
||||
|
|
|
@ -71,6 +71,10 @@
|
|||
// w32api does not #define the PBT_ macros in winuser.h like the PSDK does
|
||||
#include <pbt.h>
|
||||
#endif
|
||||
#ifndef GET_RAWINPUT_CODE_WPARAM
|
||||
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
|
||||
#endif
|
||||
|
||||
|
||||
#define USE_WINDOWS_DWORD
|
||||
#include "c_dispatch.h"
|
||||
|
@ -460,6 +464,32 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
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))
|
||||
{
|
||||
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
|
||||
|
|
|
@ -62,7 +62,8 @@ class FInputDevice
|
|||
public:
|
||||
virtual ~FInputDevice() = 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);
|
||||
};
|
||||
|
||||
|
|
|
@ -21,11 +21,6 @@
|
|||
|
||||
#define DINPUT_BUFFERSIZE 32
|
||||
|
||||
// Hi, w32api!
|
||||
#ifndef GET_RAWINPUT_CODE_WPARAM
|
||||
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
|
||||
#endif
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
||||
class FDInputKeyboard : public FKeyboard
|
||||
|
@ -36,7 +31,6 @@ public:
|
|||
|
||||
bool GetDevice();
|
||||
void ProcessInput();
|
||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||
|
||||
protected:
|
||||
LPDIRECTINPUTDEVICE8 Device;
|
||||
|
@ -49,8 +43,7 @@ public:
|
|||
~FRawKeyboard();
|
||||
|
||||
bool GetDevice();
|
||||
void ProcessInput();
|
||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||
bool ProcessRawInput(RAWINPUT *rawinput, int code);
|
||||
|
||||
protected:
|
||||
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
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FRawKeyboard::ProcessInput()
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FRawKeyboard :: WndProcHook
|
||||
// FRawKeyboard :: ProcessRawInput
|
||||
//
|
||||
// Convert scan codes to DirectInput key codes. For the most part, this is
|
||||
// straight forward: Scan codes without any prefix are passed unmodified.
|
||||
|
@ -476,25 +451,13 @@ 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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BYTE buffer[40];
|
||||
UINT size = sizeof(buffer);
|
||||
int keycode;
|
||||
|
||||
if (MyGetRawInputData((HRAWINPUT)lParam, RID_INPUT, buffer, &size, sizeof(RAWINPUTHEADER)) > 0)
|
||||
{
|
||||
RAWINPUT *raw = (RAWINPUT *)buffer;
|
||||
if (raw->header.dwType != RIM_TYPEKEYBOARD)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
keycode = raw->data.keyboard.MakeCode;
|
||||
int keycode = raw->data.keyboard.MakeCode;
|
||||
if (keycode == 0 && (raw->data.keyboard.Flags & RI_KEY_E0))
|
||||
{ // Even if the make code is 0, we might still be able to extract a
|
||||
// useful key from the message.
|
||||
|
@ -568,10 +531,8 @@ bool FRawKeyboard::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||
// 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;
|
||||
PostKeyEvent(keycode, !(raw->data.keyboard.Flags & RI_KEY_BREAK), code == RIM_INPUT);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
~FRawMouse();
|
||||
|
||||
bool GetDevice();
|
||||
void ProcessInput();
|
||||
bool ProcessRawInput(RAWINPUT *rawinput, int code);
|
||||
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||
void Grab();
|
||||
void Ungrab();
|
||||
|
@ -492,25 +492,12 @@ bool FRawMouse::GetDevice()
|
|||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FRawMouse :: ProcessInput
|
||||
//
|
||||
// All input comes through WM_INPUT messages, so nothing to do here.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FRawMouse::ProcessInput()
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FRawMouse :: Grab
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
extern BOOL AppActive;
|
||||
void FRawMouse::Grab()
|
||||
{
|
||||
if (!Grabbed)
|
||||
|
@ -563,39 +550,22 @@ void FRawMouse::Ungrab()
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// FRawMouse :: WndProcHook
|
||||
// FRawMouse :: ProcessRawInput
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
|
||||
bool FRawMouse::ProcessRawInput(RAWINPUT *raw, int code)
|
||||
{
|
||||
if (!Grabbed)
|
||||
if (!Grabbed || raw->header.dwType != RIM_TYPEMOUSE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (message == WM_INPUT)
|
||||
{
|
||||
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)
|
||||
for (int i = 0, mask = 1; i < 5; ++i)
|
||||
{
|
||||
if (raw->data.mouse.usButtonFlags & mask) // button down
|
||||
{
|
||||
|
@ -618,10 +588,22 @@ bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
|
|||
}
|
||||
PostMouseMove(m_noprescale ? raw->data.mouse.lLastX : raw->data.mouse.lLastX<<2,
|
||||
-raw->data.mouse.lLastY);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FRawMouse :: WndProcHook
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
|
||||
{
|
||||
if (!Grabbed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (message == WM_SYSCOMMAND)
|
||||
if (message == WM_SYSCOMMAND)
|
||||
{
|
||||
wParam &= 0xFFF0;
|
||||
if (wParam == SC_MOVE || wParam == SC_SIZE)
|
||||
|
@ -632,6 +614,9 @@ bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
|
|||
return false;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CreateDInputMouse
|
||||
|
@ -1128,6 +1113,9 @@ void FWin32Mouse::CenterMouse(int curx, int cury)
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// I_StartupMouse
|
||||
|
@ -1195,4 +1183,3 @@ void I_StartupMouse ()
|
|||
NativeMouse = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue