2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** i_input.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __I_INPUT_H__
|
|
|
|
#define __I_INPUT_H__
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
2009-06-20 03:16:08 +00:00
|
|
|
#include "doomdef.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-09-14 17:28:18 +00:00
|
|
|
void I_SetMouseCapture();
|
|
|
|
void I_ReleaseMouseCapture();
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
bool I_InitInput (void *hwnd);
|
2006-05-12 03:14:40 +00:00
|
|
|
void I_ShutdownInput ();
|
2006-02-24 04:48:15 +00:00
|
|
|
void I_PutInClipboard (const char *str);
|
2009-02-10 02:16:41 +00:00
|
|
|
FString I_GetFromClipboard (bool windows_has_no_selection_clipboard);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-06-20 03:16:08 +00:00
|
|
|
void I_GetEvent();
|
2009-06-26 02:45:05 +00:00
|
|
|
|
2015-07-15 12:44:37 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
INPUT_DIJoy,
|
|
|
|
INPUT_XInput,
|
|
|
|
INPUT_RawPS2,
|
|
|
|
NUM_JOYDEVICES
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-24 03:15:04 +00:00
|
|
|
#ifdef USE_WINDOWS_DWORD
|
2009-07-11 01:40:01 +00:00
|
|
|
#include "m_joy.h"
|
|
|
|
|
2009-05-24 03:15:04 +00:00
|
|
|
// Don't make these definitions available to the main body of the source code.
|
|
|
|
|
2009-06-11 22:17:50 +00:00
|
|
|
struct tagRAWINPUT;
|
|
|
|
|
2009-05-24 03:15:04 +00:00
|
|
|
class FInputDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~FInputDevice() = 0;
|
|
|
|
virtual bool GetDevice() = 0;
|
2009-06-11 03:41:24 +00:00
|
|
|
virtual void ProcessInput();
|
2009-06-11 22:17:50 +00:00
|
|
|
virtual bool ProcessRawInput(tagRAWINPUT *raw, int code);
|
2009-05-24 03:15:04 +00:00
|
|
|
virtual bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
|
|
|
|
};
|
|
|
|
|
|
|
|
class FMouse : public FInputDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FMouse();
|
|
|
|
|
|
|
|
virtual void Grab() = 0;
|
|
|
|
virtual void Ungrab() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void PostMouseMove(int x, int y);
|
2009-06-06 02:55:58 +00:00
|
|
|
void WheelMoved(int axis, int wheelmove);
|
2009-05-24 03:15:04 +00:00
|
|
|
void PostButtonEvent(int button, bool down);
|
|
|
|
void ClearButtonState();
|
|
|
|
|
2009-06-06 02:55:58 +00:00
|
|
|
int WheelMove[2];
|
2009-05-24 03:15:04 +00:00
|
|
|
int LastX, LastY; // for m_filter
|
|
|
|
WORD ButtonState; // bit mask of current button states (1=down, 0=up)
|
|
|
|
};
|
|
|
|
|
2009-05-27 20:44:54 +00:00
|
|
|
class FKeyboard : public FInputDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FKeyboard();
|
|
|
|
~FKeyboard();
|
|
|
|
|
|
|
|
void AllKeysUp();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BYTE KeyStates[256/8];
|
|
|
|
|
|
|
|
int CheckKey(int keynum) const
|
|
|
|
{
|
|
|
|
return KeyStates[keynum >> 3] & (1 << (keynum & 7));
|
|
|
|
}
|
|
|
|
void SetKey(int keynum, bool down)
|
|
|
|
{
|
|
|
|
if (down)
|
|
|
|
{
|
|
|
|
KeyStates[keynum >> 3] |= 1 << (keynum & 7);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KeyStates[keynum >> 3] &= ~(1 << (keynum & 7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool CheckAndSetKey(int keynum, INTBOOL down);
|
|
|
|
void PostKeyEvent(int keynum, INTBOOL down, bool foreground);
|
|
|
|
};
|
|
|
|
|
2009-06-26 02:45:05 +00:00
|
|
|
class NOVTABLE FJoystickCollection : public FInputDevice
|
2009-06-20 03:16:08 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void AddAxes(float axes[NUM_JOYAXIS]) = 0;
|
2009-06-26 02:45:05 +00:00
|
|
|
virtual void GetDevices(TArray<IJoystickConfig *> &sticks) = 0;
|
2009-07-15 05:53:06 +00:00
|
|
|
virtual IJoystickConfig *Rescan() = 0;
|
2009-06-20 03:16:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern FJoystickCollection *JoyDevices[NUM_JOYDEVICES];
|
|
|
|
|
2009-05-24 03:15:04 +00:00
|
|
|
void I_StartupMouse();
|
|
|
|
void I_CheckNativeMouse(bool prefer_native);
|
2009-05-27 03:16:46 +00:00
|
|
|
void I_StartupKeyboard();
|
2009-06-28 03:09:17 +00:00
|
|
|
void I_StartupXInput();
|
|
|
|
void I_StartupDirectInputJoystick();
|
2009-07-11 01:40:01 +00:00
|
|
|
void I_StartupRawPS2();
|
|
|
|
bool I_IsPS2Adapter(DWORD vidpid);
|
2009-06-28 03:09:17 +00:00
|
|
|
|
2009-05-24 03:15:04 +00:00
|
|
|
// USB HID usage page numbers
|
|
|
|
#define HID_GENERIC_DESKTOP_PAGE 0x01
|
|
|
|
#define HID_SIMULATION_CONTROLS_PAGE 0x02
|
|
|
|
#define HID_VR_CONTROLS_PAGE 0x03
|
|
|
|
#define HID_SPORT_CONTROLS_PAGE 0x04
|
|
|
|
#define HID_GAME_CONTROLS_PAGE 0x05
|
|
|
|
#define HID_GENERIC_DEVICE_CONTROLS_PAGE 0x06
|
|
|
|
#define HID_KEYBOARD_PAGE 0x07
|
|
|
|
#define HID_LED_PAGE 0x08
|
|
|
|
#define HID_BUTTON_PAGE 0x09
|
|
|
|
#define HID_ORDINAL_PAGE 0x0a
|
|
|
|
#define HID_TELEPHONY_DEVICE_PAGE 0x0b
|
|
|
|
#define HID_CONSUMER_PAGE 0x0c
|
|
|
|
#define HID_DIGITIZERS_PAGE 0x0d
|
|
|
|
#define HID_UNICODE_PAGE 0x10
|
|
|
|
#define HID_ALPHANUMERIC_DISPLAY_PAGE 0x14
|
|
|
|
#define HID_MEDICAL_INSTRUMENT_PAGE 0x40
|
|
|
|
|
|
|
|
// HID Generic Desktop Page usages
|
|
|
|
#define HID_GDP_UNDEFINED 0x00
|
|
|
|
#define HID_GDP_POINTER 0x01
|
|
|
|
#define HID_GDP_MOUSE 0x02
|
|
|
|
#define HID_GDP_JOYSTICK 0x04
|
|
|
|
#define HID_GDP_GAMEPAD 0x05
|
|
|
|
#define HID_GDP_KEYBOARD 0x06
|
|
|
|
#define HID_GDP_KEYPAD 0x07
|
|
|
|
#define HID_GDP_MULTIAXIS_CONTROLLER 0x08
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#endif
|