mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-29 16:24:16 +00:00
engine: platform: added Platform_GetKeyModifiers
This commit is contained in:
parent
26e09c240a
commit
d3e213aa1b
35
engine/key_modifiers.h
Normal file
35
engine/key_modifiers.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
key_modifiers.h - enumeration of possible key modifiers
|
||||||
|
Copyright (C) 2022 FWGS Team
|
||||||
|
|
||||||
|
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 3 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
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef KEY_MODIFIERS_H
|
||||||
|
#define KEY_MODIFIERS_H
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
KeyModifier_None = 0,
|
||||||
|
KeyModifier_LeftShift = (1 << 0),
|
||||||
|
KeyModifier_RightShift = (1 << 1),
|
||||||
|
KeyModifier_LeftCtrl = (1 << 2),
|
||||||
|
KeyModifier_RightCtrl = (1 << 3),
|
||||||
|
KeyModifier_LeftAlt = (1 << 4),
|
||||||
|
KeyModifier_RightAlt = (1 << 5),
|
||||||
|
KeyModifier_LeftSuper = (1 << 6),
|
||||||
|
KeyModifier_RightSuper = (1 << 7),
|
||||||
|
KeyModifier_NumLock = (1 << 8),
|
||||||
|
KeyModifier_CapsLock = (1 << 9)
|
||||||
|
} key_modifier_t;
|
||||||
|
|
||||||
|
#endif
|
@ -21,6 +21,7 @@ GNU General Public License for more details.
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "cursor_type.h"
|
#include "cursor_type.h"
|
||||||
|
#include "key_modifiers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@ -73,6 +74,7 @@ void*Platform_GetNativeObject( const char *name );
|
|||||||
int Platform_JoyInit( int numjoy ); // returns number of connected gamepads, negative if error
|
int Platform_JoyInit( int numjoy ); // returns number of connected gamepads, negative if error
|
||||||
// Text input
|
// Text input
|
||||||
void Platform_EnableTextInput( qboolean enable );
|
void Platform_EnableTextInput( qboolean enable );
|
||||||
|
key_modifier_t Platform_GetKeyModifiers( void );
|
||||||
// System events
|
// System events
|
||||||
void Platform_RunEvents( void );
|
void Platform_RunEvents( void );
|
||||||
// Mouse
|
// Mouse
|
||||||
|
@ -323,4 +323,41 @@ void Platform_SetCursorType( cursor_type_t type )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
========================
|
||||||
|
Platform_GetKeyModifiers
|
||||||
|
|
||||||
|
========================
|
||||||
|
*/
|
||||||
|
key_modifier_t Platform_GetKeyModifiers( void )
|
||||||
|
{
|
||||||
|
SDL_Keymod modFlags;
|
||||||
|
key_modifier_t resultFlags;
|
||||||
|
|
||||||
|
resultFlags = KeyModifier_None;
|
||||||
|
modFlags = SDL_GetModState();
|
||||||
|
if( FBitSet( modFlags, KMOD_LCTRL ))
|
||||||
|
SetBits( resultFlags, KeyModifier_LeftCtrl );
|
||||||
|
if( FBitSet( modFlags, KMOD_RCTRL ))
|
||||||
|
SetBits( resultFlags, KeyModifier_RightCtrl );
|
||||||
|
if( FBitSet( modFlags, KMOD_RSHIFT ))
|
||||||
|
SetBits( resultFlags, KeyModifier_RightShift );
|
||||||
|
if( FBitSet( modFlags, KMOD_LSHIFT ))
|
||||||
|
SetBits( resultFlags, KeyModifier_LeftShift );
|
||||||
|
if( FBitSet( modFlags, KMOD_LALT ))
|
||||||
|
SetBits( resultFlags, KeyModifier_LeftAlt );
|
||||||
|
if( FBitSet( modFlags, KMOD_RALT ))
|
||||||
|
SetBits( resultFlags, KeyModifier_RightAlt );
|
||||||
|
if( FBitSet( modFlags, KMOD_NUM ))
|
||||||
|
SetBits( resultFlags, KeyModifier_NumLock );
|
||||||
|
if( FBitSet( modFlags, KMOD_CAPS ))
|
||||||
|
SetBits( resultFlags, KeyModifier_CapsLock );
|
||||||
|
if( FBitSet( modFlags, KMOD_RGUI ))
|
||||||
|
SetBits( resultFlags, KeyModifier_RightSuper );
|
||||||
|
if( FBitSet( modFlags, KMOD_LGUI ))
|
||||||
|
SetBits( resultFlags, KeyModifier_LeftSuper );
|
||||||
|
|
||||||
|
return resultFlags;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // XASH_DEDICATED
|
#endif // XASH_DEDICATED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user