Browse Source

sound: make snd_mute_losefocus accessible outside

pull/2/head
Alibek Omarov 6 years ago
parent
commit
f4567b2c9d
  1. 75
      engine/client/in_joy.c
  2. 1
      engine/client/sound.h

75
engine/client/in_joy.c

@ -21,10 +21,7 @@ GNU General Public License for more details.
#include "keydefs.h" #include "keydefs.h"
#include "client.h" #include "client.h"
#include "gl_local.h" #include "gl_local.h"
#include "platform/platform.h"
#if defined(XASH_SDL)
#include "platform/sdl/events.h"
#endif
#ifndef SHRT_MAX #ifndef SHRT_MAX
#define SHRT_MAX 0x7FFF #define SHRT_MAX 0x7FFF
@ -62,28 +59,24 @@ static struct joy_axis_s
short val; short val;
short prevval; short prevval;
} joyaxis[MAX_AXES] = { 0 }; } joyaxis[MAX_AXES] = { 0 };
static qboolean initialized = false, forcedisable = false; static qboolean forcedisable = false;
static convar_t *joy_enable;
static byte currentbinding; // add posibility to remap keys, to place it in joykeys[] static byte currentbinding; // add posibility to remap keys, to place it in joykeys[]
static convar_t *joy_enable;
float IN_TouchDrawText( float x1, float y1, float x2, float y2, const char *s, byte *color, float size ); static convar_t *joy_pitch;
float IN_TouchDrawCharacter( float x, float y, int number, float size ); static convar_t *joy_yaw;
static convar_t *joy_forward;
convar_t *joy_pitch; static convar_t *joy_side;
convar_t *joy_yaw; static convar_t *joy_found;
convar_t *joy_forward; static convar_t *joy_index;
convar_t *joy_side; static convar_t *joy_lt_threshold;
convar_t *joy_found; static convar_t *joy_rt_threshold;
convar_t *joy_index; static convar_t *joy_side_deadzone;
convar_t *joy_lt_threshold; static convar_t *joy_forward_deadzone;
convar_t *joy_rt_threshold; static convar_t *joy_side_key_threshold;
convar_t *joy_side_deadzone; static convar_t *joy_forward_key_threshold;
convar_t *joy_forward_deadzone; static convar_t *joy_pitch_deadzone;
convar_t *joy_side_key_threshold; static convar_t *joy_yaw_deadzone;
convar_t *joy_forward_key_threshold; static convar_t *joy_axis_binding;
convar_t *joy_pitch_deadzone;
convar_t *joy_yaw_deadzone;
convar_t *joy_axis_binding;
/* /*
============ ============
@ -92,7 +85,7 @@ Joy_IsActive
*/ */
qboolean Joy_IsActive( void ) qboolean Joy_IsActive( void )
{ {
return !forcedisable && initialized; return !forcedisable && joy_found->value;
} }
/* /*
@ -117,7 +110,7 @@ void Joy_HatMotionEvent( int id, byte hat, byte value )
}; };
int i; int i;
if( !initialized ) if( !joy_found->value )
return; return;
for( i = 0; i < ARRAYSIZE( keys ); i++ ) for( i = 0; i < ARRAYSIZE( keys ); i++ )
@ -261,7 +254,7 @@ void Joy_AxisMotionEvent( int id, byte axis, short value )
{ {
byte engineAxis; byte engineAxis;
if( !initialized ) if( !joy_found->value )
return; return;
if( axis >= MAX_AXES ) if( axis >= MAX_AXES )
@ -293,7 +286,7 @@ Trackball events. UNDONE
*/ */
void Joy_BallMotionEvent( int id, byte ball, short xrel, short yrel ) void Joy_BallMotionEvent( int id, byte ball, short xrel, short yrel )
{ {
//if( !initialized ) //if( !joy_found->value )
// return; // return;
} }
@ -306,7 +299,7 @@ Button events
*/ */
void Joy_ButtonEvent( int id, byte button, byte down ) void Joy_ButtonEvent( int id, byte button, byte down )
{ {
if( !initialized ) if( !joy_found->value )
return; return;
// generic game button code. // generic game button code.
@ -331,7 +324,7 @@ Called when joystick is removed. For future expansion
*/ */
void Joy_RemoveEvent( int id ) void Joy_RemoveEvent( int id )
{ {
if( !forcedisable && initialized && joy_found->value ) if( !forcedisable && joy_found->value )
Cvar_SetValue("joy_found", joy_found->value - 1.0f); Cvar_SetValue("joy_found", joy_found->value - 1.0f);
} }
@ -347,8 +340,6 @@ void Joy_AddEvent( int id )
if( forcedisable ) if( forcedisable )
return; return;
initialized = true;
Cvar_SetValue("joy_found", joy_found->value + 1.0f); Cvar_SetValue("joy_found", joy_found->value + 1.0f);
} }
@ -361,7 +352,7 @@ Append movement from axis. Called everyframe
*/ */
void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw ) void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
{ {
if( !initialized || !joy_enable->value ) if( !joy_found->value || !joy_enable->value )
return; return;
if( FBitSet( joy_axis_binding->flags, FCVAR_CHANGED ) ) if( FBitSet( joy_axis_binding->flags, FCVAR_CHANGED ) )
@ -440,19 +431,7 @@ void Joy_Init( void )
return; return;
} }
#if defined(XASH_SDL) Cvar_SetValue( "joy_found", Platform_JoyInit( joy_index->value ) );
// SDL can tell us about connected joysticks
Cvar_SetValue( "joy_found", SDLash_JoyInit( joy_index->value ) );
#elif defined(ANDROID)
// Initalized after first Joy_AddEvent
#else
#warning "Any platform must implement platform-dependent JoyInit, start event system. Otherwise no joystick support"
#endif
if( joy_found->value > 0 )
initialized = true;
else
initialized = false;
} }
/* /*
@ -465,8 +444,6 @@ Shutdown joystick code
void Joy_Shutdown( void ) void Joy_Shutdown( void )
{ {
Cvar_SetValue( "joy_found", 0 ); Cvar_SetValue( "joy_found", 0 );
initialized = false;
} }
#endif // XASH_DEDICATED #endif // XASH_DEDICATED

1
engine/client/sound.h

@ -275,6 +275,7 @@ extern convar_t *s_lerping;
extern convar_t *dsp_off; extern convar_t *dsp_off;
extern convar_t *s_test; // cvar to testify new effects extern convar_t *s_test; // cvar to testify new effects
extern convar_t *s_samplecount; extern convar_t *s_samplecount;
extern convar_t *snd_mute_losefocus;
void S_InitScaletable( void ); void S_InitScaletable( void );
wavdata_t *S_LoadSound( sfx_t *sfx ); wavdata_t *S_LoadSound( sfx_t *sfx );

Loading…
Cancel
Save