2004-08-23 00:15:46 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2011-05-19 13:34:07 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-08-23 00:15:46 +00:00
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// in_win.c -- windows 95 mouse and joystick code
// 02/21/97 JCB Added extended DirectInput code to support external controllers.
# include "quakedef.h"
# include "winquake.h"
//#include "dosisms.h"
2014-03-30 08:55:06 +00:00
# ifndef WINRT
2005-06-29 21:20:34 +00:00
# define USINGRAWINPUT
# ifdef USINGRAWINPUT
# include "in_raw.h"
# endif
2012-10-14 09:00:49 +00:00
void INS_Accumulate ( void ) ;
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
# ifndef _MSC_VER
2005-10-21 16:29:08 +00:00
# define DIRECTINPUT_VERSION 0x0500
2004-08-23 00:15:46 +00:00
# endif
2005-10-21 16:29:08 +00:00
# include <dinput.h>
2004-08-23 00:15:46 +00:00
# define DINPUT_BUFFERSIZE 16
# define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
HRESULT ( WINAPI * pDirectInputCreate ) ( HINSTANCE hinst , DWORD dwVersion ,
LPDIRECTINPUT * lplpDirectInput , LPUNKNOWN punkOuter ) ;
# endif
2005-06-18 22:30:57 +00:00
# define DINPUT_VERSION_DX3 0x0300
# define DINPUT_VERSION_DX7 0x0700
2004-08-23 00:15:46 +00:00
// mouse variables
2012-10-14 09:00:49 +00:00
static cvar_t in_dinput = CVARF ( " in_dinput " , " 0 " , CVAR_ARCHIVE ) ;
static cvar_t in_builtinkeymap = CVARF ( " in_builtinkeymap " , " 0 " , CVAR_ARCHIVE ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
static cvar_t in_simulatemultitouch = CVAR ( " in_simulatemultitouch " , " 0 " ) ;
2014-04-24 01:53:01 +00:00
static cvar_t in_nonstandarddeadkeys = CVARD ( " in_nonstandarddeadkeys " , " 1 " , " Discard input events that result in multiple keys. Only the last key will be used. This results in behaviour that differs from eg notepad. To use a dead key, press it twice instead of the dead key followed by space. " ) ;
2004-08-23 00:15:46 +00:00
2012-10-14 09:00:49 +00:00
static cvar_t m_accel_noforce = CVAR ( " m_accel_noforce " , " 0 " ) ;
static cvar_t m_threshold_noforce = CVAR ( " m_threshold_noforce " , " 0 " ) ;
2005-08-06 22:39:28 +00:00
2013-04-13 08:15:18 +00:00
static cvar_t cl_keypad = CVAR ( " cl_keypad " , " 1 " ) ;
2004-08-23 00:15:46 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
extern float multicursor_x [ 8 ] , multicursor_y [ 8 ] ;
extern qboolean multicursor_active [ 8 ] ;
2015-04-14 23:12:17 +00:00
POINT current_mouse_pos ;
2010-08-23 04:53:20 +00:00
typedef struct {
union {
HANDLE rawinputhandle ;
} handles ;
2012-02-12 05:18:31 +00:00
int qdeviceid ;
2010-08-23 04:53:20 +00:00
} keyboard_t ;
2004-08-23 00:15:46 +00:00
typedef struct {
2005-06-29 21:20:34 +00:00
union {
HANDLE rawinputhandle ; // raw input
2006-02-17 02:51:59 +00:00
} handles ;
2004-08-23 00:15:46 +00:00
int numbuttons ;
2012-10-14 09:00:49 +00:00
int oldbuttons ;
2012-02-12 05:18:31 +00:00
int qdeviceid ; /*the device id controls which player slot it controls, if splitscreen splits it that way*/
2004-08-23 00:15:46 +00:00
} mouse_t ;
2012-10-14 09:00:49 +00:00
static mouse_t sysmouse ;
2004-08-23 00:15:46 +00:00
static qboolean restore_spi ;
2005-08-06 22:39:28 +00:00
static int originalmouseparms [ 3 ] , newmouseparms [ 3 ] = { 0 , 0 , 0 } ;
2004-08-23 00:15:46 +00:00
qboolean mouseinitialized ;
static qboolean mouseparmsvalid , mouseactivatetoggle ;
static qboolean mouseshowtoggle = 1 ;
static qboolean dinput_acquired ;
unsigned int uiWheelMessage ;
qboolean mouseactive ;
// joystick defines and variables
// where should defines be moved?
# define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
# define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
# define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
# define JOY_AXIS_X 0
# define JOY_AXIS_Y 1
# define JOY_AXIS_Z 2
# define JOY_AXIS_R 3
# define JOY_AXIS_U 4
# define JOY_AXIS_V 5
enum _ControlList
{
AxisNada = 0 , AxisForward , AxisLook , AxisSide , AxisTurn
} ;
2012-10-14 09:00:49 +00:00
static DWORD dwAxisFlags [ JOY_MAX_AXES ] =
2004-08-23 00:15:46 +00:00
{
JOY_RETURNX , JOY_RETURNY , JOY_RETURNZ , JOY_RETURNR , JOY_RETURNU , JOY_RETURNV
} ;
2012-10-14 09:00:49 +00:00
static DWORD dwAxisMap [ JOY_MAX_AXES ] ;
static DWORD dwControlMap [ JOY_MAX_AXES ] ;
2004-08-23 00:15:46 +00:00
// none of these cvars are saved over a session
// this means that advanced controller configuration needs to be executed
// each time. this avoids any problems with getting back to a default usage
// or when changing from one controller to another. this way at least something
// works.
2012-10-14 09:00:49 +00:00
static cvar_t in_joystick = CVARF ( " joystick " , " 0 " , CVAR_ARCHIVE ) ;
static cvar_t joy_name = CVAR ( " joyname " , " joystick " ) ;
static cvar_t joy_advanced = CVAR ( " joyadvanced " , " 0 " ) ;
static cvar_t joy_advaxisx = CVAR ( " joyadvaxisx " , " 0 " ) ;
static cvar_t joy_advaxisy = CVAR ( " joyadvaxisy " , " 0 " ) ;
static cvar_t joy_advaxisz = CVAR ( " joyadvaxisz " , " 0 " ) ;
static cvar_t joy_advaxisr = CVAR ( " joyadvaxisr " , " 0 " ) ;
static cvar_t joy_advaxisu = CVAR ( " joyadvaxisu " , " 0 " ) ;
static cvar_t joy_advaxisv = CVAR ( " joyadvaxisv " , " 0 " ) ;
static cvar_t joy_forwardthreshold = CVAR ( " joyforwardthreshold " , " 0.15 " ) ;
static cvar_t joy_sidethreshold = CVAR ( " joysidethreshold " , " 0.15 " ) ;
static cvar_t joy_pitchthreshold = CVAR ( " joypitchthreshold " , " 0.15 " ) ;
static cvar_t joy_yawthreshold = CVAR ( " joyyawthreshold " , " 0.15 " ) ;
static cvar_t joy_forwardsensitivity = CVAR ( " joyforwardsensitivity " , " -1.0 " ) ;
static cvar_t joy_sidesensitivity = CVAR ( " joysidesensitivity " , " -1.0 " ) ;
static cvar_t joy_pitchsensitivity = CVAR ( " joypitchsensitivity " , " 1.0 " ) ;
static cvar_t joy_yawsensitivity = CVAR ( " joyyawsensitivity " , " -1.0 " ) ;
static cvar_t joy_wwhack1 = CVAR ( " joywwhack1 " , " 0.0 " ) ;
static cvar_t joy_wwhack2 = CVAR ( " joywwhack2 " , " 0.0 " ) ;
2014-07-12 06:56:17 +00:00
static qboolean joy_advancedinit ;
2012-10-14 09:00:49 +00:00
static DWORD joy_flags ;
2014-07-12 06:56:17 +00:00
# define MAX_JOYSTICKS 4
static struct wjoy_s {
unsigned int id ; //windows id. device id is the index.
unsigned int devid ; //quake id (generally player index)
DWORD numbuttons ;
qboolean haspov ;
DWORD povstate ;
DWORD oldpovstate ;
DWORD buttonstate ;
DWORD oldbuttonstate ;
DWORD axis [ JOY_MAX_AXES ] ;
} wjoy [ MAX_JOYSTICKS ] ;
static int joy_count ;
2004-08-23 00:15:46 +00:00
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2009-11-04 21:16:50 +00:00
static const GUID fGUID_XAxis = { 0xA36D02E0 , 0xC9F3 , 0x11CF , { 0xBF , 0xC7 , 0x44 , 0x45 , 0x53 , 0x54 , 0x00 , 0x00 } } ;
static const GUID fGUID_YAxis = { 0xA36D02E1 , 0xC9F3 , 0x11CF , { 0xBF , 0xC7 , 0x44 , 0x45 , 0x53 , 0x54 , 0x00 , 0x00 } } ;
static const GUID fGUID_ZAxis = { 0xA36D02E2 , 0xC9F3 , 0x11CF , { 0xBF , 0xC7 , 0x44 , 0x45 , 0x53 , 0x54 , 0x00 , 0x00 } } ;
static const GUID fGUID_SysMouse = { 0x6F1D2B60 , 0xD5A0 , 0x11CF , { 0xBF , 0xC7 , 0x44 , 0x45 , 0x53 , 0x54 , 0x00 , 0x00 } } ;
static const GUID fIID_IDirectInputDevice7A = { 0x57d7c6bc , 0x2356 , 0x11d3 , { 0x8e , 0x9d , 0x00 , 0xC0 , 0x4f , 0x68 , 0x44 , 0xae } } ;
static const GUID fIID_IDirectInput7A = { 0x9a4cb684 , 0x236d , 0x11d3 , { 0x8e , 0x9d , 0x00 , 0xc0 , 0x4f , 0x68 , 0x44 , 0xae } } ;
2005-06-18 22:30:57 +00:00
// devices
2012-10-14 09:00:49 +00:00
static LPDIRECTINPUT g_pdi ;
static LPDIRECTINPUTDEVICE g_pMouse ;
2004-08-23 00:15:46 +00:00
static HINSTANCE hInstDI ;
2005-06-18 22:30:57 +00:00
// current DirectInput version in use, 0 means using no DirectInput
2011-05-19 13:34:07 +00:00
static int dinput ;
2004-08-23 00:15:46 +00:00
typedef struct MYDATA {
LONG lX ; // X axis goes here
LONG lY ; // Y axis goes here
LONG lZ ; // Z axis goes here
BYTE bButtonA ; // One button goes here
BYTE bButtonB ; // Another button goes here
BYTE bButtonC ; // Another button goes here
BYTE bButtonD ; // Another button goes here
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
BYTE bButtonE ; // DX7 buttons
2011-05-19 13:34:07 +00:00
BYTE bButtonF ;
BYTE bButtonG ;
2005-06-18 22:30:57 +00:00
BYTE bButtonH ;
# endif
2004-08-23 00:15:46 +00:00
} MYDATA ;
static DIOBJECTDATAFORMAT rgodf [ ] = {
2009-11-04 21:16:50 +00:00
{ & fGUID_XAxis , FIELD_OFFSET ( MYDATA , lX ) , DIDFT_AXIS | DIDFT_ANYINSTANCE , 0 , } ,
{ & fGUID_YAxis , FIELD_OFFSET ( MYDATA , lY ) , DIDFT_AXIS | DIDFT_ANYINSTANCE , 0 , } ,
{ & fGUID_ZAxis , FIELD_OFFSET ( MYDATA , lZ ) , 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE , 0 , } ,
2004-08-23 00:15:46 +00:00
{ 0 , FIELD_OFFSET ( MYDATA , bButtonA ) , DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonB ) , DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonC ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonD ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
{ 0 , FIELD_OFFSET ( MYDATA , bButtonE ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonF ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonG ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
{ 0 , FIELD_OFFSET ( MYDATA , bButtonH ) , 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE , 0 , } ,
# endif
2004-08-23 00:15:46 +00:00
} ;
# define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
static DIDATAFORMAT df = {
sizeof ( DIDATAFORMAT ) , // this structure
sizeof ( DIOBJECTDATAFORMAT ) , // size of object data format
DIDF_RELAXIS , // absolute axis coordinates
sizeof ( MYDATA ) , // device data size
NUM_OBJECTS , // number of objects
rgodf , // and here they are
} ;
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
// DX7 devices
2012-10-14 09:00:49 +00:00
static LPDIRECTINPUT7 g_pdi7 ;
static LPDIRECTINPUTDEVICE7 g_pMouse7 ;
2005-06-18 22:30:57 +00:00
// DX7 specific calls
# define iDirectInputCreateEx(a,b,c,d,e) pDirectInputCreateEx(a,b,c,d,e)
static HRESULT ( WINAPI * pDirectInputCreateEx ) ( HINSTANCE hinst ,
DWORD dwVersion , REFIID riidltf , LPVOID * ppvOut , LPUNKNOWN punkOuter ) ;
# endif
2004-08-23 00:15:46 +00:00
# else
# define dinput 0
# endif
static JOYINFOEX ji ;
2005-06-29 21:20:34 +00:00
// raw input specific defines
# ifdef USINGRAWINPUT
// defines
# define MAX_RI_DEVICE_SIZE 128
# define INIT_RIBUFFER_SIZE (sizeof(RAWINPUTHEADER)+sizeof(RAWMOUSE))
# define RI_RAWBUTTON_MASK 0x000003E0
# define RI_INVALID_POS 0x80000000
// raw input dynamic functions
2005-08-03 23:14:59 +00:00
typedef INT ( WINAPI * pGetRawInputDeviceList ) ( OUT PRAWINPUTDEVICELIST pRawInputDeviceList , IN OUT PINT puiNumDevices , IN UINT cbSize ) ;
typedef INT ( WINAPI * pGetRawInputData ) ( IN HRAWINPUT hRawInput , IN UINT uiCommand , OUT LPVOID pData , IN OUT PINT pcbSize , IN UINT cbSizeHeader ) ;
typedef INT ( WINAPI * pGetRawInputDeviceInfoA ) ( IN HANDLE hDevice , IN UINT uiCommand , OUT LPVOID pData , IN OUT PINT pcbSize ) ;
typedef BOOL ( WINAPI * pRegisterRawInputDevices ) ( IN PCRAWINPUTDEVICE pRawInputDevices , IN UINT uiNumDevices , IN UINT cbSize ) ;
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
static pGetRawInputDeviceList _GRIDL ;
static pGetRawInputData _GRID ;
static pGetRawInputDeviceInfoA _GRIDIA ;
static pRegisterRawInputDevices _RRID ;
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
static keyboard_t * rawkbd ;
static mouse_t * rawmice ;
static int rawmicecount ;
static int rawkbdcount ;
static RAWINPUT * raw ;
static int ribuffersize ;
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
static cvar_t in_rawinput = CVARD ( " in_rawinput " , " 0 " , " Enables rawinput support for mice in XP onwards. Rawinput permits independant device identification (ie: splitscreen clients can each have their own mouse) " ) ;
static cvar_t in_rawinput_keyboard = CVARD ( " in_rawinput_keyboard " , " 0 " , " Enables rawinput support for keyboards in XP onwards as well as just mice. Requires in_rawinput to be set. " ) ;
static cvar_t in_rawinput_rdp = CVARD ( " in_rawinput_rdp " , " 0 " , " Activate Remote Desktop Protocol devices too. " ) ;
2005-12-11 03:22:43 +00:00
2012-10-14 09:00:49 +00:00
void INS_RawInput_MouseDeRegister ( void ) ;
int INS_RawInput_MouseRegister ( void ) ;
void INS_RawInput_KeyboardDeRegister ( void ) ;
int INS_RawInput_KeyboardRegister ( void ) ;
void INS_RawInput_DeInit ( void ) ;
2005-12-11 03:22:43 +00:00
2005-06-29 21:20:34 +00:00
# endif
2004-08-23 00:15:46 +00:00
// forward-referenced functions
2012-10-14 09:00:49 +00:00
void INS_StartupJoystick ( void ) ;
2004-08-23 00:15:46 +00:00
void Joy_AdvancedUpdate_f ( void ) ;
2012-10-14 09:00:49 +00:00
void INS_JoyMove ( float * movements , int pnum ) ;
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = =
Force_CenterView_f
= = = = = = = = = = =
*/
void Force_CenterView_f ( void )
{
2012-07-05 19:42:36 +00:00
cl . playerview [ 0 ] . viewangles [ PITCH ] = 0 ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_UpdateClipCursor
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_UpdateClipCursor ( void )
2004-08-23 00:15:46 +00:00
{
if ( mouseinitialized & & mouseactive & & ! dinput )
{
ClipCursor ( & window_rect ) ;
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_ShowMouse
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
static void INS_ShowMouse ( void )
2004-08-23 00:15:46 +00:00
{
if ( ! mouseshowtoggle )
{
ShowCursor ( TRUE ) ;
mouseshowtoggle = 1 ;
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_HideMouse
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
static void INS_HideMouse ( void )
2004-08-23 00:15:46 +00:00
{
if ( mouseshowtoggle )
{
ShowCursor ( FALSE ) ;
mouseshowtoggle = 0 ;
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_ActivateMouse
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
static void INS_ActivateMouse ( void )
2004-08-23 00:15:46 +00:00
{
mouseactivatetoggle = true ;
2009-04-01 22:03:56 +00:00
if ( mouseinitialized & & ! mouseactive )
2004-08-23 00:15:46 +00:00
{
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
if ( dinput > = DINPUT_VERSION_DX7 )
{
if ( g_pMouse7 )
{
if ( ! dinput_acquired )
{
IDirectInputDevice7_Acquire ( g_pMouse7 ) ;
dinput_acquired = true ;
}
}
else
{
return ;
}
}
else
# endif
2004-08-23 00:15:46 +00:00
if ( dinput )
{
if ( g_pMouse )
{
if ( ! dinput_acquired )
{
IDirectInputDevice_Acquire ( g_pMouse ) ;
dinput_acquired = true ;
}
}
else
{
return ;
}
}
else
# endif
{
2005-12-11 03:22:43 +00:00
# ifdef USINGRAWINPUT
if ( rawmicecount > 0 )
{
2012-10-14 09:00:49 +00:00
if ( INS_RawInput_MouseRegister ( ) )
2010-08-24 02:18:42 +00:00
{
2010-08-23 04:53:20 +00:00
Con_SafePrintf ( " Raw input: unable to register raw input for mice, deinitializing \n " ) ;
2012-10-14 09:00:49 +00:00
INS_RawInput_MouseDeRegister ( ) ;
2005-12-11 03:22:43 +00:00
}
}
2010-08-24 02:18:42 +00:00
if ( rawkbdcount > 0 )
{
2012-10-14 09:00:49 +00:00
if ( INS_RawInput_KeyboardRegister ( ) )
2010-08-24 02:18:42 +00:00
{
Con_SafePrintf ( " Raw input: unable to register raw input for keyboard, deinitializing \n " ) ;
2012-10-14 09:00:49 +00:00
INS_RawInput_KeyboardDeRegister ( ) ;
2010-08-24 02:18:42 +00:00
}
}
2005-12-11 03:22:43 +00:00
# endif
2004-08-23 00:15:46 +00:00
if ( mouseparmsvalid )
2013-09-22 06:26:40 +00:00
{
SystemParametersInfo ( SPI_SETMOUSE , 0 , newmouseparms , 0 ) ;
restore_spi = true ;
}
2004-08-23 00:15:46 +00:00
SetCursorPos ( window_center_x , window_center_y ) ;
SetCapture ( mainwindow ) ;
ClipCursor ( & window_rect ) ;
}
mouseactive = true ;
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
static void INS_DeactivateMouse ( void )
2004-08-23 00:15:46 +00:00
{
mouseactivatetoggle = false ;
2009-04-01 22:03:56 +00:00
if ( mouseinitialized & & mouseactive )
2004-08-23 00:15:46 +00:00
{
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
if ( dinput > = DINPUT_VERSION_DX7 )
{
if ( g_pMouse7 )
{
if ( dinput_acquired )
{
IDirectInputDevice_Unacquire ( g_pMouse7 ) ;
dinput_acquired = false ;
}
}
else
{
return ;
}
}
else
# endif
2004-08-23 00:15:46 +00:00
if ( dinput )
{
if ( g_pMouse )
{
if ( dinput_acquired )
{
IDirectInputDevice_Unacquire ( g_pMouse ) ;
dinput_acquired = false ;
}
}
}
else
# endif
{
2005-12-11 03:22:43 +00:00
# ifdef USINGRAWINPUT
if ( rawmicecount > 0 )
2012-10-14 09:00:49 +00:00
INS_RawInput_MouseDeRegister ( ) ;
2005-12-11 03:22:43 +00:00
# endif
2004-08-23 00:15:46 +00:00
if ( restore_spi )
SystemParametersInfo ( SPI_SETMOUSE , 0 , originalmouseparms , 0 ) ;
ClipCursor ( NULL ) ;
ReleaseCapture ( ) ;
}
mouseactive = false ;
}
}
2009-04-01 22:03:56 +00:00
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_SetQuakeMouseState
2009-04-01 22:03:56 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_SetQuakeMouseState ( void )
2009-04-01 22:03:56 +00:00
{
if ( mouseactivatetoggle )
2012-10-14 09:00:49 +00:00
INS_ActivateMouse ( ) ;
2009-04-01 22:03:56 +00:00
else
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
2009-04-01 22:03:56 +00:00
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_RestoreOriginalMouseState
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_RestoreOriginalMouseState ( void )
2004-08-23 00:15:46 +00:00
{
if ( mouseactivatetoggle )
{
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
2004-08-23 00:15:46 +00:00
mouseactivatetoggle = true ;
}
// try to redraw the cursor so it gets reinitialized, because sometimes it
// has garbage after the mode switch
ShowCursor ( TRUE ) ;
ShowCursor ( FALSE ) ;
}
2009-04-01 22:03:56 +00:00
2012-10-14 09:00:49 +00:00
void INS_UpdateGrabs ( int fullscreen , int activeapp )
2009-04-01 22:03:56 +00:00
{
int grabmouse ;
2009-07-17 15:34:16 +00:00
if ( ! activeapp )
grabmouse = false ;
2014-12-06 02:24:46 +00:00
else if ( fullscreen | | in_simulatemultitouch . ival | | _windowed_mouse . value )
2009-04-01 22:03:56 +00:00
{
if ( ! Key_MouseShouldBeFree ( ) )
grabmouse = true ;
else
grabmouse = false ;
}
else
grabmouse = false ;
2015-04-14 23:12:17 +00:00
if ( activeapp )
{
if ( ! SCR_HardwareCursorIsActive ( ) & & ( fullscreen | | in_simulatemultitouch . ival | | _windowed_mouse . value ) & & ( current_mouse_pos . x > = window_rect . left & & current_mouse_pos . y > = window_rect . top & & current_mouse_pos . x < = window_rect . right & & current_mouse_pos . y < = window_rect . bottom ) )
{
INS_HideMouse ( ) ;
}
else
{
INS_ShowMouse ( ) ;
grabmouse = false ;
}
}
2009-04-01 22:03:56 +00:00
else
2014-09-02 02:44:43 +00:00
{
2012-10-14 09:00:49 +00:00
INS_ShowMouse ( ) ;
2014-09-02 02:44:43 +00:00
grabmouse = false ;
}
2009-04-01 22:03:56 +00:00
# ifdef HLCLIENT
//halflife gamecode does its own mouse control... yes this is vile.
if ( grabmouse )
{
if ( CLHL_GamecodeDoesMouse ( ) )
grabmouse = 2 ;
}
if ( grabmouse = = 2 )
{
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
2009-04-01 22:03:56 +00:00
CLHL_SetMouseActive ( true ) ;
return ;
}
CLHL_SetMouseActive ( false ) ;
# endif
if ( grabmouse )
2012-10-14 09:00:49 +00:00
INS_ActivateMouse ( ) ;
2009-04-01 22:03:56 +00:00
else
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
2009-04-01 22:03:56 +00:00
}
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2015-04-14 23:12:17 +00:00
BOOL CALLBACK INS_EnumerateDI7Devices ( LPCDIDEVICEINSTANCE inst , LPVOID parm )
2004-08-23 00:15:46 +00:00
{
2006-01-28 23:22:17 +00:00
Con_DPrintf ( " EnumerateDevices found: %s \n " , inst - > tszProductName ) ;
2005-06-29 21:20:34 +00:00
return DIENUM_CONTINUE ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_InitDInput
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
int INS_InitDInput ( void )
2004-08-23 00:15:46 +00:00
{
HRESULT hr ;
DIPROPDWORD dipdw = {
{
sizeof ( DIPROPDWORD ) , // diph.dwSize
sizeof ( DIPROPHEADER ) , // diph.dwHeaderSize
0 , // diph.dwObj
DIPH_DEVICE , // diph.dwHow
} ,
DINPUT_BUFFERSIZE , // dwData
} ;
if ( ! hInstDI )
{
hInstDI = LoadLibrary ( " dinput.dll " ) ;
2011-05-19 13:34:07 +00:00
2004-08-23 00:15:46 +00:00
if ( hInstDI = = NULL )
{
Con_SafePrintf ( " Couldn't load dinput.dll \n " ) ;
2005-06-18 22:30:57 +00:00
return 0 ;
}
}
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
if ( ! pDirectInputCreateEx )
pDirectInputCreateEx = ( void * ) GetProcAddress ( hInstDI , " DirectInputCreateEx " ) ;
if ( pDirectInputCreateEx ) // use DirectInput 7
{
// register with DirectInput and get an IDirectInput to play with.
2009-11-04 21:16:50 +00:00
hr = iDirectInputCreateEx ( global_hInstance , DINPUT_VERSION_DX7 , & fIID_IDirectInput7A , & g_pdi7 , NULL ) ;
2005-06-18 22:30:57 +00:00
if ( FAILED ( hr ) )
return 0 ;
2015-04-14 23:12:17 +00:00
IDirectInput7_EnumDevices ( g_pdi7 , 0 , & INS_EnumerateDI7Devices , NULL , DIEDFL_ATTACHEDONLY ) ;
2005-06-18 22:30:57 +00:00
// obtain an interface to the system mouse device.
2009-11-04 21:16:50 +00:00
hr = IDirectInput7_CreateDeviceEx ( g_pdi7 , & fGUID_SysMouse , & fIID_IDirectInputDevice7A , & g_pMouse7 , NULL ) ;
2005-06-18 22:30:57 +00:00
if ( FAILED ( hr ) ) {
Con_SafePrintf ( " Couldn't open DI7 mouse device \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
2005-06-18 22:30:57 +00:00
// set the data format to "mouse format".
hr = IDirectInputDevice7_SetDataFormat ( g_pMouse7 , & df ) ;
if ( FAILED ( hr ) ) {
Con_SafePrintf ( " Couldn't set DI7 mouse format \n " ) ;
return 0 ;
}
// set the cooperativity level.
hr = IDirectInputDevice7_SetCooperativeLevel ( g_pMouse7 , mainwindow ,
DISCL_EXCLUSIVE | DISCL_FOREGROUND ) ;
if ( FAILED ( hr ) ) {
Con_SafePrintf ( " Couldn't set DI7 coop level \n " ) ;
return 0 ;
}
// set the buffer size to DINPUT_BUFFERSIZE elements.
// the buffer size is a DWORD property associated with the device
hr = IDirectInputDevice7_SetProperty ( g_pMouse7 , DIPROP_BUFFERSIZE , & dipdw . diph ) ;
if ( FAILED ( hr ) ) {
Con_SafePrintf ( " Couldn't set DI7 buffersize \n " ) ;
return 0 ;
}
return DINPUT_VERSION_DX7 ;
2004-08-23 00:15:46 +00:00
}
2005-06-18 22:30:57 +00:00
# endif
2004-08-23 00:15:46 +00:00
if ( ! pDirectInputCreate )
{
pDirectInputCreate = ( void * ) GetProcAddress ( hInstDI , " DirectInputCreateA " ) ;
if ( ! pDirectInputCreate )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " Couldn't get DI3 proc addr \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
}
// register with DirectInput and get an IDirectInput to play with.
2005-06-18 22:30:57 +00:00
hr = iDirectInputCreate ( global_hInstance , DINPUT_VERSION_DX3 , & g_pdi , NULL ) ;
2004-08-23 00:15:46 +00:00
if ( FAILED ( hr ) )
{
2005-06-18 22:30:57 +00:00
return 0 ;
2004-08-23 00:15:46 +00:00
}
2015-04-14 23:12:17 +00:00
IDirectInput_EnumDevices ( g_pdi , 0 , & INS_EnumerateDI7Devices , NULL , DIEDFL_ATTACHEDONLY ) ;
2004-08-23 00:15:46 +00:00
// obtain an interface to the system mouse device.
2009-11-04 21:16:50 +00:00
hr = IDirectInput_CreateDevice ( g_pdi , & fGUID_SysMouse , & g_pMouse , NULL ) ;
2004-08-23 00:15:46 +00:00
if ( FAILED ( hr ) )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " Couldn't open DI3 mouse device \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
// set the data format to "mouse format".
hr = IDirectInputDevice_SetDataFormat ( g_pMouse , & df ) ;
if ( FAILED ( hr ) )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " Couldn't set DI3 mouse format \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
// set the cooperativity level.
hr = IDirectInputDevice_SetCooperativeLevel ( g_pMouse , mainwindow ,
DISCL_EXCLUSIVE | DISCL_FOREGROUND ) ;
if ( FAILED ( hr ) )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " Couldn't set DI3 coop level \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
// set the buffer size to DINPUT_BUFFERSIZE elements.
// the buffer size is a DWORD property associated with the device
hr = IDirectInputDevice_SetProperty ( g_pMouse , DIPROP_BUFFERSIZE , & dipdw . diph ) ;
if ( FAILED ( hr ) )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " Couldn't set DI3 buffersize \n " ) ;
return 0 ;
2004-08-23 00:15:46 +00:00
}
2005-06-18 22:30:57 +00:00
return DINPUT_VERSION_DX3 ;
2004-08-23 00:15:46 +00:00
}
2012-10-14 09:00:49 +00:00
void INS_CloseDInput ( void )
2004-08-23 00:15:46 +00:00
{
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
if ( g_pMouse7 )
{
IDirectInputDevice7_Release ( g_pMouse7 ) ;
g_pMouse7 = NULL ;
}
if ( g_pdi7 )
{
IDirectInput7_Release ( g_pdi7 ) ;
g_pdi7 = NULL ;
}
# endif
2004-08-23 00:15:46 +00:00
if ( g_pMouse )
{
IDirectInputDevice_Release ( g_pMouse ) ;
g_pMouse = NULL ;
}
if ( g_pdi )
{
IDirectInput_Release ( g_pdi ) ;
g_pdi = NULL ;
}
if ( hInstDI )
{
FreeLibrary ( hInstDI ) ;
hInstDI = NULL ;
pDirectInputCreate = NULL ;
}
}
# endif
2005-06-29 21:20:34 +00:00
# ifdef USINGRAWINPUT
2012-10-14 09:00:49 +00:00
void INS_RawInput_MouseDeRegister ( void )
2005-06-29 21:20:34 +00:00
{
RAWINPUTDEVICE Rid ;
// deregister raw input
2011-05-19 13:34:07 +00:00
Rid . usUsagePage = 0x01 ;
Rid . usUsage = 0x02 ;
2005-06-29 21:20:34 +00:00
Rid . dwFlags = RIDEV_REMOVE ;
Rid . hwndTarget = NULL ;
( * _RRID ) ( & Rid , 1 , sizeof ( Rid ) ) ;
2005-12-11 03:22:43 +00:00
}
2012-10-14 09:00:49 +00:00
void INS_RawInput_KeyboardDeRegister ( void )
2005-12-11 03:22:43 +00:00
{
2010-08-23 04:53:20 +00:00
RAWINPUTDEVICE Rid ;
2005-12-11 03:22:43 +00:00
2010-08-23 04:53:20 +00:00
// deregister raw input
2011-05-19 13:34:07 +00:00
Rid . usUsagePage = 0x01 ;
2015-01-21 18:18:37 +00:00
Rid . usUsage = 0x06 ;
2010-08-23 04:53:20 +00:00
Rid . dwFlags = RIDEV_REMOVE ;
Rid . hwndTarget = NULL ;
2005-06-29 21:20:34 +00:00
2010-08-23 04:53:20 +00:00
( * _RRID ) ( & Rid , 1 , sizeof ( Rid ) ) ;
}
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
void INS_RawInput_DeInit ( void )
2010-08-23 04:53:20 +00:00
{
if ( rawmicecount > 0 )
2012-10-14 09:00:49 +00:00
INS_RawInput_MouseDeRegister ( ) ;
2010-08-23 04:53:20 +00:00
if ( rawkbdcount > 0 )
2012-10-14 09:00:49 +00:00
INS_RawInput_KeyboardDeRegister ( ) ;
2015-01-21 18:18:37 +00:00
rawmicecount = 0 ;
rawkbdcount = 0 ;
Z_Free ( rawmice ) ;
rawmice = NULL ;
Z_Free ( rawkbd ) ;
rawkbd = NULL ;
Z_Free ( raw ) ;
raw = NULL ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
memset ( multicursor_active , 0 , sizeof ( multicursor_active ) ) ;
2005-06-29 21:20:34 +00:00
}
# endif
# ifdef USINGRAWINPUT
// raw input registration functions
2012-10-14 09:00:49 +00:00
int INS_RawInput_MouseRegister ( void )
2005-06-29 21:20:34 +00:00
{
// This function registers to receive the WM_INPUT messages
2011-05-19 13:34:07 +00:00
RAWINPUTDEVICE Rid ; // Register only for mouse messages from wm_input.
2005-06-29 21:20:34 +00:00
//register to get wm_input messages
2011-05-19 13:34:07 +00:00
Rid . usUsagePage = 0x01 ;
Rid . usUsage = 0x02 ;
2005-06-29 21:20:34 +00:00
Rid . dwFlags = RIDEV_NOLEGACY ; // adds HID mouse and also ignores legacy mouse messages
Rid . hwndTarget = NULL ;
// Register to receive the WM_INPUT message for any change in mouse (buttons, wheel, and movement will all generate the same message)
if ( ! ( * _RRID ) ( & Rid , 1 , sizeof ( Rid ) ) )
2005-12-11 03:22:43 +00:00
return 1 ;
2005-06-29 21:20:34 +00:00
2005-12-11 03:22:43 +00:00
return 0 ;
2005-06-29 21:20:34 +00:00
}
2012-10-14 09:00:49 +00:00
int INS_RawInput_KeyboardRegister ( void )
2005-06-29 21:20:34 +00:00
{
2010-08-23 04:53:20 +00:00
RAWINPUTDEVICE Rid ;
2011-05-19 13:34:07 +00:00
Rid . usUsagePage = 0x01 ;
Rid . usUsage = 0x06 ;
2010-08-23 04:53:20 +00:00
Rid . dwFlags = RIDEV_NOLEGACY | RIDEV_APPKEYS | RIDEV_NOHOTKEYS ; // fetch everything, disable hotkey behavior (should cvar?)
Rid . hwndTarget = NULL ;
if ( ! ( * _RRID ) ( & Rid , 1 , sizeof ( Rid ) ) )
return 1 ;
return 0 ;
}
2012-10-14 09:00:49 +00:00
int INS_RawInput_Register ( void )
2010-08-23 04:53:20 +00:00
{
2012-10-14 09:00:49 +00:00
if ( INS_RawInput_MouseRegister ( ) )
return ! in_rawinput_keyboard . ival | | INS_RawInput_KeyboardRegister ( ) ;
2010-08-23 04:53:20 +00:00
return 0 ;
}
2012-10-14 09:00:49 +00:00
int INS_RawInput_IsRDPDevice ( char * cDeviceString )
2010-08-23 04:53:20 +00:00
{
// mouse is \\?\Root#RDP_MOU#, keyboard is \\?\Root#RDP_KBD#"
char cRDPString [ ] = " \\ \\ ? \\ Root#RDP_ " ;
2005-06-29 21:20:34 +00:00
int i ;
if ( strlen ( cDeviceString ) < strlen ( cRDPString ) ) {
return 0 ;
}
for ( i = strlen ( cRDPString ) - 1 ; i > = 0 ; i - - )
{
if ( cDeviceString [ i ] ! = cRDPString [ i ] )
return 0 ;
}
2010-08-23 04:53:20 +00:00
return 1 ;
2005-06-29 21:20:34 +00:00
}
2012-10-14 09:00:49 +00:00
void INS_RawInput_Init ( void )
2005-06-29 21:20:34 +00:00
{
// "0" to exclude, "1" to include
PRAWINPUTDEVICELIST pRawInputDeviceList ;
2010-08-23 04:53:20 +00:00
int inputdevices , i , j , mtemp , ktemp ;
2005-06-29 21:20:34 +00:00
char dname [ MAX_RI_DEVICE_SIZE ] ;
// Return 0 if rawinput is not available
HMODULE user32 = LoadLibrary ( " user32.dll " ) ;
if ( ! user32 )
{
Con_SafePrintf ( " Raw input: unable to load user32.dll \n " ) ;
return ;
}
_RRID = ( pRegisterRawInputDevices ) GetProcAddress ( user32 , " RegisterRawInputDevices " ) ;
if ( ! _RRID )
{
Con_SafePrintf ( " Raw input: function RegisterRawInputDevices could not be registered \n " ) ;
return ;
}
_GRIDL = ( pGetRawInputDeviceList ) GetProcAddress ( user32 , " GetRawInputDeviceList " ) ;
if ( ! _GRIDL )
{
Con_SafePrintf ( " Raw input: function GetRawInputDeviceList could not be registered \n " ) ;
return ;
}
_GRIDIA = ( pGetRawInputDeviceInfoA ) GetProcAddress ( user32 , " GetRawInputDeviceInfoA " ) ;
if ( ! _GRIDIA )
{
Con_SafePrintf ( " Raw input: function GetRawInputDeviceInfoA could not be registered \n " ) ;
return ;
}
_GRID = ( pGetRawInputData ) GetProcAddress ( user32 , " GetRawInputData " ) ;
if ( ! _GRID )
{
Con_SafePrintf ( " Raw input: function GetRawInputData could not be registered \n " ) ;
return ;
}
rawmicecount = 0 ;
rawmice = NULL ;
raw = NULL ;
ribuffersize = 0 ;
// 1st call to GetRawInputDeviceList: Pass NULL to get the number of devices.
if ( ( * _GRIDL ) ( NULL , & inputdevices , sizeof ( RAWINPUTDEVICELIST ) ) ! = 0 )
{
Con_SafePrintf ( " Raw input: unable to count raw input devices \n " ) ;
return ;
}
// Allocate the array to hold the DeviceList
pRawInputDeviceList = Z_Malloc ( sizeof ( RAWINPUTDEVICELIST ) * inputdevices ) ;
// 2nd call to GetRawInputDeviceList: Pass the pointer to our DeviceList and GetRawInputDeviceList() will fill the array
if ( ( * _GRIDL ) ( pRawInputDeviceList , & inputdevices , sizeof ( RAWINPUTDEVICELIST ) ) = = - 1 )
{
Con_SafePrintf ( " Raw input: unable to get raw input device list \n " ) ;
return ;
}
// Loop through all devices and count the mice
2010-08-23 04:53:20 +00:00
for ( i = 0 , mtemp = 0 , ktemp = 0 ; i < inputdevices ; i + + )
2005-06-29 21:20:34 +00:00
{
2010-08-23 04:53:20 +00:00
j = MAX_RI_DEVICE_SIZE ;
2005-06-29 21:20:34 +00:00
2010-08-23 04:53:20 +00:00
// Get the device name and use it to determine if it's the RDP Terminal Services virtual device.
if ( ( * _GRIDIA ) ( pRawInputDeviceList [ i ] . hDevice , RIDI_DEVICENAME , dname , & j ) < 0 )
dname [ 0 ] = 0 ;
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
if ( ! ( in_rawinput_rdp . value ) & & INS_RawInput_IsRDPDevice ( dname ) ) // use rdp (cvar)
2010-08-23 04:53:20 +00:00
continue ;
2005-06-29 21:20:34 +00:00
2010-08-23 04:53:20 +00:00
switch ( pRawInputDeviceList [ i ] . dwType )
{
case RIM_TYPEMOUSE :
2005-06-29 21:20:34 +00:00
mtemp + + ;
2010-08-23 04:53:20 +00:00
break ;
case RIM_TYPEKEYBOARD :
if ( ! in_rawinput_keyboard . ival )
continue ;
ktemp + + ;
break ;
default : // (RIM_TYPEHID) support joysticks?
break ;
2005-06-29 21:20:34 +00:00
}
}
// exit out if no devices found
2010-08-23 04:53:20 +00:00
if ( ! mtemp & & ! ktemp )
2005-06-29 21:20:34 +00:00
{
Con_SafePrintf ( " Raw input: no usable device found \n " ) ;
return ;
}
// Loop again and bind devices
2010-08-23 04:53:20 +00:00
rawmice = ( mouse_t * ) Z_Malloc ( sizeof ( mouse_t ) * mtemp ) ;
rawkbd = ( keyboard_t * ) Z_Malloc ( sizeof ( keyboard_t ) * ktemp ) ;
2005-06-29 21:20:34 +00:00
for ( i = 0 ; i < inputdevices ; i + + )
{
2010-08-23 04:53:20 +00:00
j = MAX_RI_DEVICE_SIZE ;
2005-06-29 21:20:34 +00:00
2010-08-23 04:53:20 +00:00
// Get the device name and use it to determine if it's the RDP Terminal Services virtual device.
if ( ( * _GRIDIA ) ( pRawInputDeviceList [ i ] . hDevice , RIDI_DEVICENAME , dname , & j ) < 0 )
dname [ 0 ] = 0 ;
2005-06-29 21:20:34 +00:00
2012-10-14 09:00:49 +00:00
if ( ! ( in_rawinput_rdp . value ) & & INS_RawInput_IsRDPDevice ( dname ) ) // use rdp (cvar)
2010-08-23 04:53:20 +00:00
continue ;
2005-06-29 21:20:34 +00:00
2010-08-23 04:53:20 +00:00
switch ( pRawInputDeviceList [ i ] . dwType )
2011-05-19 13:34:07 +00:00
{
2010-08-23 04:53:20 +00:00
case RIM_TYPEMOUSE :
2005-06-29 21:20:34 +00:00
// set handle
2006-02-17 02:51:59 +00:00
rawmice [ rawmicecount ] . handles . rawinputhandle = pRawInputDeviceList [ i ] . hDevice ;
2005-06-29 21:20:34 +00:00
rawmice [ rawmicecount ] . numbuttons = 10 ;
2012-02-12 05:18:31 +00:00
rawmice [ rawmicecount ] . qdeviceid = rawmicecount ;
2005-06-29 21:20:34 +00:00
rawmicecount + + ;
2010-08-23 04:53:20 +00:00
break ;
case RIM_TYPEKEYBOARD :
if ( ! in_rawinput_keyboard . ival )
continue ;
rawkbd [ rawkbdcount ] . handles . rawinputhandle = pRawInputDeviceList [ i ] . hDevice ;
2012-02-12 05:18:31 +00:00
rawkbd [ rawkbdcount ] . qdeviceid = rawkbdcount ;
2010-08-23 04:53:20 +00:00
rawkbdcount + + ;
break ;
default :
continue ;
}
// print pretty message about device
dname [ MAX_RI_DEVICE_SIZE - 1 ] = 0 ;
for ( mtemp = strlen ( dname ) ; mtemp > = 0 ; mtemp - - )
{
if ( dname [ mtemp ] = = ' # ' )
{
dname [ mtemp + 1 ] = 0 ;
break ;
}
2005-06-29 21:20:34 +00:00
}
2011-05-19 13:34:07 +00:00
Con_SafePrintf ( " Raw input type %i: [%i] %s \n " , ( int ) pRawInputDeviceList [ i ] . dwType , i , dname ) ;
2005-06-29 21:20:34 +00:00
}
2011-05-19 13:34:07 +00:00
2005-06-29 21:20:34 +00:00
// free the RAWINPUTDEVICELIST
Z_Free ( pRawInputDeviceList ) ;
// alloc raw input buffer
raw = BZ_Malloc ( INIT_RIBUFFER_SIZE ) ;
ribuffersize = INIT_RIBUFFER_SIZE ;
2010-08-23 04:53:20 +00:00
Con_SafePrintf ( " Raw input: initialized with %i mice and %i keyboards \n " , rawmicecount , rawkbdcount ) ;
2005-06-29 21:20:34 +00:00
return ; // success
}
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_StartupMouse
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_StartupMouse ( void )
2004-08-23 00:15:46 +00:00
{
2011-05-19 13:34:07 +00:00
if ( COM_CheckParm ( " -nomouse " ) )
return ;
2004-08-23 00:15:46 +00:00
mouseinitialized = true ;
2009-08-04 23:56:43 +00:00
//make sure it can't get stuck
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
2009-08-04 23:56:43 +00:00
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2004-08-23 00:15:46 +00:00
if ( in_dinput . value )
{
2012-10-14 09:00:49 +00:00
dinput = INS_InitDInput ( ) ;
2004-08-23 00:15:46 +00:00
if ( dinput )
{
2005-06-18 22:30:57 +00:00
Con_SafePrintf ( " DirectInput initialized, version %i \n " , ( dinput > > 8 & 0xFF ) ) ;
2004-08-23 00:15:46 +00:00
}
else
{
Con_SafePrintf ( " DirectInput not initialized \n " ) ;
}
}
2005-01-04 12:01:48 +00:00
else
2005-06-18 22:30:57 +00:00
dinput = 0 ;
2004-08-23 00:15:46 +00:00
if ( ! dinput )
# endif
{
if ( ! mouseparmsvalid )
mouseparmsvalid = SystemParametersInfo ( SPI_GETMOUSE , 0 , originalmouseparms , 0 ) ;
if ( mouseparmsvalid )
{
2011-05-19 13:34:07 +00:00
if ( m_accel_noforce . value )
2004-08-23 00:15:46 +00:00
newmouseparms [ 2 ] = originalmouseparms [ 2 ] ;
2011-05-19 13:34:07 +00:00
if ( m_threshold_noforce . value )
2004-08-23 00:15:46 +00:00
{
newmouseparms [ 0 ] = originalmouseparms [ 0 ] ;
newmouseparms [ 1 ] = originalmouseparms [ 1 ] ;
}
}
}
sysmouse . numbuttons = 10 ;
// if a fullscreen video mode was set before the mouse was initialized,
// set the mouse state appropriately
if ( mouseactivatetoggle )
2012-10-14 09:00:49 +00:00
INS_ActivateMouse ( ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_Init
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_ReInit ( void )
2006-05-10 22:12:20 +00:00
{
2010-08-23 04:53:20 +00:00
# ifdef USINGRAWINPUT
if ( in_rawinput . value )
{
2012-10-14 09:00:49 +00:00
INS_RawInput_Init ( ) ;
2010-08-23 04:53:20 +00:00
}
# endif
2012-10-14 09:00:49 +00:00
INS_StartupMouse ( ) ;
INS_StartupJoystick ( ) ;
// INS_ActivateMouse();
2006-05-10 22:12:20 +00:00
}
2012-10-14 09:00:49 +00:00
void INS_Init ( void )
2004-08-23 00:15:46 +00:00
{
2006-05-10 22:12:20 +00:00
//keyboard variables
Cvar_Register ( & cl_keypad , " Input Controls " ) ;
2004-08-23 00:15:46 +00:00
2006-05-10 22:12:20 +00:00
Cvar_Register ( & in_dinput , " Input Controls " ) ;
2009-07-05 18:45:53 +00:00
Cvar_Register ( & in_builtinkeymap , " Input Controls " ) ;
2014-04-24 01:53:01 +00:00
Cvar_Register ( & in_nonstandarddeadkeys , " Input Controls " ) ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
Cvar_Register ( & in_simulatemultitouch , " Input Controls " ) ;
2004-08-23 00:15:46 +00:00
2006-05-10 22:12:20 +00:00
Cvar_Register ( & m_accel_noforce , " Input Controls " ) ;
Cvar_Register ( & m_threshold_noforce , " Input Controls " ) ;
2005-08-06 22:39:28 +00:00
2006-05-10 22:12:20 +00:00
// this looks strange but quake cmdline definitions
// and MS documentation don't agree with each other
if ( COM_CheckParm ( " -noforcemspd " ) )
Cvar_Set ( & m_accel_noforce , " 1 " ) ;
2005-08-06 22:39:28 +00:00
2006-05-10 22:12:20 +00:00
if ( COM_CheckParm ( " -noforcemaccel " ) )
Cvar_Set ( & m_threshold_noforce , " 1 " ) ;
2005-08-06 22:39:28 +00:00
2006-05-10 22:12:20 +00:00
if ( COM_CheckParm ( " -noforcemparms " ) )
{
Cvar_Set ( & m_accel_noforce , " 1 " ) ;
Cvar_Set ( & m_threshold_noforce , " 1 " ) ;
}
2005-08-06 22:39:28 +00:00
2006-05-10 22:12:20 +00:00
if ( COM_CheckParm ( " -dinput " ) )
Cvar_Set ( & in_dinput , " 1 " ) ;
2004-08-23 00:15:46 +00:00
2011-05-19 13:34:07 +00:00
// joystick variables
2006-05-10 22:12:20 +00:00
Cvar_Register ( & in_joystick , " Joystick variables " ) ;
Cvar_Register ( & joy_name , " Joystick variables " ) ;
Cvar_Register ( & joy_advanced , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisx , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisy , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisz , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisr , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisu , " Joystick variables " ) ;
Cvar_Register ( & joy_advaxisv , " Joystick variables " ) ;
Cvar_Register ( & joy_forwardthreshold , " Joystick variables " ) ;
Cvar_Register ( & joy_sidethreshold , " Joystick variables " ) ;
Cvar_Register ( & joy_pitchthreshold , " Joystick variables " ) ;
Cvar_Register ( & joy_yawthreshold , " Joystick variables " ) ;
Cvar_Register ( & joy_forwardsensitivity , " Joystick variables " ) ;
Cvar_Register ( & joy_sidesensitivity , " Joystick variables " ) ;
Cvar_Register ( & joy_pitchsensitivity , " Joystick variables " ) ;
Cvar_Register ( & joy_yawsensitivity , " Joystick variables " ) ;
Cvar_Register ( & joy_wwhack1 , " Joystick variables " ) ;
Cvar_Register ( & joy_wwhack2 , " Joystick variables " ) ;
Cmd_AddCommand ( " force_centerview " , Force_CenterView_f ) ;
Cmd_AddCommand ( " joyadvancedupdate " , Joy_AdvancedUpdate_f ) ;
2013-11-21 23:02:28 +00:00
uiWheelMessage = RegisterWindowMessageA ( " MSWHEEL_ROLLMSG " ) ;
2005-06-29 21:20:34 +00:00
# ifdef USINGRAWINPUT
2006-05-10 22:12:20 +00:00
Cvar_Register ( & in_rawinput , " Input Controls " ) ;
2010-08-23 04:53:20 +00:00
Cvar_Register ( & in_rawinput_keyboard , " Input Controls " ) ;
2006-05-10 22:12:20 +00:00
Cvar_Register ( & in_rawinput_rdp , " Input Controls " ) ;
2005-06-29 21:20:34 +00:00
# endif
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_Shutdown
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_Shutdown ( void )
2004-08-23 00:15:46 +00:00
{
2012-10-14 09:00:49 +00:00
INS_DeactivateMouse ( ) ;
INS_ShowMouse ( ) ;
2004-08-23 00:15:46 +00:00
2013-09-22 06:26:40 +00:00
mouseinitialized = false ;
2004-08-23 00:15:46 +00:00
mouseparmsvalid = false ;
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2012-10-14 09:00:49 +00:00
INS_CloseDInput ( ) ;
2004-08-23 00:15:46 +00:00
# endif
2005-06-29 21:20:34 +00:00
# ifdef USINGRAWINPUT
2012-10-14 09:00:49 +00:00
INS_RawInput_DeInit ( ) ;
2005-06-29 21:20:34 +00:00
# endif
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_MouseEvent
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
a mouse button was pressed / released , mstate is the current set of buttons pressed .
2004-08-23 00:15:46 +00:00
*/
2012-10-14 09:00:49 +00:00
void INS_MouseEvent ( int mstate )
2004-08-23 00:15:46 +00:00
{
int i ;
2009-07-25 11:05:06 +00:00
if ( dinput & & mouseactive )
2009-04-01 22:03:56 +00:00
return ;
# ifdef HLCLIENT
if ( CLHL_MouseEvent ( mstate ) )
return ;
# endif
2009-07-25 11:05:06 +00:00
if ( 1 ) //mouseactive || (key_dest != key_game))
2004-08-23 00:15:46 +00:00
{
// perform button actions
for ( i = 0 ; i < sysmouse . numbuttons ; i + + )
{
if ( ( mstate & ( 1 < < i ) ) & &
! ( sysmouse . oldbuttons & ( 1 < < i ) ) )
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( 0 , true , K_MOUSE1 + i , 0 ) ;
2004-08-23 00:15:46 +00:00
}
if ( ! ( mstate & ( 1 < < i ) ) & &
( sysmouse . oldbuttons & ( 1 < < i ) ) )
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( 0 , false , K_MOUSE1 + i , 0 ) ;
2004-08-23 00:15:46 +00:00
}
2011-05-19 13:34:07 +00:00
}
2004-08-23 00:15:46 +00:00
sysmouse . oldbuttons = mstate ;
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_MouseMove
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_MouseMove ( float * movements , int pnum )
2004-08-23 00:15:46 +00:00
{
2009-03-07 04:37:24 +00:00
# ifdef AVAIL_DINPUT
2012-11-27 03:23:19 +00:00
if ( dinput & & mouseactive )
2004-08-23 00:15:46 +00:00
{
DIDEVICEOBJECTDATA od ;
DWORD dwElements ;
HRESULT hr ;
2012-10-14 09:00:49 +00:00
int xd = 0 , yd = 0 , zd = 0 ;
2004-08-23 00:15:46 +00:00
for ( ; ; )
{
dwElements = 1 ;
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
if ( dinput > = DINPUT_VERSION_DX7 )
{
hr = IDirectInputDevice7_GetDeviceData ( g_pMouse7 ,
sizeof ( DIDEVICEOBJECTDATA ) , & od , & dwElements , 0 ) ;
2004-08-23 00:15:46 +00:00
2005-06-18 22:30:57 +00:00
if ( ( hr = = DIERR_INPUTLOST ) | | ( hr = = DIERR_NOTACQUIRED ) )
{
dinput_acquired = true ;
IDirectInputDevice7_Acquire ( g_pMouse7 ) ;
break ;
}
}
else
# endif
2004-08-23 00:15:46 +00:00
{
2005-06-18 22:30:57 +00:00
hr = IDirectInputDevice_GetDeviceData ( g_pMouse ,
sizeof ( DIDEVICEOBJECTDATA ) , & od , & dwElements , 0 ) ;
if ( ( hr = = DIERR_INPUTLOST ) | | ( hr = = DIERR_NOTACQUIRED ) )
{
dinput_acquired = true ;
IDirectInputDevice_Acquire ( g_pMouse ) ;
break ;
}
2004-08-23 00:15:46 +00:00
}
/* Unable to read data or no data available */
if ( FAILED ( hr ) | | dwElements = = 0 )
{
break ;
}
/* Look at the element to see what happened */
switch ( od . dwOfs )
{
case DIMOFS_X :
2012-10-14 09:00:49 +00:00
xd + = od . dwData ;
2004-08-23 00:15:46 +00:00
break ;
case DIMOFS_Y :
2012-10-14 09:00:49 +00:00
yd + = od . dwData ;
2004-08-23 00:15:46 +00:00
break ;
2004-09-20 23:25:38 +00:00
case DIMOFS_Z :
2012-10-14 09:00:49 +00:00
zd + = od . dwData ;
2004-09-20 23:25:38 +00:00
break ;
2004-08-23 00:15:46 +00:00
case DIMOFS_BUTTON0 :
case DIMOFS_BUTTON1 :
case DIMOFS_BUTTON2 :
2004-09-20 23:25:38 +00:00
case DIMOFS_BUTTON3 :
2005-06-18 22:30:57 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
2004-09-20 23:25:38 +00:00
case DIMOFS_BUTTON4 :
case DIMOFS_BUTTON5 :
case DIMOFS_BUTTON6 :
case DIMOFS_BUTTON7 :
# endif
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( sysmouse . qdeviceid , ( od . dwData & 0x80 ) ? true : false , K_MOUSE1 + ( ( od . dwOfs - DIMOFS_BUTTON0 ) / ( DIMOFS_BUTTON1 - DIMOFS_BUTTON0 ) ) , 0 ) ;
break ;
2004-08-23 00:15:46 +00:00
}
}
2012-10-14 09:00:49 +00:00
if ( xd | | yd | | zd )
IN_MouseMove ( sysmouse . qdeviceid , false , xd , yd , zd , 0 ) ;
2004-08-23 00:15:46 +00:00
}
else
# endif
{
2012-10-14 09:00:49 +00:00
INS_Accumulate ( ) ;
2005-06-29 21:20:34 +00:00
}
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_Move
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_Move ( float * movements , int pnum )
2004-08-23 00:15:46 +00:00
{
if ( ActiveApp & & ! Minimized )
{
2012-10-14 09:00:49 +00:00
INS_MouseMove ( movements , pnum ) ;
2014-07-12 06:56:17 +00:00
INS_JoyMove ( movements , pnum ) ;
2004-08-23 00:15:46 +00:00
}
2015-04-14 23:12:17 +00:00
else
INS_Accumulate ( ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_Accumulate
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
potentially called multiple times per frame .
2004-08-23 00:15:46 +00:00
*/
2012-10-14 09:00:49 +00:00
void INS_Accumulate ( void )
2004-08-23 00:15:46 +00:00
{
if ( mouseactive & & ! dinput )
{
2005-06-29 21:20:34 +00:00
# ifdef USINGRAWINPUT
2012-10-14 09:00:49 +00:00
//raw input disables the system mouse, to avoid dupes
if ( ! rawmicecount )
2005-06-29 21:20:34 +00:00
# endif
{
2015-04-14 23:12:17 +00:00
GetCursorPos ( & current_mouse_pos ) ;
2015-04-21 04:12:00 +00:00
SetCursorPos ( window_center_x , window_center_y ) ;
2004-08-23 00:15:46 +00:00
2015-04-14 23:12:17 +00:00
IN_MouseMove ( sysmouse . qdeviceid , false , current_mouse_pos . x - window_center_x , current_mouse_pos . y - window_center_y , 0 , 0 ) ;
2005-06-29 21:20:34 +00:00
}
2015-04-21 04:12:00 +00:00
else
{
// force the mouse to the center, so there's room to move (rawinput ignore this apparently)
SetCursorPos ( window_center_x , window_center_y ) ;
}
2004-08-23 00:15:46 +00:00
}
2012-10-14 09:00:49 +00:00
if ( ! mouseactive )
{
extern int window_x , window_y ;
2015-04-14 23:12:17 +00:00
GetCursorPos ( & current_mouse_pos ) ;
2012-10-14 09:00:49 +00:00
2015-04-14 23:12:17 +00:00
IN_MouseMove ( sysmouse . qdeviceid , true , current_mouse_pos . x - window_x , current_mouse_pos . y - window_y , 0 , 0 ) ;
2012-10-14 09:00:49 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
}
2005-06-29 21:20:34 +00:00
# ifdef USINGRAWINPUT
2012-10-14 09:00:49 +00:00
void INS_RawInput_MouseRead ( void )
2005-06-29 21:20:34 +00:00
{
2010-08-23 04:53:20 +00:00
int i , tbuttons , j ;
2012-02-12 05:18:31 +00:00
mouse_t * mouse ;
2005-06-29 21:20:34 +00:00
// find mouse in our mouse list
2010-08-23 04:53:20 +00:00
for ( i = 0 ; i < rawmicecount ; i + + )
2005-06-29 21:20:34 +00:00
{
2006-02-17 02:51:59 +00:00
if ( rawmice [ i ] . handles . rawinputhandle = = raw - > header . hDevice )
2005-06-29 21:20:34 +00:00
break ;
}
2010-08-23 04:53:20 +00:00
if ( i = = rawmicecount ) // we're not tracking this device
2005-06-29 21:20:34 +00:00
return ;
2012-02-12 05:18:31 +00:00
mouse = & rawmice [ i ] ;
2010-08-14 00:15:07 +00:00
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
multicursor_active [ mouse - > qdeviceid & 7 ] = 0 ;
2005-06-29 21:20:34 +00:00
// movement
if ( raw - > data . mouse . usFlags & MOUSE_MOVE_ABSOLUTE )
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( in_simulatemultitouch . ival )
{
multicursor_active [ mouse - > qdeviceid & 7 ] = true ;
multicursor_x [ mouse - > qdeviceid & 7 ] = raw - > data . mouse . lLastX ;
multicursor_y [ mouse - > qdeviceid & 7 ] = raw - > data . mouse . lLastY ;
}
2012-10-14 09:00:49 +00:00
IN_MouseMove ( mouse - > qdeviceid , true , raw - > data . mouse . lLastX , raw - > data . mouse . lLastY , 0 , 0 ) ;
2005-06-29 21:20:34 +00:00
}
else // RELATIVE
{
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( in_simulatemultitouch . ival )
{
multicursor_active [ mouse - > qdeviceid & 7 ] = true ;
multicursor_x [ mouse - > qdeviceid & 7 ] + = raw - > data . mouse . lLastX ;
multicursor_y [ mouse - > qdeviceid & 7 ] + = raw - > data . mouse . lLastY ;
multicursor_x [ mouse - > qdeviceid & 7 ] = bound ( 0 , multicursor_x [ mouse - > qdeviceid & 7 ] , vid . pixelwidth ) ;
multicursor_y [ mouse - > qdeviceid & 7 ] = bound ( 0 , multicursor_y [ mouse - > qdeviceid & 7 ] , vid . pixelheight ) ;
IN_MouseMove ( mouse - > qdeviceid , true , multicursor_x [ mouse - > qdeviceid & 7 ] , multicursor_y [ mouse - > qdeviceid & 7 ] , 0 , 0 ) ;
}
else
IN_MouseMove ( mouse - > qdeviceid , false , raw - > data . mouse . lLastX , raw - > data . mouse . lLastY , 0 , 0 ) ;
2005-06-29 21:20:34 +00:00
}
// buttons
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_1_DOWN )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE1 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_1_UP )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE1 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_2_DOWN )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE2 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_2_UP )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE2 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_3_DOWN )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE3 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_3_UP )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE3 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_4_DOWN )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE4 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_4_UP )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE4 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_5_DOWN )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE5 , 0 ) ;
2011-05-19 13:34:07 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_BUTTON_5_UP )
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE5 , 0 ) ;
2005-06-29 21:20:34 +00:00
// mouse wheel
2009-01-18 01:47:48 +00:00
if ( raw - > data . mouse . usButtonFlags & RI_MOUSE_WHEEL )
2006-02-17 02:51:59 +00:00
{ // If the current message has a mouse_wheel message
2011-05-19 13:34:07 +00:00
if ( ( SHORT ) raw - > data . mouse . usButtonData > 0 )
2006-02-17 02:51:59 +00:00
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MWHEELUP , 0 ) ;
IN_KeyEvent ( mouse - > qdeviceid , false , K_MWHEELUP , 0 ) ;
2005-06-29 21:20:34 +00:00
}
2009-01-18 01:47:48 +00:00
if ( ( SHORT ) raw - > data . mouse . usButtonData < 0 )
2006-02-17 02:51:59 +00:00
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MWHEELDOWN , 0 ) ;
IN_KeyEvent ( mouse - > qdeviceid , false , K_MWHEELDOWN , 0 ) ;
2005-06-29 21:20:34 +00:00
}
}
// extra buttons
tbuttons = raw - > data . mouse . ulRawButtons & RI_RAWBUTTON_MASK ;
for ( j = 6 ; j < rawmice [ i ] . numbuttons ; j + + )
{
2012-10-14 09:00:49 +00:00
if ( ( tbuttons & ( 1 < < j ) ) & & ! ( rawmice [ i ] . oldbuttons & ( 1 < < j ) ) )
2005-06-29 21:20:34 +00:00
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , true , K_MOUSE1 + j , 0 ) ;
2005-06-29 21:20:34 +00:00
}
2012-10-14 09:00:49 +00:00
if ( ! ( tbuttons & ( 1 < < j ) ) & & ( rawmice [ i ] . oldbuttons & ( 1 < < j ) ) )
2005-06-29 21:20:34 +00:00
{
2012-10-14 09:00:49 +00:00
IN_KeyEvent ( mouse - > qdeviceid , false , K_MOUSE1 + j , 0 ) ;
2005-06-29 21:20:34 +00:00
}
}
2012-10-14 09:00:49 +00:00
rawmice [ i ] . oldbuttons & = ~ RI_RAWBUTTON_MASK ;
rawmice [ i ] . oldbuttons | = tbuttons ;
2005-06-29 21:20:34 +00:00
}
2010-08-23 04:53:20 +00:00
2012-10-14 09:00:49 +00:00
void INS_RawInput_KeyboardRead ( void )
2010-08-23 04:53:20 +00:00
{
int i ;
qboolean down ;
WPARAM wParam ;
LPARAM lParam ;
for ( i = 0 ; i < rawkbdcount ; i + + )
{
if ( rawkbd [ i ] . handles . rawinputhandle = = raw - > header . hDevice )
break ;
}
if ( i = = rawkbdcount ) // not tracking this device
return ;
down = ! ( raw - > data . keyboard . Flags & RI_KEY_BREAK ) ;
2015-01-21 18:18:37 +00:00
wParam = raw - > data . keyboard . VKey ; //(-down) & 0xC0000000;
lParam = ( MapVirtualKey ( raw - > data . keyboard . VKey , 0 ) < < 16 ) | ( ( ! ! ( raw - > data . keyboard . Flags & RI_KEY_E0 ) ) < < 24 ) ;
2010-08-23 04:53:20 +00:00
2015-01-21 18:18:37 +00:00
INS_TranslateKeyEvent ( wParam , lParam , down , rawkbd [ i ] . qdeviceid , true ) ;
2010-08-23 04:53:20 +00:00
}
2012-10-14 09:00:49 +00:00
void INS_RawInput_Read ( HANDLE in_device_handle )
2010-08-23 04:53:20 +00:00
{
int dwSize ;
// get raw input
2011-05-19 13:34:07 +00:00
if ( ( * _GRID ) ( ( HRAWINPUT ) in_device_handle , RID_INPUT , NULL , & dwSize , sizeof ( RAWINPUTHEADER ) ) = = - 1 )
2010-08-23 04:53:20 +00:00
{
Con_Printf ( " Raw input: unable to add to get size of raw input header. \n " ) ;
return ;
}
if ( dwSize > ribuffersize )
{
ribuffersize = dwSize ;
raw = ( RAWINPUT * ) BZ_Realloc ( raw , dwSize ) ;
}
2011-05-19 13:34:07 +00:00
2010-08-23 04:53:20 +00:00
if ( ( * _GRID ) ( ( HRAWINPUT ) in_device_handle , RID_INPUT , raw , & dwSize , sizeof ( RAWINPUTHEADER ) ) ! = dwSize ) {
Con_Printf ( " Raw input: unable to add to get raw input header. \n " ) ;
return ;
}
2012-10-14 09:00:49 +00:00
INS_RawInput_MouseRead ( ) ;
INS_RawInput_KeyboardRead ( ) ;
2010-08-23 04:53:20 +00:00
}
2005-06-29 21:20:34 +00:00
# else
2012-10-14 09:00:49 +00:00
void INS_RawInput_Read ( HANDLE in_device_handle )
2005-06-29 21:20:34 +00:00
{
}
# endif
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_ClearStates
2004-08-23 00:15:46 +00:00
= = = = = = = = = = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_ClearStates ( void )
2004-08-23 00:15:46 +00:00
{
if ( mouseactive )
{
memset ( & sysmouse , 0 , sizeof ( sysmouse ) ) ;
sysmouse . numbuttons = 10 ;
}
}
2011-05-19 13:34:07 +00:00
/*
= = = = = = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_StartupJoystick
2011-05-19 13:34:07 +00:00
= = = = = = = = = = = = = = =
*/
2014-07-12 06:56:17 +00:00
static void INS_StartupJoystickId ( unsigned int id )
2011-05-19 13:34:07 +00:00
{
2004-08-23 00:15:46 +00:00
JOYCAPS jc ;
MMRESULT mmr ;
2014-07-12 06:56:17 +00:00
struct wjoy_s * joy ;
if ( joy_count = = MAX_JOYSTICKS )
return ;
joy = & wjoy [ joy_count ] ;
memset ( joy , 0 , sizeof ( * joy ) ) ;
joy - > id = id ;
joy - > devid = 1 + joy_count ; //FIXME: this is a hack. make joysticks 1-based. this means mouse0 controls 1st player, joy0 controls 2nd player (controls wrap so joy1 controls 1st player too.
// get the capabilities of the selected joystick
// abort startup if command fails
memset ( & jc , 0 , sizeof ( jc ) ) ;
if ( ( mmr = joyGetDevCaps ( joy - > id , & jc , sizeof ( jc ) ) ) ! = JOYERR_NOERROR )
{
Con_Printf ( " joystick %03x not found -- invalid joystick capabilities (%x) \n " , id , mmr ) ;
return ;
}
// save the joystick's number of buttons and POV status
joy - > numbuttons = jc . wNumButtons ;
joy - > haspov = jc . wCaps & JOYCAPS_HASPOV ;
// mark the joystick as available and advanced initialization not completed
// this is needed as cvars are not available during initialization
joy_advancedinit = false ;
joy_count + + ;
}
void INS_StartupJoystick ( void )
{
unsigned int id , numdevs ;
MMRESULT mmr ;
2011-05-19 13:34:07 +00:00
2014-07-12 06:56:17 +00:00
// assume no joysticks
joy_count = 0 ;
2004-08-23 00:15:46 +00:00
// abort startup if user requests no joystick
2011-05-19 13:34:07 +00:00
if ( COM_CheckParm ( " -nojoy " ) )
return ;
2004-08-23 00:15:46 +00:00
// verify joystick driver is present
if ( ( numdevs = joyGetNumDevs ( ) ) = = 0 )
{
2009-07-05 18:45:53 +00:00
Con_Printf ( " joystick not found -- driver not present \n " ) ;
2004-08-23 00:15:46 +00:00
return ;
}
mmr = JOYERR_UNPLUGGED ;
// cycle through the joystick ids for the first valid one
2014-07-12 06:56:17 +00:00
for ( id = 0 ; id < numdevs ; id + + )
2004-08-23 00:15:46 +00:00
{
memset ( & ji , 0 , sizeof ( ji ) ) ;
ji . dwSize = sizeof ( ji ) ;
ji . dwFlags = JOY_RETURNCENTERED ;
2014-07-12 06:56:17 +00:00
if ( ( mmr = joyGetPosEx ( id , & ji ) ) = = JOYERR_NOERROR )
{
INS_StartupJoystickId ( id ) ;
}
2004-08-23 00:15:46 +00:00
}
2014-10-05 20:04:11 +00:00
if ( joy_count )
Con_Printf ( " found %i joysticks \n " , joy_count ) ;
else
Con_DPrintf ( " found no joysticks \n " ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = =
Joy_AdvancedUpdate_f
= = = = = = = = = = =
*/
void Joy_AdvancedUpdate_f ( void )
{
2012-10-14 09:00:49 +00:00
// called once by INS_ReadJoystick and by user whenever an update is needed
2004-08-23 00:15:46 +00:00
// cvars are now available
int i ;
DWORD dwTemp ;
// initialize all the maps
for ( i = 0 ; i < JOY_MAX_AXES ; i + + )
{
dwAxisMap [ i ] = AxisNada ;
dwControlMap [ i ] = JOY_ABSOLUTE_AXIS ;
}
if ( joy_advanced . value = = 0.0 )
{
// default joystick initialization
// 2 axes only with joystick control
dwAxisMap [ JOY_AXIS_X ] = AxisTurn ;
// dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
dwAxisMap [ JOY_AXIS_Y ] = AxisForward ;
// dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
}
else
{
if ( Q_strcmp ( joy_name . string , " joystick " ) ! = 0 )
{
// notify user of advanced controller
Con_Printf ( " \n %s configured \n \n " , joy_name . string ) ;
}
// advanced initialization here
// data supplied by user via joy_axisn cvars
dwTemp = ( DWORD ) joy_advaxisx . value ;
dwAxisMap [ JOY_AXIS_X ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_X ] = dwTemp & JOY_RELATIVE_AXIS ;
dwTemp = ( DWORD ) joy_advaxisy . value ;
dwAxisMap [ JOY_AXIS_Y ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_Y ] = dwTemp & JOY_RELATIVE_AXIS ;
dwTemp = ( DWORD ) joy_advaxisz . value ;
dwAxisMap [ JOY_AXIS_Z ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_Z ] = dwTemp & JOY_RELATIVE_AXIS ;
dwTemp = ( DWORD ) joy_advaxisr . value ;
dwAxisMap [ JOY_AXIS_R ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_R ] = dwTemp & JOY_RELATIVE_AXIS ;
dwTemp = ( DWORD ) joy_advaxisu . value ;
dwAxisMap [ JOY_AXIS_U ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_U ] = dwTemp & JOY_RELATIVE_AXIS ;
dwTemp = ( DWORD ) joy_advaxisv . value ;
dwAxisMap [ JOY_AXIS_V ] = dwTemp & 0x0000000f ;
dwControlMap [ JOY_AXIS_V ] = dwTemp & JOY_RELATIVE_AXIS ;
}
// compute the axes to collect from DirectInput
joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV ;
for ( i = 0 ; i < JOY_MAX_AXES ; i + + )
{
if ( dwAxisMap [ i ] ! = AxisNada )
{
joy_flags | = dwAxisFlags [ i ] ;
}
}
}
/*
= = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_Commands
2004-08-23 00:15:46 +00:00
= = = = = = = = = = =
*/
2012-10-14 09:00:49 +00:00
void INS_Commands ( void )
2004-08-23 00:15:46 +00:00
{
int i , key_index ;
DWORD buttonstate , povstate ;
2014-07-12 06:56:17 +00:00
unsigned int idx ;
struct wjoy_s * joy ;
2004-08-23 00:15:46 +00:00
2014-07-12 06:56:17 +00:00
for ( idx = 0 ; idx < joy_count ; idx + + )
2004-08-23 00:15:46 +00:00
{
2014-07-12 06:56:17 +00:00
joy = & wjoy [ idx ] ;
2011-05-19 13:34:07 +00:00
2014-07-12 06:56:17 +00:00
// loop through the joystick buttons
// key a joystick event or auxillary event for higher number buttons for each state change
buttonstate = joy - > buttonstate ;
for ( i = 0 ; i < joy - > numbuttons ; i + + )
2004-08-23 00:15:46 +00:00
{
2014-07-12 06:56:17 +00:00
if ( ( buttonstate & ( 1 < < i ) ) & & ! ( joy - > oldbuttonstate & ( 1 < < i ) ) )
{
key_index = ( i < 4 ) ? K_JOY1 : K_AUX1 ;
Key_Event ( joy - > devid , key_index + i , 0 , true ) ;
}
2004-08-23 00:15:46 +00:00
2014-07-12 06:56:17 +00:00
if ( ! ( buttonstate & ( 1 < < i ) ) & & ( joy - > oldbuttonstate & ( 1 < < i ) ) )
{
key_index = ( i < 4 ) ? K_JOY1 : K_AUX1 ;
Key_Event ( joy - > devid , key_index + i , 0 , false ) ;
}
2004-08-23 00:15:46 +00:00
}
2014-07-12 06:56:17 +00:00
joy - > oldbuttonstate = buttonstate ;
2004-08-23 00:15:46 +00:00
2014-07-12 06:56:17 +00:00
if ( joy - > haspov )
2004-08-23 00:15:46 +00:00
{
2014-07-12 06:56:17 +00:00
// convert POV information into 4 bits of state information
// this avoids any potential problems related to moving from one
// direction to another without going through the center position
povstate = 0 ;
if ( joy - > povstate ! = JOY_POVCENTERED )
2004-08-23 00:15:46 +00:00
{
2014-07-12 06:56:17 +00:00
if ( joy - > povstate = = JOY_POVFORWARD )
povstate | = 0x01 ;
if ( joy - > povstate = = JOY_POVRIGHT )
povstate | = 0x02 ;
if ( joy - > povstate = = JOY_POVBACKWARD )
povstate | = 0x04 ;
if ( joy - > povstate = = JOY_POVLEFT )
povstate | = 0x08 ;
2004-08-23 00:15:46 +00:00
}
2014-07-12 06:56:17 +00:00
// determine which bits have changed and key an auxillary event for each change
for ( i = 0 ; i < 4 ; i + + )
2004-08-23 00:15:46 +00:00
{
2014-07-12 06:56:17 +00:00
if ( ( povstate & ( 1 < < i ) ) & & ! ( joy - > oldpovstate & ( 1 < < i ) ) )
{
Key_Event ( joy - > devid , K_AUX29 + i , 0 , true ) ;
}
if ( ! ( povstate & ( 1 < < i ) ) & & ( joy - > oldpovstate & ( 1 < < i ) ) )
{
Key_Event ( joy - > devid , K_AUX29 + i , 0 , false ) ;
}
2004-08-23 00:15:46 +00:00
}
2014-07-12 06:56:17 +00:00
joy - > oldpovstate = povstate ;
2004-08-23 00:15:46 +00:00
}
}
}
2011-05-19 13:34:07 +00:00
/*
= = = = = = = = = = = = = = =
2012-10-14 09:00:49 +00:00
INS_ReadJoystick
2011-05-19 13:34:07 +00:00
= = = = = = = = = = = = = = =
*/
2014-07-12 06:56:17 +00:00
qboolean INS_ReadJoystick ( struct wjoy_s * joy )
2004-08-23 00:15:46 +00:00
{
memset ( & ji , 0 , sizeof ( ji ) ) ;
ji . dwSize = sizeof ( ji ) ;
ji . dwFlags = joy_flags ;
2014-07-12 06:56:17 +00:00
if ( joyGetPosEx ( joy - > id , & ji ) = = JOYERR_NOERROR )
2004-08-23 00:15:46 +00:00
{
// this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
// rather than having 32768 be the zero point, they have the zero point at 32668
// go figure -- anyway, now we get the full resolution out of the device
if ( joy_wwhack1 . value ! = 0.0 )
{
ji . dwUpos + = 100 ;
}
2014-07-12 06:56:17 +00:00
joy - > povstate = ji . dwPOV ;
joy - > buttonstate = ji . dwButtons ;
joy - > axis [ JOY_AXIS_X ] = ji . dwXpos ;
joy - > axis [ JOY_AXIS_Y ] = ji . dwYpos ;
joy - > axis [ JOY_AXIS_Z ] = ji . dwZpos ;
joy - > axis [ JOY_AXIS_R ] = ji . dwRpos ;
joy - > axis [ JOY_AXIS_U ] = ji . dwUpos ;
joy - > axis [ JOY_AXIS_V ] = ji . dwVpos ;
2004-08-23 00:15:46 +00:00
return true ;
}
else
{
2015-04-14 23:12:17 +00:00
joy - > povstate = 0 ;
joy - > buttonstate = 0 ;
joy - > axis [ JOY_AXIS_X ] = 32768 ;
joy - > axis [ JOY_AXIS_Y ] = 32768 ;
joy - > axis [ JOY_AXIS_Z ] = 32768 ;
joy - > axis [ JOY_AXIS_R ] = 32768 ;
joy - > axis [ JOY_AXIS_U ] = 32768 ;
joy - > axis [ JOY_AXIS_V ] = 32768 ;
2004-08-23 00:15:46 +00:00
// read error occurred
2004-09-13 04:16:52 +00:00
// turning off the joystick seems too harsh for 1 read error,
2004-08-23 00:15:46 +00:00
// but what should be done?
2012-10-14 09:00:49 +00:00
// Con_Printf ("INS_ReadJoystick: no response\n");
2004-08-23 00:15:46 +00:00
// joy_avail = false;
return false ;
}
}
2014-07-12 06:56:17 +00:00
static void INS_JoyMovePtr ( struct wjoy_s * joy , float * movements , int pnum )
2004-08-23 00:15:46 +00:00
{
float speed , aspeed ;
float fAxisValue , fTemp ;
int i ;
2014-07-12 06:56:17 +00:00
int wpnum ;
/*each device will be processed when its player comes to be processed*/
wpnum = cl . splitclients ;
if ( wpnum < 1 )
wpnum = 1 ;
2015-03-03 00:14:43 +00:00
if ( cl_forceseat . ival )
wpnum = ( cl_forceseat . ival - 1 ) % wpnum ;
2014-07-12 06:56:17 +00:00
else
wpnum = joy - > devid % wpnum ;
if ( wpnum ! = pnum )
2011-05-19 13:34:07 +00:00
return ;
2014-07-12 06:56:17 +00:00
2011-05-19 13:34:07 +00:00
2004-08-23 00:15:46 +00:00
// collect the joystick data, if possible
2014-07-12 06:56:17 +00:00
if ( INS_ReadJoystick ( joy ) ! = true )
2004-08-23 00:15:46 +00:00
{
return ;
}
if ( in_speed . state [ pnum ] & 1 )
speed = cl_movespeedkey . value ;
else
speed = 1 ;
aspeed = speed * host_frametime ;
// loop through the axes
for ( i = 0 ; i < JOY_MAX_AXES ; i + + )
{
// get the floating point zero-centered, potentially-inverted data for the current axis
2014-07-12 06:56:17 +00:00
fAxisValue = ( float ) joy - > axis [ i ] ;
2004-08-23 00:15:46 +00:00
// move centerpoint to zero
fAxisValue - = 32768.0 ;
if ( joy_wwhack2 . value ! = 0.0 )
{
if ( dwAxisMap [ i ] = = AxisTurn )
{
// this is a special formula for the Logitech WingMan Warrior
// y=ax^b; where a = 300 and b = 1.3
// also x values are in increments of 800 (so this is factored out)
// then bounds check result to level out excessively high spin rates
fTemp = 300.0 * pow ( abs ( fAxisValue ) / 800.0 , 1.3 ) ;
if ( fTemp > 14000.0 )
fTemp = 14000.0 ;
// restore direction information
fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : - fTemp ;
}
}
2011-05-19 13:34:07 +00:00
// convert range from -32768..32767 to -1..1
2004-08-23 00:15:46 +00:00
fAxisValue / = 32768.0 ;
2014-06-27 16:19:22 +00:00
# ifdef CSQC_DAT
2014-07-12 06:56:17 +00:00
if ( CSQC_JoystickAxis ( i , fAxisValue , joy - > devid ) )
2014-06-27 16:10:10 +00:00
continue ;
2014-06-27 16:19:22 +00:00
# endif
2014-06-27 16:10:10 +00:00
2004-08-23 00:15:46 +00:00
switch ( dwAxisMap [ i ] )
{
case AxisForward :
if ( ( joy_advanced . value = = 0.0 ) & & ( in_mlook . state [ pnum ] & 1 ) )
{
// user wants forward control to become look control
if ( fabs ( fAxisValue ) > joy_pitchthreshold . value )
2011-05-19 13:34:07 +00:00
{
2004-08-23 00:15:46 +00:00
// if mouse invert is on, invert the joystick pitch value
// only absolute control support here (joy_advanced is false)
if ( m_pitch . value < 0.0 )
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ PITCH ] - = ( fAxisValue * joy_pitchsensitivity . value ) * aspeed * cl_pitchspeed . value ;
2004-08-23 00:15:46 +00:00
}
else
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ PITCH ] + = ( fAxisValue * joy_pitchsensitivity . value ) * aspeed * cl_pitchspeed . value ;
2004-08-23 00:15:46 +00:00
}
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
else
{
// no pitch movement
// disable pitch return-to-center unless requested by user
// *** this code can be removed when the lookspring bug is fixed
// *** the bug always has the lookspring feature on
if ( lookspring . value = = 0.0 )
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
}
else
{
// user wants forward control to be forward control
if ( fabs ( fAxisValue ) > joy_forwardthreshold . value )
{
2009-05-24 10:11:17 +00:00
movements [ 0 ] + = ( fAxisValue * joy_forwardsensitivity . value ) * speed * cl_forwardspeed . value ;
2004-08-23 00:15:46 +00:00
}
}
break ;
case AxisSide :
if ( fabs ( fAxisValue ) > joy_sidethreshold . value )
{
2009-05-24 10:11:17 +00:00
movements [ 1 ] + = ( fAxisValue * joy_sidesensitivity . value ) * speed * cl_sidespeed . value ;
2004-08-23 00:15:46 +00:00
}
break ;
case AxisTurn :
if ( ( in_strafe . state [ pnum ] & 1 ) | | ( lookstrafe . value & & ( in_mlook . state [ pnum ] & 1 ) ) )
{
// user wants turn control to become side control
if ( fabs ( fAxisValue ) > joy_sidethreshold . value )
{
2009-05-24 10:11:17 +00:00
movements [ 2 ] - = ( fAxisValue * joy_sidesensitivity . value ) * speed * cl_sidespeed . value ;
2004-08-23 00:15:46 +00:00
}
}
else
{
// user wants turn control to be turn control
if ( fabs ( fAxisValue ) > joy_yawthreshold . value )
{
if ( dwControlMap [ i ] = = JOY_ABSOLUTE_AXIS )
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ YAW ] + = ( fAxisValue * joy_yawsensitivity . value ) * aspeed * cl_yawspeed . value ;
2004-08-23 00:15:46 +00:00
}
else
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ YAW ] + = ( fAxisValue * joy_yawsensitivity . value ) * speed * 180.0 ;
2004-08-23 00:15:46 +00:00
}
}
}
break ;
case AxisLook :
if ( in_mlook . state [ pnum ] & 1 )
{
if ( fabs ( fAxisValue ) > joy_pitchthreshold . value )
{
// pitch movement detected and pitch movement desired by user
if ( dwControlMap [ i ] = = JOY_ABSOLUTE_AXIS )
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ PITCH ] + = ( fAxisValue * joy_pitchsensitivity . value ) * aspeed * cl_pitchspeed . value ;
2004-08-23 00:15:46 +00:00
}
else
{
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ PITCH ] + = ( fAxisValue * joy_pitchsensitivity . value ) * speed * 180.0 ;
2004-08-23 00:15:46 +00:00
}
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
else
{
// no pitch movement
// disable pitch return-to-center unless requested by user
// *** this code can be removed when the lookspring bug is fixed
// *** the bug always has the lookspring feature on
if ( lookspring . value = = 0.0 )
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
}
break ;
default :
break ;
}
}
CL_ClampPitch ( pnum ) ;
}
2014-07-12 06:56:17 +00:00
/*
= = = = = = = = = = =
INS_JoyMove
= = = = = = = = = = =
*/
void INS_JoyMove ( float * movements , int pnum )
{
unsigned int idx ;
// complete initialization if first time in
// this is needed as cvars are not available at initialization time
if ( joy_advancedinit ! = true )
{
Joy_AdvancedUpdate_f ( ) ;
joy_advancedinit = true ;
}
// verify joystick is available and that the user wants to use it
if ( ! in_joystick . value )
return ;
for ( idx = 0 ; idx < joy_count ; idx + + )
{
2015-04-14 23:12:17 +00:00
INS_JoyMovePtr ( & wjoy [ idx ] , movements , pnum ) ;
2014-07-12 06:56:17 +00:00
}
}
2004-08-23 00:15:46 +00:00
2015-04-14 23:12:17 +00:00
void INS_EnumerateDevices ( void * ctx , void ( * callback ) ( void * ctx , char * type , char * devicename , int * qdevid ) )
{
int idx ;
for ( idx = 0 ; idx < rawmicecount ; idx + + )
callback ( ctx , " mouse " , va ( " raw%i " , idx ) , & rawmice [ idx ] . qdeviceid ) ;
for ( idx = 0 ; idx < rawkbdcount ; idx + + )
2015-04-21 23:11:26 +00:00
callback ( ctx , " keyboard " , va ( " raw%i " , idx ) , & rawkbd [ idx ] . qdeviceid ) ;
2015-04-14 23:12:17 +00:00
2015-04-21 23:11:26 +00:00
# if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
2015-04-14 23:12:17 +00:00
if ( dinput > = DINPUT_VERSION_DX7 & & g_pMouse7 )
callback ( ctx , " mouse " , " di7 " , NULL ) ;
2015-04-21 23:11:26 +00:00
else
# endif
if ( dinput & & g_pMouse )
2015-04-14 23:12:17 +00:00
callback ( ctx , " mouse " , " di " , NULL ) ;
callback ( ctx , " mouse " , " system " , NULL ) ;
for ( idx = 0 ; idx < joy_count ; idx + + )
callback ( ctx , " joy " , va ( " mmj%i " , idx ) , & wjoy [ idx ] . devid ) ;
}
2013-05-11 14:02:55 +00:00
static qbyte scantokey [ ] =
{
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0 , 27 , ' 1 ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , // 0
' 7 ' , ' 8 ' , ' 9 ' , ' 0 ' , ' - ' , ' = ' , K_BACKSPACE , 9 , // 0
' q ' , ' w ' , ' e ' , ' r ' , ' t ' , ' y ' , ' u ' , ' i ' , // 1
' o ' , ' p ' , ' [ ' , ' ] ' , K_ENTER , K_LCTRL , ' a ' , ' s ' , // 1
' d ' , ' f ' , ' g ' , ' h ' , ' j ' , ' k ' , ' l ' , ' ; ' , // 2
' \' ' , ' ` ' , K_LSHIFT , ' \\ ' , ' z ' , ' x ' , ' c ' , ' v ' , // 2
' b ' , ' n ' , ' m ' , ' , ' , ' . ' , ' / ' , K_RSHIFT , K_KP_STAR , // 3
K_LALT , ' ' , K_CAPSLOCK , K_F1 , K_F2 , K_F3 , K_F4 , K_F5 , // 3
K_F6 , K_F7 , K_F8 , K_F9 , K_F10 , K_PAUSE , K_SCRLCK , K_KP_HOME , // 4
K_KP_UPARROW , K_KP_PGUP , K_KP_MINUS , K_KP_LEFTARROW , K_KP_5 , K_KP_RIGHTARROW , K_KP_PLUS , K_KP_END , // 4
K_KP_DOWNARROW , K_KP_PGDN , K_KP_INS , K_KP_DEL , 0 , 0 , 0 , K_F11 , // 5
K_F12 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 5
0 , 0 , 0 , 0 , 0 , ' \\ ' , 0 , 0 , // 6
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 6
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 7
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 7
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 8
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 8
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 9
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 9
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // a
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // a
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // b
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // b
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // c
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // c
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // d
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // d
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // e
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // e
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // f
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // f
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0 , 27 , ' 1 ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , // 0
' 7 ' , ' 8 ' , ' 9 ' , ' 0 ' , ' - ' , ' = ' , K_BACKSPACE , 9 , // 0
' q ' , ' w ' , ' e ' , ' r ' , ' t ' , ' y ' , ' u ' , ' i ' , // 1
' o ' , ' p ' , ' [ ' , ' ] ' , K_KP_ENTER , K_RCTRL , ' a ' , ' s ' , // 1
' d ' , ' f ' , ' g ' , ' h ' , ' j ' , ' k ' , ' l ' , ' ; ' , // 2
' \' ' , ' ` ' , K_SHIFT , ' \\ ' , ' z ' , ' x ' , ' c ' , ' v ' , // 2
' b ' , ' n ' , ' m ' , ' , ' , ' . ' , K_KP_SLASH , K_SHIFT , K_PRINTSCREEN , // 3
K_RALT , ' ' , K_CAPSLOCK , K_F1 , K_F2 , K_F3 , K_F4 , K_F5 , // 3
K_F6 , K_F7 , K_F8 , K_F9 , K_F10 , K_KP_NUMLOCK , K_SCRLCK , K_HOME , // 4
K_UPARROW , K_PGUP , ' - ' , K_LEFTARROW , 0 , K_RIGHTARROW , ' + ' , K_END , // 4
K_DOWNARROW , K_PGDN , K_INS , K_DEL , 0 , 0 , 0 , K_F11 , // 5
K_F12 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 5
0 , 0 , 0 , 0 , 0 , ' \\ ' , 0 , 0 , // 6
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 6
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 7
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
} ;
2004-08-23 00:15:46 +00:00
/*
= = = = = = =
MapKey
Map from windows to quake keynums
= = = = = = =
*/
2009-07-05 18:45:53 +00:00
static int MapKey ( int vkey )
2004-08-23 00:15:46 +00:00
{
int key ;
2013-05-11 14:02:55 +00:00
key = ( vkey > > 16 ) & 511 ;
2004-08-23 00:15:46 +00:00
2013-05-11 14:02:55 +00:00
if ( key < sizeof ( scantokey ) / sizeof ( scantokey [ 0 ] ) )
key = scantokey [ key ] ;
else
key = 0 ;
if ( ! cl_keypad . ival )
2004-08-23 00:15:46 +00:00
{
2013-05-20 02:18:50 +00:00
switch ( key )
2004-08-23 00:15:46 +00:00
{
2013-05-11 14:02:55 +00:00
case K_KP_HOME : return ' 7 ' ;
case K_KP_UPARROW : return ' 8 ' ;
case K_KP_PGUP : return ' 9 ' ;
case K_KP_LEFTARROW : return ' 4 ' ;
case K_KP_5 : return ' 5 ' ;
case K_KP_RIGHTARROW : return ' 6 ' ;
case K_KP_END : return ' 1 ' ;
case K_KP_DOWNARROW : return ' 2 ' ;
case K_KP_PGDN : return ' 3 ' ;
case K_KP_ENTER : return K_ENTER ;
case K_KP_INS : return ' 0 ' ;
case K_KP_DEL : return ' . ' ;
case K_KP_SLASH : return ' / ' ;
case K_KP_MINUS : return ' - ' ;
case K_KP_PLUS : return ' + ' ;
case K_KP_STAR : return ' * ' ;
case K_KP_EQUALS : return ' = ' ;
2004-08-23 00:15:46 +00:00
}
}
2013-05-11 14:02:55 +00:00
if ( key = = 0 )
2004-08-23 00:15:46 +00:00
Con_DPrintf ( " key 0x%02x has no translation \n " , key ) ;
2013-05-11 14:02:55 +00:00
return key ;
2004-08-23 00:15:46 +00:00
}
2009-07-05 18:45:53 +00:00
2015-01-21 18:18:37 +00:00
void INS_TranslateKeyEvent ( WPARAM wParam , LPARAM lParam , qboolean down , int qdeviceid , qboolean genkeystate )
2009-07-05 18:45:53 +00:00
{
extern cvar_t in_builtinkeymap ;
int qcode ;
int unicode ;
2014-04-24 01:53:01 +00:00
int chars ;
2012-02-27 12:23:15 +00:00
extern int keyshift [ 256 ] ;
extern int shift_down ;
2009-07-05 18:45:53 +00:00
qcode = MapKey ( lParam ) ;
if ( WinNT & & ! in_builtinkeymap . value )
{
BYTE keystate [ 256 ] ;
WCHAR wchars [ 2 ] ;
2015-01-21 18:18:37 +00:00
if ( genkeystate )
{
extern qboolean keydown [ K_MAX ] ;
memset ( keystate , 0 , sizeof ( keystate ) ) ;
//128 for held.
//1 for toggled (ie: caps / num)
keystate [ VK_LSHIFT ] = 128 * ! ! keydown [ K_LSHIFT ] ;
keystate [ VK_RSHIFT ] = 128 * ! ! keydown [ K_RSHIFT ] ;
keystate [ VK_LCONTROL ] = 128 * ! ! keydown [ K_LCTRL ] ;
keystate [ VK_RCONTROL ] = 128 * ! ! keydown [ K_RCTRL ] ;
keystate [ VK_LMENU ] = 128 * ! ! keydown [ K_LALT ] ;
keystate [ VK_RMENU ] = 128 * ! ! keydown [ K_RALT ] ;
//seems to matter
keystate [ VK_SHIFT ] = keystate [ VK_LSHIFT ] | keystate [ VK_RSHIFT ] ;
keystate [ VK_CONTROL ] = keystate [ VK_LCONTROL ] | keystate [ VK_RCONTROL ] ;
keystate [ VK_MENU ] = keystate [ VK_LMENU ] | keystate [ VK_RMENU ] ;
keystate [ VK_NUMLOCK ] = 1 ; //doesn't seem to matter?
}
else
GetKeyboardState ( keystate ) ;
2014-04-24 01:53:01 +00:00
chars = ToUnicode ( wParam , HIWORD ( lParam ) , keystate , wchars , sizeof ( wchars ) / sizeof ( wchars [ 0 ] ) , 0 ) ;
if ( chars > 0 )
2009-07-05 18:45:53 +00:00
{
2014-04-24 01:53:01 +00:00
if ( ! in_nonstandarddeadkeys . ival )
{
for ( unicode = 0 ; unicode < chars - 1 ; unicode + + )
Key_Event ( qdeviceid , 0 , wchars [ unicode ] , down ) ;
}
unicode = wchars [ chars - 1 ] ;
2009-07-05 18:45:53 +00:00
}
2012-02-27 12:23:15 +00:00
else unicode = 0 ;
}
else
{
unicode = ( qcode < 128 ) ? qcode : 0 ;
if ( shift_down & & unicode < K_MAX & & keyshift [ unicode ] )
unicode = keyshift [ unicode ] ;
2009-07-05 18:45:53 +00:00
}
2012-02-12 05:18:31 +00:00
Key_Event ( qdeviceid , qcode , unicode , down ) ;
2009-07-05 18:45:53 +00:00
}
2014-03-30 08:55:06 +00:00
# endif