Roman Chistokhodov
7 years ago
7 changed files with 204 additions and 57 deletions
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
#include "input_mouse.h" |
||||
#include "exportdef.h" |
||||
#include "hud.h" |
||||
|
||||
// shared between backends
|
||||
Vector dead_viewangles(0, 0, 0); |
||||
cvar_t *sensitivity; |
||||
cvar_t *in_joystick; |
||||
|
||||
FWGSInput fwgsInput; |
||||
|
||||
#ifdef SUPPORT_GOLDSOURCE_INPUT |
||||
GoldSourceInput goldSourceInput; |
||||
AbstractInput* currentInput = &goldSourceInput; |
||||
#else |
||||
AbstractInput* currentInput = &fwgsInput; |
||||
#endif |
||||
extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ) |
||||
{ |
||||
currentInput->IN_ClientMoveEvent(forwardmove, sidemove); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ) |
||||
{ |
||||
currentInput->IN_ClientLookEvent(relyaw, relpitch); |
||||
} |
||||
|
||||
void IN_Move( float frametime, usercmd_t *cmd ) |
||||
{ |
||||
currentInput->IN_Move(frametime, cmd); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) |
||||
{ |
||||
currentInput->IN_MouseEvent(mstate); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_ClearStates( void ) |
||||
{ |
||||
currentInput->IN_ClearStates(); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_ActivateMouse( void ) |
||||
{ |
||||
currentInput->IN_ActivateMouse(); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_DeactivateMouse( void ) |
||||
{ |
||||
currentInput->IN_DeactivateMouse(); |
||||
} |
||||
|
||||
extern "C" void DLLEXPORT IN_Accumulate( void ) |
||||
{ |
||||
currentInput->IN_Accumulate(); |
||||
} |
||||
|
||||
void IN_Commands( void ) |
||||
{ |
||||
currentInput->IN_Commands(); |
||||
} |
||||
|
||||
void IN_Shutdown( void ) |
||||
{ |
||||
currentInput->IN_Shutdown(); |
||||
} |
||||
|
||||
void IN_Init( void ) |
||||
{ |
||||
#ifdef SUPPORT_GOLDSOURCE_INPUT |
||||
if (gMobileEngfuncs) { |
||||
gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); |
||||
currentInput = &fwgsInput; |
||||
} else { |
||||
gEngfuncs.Con_Printf( "GoldSource input is in use\n" ); |
||||
currentInput = &goldSourceInput; |
||||
} |
||||
#else |
||||
currentInput = &fwgsInput; |
||||
#endif |
||||
currentInput->IN_Init(); |
||||
} |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
#ifndef INPUT_MOUSE_H |
||||
#define INPUT_MOUSE_H |
||||
#include "cl_dll.h" |
||||
#include "usercmd.h" |
||||
#include "in_defs.h" |
||||
|
||||
class AbstractInput |
||||
{ |
||||
public: |
||||
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) = 0; |
||||
virtual void IN_ClientLookEvent( float relyaw, float relpitch ) = 0; |
||||
virtual void IN_Move( float frametime, usercmd_t *cmd ) = 0; |
||||
virtual void IN_MouseEvent( int mstate ) = 0; |
||||
virtual void IN_ClearStates( void ) = 0; |
||||
virtual void IN_ActivateMouse( void ) = 0; |
||||
virtual void IN_DeactivateMouse( void ) = 0; |
||||
virtual void IN_Accumulate( void ) = 0; |
||||
virtual void IN_Commands( void ) = 0; |
||||
virtual void IN_Shutdown( void ) = 0; |
||||
virtual void IN_Init( void ) = 0; |
||||
}; |
||||
|
||||
class FWGSInput : public AbstractInput |
||||
{ |
||||
public: |
||||
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ); |
||||
virtual void IN_ClientLookEvent( float relyaw, float relpitch ); |
||||
virtual void IN_Move( float frametime, usercmd_t *cmd ); |
||||
virtual void IN_MouseEvent( int mstate ); |
||||
virtual void IN_ClearStates( void ); |
||||
virtual void IN_ActivateMouse( void ); |
||||
virtual void IN_DeactivateMouse( void ); |
||||
virtual void IN_Accumulate( void ); |
||||
virtual void IN_Commands( void ); |
||||
virtual void IN_Shutdown( void ); |
||||
virtual void IN_Init( void ); |
||||
|
||||
protected: |
||||
float ac_forwardmove; |
||||
float ac_sidemove; |
||||
int ac_movecount; |
||||
float rel_yaw; |
||||
float rel_pitch; |
||||
}; |
||||
|
||||
// No need for goldsource input support on the platforms that are not supported by GoldSource.
|
||||
#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) |
||||
#define SUPPORT_GOLDSOURCE_INPUT |
||||
class GoldSourceInput : public AbstractInput |
||||
{ |
||||
public: |
||||
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) {} |
||||
virtual void IN_ClientLookEvent( float relyaw, float relpitch ) {} |
||||
virtual void IN_Move( float frametime, usercmd_t *cmd ); |
||||
virtual void IN_MouseEvent( int mstate ); |
||||
virtual void IN_ClearStates( void ); |
||||
virtual void IN_ActivateMouse( void ); |
||||
virtual void IN_DeactivateMouse( void ); |
||||
virtual void IN_Accumulate( void ); |
||||
virtual void IN_Commands( void ); |
||||
virtual void IN_Shutdown( void ); |
||||
virtual void IN_Init( void ); |
||||
|
||||
protected: |
||||
void IN_GetMouseDelta( int *pOutX, int *pOutY); |
||||
void IN_MouseMove ( float frametime, usercmd_t *cmd); |
||||
void IN_StartupMouse (void); |
||||
|
||||
int mouse_buttons; |
||||
int mouse_oldbuttonstate; |
||||
POINT current_pos; |
||||
int old_mouse_x, old_mouse_y, mx_accum, my_accum; |
||||
int mouseinitialized; |
||||
}; |
||||
#endif |
||||
|
||||
#endif |
Loading…
Reference in new issue