DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
vid_sdl.c File Reference
#include <SDL.h>
#include <stdio.h>
#include "quakedef.h"
#include "image.h"
#include "utf8lib.h"
+ Include dependency graph for vid_sdl.c:

Go to the source code of this file.

Macros

#define MAXFINGERS   11
 
#define SDLK_PERCENT   '%'
 
#define Vid_ClearAllTouchscreenAreas(skip)
 

Functions

qbool GL_ExtensionSupported (const char *name)
 
voidGL_GetProcAddress (const char *name)
 
void IN_Move (void)
 
static void IN_Move_TouchScreen_Quake (void)
 
static void IN_Move_TouchScreen_SteelStorm (void)
 
static int MapKey (unsigned int sdlkey)
 
void Sys_SDL_HandleEvents (void)
 Perform Key_Event () callbacks until the input que is empty.
 
static void VID_ApplyDisplayMode (const viddef_mode_t *mode)
 Applies display settings immediately (no vid_restart required).
 
static void VID_ApplyDisplayMode_c (cvar_t *var)
 
void VID_BuildJoyState (vid_joystate_t *joystate)
 
void VID_EnableJoystick (qbool enable)
 
void VID_Finish (void)
 
vid_mode_t VID_GetDesktopMode (void)
 
qbool VID_HasScreenKeyboardSupport (void)
 
void VID_Init (void)
 Called at startup.
 
qbool VID_InitMode (const viddef_mode_t *mode)
 allocates and opens an appropriate OpenGL context (and its window)
 
static qbool VID_InitModeGL (const viddef_mode_t *mode)
 
size_t VID_ListModes (vid_mode_t *modes, size_t maxcount)
 
static void VID_SetHints_c (cvar_t *var)
 
static void VID_SetMouse (qbool relative, qbool hidecursor)
 
static void VID_SetVsync_c (cvar_t *var)
 
qbool VID_ShowingKeyboard (void)
 
void VID_ShowKeyboard (qbool show)
 
void VID_Shutdown (void)
 Called at shutdown.
 
static qbool VID_TouchscreenArea (int corner, float px, float py, float pwidth, float pheight, const char *icon, float textheight, const char *text, float *resultmove, qbool *resultbutton, keynum_t key, const char *typedtext, float deadzone, float oversizepixels_x, float oversizepixels_y, qbool iamexclusive)
 
static void VID_TouchscreenCursor (float px, float py, float pwidth, float pheight, qbool *resultbutton, keynum_t key)
 

Variables

static keynum_t buttonremap []
 
int cl_available = true
 
static SDL_GLContext context
 
static cvar_t joy_sdl2_trigger_deadzone = {CF_ARCHIVE | CF_CLIENT, "joy_sdl2_trigger_deadzone", "0.5", "deadzone for triggers to be registered as key presses"}
 
float multitouch [MAXFINGERS][3]
 
int multitouchs [MAXFINGERS]
 
static cvar_tsteelstorm_showing_map = NULL
 
static cvar_tsteelstorm_showing_mousecursor = NULL
 
static qbool vid_hasfocus = false
 
static SDL_GameController * vid_sdlgamecontroller = NULL
 
static SDL_Joystick * vid_sdljoystick = NULL
 
static int vid_sdljoystickindex = -1
 
qbool vid_supportrefreshrate = false
 
static qbool vid_usinghidecursor = false
 
static qbool vid_usingmouse = false
 
static qbool vid_usingmouse_relativeworks = false
 
static qbool vid_wmborder_waiting
 
static qbool vid_wmborderless
 
static SDL_Window * window
 

Macro Definition Documentation

◆ MAXFINGERS

◆ SDLK_PERCENT

#define SDLK_PERCENT   '%'

Definition at line 86 of file vid_sdl.c.

Referenced by MapKey().

◆ Vid_ClearAllTouchscreenAreas

#define Vid_ClearAllTouchscreenAreas ( skip)
Value:
if (skip != 0) \
VID_TouchscreenCursor(0, 0, 0, 0, &buttons[0], K_MOUSE1); \
if (skip != 1) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[1], K_MOUSE4, NULL, 0, 0, 0, false); \
if (skip != 2) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[2], K_MOUSE5, NULL, 0, 0, 0, false); \
if (skip != 3) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SHIFT, NULL, 0, 0, 0, false); \
if (skip != 4) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, false); \
if (skip != 9) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[9], K_MOUSE3, NULL, 0, 0, 0, false); \
if (skip != 10) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, false); \
if (skip != 11) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[11], (keynum_t)'b', NULL, 0, 0, 0, false); \
if (skip != 12) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[12], (keynum_t)'q', NULL, 0, 0, 0, false); \
if (skip != 13) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, false); \
if (skip != 14) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false); \
if (skip != 15) \
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, false); \
float K_SHIFT
Definition keycodes.qc:22
float K_MOUSE1
Definition keycodes.qc:129
float K_MOUSE3
Definition keycodes.qc:131
float K_SPACE
Definition keycodes.qc:10
float K_MOUSE2
Definition keycodes.qc:130
float K_MOUSE5
Definition keycodes.qc:135
float K_MOUSE4
Definition keycodes.qc:134
float K_ESCAPE
Definition keycodes.qc:9
keynum_t
Definition keys.h:52
#define NULL
Definition qtypes.h:12

Definition at line 722 of file vid_sdl.c.

722#define Vid_ClearAllTouchscreenAreas(skip) \
723 if (skip != 0) \
724 VID_TouchscreenCursor(0, 0, 0, 0, &buttons[0], K_MOUSE1); \
725 if (skip != 1) \
726 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[1], K_MOUSE4, NULL, 0, 0, 0, false); \
727 if (skip != 2) \
728 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[2], K_MOUSE5, NULL, 0, 0, 0, false); \
729 if (skip != 3) \
730 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SHIFT, NULL, 0, 0, 0, false); \
731 if (skip != 4) \
732 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, false); \
733 if (skip != 9) \
734 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[9], K_MOUSE3, NULL, 0, 0, 0, false); \
735 if (skip != 10) \
736 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, false); \
737 if (skip != 11) \
738 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[11], (keynum_t)'b', NULL, 0, 0, 0, false); \
739 if (skip != 12) \
740 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[12], (keynum_t)'q', NULL, 0, 0, 0, false); \
741 if (skip != 13) \
742 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, false); \
743 if (skip != 14) \
744 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false); \
745 if (skip != 15) \
746 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, false); \
747

Referenced by IN_Move_TouchScreen_SteelStorm().

Function Documentation

◆ GL_ExtensionSupported()

qbool GL_ExtensionSupported ( const char * name)

Definition at line 1351 of file vid_sdl.c.

1352{
1353 return SDL_GL_ExtensionSupported(name);
1354}
const GLchar * name
Definition glquake.h:601

References name.

Referenced by GL_CheckExtension().

◆ GL_GetProcAddress()

void * GL_GetProcAddress ( const char * name)

Definition at line 1344 of file vid_sdl.c.

1345{
1346 void *p = NULL;
1347 p = SDL_GL_GetProcAddress(name);
1348 return p;
1349}

References name, and NULL.

Referenced by GL_InitFunctions().

◆ IN_Move()

void IN_Move ( void )

Definition at line 936 of file vid_sdl.c.

937{
938 static int old_x = 0, old_y = 0;
939 static int stuck = 0;
940 static keydest_t oldkeydest;
941 static qbool oldshowkeyboard;
942 int x, y;
943 vid_joystate_t joystate;
945
947
948 // Only apply the new keyboard state if the input changes.
949 if (keydest != oldkeydest || !!vid_touchscreen_showkeyboard.integer != oldshowkeyboard)
950 {
951 switch(keydest)
952 {
953 case key_console: VID_ShowKeyboard(true);break;
954 case key_message: VID_ShowKeyboard(true);break;
956 }
957 }
958 oldkeydest = keydest;
959 oldshowkeyboard = !!vid_touchscreen_showkeyboard.integer;
960
962 {
963 switch(gamemode)
964 {
965 case GAME_STEELSTORM:
967 break;
968 default:
970 break;
971 }
972 }
973 else
974 {
975 if (vid_usingmouse)
976 {
978 {
979 // have the mouse stuck in the middle, example use: prevent expose effect of beryl during the game when not using
980 // window grabbing. --blub
981 int win_half_width = vid.mode.width>>1;
982 int win_half_height = vid.mode.height>>1;
983
984 // we need 2 frames to initialize the center position
985 if(!stuck)
986 {
987 SDL_WarpMouseInWindow(window, win_half_width, win_half_height);
988 SDL_GetMouseState(&x, &y);
989 SDL_GetRelativeMouseState(&x, &y);
990 ++stuck;
991 } else {
992 SDL_GetRelativeMouseState(&x, &y);
993 in_mouse_x = x + old_x;
994 in_mouse_y = y + old_y;
995 SDL_GetMouseState(&x, &y);
996 old_x = x - win_half_width;
997 old_y = y - win_half_height;
998 SDL_WarpMouseInWindow(window, win_half_width, win_half_height);
999 }
1000 } else {
1001 SDL_GetRelativeMouseState( &x, &y );
1002 in_mouse_x = x;
1003 in_mouse_y = y;
1004 }
1005 }
1006
1007 SDL_GetMouseState(&x, &y);
1010 }
1011
1012 //Con_Printf("Mouse position: in_mouse %f %f in_windowmouse %f %f\n", in_mouse_x, in_mouse_y, in_windowmouse_x, in_windowmouse_y);
1013
1014 VID_BuildJoyState(&joystate);
1015 VID_ApplyJoyState(&joystate);
1016}
int scr_numtouchscreenareas
Definition cl_screen.c:1504
gamemode_t gamemode
Definition com_game.c:26
@ GAME_STEELSTORM
added by motorsep
Definition com_game.h:53
GLint GLenum GLint GLint y
Definition glquake.h:651
GLint GLenum GLint x
Definition glquake.h:651
float in_windowmouse_y
Definition input.h:32
float in_windowmouse_x
Definition vid_shared.c:71
float in_mouse_y
Definition input.h:33
float in_mouse_x
Definition vid_shared.c:70
keydest_t key_dest
Definition keys.c:37
int key_consoleactive
Definition keys.c:38
#define KEY_CONSOLEACTIVE_USER
Definition keys.h:380
keydest_t
Definition keys.h:372
@ key_message
Definition keys.h:372
@ key_console
Definition keys.h:372
bool qbool
Definition qtypes.h:9
int integer
Definition cvar.h:73
int width
Definition vid.h:60
int height
Definition vid.h:61
viddef_mode_t mode
currently active video mode
Definition vid.h:73
cvar_t vid_stick_mouse
Definition vid_shared.c:163
cvar_t vid_touchscreen_showkeyboard
Definition vid_shared.c:161
void VID_ApplyJoyState(vid_joystate_t *joystate)
viddef_t vid
global video state
Definition vid_shared.c:64
cvar_t vid_touchscreen
Definition vid_shared.c:160
static void IN_Move_TouchScreen_Quake(void)
Definition vid_sdl.c:867
static SDL_Window * window
Definition vid_sdl.c:81
static void IN_Move_TouchScreen_SteelStorm(void)
Definition vid_sdl.c:752
void VID_ShowKeyboard(qbool show)
Definition vid_sdl.c:343
static qbool vid_usingmouse_relativeworks
Definition vid_sdl.c:69
static qbool vid_usingmouse
Definition vid_sdl.c:68
void VID_BuildJoyState(vid_joystate_t *joystate)
Definition vid_sdl.c:683

References GAME_STEELSTORM, gamemode, viddef_mode_t::height, in_mouse_x, in_mouse_y, IN_Move_TouchScreen_Quake(), IN_Move_TouchScreen_SteelStorm(), in_windowmouse_x, in_windowmouse_y, cvar_t::integer, key_console, key_consoleactive, KEY_CONSOLEACTIVE_USER, key_dest, key_message, viddef_t::mode, scr_numtouchscreenareas, vid, VID_ApplyJoyState(), VID_BuildJoyState(), VID_ShowKeyboard(), vid_stick_mouse, vid_touchscreen, vid_touchscreen_showkeyboard, vid_usingmouse, vid_usingmouse_relativeworks, viddef_mode_t::width, window, x, and y.

Referenced by CL_Input().

◆ IN_Move_TouchScreen_Quake()

static void IN_Move_TouchScreen_Quake ( void )
static

Definition at line 867 of file vid_sdl.c.

868{
869 int x, y;
870 float move[3], aim[3], click[3];
871 static qbool oldbuttons[128];
872 static qbool buttons[128];
874 memcpy(oldbuttons, buttons, sizeof(oldbuttons));
875 memset(multitouchs, 0, sizeof(multitouchs));
876
877 // simple quake controls
878 multitouch[MAXFINGERS-1][0] = SDL_GetMouseState(&x, &y);
879 multitouch[MAXFINGERS-1][1] = x * 32768 / vid.mode.width;
880 multitouch[MAXFINGERS-1][2] = y * 32768 / vid.mode.height;
881
882 // top of screen is toggleconsole and K_ESCAPE
883 switch(keydest)
884 {
885 case key_console:
886 VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
887 VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
888 if (!VID_ShowingKeyboard())
889 {
890 // user entered a command, close the console now
892 }
893 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
894 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
895 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
896 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, click,&buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
897 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
898 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
899 break;
900 case key_game:
901 VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
902 VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
903 VID_TouchscreenArea( 2, 0,-128, 128, 128, "gfx/touch_movebutton.tga" , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
904 VID_TouchscreenArea( 3,-128,-128, 128, 128, "gfx/touch_aimbutton.tga" , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
905 VID_TouchscreenArea( 2, 0,-160, 64, 32, "gfx/touch_jumpbutton.tga" , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
906 VID_TouchscreenArea( 3,-128,-160, 64, 32, "gfx/touch_attackbutton.tga" , 0.0f, NULL, NULL, &buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
907 VID_TouchscreenArea( 3, -64,-160, 64, 32, "gfx/touch_attack2button.tga", 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
908 buttons[15] = false;
909 break;
910 default:
911 VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
912 VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
913 // in menus, an icon in the corner activates keyboard
914 VID_TouchscreenArea( 2, 0, -32, 32, 32, "gfx/touch_keyboard.tga" , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
915 if (buttons[15])
916 VID_ShowKeyboard(true);
917 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
918 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
919 VID_TouchscreenArea(16, -320,-480,640, 960, NULL , 0.0f, NULL, click,&buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
920 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
921 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
922 if (buttons[2])
923 {
926 }
927 break;
928 }
929
931 cl.cmd.sidemove += move[0] * cl_sidespeed.value;
934}
cvar_t cl_yawspeed
Definition cl_input.c:372
cvar_t cl_sidespeed
Definition cl_input.c:367
cvar_t cl_pitchspeed
Definition cl_input.c:373
cvar_t cl_forwardspeed
Definition cl_input.c:365
client_state_t cl
Definition cl_main.c:117
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
void Con_ToggleConsole_f(cmd_state_t *cmd)
Definition console.c:686
@ key_game
Definition keys.h:372
vec3_t viewangles
Definition client.h:786
double realframetime
Definition client.h:871
usercmd_t cmd
Definition client.h:752
float value
Definition cvar.h:74
float forwardmove
Definition protocol.h:380
float sidemove
Definition protocol.h:381
static qbool VID_TouchscreenArea(int corner, float px, float py, float pwidth, float pheight, const char *icon, float textheight, const char *text, float *resultmove, qbool *resultbutton, keynum_t key, const char *typedtext, float deadzone, float oversizepixels_x, float oversizepixels_y, qbool iamexclusive)
Definition vid_sdl.c:452
#define MAXFINGERS
Definition vid_sdl.c:445
qbool VID_ShowingKeyboard(void)
Definition vid_sdl.c:360
int multitouchs[MAXFINGERS]
Definition vid_sdl.c:449
float multitouch[MAXFINGERS][3]
Definition vid_sdl.c:446

References cl, cl_forwardspeed, cl_pitchspeed, cl_sidespeed, cl_yawspeed, client_state_t::cmd, cmd_local, Con_ToggleConsole_f(), usercmd_t::forwardmove, viddef_mode_t::height, in_windowmouse_x, in_windowmouse_y, K_ESCAPE, K_MOUSE1, K_MOUSE2, K_MOUSE4, K_MOUSE5, K_SPACE, key_console, key_consoleactive, KEY_CONSOLEACTIVE_USER, key_dest, key_game, MAXFINGERS, viddef_t::mode, multitouch, multitouchs, NULL, client_state_t::realframetime, usercmd_t::sidemove, cvar_t::value, vid, VID_ShowingKeyboard(), VID_ShowKeyboard(), VID_TouchscreenArea(), client_state_t::viewangles, viddef_mode_t::width, x, and y.

Referenced by IN_Move().

◆ IN_Move_TouchScreen_SteelStorm()

static void IN_Move_TouchScreen_SteelStorm ( void )
static

Definition at line 752 of file vid_sdl.c.

753{
754 // ELUAN
755 int i, numfingers;
756 float xscale, yscale;
757 float move[3], aim[3];
758 static qbool oldbuttons[128];
759 static qbool buttons[128];
761 memcpy(oldbuttons, buttons, sizeof(oldbuttons));
762 memset(multitouchs, 0, sizeof(multitouchs));
763
764 for (i = 0, numfingers = 0; i < MAXFINGERS - 1; i++)
765 if (multitouch[i][0])
766 numfingers++;
767
768 /*
769 Enable this to use a mouse as a touch device (it may conflict with the iamexclusive parameter if a finger is also reported as a mouse at the same location
770 if (numfingers == 1)
771 {
772 multitouch[MAXFINGERS-1][0] = SDL_GetMouseState(&x, &y) ? 11 : 0;
773 multitouch[MAXFINGERS-1][1] = (float)x / vid.width;
774 multitouch[MAXFINGERS-1][2] = (float)y / vid.height;
775 }
776 else
777 {
778 // disable it so it doesn't get stuck, because SDL seems to stop updating it if there are more than 1 finger on screen
779 multitouch[MAXFINGERS-1][0] = 0;
780 }*/
781
782 // TODO: make touchscreen areas controlled by a config file or the VMs. THIS IS A MESS!
783 // TODO: can't just clear buttons[] when entering a new keydest, some keys would remain pressed
784 // SS:BR menuqc has many peculiarities, including that it can't accept more than one command per frame and pressing and releasing on the same frame
785
786 // Tuned for the SGS3, use it's value as a base. CLEAN THIS.
787 xscale = vid_touchscreen_density.value / 2.0f;
788 yscale = vid_touchscreen_density.value / 2.0f;
789 switch(keydest)
790 {
791 case key_console:
793 VID_TouchscreenArea( 0, 0, 160, 64, 64, "gfx/gui/touch_menu_button.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false);
794 break;
795 case key_game:
796 if (steelstorm_showing_map && steelstorm_showing_map->integer) // FIXME: another hack to be removed when touchscreen areas go to QC
797 {
798 VID_TouchscreenArea( 0, 0, 0, vid_conwidth.value, vid_conheight.value, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, false);
800 }
802 {
803 // in_windowmouse_x* is in screen resolution coordinates, not console resolution
806 }
807 else
808 {
809 VID_TouchscreenCursor(0, 0, 0, 0, &buttons[0], K_MOUSE1);
810
811 VID_TouchscreenArea( 2,16*xscale,-240*yscale, 224*xscale, 224*yscale, "gfx/gui/touch_l_thumb_dpad.tga", 0.0f, NULL, move, &buttons[1], (keynum_t)0, NULL, 0.15, 112*xscale, 112*yscale, false);
812
813 VID_TouchscreenArea( 3,-240*xscale,-160*yscale, 224*xscale, 128*yscale, "gfx/gui/touch_r_thumb_turn_n_shoot.tga" , 0.0f, NULL, NULL, 0, (keynum_t)0, NULL, 0, 56*xscale, 0, false);
814 VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 224*yscale, NULL , 0.0f, NULL, aim, &buttons[2], (keynum_t)0, NULL, 0.2, 56*xscale, 0, false);
815
816 VID_TouchscreenArea( 2, (vid_conwidth.value / 2) - 128,-80, 256, 80, NULL, 0.0f, NULL, NULL, &buttons[3], K_SHIFT, NULL, 0, 0, 0, true);
817
818 VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_secondary_slide.tga", 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 56*xscale, 0, false);
819 VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 160*yscale, NULL , 0.0f, NULL, NULL, &buttons[9], K_MOUSE3, NULL, 0.2, 56*xscale, 0, false);
820
821 VID_TouchscreenArea( 1,-100, 0, 100, 100, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, true);
822 VID_TouchscreenArea( 1,-100, 120, 100, 100, NULL , 0.0f, NULL, NULL, &buttons[11], (keynum_t)'b', NULL, 0, 0, 0, true);
823 VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[12], (keynum_t)'q', NULL, 0, 0, 0, true);
824 if (developer.integer)
825 VID_TouchscreenArea( 0, 0, 96, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
826 else
827 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, false);
828 VID_TouchscreenArea( 0, 0, 160, 64, 64, "gfx/gui/touch_menu_button.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
829 switch(cl.activeweapon)
830 {
831 case 14:
832 VID_TouchscreenArea( 2, 16*xscale,-320*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_booster.tga" , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, true);
833 break;
834 case 12:
835 VID_TouchscreenArea( 2, 16*xscale,-320*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_shockwave.tga" , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, true);
836 break;
837 default:
838 VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, false);
839 }
840 }
841 break;
842 default:
844 {
846 // this way we can skip cutscenes
847 VID_TouchscreenArea( 0, 0, 0, vid_conwidth.value, vid_conheight.value, NULL , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false);
848 }
849 else
850 {
851 // in_windowmouse_x* is in screen resolution coordinates, not console resolution
854 }
855 break;
856 }
857
858 if (VID_ShowingKeyboard() && (float)in_windowmouse_y > vid_height.value / 2 - 10)
859 in_windowmouse_y = 128;
860
862 cl.cmd.sidemove += move[0] * cl_sidespeed.value;
865}
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
cvar_t developer
Definition host.c:48
int i
int activeweapon
Definition client.h:765
cvar_t vid_width
Definition vid_shared.c:136
cvar_t vid_height
Definition vid_shared.c:137
cvar_t vid_touchscreen_density
Definition vid_shared.c:145
static void VID_TouchscreenCursor(float px, float py, float pwidth, float pheight, qbool *resultbutton, keynum_t key)
Definition vid_sdl.c:565
static cvar_t * steelstorm_showing_map
Definition vid_sdl.c:77
static cvar_t * steelstorm_showing_mousecursor
Definition vid_sdl.c:78
#define Vid_ClearAllTouchscreenAreas(skip)
Definition vid_sdl.c:722

References client_state_t::activeweapon, cl, cl_forwardspeed, cl_pitchspeed, cl_sidespeed, cl_yawspeed, client_state_t::cmd, developer, usercmd_t::forwardmove, i, in_windowmouse_x, in_windowmouse_y, cvar_t::integer, K_ESCAPE, K_MOUSE1, K_MOUSE2, K_MOUSE3, K_SHIFT, K_SPACE, key_console, key_consoleactive, KEY_CONSOLEACTIVE_USER, key_dest, key_game, MAXFINGERS, multitouch, multitouchs, NULL, client_state_t::realframetime, usercmd_t::sidemove, steelstorm_showing_map, steelstorm_showing_mousecursor, cvar_t::value, Vid_ClearAllTouchscreenAreas, vid_conheight, vid_conwidth, vid_height, VID_ShowingKeyboard(), vid_touchscreen_density, VID_TouchscreenArea(), VID_TouchscreenCursor(), vid_width, and client_state_t::viewangles.

Referenced by IN_Move().

◆ MapKey()

static int MapKey ( unsigned int sdlkey)
static

Definition at line 89 of file vid_sdl.c.

90{
91 switch(sdlkey)
92 {
93 // sdlkey can be Unicode codepoint for non-ascii keys, which are valid
94 default: return sdlkey & SDLK_SCANCODE_MASK ? 0 : sdlkey;
95// case SDLK_UNKNOWN: return K_UNKNOWN;
96 case SDLK_RETURN: return K_ENTER;
97 case SDLK_ESCAPE: return K_ESCAPE;
98 case SDLK_BACKSPACE: return K_BACKSPACE;
99 case SDLK_TAB: return K_TAB;
100 case SDLK_SPACE: return K_SPACE;
101 case SDLK_EXCLAIM: return '!';
102 case SDLK_QUOTEDBL: return '"';
103 case SDLK_HASH: return '#';
104 case SDLK_PERCENT: return '%';
105 case SDLK_DOLLAR: return '$';
106 case SDLK_AMPERSAND: return '&';
107 case SDLK_QUOTE: return '\'';
108 case SDLK_LEFTPAREN: return '(';
109 case SDLK_RIGHTPAREN: return ')';
110 case SDLK_ASTERISK: return '*';
111 case SDLK_PLUS: return '+';
112 case SDLK_COMMA: return ',';
113 case SDLK_MINUS: return '-';
114 case SDLK_PERIOD: return '.';
115 case SDLK_SLASH: return '/';
116 case SDLK_0: return '0';
117 case SDLK_1: return '1';
118 case SDLK_2: return '2';
119 case SDLK_3: return '3';
120 case SDLK_4: return '4';
121 case SDLK_5: return '5';
122 case SDLK_6: return '6';
123 case SDLK_7: return '7';
124 case SDLK_8: return '8';
125 case SDLK_9: return '9';
126 case SDLK_COLON: return ':';
127 case SDLK_SEMICOLON: return ';';
128 case SDLK_LESS: return '<';
129 case SDLK_EQUALS: return '=';
130 case SDLK_GREATER: return '>';
131 case SDLK_QUESTION: return '?';
132 case SDLK_AT: return '@';
133 case SDLK_LEFTBRACKET: return '[';
134 case SDLK_BACKSLASH: return '\\';
135 case SDLK_RIGHTBRACKET: return ']';
136 case SDLK_CARET: return '^';
137 case SDLK_UNDERSCORE: return '_';
138 case SDLK_BACKQUOTE: return '`';
139 case SDLK_a: return 'a';
140 case SDLK_b: return 'b';
141 case SDLK_c: return 'c';
142 case SDLK_d: return 'd';
143 case SDLK_e: return 'e';
144 case SDLK_f: return 'f';
145 case SDLK_g: return 'g';
146 case SDLK_h: return 'h';
147 case SDLK_i: return 'i';
148 case SDLK_j: return 'j';
149 case SDLK_k: return 'k';
150 case SDLK_l: return 'l';
151 case SDLK_m: return 'm';
152 case SDLK_n: return 'n';
153 case SDLK_o: return 'o';
154 case SDLK_p: return 'p';
155 case SDLK_q: return 'q';
156 case SDLK_r: return 'r';
157 case SDLK_s: return 's';
158 case SDLK_t: return 't';
159 case SDLK_u: return 'u';
160 case SDLK_v: return 'v';
161 case SDLK_w: return 'w';
162 case SDLK_x: return 'x';
163 case SDLK_y: return 'y';
164 case SDLK_z: return 'z';
165 case SDLK_CAPSLOCK: return K_CAPSLOCK;
166 case SDLK_F1: return K_F1;
167 case SDLK_F2: return K_F2;
168 case SDLK_F3: return K_F3;
169 case SDLK_F4: return K_F4;
170 case SDLK_F5: return K_F5;
171 case SDLK_F6: return K_F6;
172 case SDLK_F7: return K_F7;
173 case SDLK_F8: return K_F8;
174 case SDLK_F9: return K_F9;
175 case SDLK_F10: return K_F10;
176 case SDLK_F11: return K_F11;
177 case SDLK_F12: return K_F12;
178 case SDLK_PRINTSCREEN: return K_PRINTSCREEN;
179 case SDLK_SCROLLLOCK: return K_SCROLLOCK;
180 case SDLK_PAUSE: return K_PAUSE;
181 case SDLK_INSERT: return K_INS;
182 case SDLK_HOME: return K_HOME;
183 case SDLK_PAGEUP: return K_PGUP;
184#ifdef __IPHONEOS__
185 case SDLK_DELETE: return K_BACKSPACE;
186#else
187 case SDLK_DELETE: return K_DEL;
188#endif
189 case SDLK_END: return K_END;
190 case SDLK_PAGEDOWN: return K_PGDN;
191 case SDLK_RIGHT: return K_RIGHTARROW;
192 case SDLK_LEFT: return K_LEFTARROW;
193 case SDLK_DOWN: return K_DOWNARROW;
194 case SDLK_UP: return K_UPARROW;
195 case SDLK_NUMLOCKCLEAR: return K_NUMLOCK;
196 case SDLK_KP_DIVIDE: return K_KP_DIVIDE;
197 case SDLK_KP_MULTIPLY: return K_KP_MULTIPLY;
198 case SDLK_KP_MINUS: return K_KP_MINUS;
199 case SDLK_KP_PLUS: return K_KP_PLUS;
200 case SDLK_KP_ENTER: return K_KP_ENTER;
201 case SDLK_KP_1: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_1 : K_END);
202 case SDLK_KP_2: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_2 : K_DOWNARROW);
203 case SDLK_KP_3: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_3 : K_PGDN);
204 case SDLK_KP_4: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_4 : K_LEFTARROW);
205 case SDLK_KP_5: return K_KP_5;
206 case SDLK_KP_6: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_6 : K_RIGHTARROW);
207 case SDLK_KP_7: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_7 : K_HOME);
208 case SDLK_KP_8: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_8 : K_UPARROW);
209 case SDLK_KP_9: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_9 : K_PGUP);
210 case SDLK_KP_0: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_0 : K_INS);
211 case SDLK_KP_PERIOD: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_PERIOD : K_DEL);
212// case SDLK_APPLICATION: return K_APPLICATION;
213// case SDLK_POWER: return K_POWER;
214 case SDLK_KP_EQUALS: return K_KP_EQUALS;
215// case SDLK_F13: return K_F13;
216// case SDLK_F14: return K_F14;
217// case SDLK_F15: return K_F15;
218// case SDLK_F16: return K_F16;
219// case SDLK_F17: return K_F17;
220// case SDLK_F18: return K_F18;
221// case SDLK_F19: return K_F19;
222// case SDLK_F20: return K_F20;
223// case SDLK_F21: return K_F21;
224// case SDLK_F22: return K_F22;
225// case SDLK_F23: return K_F23;
226// case SDLK_F24: return K_F24;
227// case SDLK_EXECUTE: return K_EXECUTE;
228// case SDLK_HELP: return K_HELP;
229// case SDLK_MENU: return K_MENU;
230// case SDLK_SELECT: return K_SELECT;
231// case SDLK_STOP: return K_STOP;
232// case SDLK_AGAIN: return K_AGAIN;
233// case SDLK_UNDO: return K_UNDO;
234// case SDLK_CUT: return K_CUT;
235// case SDLK_COPY: return K_COPY;
236// case SDLK_PASTE: return K_PASTE;
237// case SDLK_FIND: return K_FIND;
238// case SDLK_MUTE: return K_MUTE;
239// case SDLK_VOLUMEUP: return K_VOLUMEUP;
240// case SDLK_VOLUMEDOWN: return K_VOLUMEDOWN;
241// case SDLK_KP_COMMA: return K_KP_COMMA;
242// case SDLK_KP_EQUALSAS400: return K_KP_EQUALSAS400;
243// case SDLK_ALTERASE: return K_ALTERASE;
244// case SDLK_SYSREQ: return K_SYSREQ;
245// case SDLK_CANCEL: return K_CANCEL;
246// case SDLK_CLEAR: return K_CLEAR;
247// case SDLK_PRIOR: return K_PRIOR;
248// case SDLK_RETURN2: return K_RETURN2;
249// case SDLK_SEPARATOR: return K_SEPARATOR;
250// case SDLK_OUT: return K_OUT;
251// case SDLK_OPER: return K_OPER;
252// case SDLK_CLEARAGAIN: return K_CLEARAGAIN;
253// case SDLK_CRSEL: return K_CRSEL;
254// case SDLK_EXSEL: return K_EXSEL;
255// case SDLK_KP_00: return K_KP_00;
256// case SDLK_KP_000: return K_KP_000;
257// case SDLK_THOUSANDSSEPARATOR: return K_THOUSANDSSEPARATOR;
258// case SDLK_DECIMALSEPARATOR: return K_DECIMALSEPARATOR;
259// case SDLK_CURRENCYUNIT: return K_CURRENCYUNIT;
260// case SDLK_CURRENCYSUBUNIT: return K_CURRENCYSUBUNIT;
261// case SDLK_KP_LEFTPAREN: return K_KP_LEFTPAREN;
262// case SDLK_KP_RIGHTPAREN: return K_KP_RIGHTPAREN;
263// case SDLK_KP_LEFTBRACE: return K_KP_LEFTBRACE;
264// case SDLK_KP_RIGHTBRACE: return K_KP_RIGHTBRACE;
265// case SDLK_KP_TAB: return K_KP_TAB;
266// case SDLK_KP_BACKSPACE: return K_KP_BACKSPACE;
267// case SDLK_KP_A: return K_KP_A;
268// case SDLK_KP_B: return K_KP_B;
269// case SDLK_KP_C: return K_KP_C;
270// case SDLK_KP_D: return K_KP_D;
271// case SDLK_KP_E: return K_KP_E;
272// case SDLK_KP_F: return K_KP_F;
273// case SDLK_KP_XOR: return K_KP_XOR;
274// case SDLK_KP_POWER: return K_KP_POWER;
275// case SDLK_KP_PERCENT: return K_KP_PERCENT;
276// case SDLK_KP_LESS: return K_KP_LESS;
277// case SDLK_KP_GREATER: return K_KP_GREATER;
278// case SDLK_KP_AMPERSAND: return K_KP_AMPERSAND;
279// case SDLK_KP_DBLAMPERSAND: return K_KP_DBLAMPERSAND;
280// case SDLK_KP_VERTICALBAR: return K_KP_VERTICALBAR;
281// case SDLK_KP_DBLVERTICALBAR: return K_KP_DBLVERTICALBAR;
282// case SDLK_KP_COLON: return K_KP_COLON;
283// case SDLK_KP_HASH: return K_KP_HASH;
284// case SDLK_KP_SPACE: return K_KP_SPACE;
285// case SDLK_KP_AT: return K_KP_AT;
286// case SDLK_KP_EXCLAM: return K_KP_EXCLAM;
287// case SDLK_KP_MEMSTORE: return K_KP_MEMSTORE;
288// case SDLK_KP_MEMRECALL: return K_KP_MEMRECALL;
289// case SDLK_KP_MEMCLEAR: return K_KP_MEMCLEAR;
290// case SDLK_KP_MEMADD: return K_KP_MEMADD;
291// case SDLK_KP_MEMSUBTRACT: return K_KP_MEMSUBTRACT;
292// case SDLK_KP_MEMMULTIPLY: return K_KP_MEMMULTIPLY;
293// case SDLK_KP_MEMDIVIDE: return K_KP_MEMDIVIDE;
294// case SDLK_KP_PLUSMINUS: return K_KP_PLUSMINUS;
295// case SDLK_KP_CLEAR: return K_KP_CLEAR;
296// case SDLK_KP_CLEARENTRY: return K_KP_CLEARENTRY;
297// case SDLK_KP_BINARY: return K_KP_BINARY;
298// case SDLK_KP_OCTAL: return K_KP_OCTAL;
299// case SDLK_KP_DECIMAL: return K_KP_DECIMAL;
300// case SDLK_KP_HEXADECIMAL: return K_KP_HEXADECIMAL;
301 case SDLK_LCTRL: return K_CTRL;
302 case SDLK_LSHIFT: return K_SHIFT;
303 case SDLK_LALT: return K_ALT;
304// case SDLK_LGUI: return K_LGUI;
305 case SDLK_RCTRL: return K_CTRL;
306 case SDLK_RSHIFT: return K_SHIFT;
307 case SDLK_RALT: return K_ALT;
308// case SDLK_RGUI: return K_RGUI;
309// case SDLK_MODE: return K_MODE;
310// case SDLK_AUDIONEXT: return K_AUDIONEXT;
311// case SDLK_AUDIOPREV: return K_AUDIOPREV;
312// case SDLK_AUDIOSTOP: return K_AUDIOSTOP;
313// case SDLK_AUDIOPLAY: return K_AUDIOPLAY;
314// case SDLK_AUDIOMUTE: return K_AUDIOMUTE;
315// case SDLK_MEDIASELECT: return K_MEDIASELECT;
316// case SDLK_WWW: return K_WWW;
317// case SDLK_MAIL: return K_MAIL;
318// case SDLK_CALCULATOR: return K_CALCULATOR;
319// case SDLK_COMPUTER: return K_COMPUTER;
320// case SDLK_AC_SEARCH: return K_AC_SEARCH; // Android button
321// case SDLK_AC_HOME: return K_AC_HOME; // Android button
322 case SDLK_AC_BACK: return K_ESCAPE; // Android button
323// case SDLK_AC_FORWARD: return K_AC_FORWARD; // Android button
324// case SDLK_AC_STOP: return K_AC_STOP; // Android button
325// case SDLK_AC_REFRESH: return K_AC_REFRESH; // Android button
326// case SDLK_AC_BOOKMARKS: return K_AC_BOOKMARKS; // Android button
327// case SDLK_BRIGHTNESSDOWN: return K_BRIGHTNESSDOWN;
328// case SDLK_BRIGHTNESSUP: return K_BRIGHTNESSUP;
329// case SDLK_DISPLAYSWITCH: return K_DISPLAYSWITCH;
330// case SDLK_KBDILLUMTOGGLE: return K_KBDILLUMTOGGLE;
331// case SDLK_KBDILLUMDOWN: return K_KBDILLUMDOWN;
332// case SDLK_KBDILLUMUP: return K_KBDILLUMUP;
333// case SDLK_EJECT: return K_EJECT;
334// case SDLK_SLEEP: return K_SLEEP;
335 }
336}
float K_F8
Definition keycodes.qc:31
float K_KP_9
Definition keycodes.qc:65
float K_F1
Definition keycodes.qc:24
float K_KP_EQUALS
Definition keycodes.qc:75
float K_KP_8
Definition keycodes.qc:63
float K_UPARROW
Definition keycodes.qc:15
float K_F9
Definition keycodes.qc:32
float K_PGDN
Definition keycodes.qc:39
float K_F11
Definition keycodes.qc:34
float K_F10
Definition keycodes.qc:33
float K_BACKSPACE
Definition keycodes.qc:14
float K_CAPSLOCK
Definition keycodes.qc:45
float K_KP_PERIOD
Definition keycodes.qc:67
float K_KP_3
Definition keycodes.qc:54
float K_KP_0
Definition keycodes.qc:48
float K_DOWNARROW
Definition keycodes.qc:16
float K_KP_7
Definition keycodes.qc:61
float K_KP_4
Definition keycodes.qc:56
float K_CTRL
Definition keycodes.qc:21
float K_RIGHTARROW
Definition keycodes.qc:18
float K_F6
Definition keycodes.qc:29
float K_F2
Definition keycodes.qc:25
float K_KP_PLUS
Definition keycodes.qc:73
float K_F4
Definition keycodes.qc:27
float K_F12
Definition keycodes.qc:35
float K_DEL
Definition keycodes.qc:38
float K_PGUP
Definition keycodes.qc:40
float K_ALT
Definition keycodes.qc:20
float K_ENTER
Definition keycodes.qc:8
float K_KP_5
Definition keycodes.qc:58
float K_KP_2
Definition keycodes.qc:52
float K_LEFTARROW
Definition keycodes.qc:17
float K_F3
Definition keycodes.qc:26
float K_NUMLOCK
Definition keycodes.qc:44
float K_HOME
Definition keycodes.qc:41
float K_KP_ENTER
Definition keycodes.qc:74
float K_SCROLLOCK
Definition keycodes.qc:46
float K_F5
Definition keycodes.qc:28
float K_END
Definition keycodes.qc:42
float K_KP_MULTIPLY
Definition keycodes.qc:71
float K_INS
Definition keycodes.qc:37
float K_KP_1
Definition keycodes.qc:50
float K_F7
Definition keycodes.qc:30
float K_TAB
Definition keycodes.qc:7
float K_KP_6
Definition keycodes.qc:59
float K_KP_DIVIDE
Definition keycodes.qc:69
float K_KP_MINUS
Definition keycodes.qc:72
float K_PAUSE
Definition keycodes.qc:78
@ K_PRINTSCREEN
Definition keys.h:126
#define SDLK_PERCENT
Definition vid_sdl.c:86

References K_ALT, K_BACKSPACE, K_CAPSLOCK, K_CTRL, K_DEL, K_DOWNARROW, K_END, K_ENTER, K_ESCAPE, K_F1, K_F10, K_F11, K_F12, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_HOME, K_INS, K_KP_0, K_KP_1, K_KP_2, K_KP_3, K_KP_4, K_KP_5, K_KP_6, K_KP_7, K_KP_8, K_KP_9, K_KP_DIVIDE, K_KP_ENTER, K_KP_EQUALS, K_KP_MINUS, K_KP_MULTIPLY, K_KP_PERIOD, K_KP_PLUS, K_LEFTARROW, K_NUMLOCK, K_PAUSE, K_PGDN, K_PGUP, K_PRINTSCREEN, K_RIGHTARROW, K_SCROLLOCK, K_SHIFT, K_SPACE, K_TAB, K_UPARROW, and SDLK_PERCENT.

Referenced by Sys_SDL_HandleEvents().

◆ Sys_SDL_HandleEvents()

void Sys_SDL_HandleEvents ( void )

Perform Key_Event () callbacks until the input que is empty.

Definition at line 1043 of file vid_sdl.c.

1044{
1045 int keycode;
1046 int i;
1047 const char *chp;
1048 qbool isdown;
1049 Uchar unicode;
1050 SDL_Event event;
1051
1052 VID_EnableJoystick(true);
1053
1054 while( SDL_PollEvent( &event ) )
1055 loop_start:
1056 switch( event.type ) {
1057 case SDL_QUIT:
1058#ifdef DEBUGSDLEVENTS
1059 Con_DPrintf("SDL_Event: SDL_QUIT\n");
1060#endif
1062 break;
1063 case SDL_KEYDOWN:
1064 case SDL_KEYUP:
1065#ifdef DEBUGSDLEVENTS
1066 if (event.type == SDL_KEYDOWN)
1067 Con_DPrintf("SDL_Event: SDL_KEYDOWN %i\n", event.key.keysym.sym);
1068 else
1069 Con_DPrintf("SDL_Event: SDL_KEYUP %i\n", event.key.keysym.sym);
1070#endif
1071 keycode = MapKey(event.key.keysym.sym);
1072 isdown = (event.key.state == SDL_PRESSED);
1073 unicode = 0;
1074 if(isdown)
1075 {
1076 if(SDL_PollEvent(&event))
1077 {
1078 if(event.type == SDL_TEXTINPUT)
1079 {
1080 // combine key code from SDL_KEYDOWN event and character
1081 // from SDL_TEXTINPUT event in a single Key_Event call
1082#ifdef DEBUGSDLEVENTS
1083 Con_DPrintf("SDL_Event: SDL_TEXTINPUT - text: %s\n", event.text.text);
1084#endif
1085 unicode = u8_getchar_utf8_enabled(event.text.text + (int)u8_bytelen(event.text.text, 0), NULL);
1086 }
1087 else
1088 {
1089 if (!VID_JoyBlockEmulatedKeys(keycode))
1090 Key_Event(keycode, 0, isdown);
1091 goto loop_start;
1092 }
1093 }
1094 }
1095 if (!VID_JoyBlockEmulatedKeys(keycode))
1096 Key_Event(keycode, unicode, isdown);
1097 break;
1098 case SDL_MOUSEBUTTONDOWN:
1099 case SDL_MOUSEBUTTONUP:
1100#ifdef DEBUGSDLEVENTS
1101 if (event.type == SDL_MOUSEBUTTONDOWN)
1102 Con_DPrintf("SDL_Event: SDL_MOUSEBUTTONDOWN\n");
1103 else
1104 Con_DPrintf("SDL_Event: SDL_MOUSEBUTTONUP\n");
1105#endif
1107 if (event.button.button > 0 && event.button.button <= ARRAY_SIZE(buttonremap))
1108 Key_Event( buttonremap[event.button.button - 1], 0, event.button.state == SDL_PRESSED );
1109 break;
1110 case SDL_MOUSEWHEEL:
1111 // TODO support wheel x direction.
1112 i = event.wheel.y;
1113 while (i > 0) {
1114 --i;
1115 Key_Event( K_MWHEELUP, 0, true );
1116 Key_Event( K_MWHEELUP, 0, false );
1117 }
1118 while (i < 0) {
1119 ++i;
1120 Key_Event( K_MWHEELDOWN, 0, true );
1121 Key_Event( K_MWHEELDOWN, 0, false );
1122 }
1123 break;
1124 case SDL_JOYBUTTONDOWN:
1125 case SDL_JOYBUTTONUP:
1126 case SDL_JOYAXISMOTION:
1127 case SDL_JOYBALLMOTION:
1128 case SDL_JOYHATMOTION:
1129#ifdef DEBUGSDLEVENTS
1130 Con_DPrintf("SDL_Event: SDL_JOY*\n");
1131#endif
1132 break;
1133 case SDL_WINDOWEVENT:
1134#ifdef DEBUGSDLEVENTS
1135 Con_DPrintf("SDL_Event: SDL_WINDOWEVENT %i\n", (int)event.window.event);
1136#endif
1137 //if (event.window.windowID == window) // how to compare?
1138 {
1139 switch(event.window.event)
1140 {
1141 case SDL_WINDOWEVENT_SHOWN:
1142 vid_hidden = false;
1143 break;
1144 case SDL_WINDOWEVENT_HIDDEN:
1145 vid_hidden = true;
1146 break;
1147 case SDL_WINDOWEVENT_EXPOSED:
1148#ifdef DEBUGSDLEVENTS
1149 Con_DPrintf("SDL_Event: SDL_WINDOWEVENT_EXPOSED\n");
1150#endif
1151 break;
1152 case SDL_WINDOWEVENT_MOVED:
1153 vid.xPos = event.window.data1;
1154 vid.yPos = event.window.data2;
1155 // Update vid.displayindex (current monitor) as it may have changed
1156 // SDL_GetWindowDisplayIndex() doesn't work if the window manager moves the fullscreen window, but this works:
1157 for (i = 0; i < vid_info_displaycount.integer; ++i)
1158 {
1159 SDL_Rect displaybounds;
1160 if (SDL_GetDisplayBounds(i, &displaybounds) < 0)
1161 {
1162 Con_Printf(CON_ERROR "Error getting bounds of display %i: \"%s\"\n", i, SDL_GetError());
1163 return;
1164 }
1165 if (vid.xPos >= displaybounds.x && vid.xPos < displaybounds.x + displaybounds.w)
1166 if (vid.yPos >= displaybounds.y && vid.yPos < displaybounds.y + displaybounds.h)
1167 {
1168 vid.mode.display = i;
1169 break;
1170 }
1171 }
1172 // when the window manager adds/removes the border it's likely to move the SDL window
1173 // we'll need to correct that to (re)align the xhair with the monitor
1175 {
1176 SDL_GetWindowBordersSize(window, &i, NULL, NULL, NULL);
1177 if (!i != vid_wmborderless) // border state changed
1178 {
1179 SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(vid.mode.display), SDL_WINDOWPOS_CENTERED_DISPLAY(vid.mode.display));
1180 SDL_GetWindowPosition(window, &vid.xPos, &vid.yPos);
1181 vid_wmborder_waiting = false;
1182 }
1183 }
1184 break;
1185 case SDL_WINDOWEVENT_RESIZED: // external events only
1186 if(vid_resizable.integer < 2)
1187 {
1188 //vid.width = event.window.data1;
1189 //vid.height = event.window.data2;
1190 // get the real framebuffer size in case the platform's screen coordinates are DPI scaled
1191 SDL_GL_GetDrawableSize(window, &vid.mode.width, &vid.mode.height);
1192 }
1193 break;
1194 case SDL_WINDOWEVENT_SIZE_CHANGED: // internal and external events
1195 break;
1196 case SDL_WINDOWEVENT_MINIMIZED:
1197 break;
1198 case SDL_WINDOWEVENT_MAXIMIZED:
1199 break;
1200 case SDL_WINDOWEVENT_RESTORED:
1201 break;
1202 case SDL_WINDOWEVENT_ENTER:
1203 break;
1204 case SDL_WINDOWEVENT_LEAVE:
1205 break;
1206 case SDL_WINDOWEVENT_FOCUS_GAINED:
1207 vid_hasfocus = true;
1208 break;
1209 case SDL_WINDOWEVENT_FOCUS_LOST:
1210 vid_hasfocus = false;
1211 break;
1212 case SDL_WINDOWEVENT_CLOSE:
1214 break;
1215 case SDL_WINDOWEVENT_TAKE_FOCUS:
1216 break;
1217 case SDL_WINDOWEVENT_HIT_TEST:
1218 break;
1219 case SDL_WINDOWEVENT_ICCPROF_CHANGED:
1220 break;
1221 case SDL_WINDOWEVENT_DISPLAY_CHANGED:
1222 // this event can't be relied on in fullscreen, see SDL_WINDOWEVENT_MOVED above
1223 vid.mode.display = event.window.data1;
1224 break;
1225 }
1226 }
1227 break;
1228 case SDL_DISPLAYEVENT: // Display hotplugging
1229 switch (event.display.event)
1230 {
1231 case SDL_DISPLAYEVENT_CONNECTED:
1232 Con_Printf(CON_WARN "Display %i connected: %s\n", event.display.display, SDL_GetDisplayName(event.display.display));
1233#ifdef __linux__
1234 Con_Print(CON_WARN "A vid_restart may be necessary!\n");
1235#endif
1236 Cvar_SetValueQuick(&vid_info_displaycount, SDL_GetNumVideoDisplays());
1237 // Ideally we'd call VID_ApplyDisplayMode() to try to switch to the preferred display here,
1238 // but we may need a vid_restart first, see comments in VID_ApplyDisplayMode().
1239 break;
1240 case SDL_DISPLAYEVENT_DISCONNECTED:
1241 Con_Printf(CON_WARN "Display %i disconnected.\n", event.display.display);
1242#ifdef __linux__
1243 Con_Print(CON_WARN "A vid_restart may be necessary!\n");
1244#endif
1245 Cvar_SetValueQuick(&vid_info_displaycount, SDL_GetNumVideoDisplays());
1246 break;
1247 case SDL_DISPLAYEVENT_ORIENTATION:
1248 break;
1249 }
1250 break;
1251 case SDL_TEXTEDITING:
1252#ifdef DEBUGSDLEVENTS
1253 Con_DPrintf("SDL_Event: SDL_TEXTEDITING - composition = %s, cursor = %d, selection lenght = %d\n", event.edit.text, event.edit.start, event.edit.length);
1254#endif
1255 // FIXME! this is where composition gets supported
1256 break;
1257 case SDL_TEXTINPUT:
1258#ifdef DEBUGSDLEVENTS
1259 Con_DPrintf("SDL_Event: SDL_TEXTINPUT - text: %s\n", event.text.text);
1260#endif
1261 // convert utf8 string to char
1262 // NOTE: this code is supposed to run even if utf8enable is 0
1263 chp = event.text.text;
1264 while (*chp != 0)
1265 {
1266 // input the chars one by one (there can be multiple chars when e.g. using an "input method")
1267 unicode = u8_getchar_utf8_enabled(chp, &chp);
1268 Key_Event(K_TEXT, unicode, true);
1269 Key_Event(K_TEXT, unicode, false);
1270 }
1271 break;
1272 case SDL_MOUSEMOTION:
1273 break;
1274 case SDL_FINGERDOWN:
1275#ifdef DEBUGSDLEVENTS
1276 Con_DPrintf("SDL_FINGERDOWN for finger %i\n", (int)event.tfinger.fingerId);
1277#endif
1278 for (i = 0;i < MAXFINGERS-1;i++)
1279 {
1280 if (!multitouch[i][0])
1281 {
1282 multitouch[i][0] = event.tfinger.fingerId + 1;
1283 multitouch[i][1] = event.tfinger.x;
1284 multitouch[i][2] = event.tfinger.y;
1285 // TODO: use event.tfinger.pressure?
1286 break;
1287 }
1288 }
1289 if (i == MAXFINGERS-1)
1290 Con_DPrintf("Too many fingers at once!\n");
1291 break;
1292 case SDL_FINGERUP:
1293#ifdef DEBUGSDLEVENTS
1294 Con_DPrintf("SDL_FINGERUP for finger %i\n", (int)event.tfinger.fingerId);
1295#endif
1296 for (i = 0;i < MAXFINGERS-1;i++)
1297 {
1298 if (multitouch[i][0] == event.tfinger.fingerId + 1)
1299 {
1300 multitouch[i][0] = 0;
1301 break;
1302 }
1303 }
1304 if (i == MAXFINGERS-1)
1305 Con_DPrintf("No SDL_FINGERDOWN event matches this SDL_FINGERMOTION event\n");
1306 break;
1307 case SDL_FINGERMOTION:
1308#ifdef DEBUGSDLEVENTS
1309 Con_DPrintf("SDL_FINGERMOTION for finger %i\n", (int)event.tfinger.fingerId);
1310#endif
1311 for (i = 0;i < MAXFINGERS-1;i++)
1312 {
1313 if (multitouch[i][0] == event.tfinger.fingerId + 1)
1314 {
1315 multitouch[i][1] = event.tfinger.x;
1316 multitouch[i][2] = event.tfinger.y;
1317 break;
1318 }
1319 }
1320 if (i == MAXFINGERS-1)
1321 Con_DPrintf("No SDL_FINGERDOWN event matches this SDL_FINGERMOTION event\n");
1322 break;
1323 default:
1324#ifdef DEBUGSDLEVENTS
1325 Con_DPrintf("Received unrecognized SDL_Event type 0x%x\n", event.type);
1326#endif
1327 break;
1328 }
1329
1331
1333 VID_SetMouse(false, false);
1334 else if (key_dest == key_menu || key_dest == key_menu_grabbed)
1336 else
1338}
client_static_t cls
Definition cl_main.c:116
cvar_t cl_prydoncursor
Definition cl_main.c:92
cvar_t cl_demo_mousegrab
Definition cl_screen.c:92
qbool scr_loading
Definition cl_screen.c:104
#define ARRAY_SIZE(a)
Definition common.h:318
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_WARN
Definition console.h:101
#define CON_ERROR
Definition console.h:102
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
host_static_t host
Definition host.c:41
@ host_shutdown
states >= host_shutdown cause graceful shutdown, see Sys_HandleCrash() comments
Definition host.h:27
qbool in_client_mouse
Definition vid_shared.c:67
float K_MWHEELDOWN
Definition keycodes.qc:133
float K_MWHEELUP
Definition keycodes.qc:132
void Key_Event(int key, int ascii, qbool down)
Definition keys.c:1836
@ K_TEXT
Definition keys.h:53
@ key_menu
Definition keys.h:372
@ key_menu_grabbed
Definition keys.h:372
qbool csqc_wantsmousemove
Definition client.h:835
qbool demoplayback
Definition client.h:587
int state
Definition host.h:44
int display
Definition vid.h:57
int yPos
current virtual position of the top left corner of the SDL window
Definition vid.h:93
int xPos
Definition vid.h:93
size_t u8_bytelen(const char *_s, size_t n)
Get the number of bytes used in a string to represent an amount of characters.
Definition utf8lib.c:340
Uchar u8_getchar_utf8_enabled(const char *_s, const char **_end)
Fetch a character from an utf-8 encoded string.
Definition utf8lib.c:592
int32_t Uchar
Definition utf8lib.h:35
qbool VID_JoyBlockEmulatedKeys(int keycode)
Definition vid_shared.c:864
cvar_t vid_info_displaycount
Definition vid_shared.c:167
cvar_t vid_mouse
Definition vid_shared.c:150
cvar_t vid_resizable
Definition vid_shared.c:164
qbool vid_hidden
Definition vid_shared.c:74
qbool vid_activewindow
Definition vid_shared.c:77
void VID_EnableJoystick(qbool enable)
Definition vid_sdl.c:1583
static qbool vid_wmborderless
Definition vid_sdl.c:72
static qbool vid_hasfocus
Definition vid_sdl.c:71
static keynum_t buttonremap[]
Definition vid_sdl.c:1022
static int MapKey(unsigned int sdlkey)
Definition vid_sdl.c:89
static void VID_SetMouse(qbool relative, qbool hidecursor)
Definition vid_sdl.c:365
static qbool vid_wmborder_waiting
Definition vid_sdl.c:72

References ARRAY_SIZE, buttonremap, cl, cl_demo_mousegrab, cl_prydoncursor, cls, Con_DPrintf(), CON_ERROR, Con_Print(), Con_Printf(), CON_WARN, client_state_t::csqc_wantsmousemove, Cvar_SetValueQuick(), client_static_t::demoplayback, viddef_mode_t::display, viddef_mode_t::height, host, host_shutdown, i, in_client_mouse, cvar_t::integer, K_MWHEELDOWN, K_MWHEELUP, K_TEXT, key_consoleactive, key_dest, Key_Event(), key_menu, key_menu_grabbed, MapKey(), MAXFINGERS, viddef_t::mode, multitouch, NULL, scr_loading, host_static_t::state, u8_bytelen(), u8_getchar_utf8_enabled(), vid, vid_activewindow, VID_EnableJoystick(), vid_hasfocus, vid_hidden, vid_info_displaycount, VID_JoyBlockEmulatedKeys(), vid_mouse, vid_resizable, VID_SetMouse(), vid_touchscreen, vid_wmborder_waiting, vid_wmborderless, viddef_mode_t::width, window, viddef_t::xPos, and viddef_t::yPos.

Referenced by Host_Frame().

◆ VID_ApplyDisplayMode()

static void VID_ApplyDisplayMode ( const viddef_mode_t * mode)
static

Applies display settings immediately (no vid_restart required).

Definition at line 1357 of file vid_sdl.c.

1358{
1359 uint32_t fullscreenwanted;
1360 int displaywanted = bound(0, mode->display, vid_info_displaycount.integer - 1);
1361 SDL_DisplayMode modefinal;
1362
1363 if (mode->fullscreen)
1364 fullscreenwanted = mode->desktopfullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
1365 else
1366 fullscreenwanted = 0;
1367
1368 // moving to another display or switching to windowed
1369 if (vid.mode.display != displaywanted // SDL seems unable to move any fullscreen window to another display
1370 || !fullscreenwanted)
1371 {
1372 if (SDL_SetWindowFullscreen(window, 0) < 0)
1373 {
1374 Con_Printf(CON_ERROR "ERROR: can't deactivate fullscreen on display %i because %s\n", vid.mode.display, SDL_GetError());
1375 return;
1376 }
1378 Con_DPrintf("Fullscreen deactivated on display %i\n", vid.mode.display);
1379 }
1380
1381 // switching to windowed
1382 if (!fullscreenwanted)
1383 {
1384 int toppx;
1385
1386 SDL_SetWindowSize(window, vid.mode.width = mode->width, vid.mode.height = mode->height);
1387 // resizable and borderless set here cos a separate callback would fail if the cvar is changed when the window is fullscreen
1388 SDL_SetWindowResizable(window, vid_resizable.integer ? SDL_TRUE : SDL_FALSE);
1389 SDL_SetWindowBordered(window, (SDL_bool)!vid_borderless.integer);
1390 SDL_GetWindowBordersSize(window, &toppx, NULL, NULL, NULL);
1391 vid_wmborderless = !toppx;
1392 if (vid_borderless.integer != vid_wmborderless) // this is not the state we're looking for
1393 vid_wmborder_waiting = true;
1394 }
1395
1396 // moving to another display or switching to windowed
1397 if (vid.mode.display != displaywanted || !fullscreenwanted)
1398 {
1399// SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(displaywanted), SDL_WINDOWPOS_CENTERED_DISPLAY(displaywanted));
1400// SDL_GetWindowPosition(window, &vid.xPos, &vid.yPos);
1401
1402 /* bones_was_here BUG: after SDL_DISPLAYEVENT hotplug events, on Xorg + NVIDIA,
1403 * SDL_WINDOWPOS_CENTERED_DISPLAY(displaywanted) may place the window somewhere completely invisible.
1404 * WORKAROUND: manual positioning seems safer: although SDL_GetDisplayBounds() may return outdated values,
1405 * SDL_SetWindowPosition() always placed the window somewhere fully visible, even if it wasn't correct,
1406 * when tested with SDL 2.26.5.
1407 */
1408 SDL_Rect displaybounds;
1409 if (SDL_GetDisplayBounds(displaywanted, &displaybounds) < 0)
1410 {
1411 Con_Printf(CON_ERROR "Error getting bounds of display %i: \"%s\"\n", displaywanted, SDL_GetError());
1412 return;
1413 }
1414 vid.xPos = displaybounds.x + 0.5 * (displaybounds.w - vid.mode.width);
1415 vid.yPos = displaybounds.y + 0.5 * (displaybounds.h - vid.mode.height);
1416 SDL_SetWindowPosition(window, vid.xPos, vid.yPos);
1417
1418 vid.mode.display = displaywanted;
1419 }
1420
1421 // switching to a fullscreen mode
1422 if (fullscreenwanted)
1423 {
1424 if (fullscreenwanted == SDL_WINDOW_FULLSCREEN)
1425 {
1426 // determine if a modeset is needed and if the requested resolution is supported
1427 SDL_DisplayMode modewanted, modecurrent;
1428
1429 modewanted.w = mode->width;
1430 modewanted.h = mode->height;
1431 modewanted.format = mode->bitsperpixel == 16 ? SDL_PIXELFORMAT_RGB565 : SDL_PIXELFORMAT_RGB888;
1432 modewanted.refresh_rate = mode->refreshrate;
1433 if (!SDL_GetClosestDisplayMode(displaywanted, &modewanted, &modefinal))
1434 {
1435 // SDL_GetError() returns a random unrelated error if this fails (in 2.26.5)
1436 Con_Printf(CON_ERROR "Error getting closest mode to %ix%i@%ihz for display %i\n", modewanted.w, modewanted.h, modewanted.refresh_rate, vid.mode.display);
1437 return;
1438 }
1439 if (SDL_GetCurrentDisplayMode(displaywanted, &modecurrent) < 0)
1440 {
1441 Con_Printf(CON_ERROR "Error getting current mode of display %i: \"%s\"\n", vid.mode.display, SDL_GetError());
1442 return;
1443 }
1444 if (memcmp(&modecurrent, &modefinal, sizeof(modecurrent)) != 0)
1445 {
1446 if (mode->width != modefinal.w || mode->height != modefinal.h)
1447 {
1448 Con_Printf(CON_WARN "Display %i doesn't support resolution %ix%i\n", vid.mode.display, modewanted.w, modewanted.h);
1449 return;
1450 }
1451 if (SDL_SetWindowDisplayMode(window, &modefinal) < 0)
1452 {
1453 Con_Printf(CON_ERROR "Error setting mode %ix%i@%ihz for display %i: \"%s\"\n", modefinal.w, modefinal.h, modefinal.refresh_rate, vid.mode.display, SDL_GetError());
1454 return;
1455 }
1456 // HACK to work around SDL BUG when switching from a lower to a higher res:
1457 // the display res gets increased but the window size isn't increased
1458 // (unless we do this first; switching to windowed mode first also works).
1459 SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
1460 }
1461 }
1462
1463 if (SDL_SetWindowFullscreen(window, fullscreenwanted) < 0)
1464 {
1465 Con_Printf(CON_ERROR "ERROR: can't activate fullscreen on display %i because %s\n", vid.mode.display, SDL_GetError());
1466 return;
1467 }
1468 // get the real framebuffer size in case the platform's screen coordinates are DPI scaled
1469 SDL_GL_GetDrawableSize(window, &vid.mode.width, &vid.mode.height);
1470 vid.mode.fullscreen = true;
1471 vid.mode.desktopfullscreen = fullscreenwanted == SDL_WINDOW_FULLSCREEN_DESKTOP;
1472 Con_DPrintf("Fullscreen activated on display %i\n", vid.mode.display);
1473 }
1474
1475 if (!fullscreenwanted || fullscreenwanted == SDL_WINDOW_FULLSCREEN_DESKTOP)
1476 SDL_GetDesktopDisplayMode(displaywanted, &modefinal);
1477 else { /* modefinal was set by SDL_GetClosestDisplayMode */ }
1478 vid.mode.bitsperpixel = SDL_BITSPERPIXEL(modefinal.format);
1479 vid.mode.refreshrate = mode->refreshrate && mode->fullscreen && !mode->desktopfullscreen ? modefinal.refresh_rate : 0;
1480 vid.stencil = mode->bitsperpixel > 16;
1481}
GLenum mode
Definition glquake.h:718
#define bound(min, num, max)
Definition mathlib.h:34
qbool desktopfullscreen
whether the display hardware mode can be changed
Definition vid.h:59
float refreshrate
Definition vid.h:63
qbool fullscreen
Definition vid.h:58
int bitsperpixel
Definition vid.h:62
qbool stencil
Definition vid.h:74
cvar_t vid_borderless
Definition vid_shared.c:135

References viddef_mode_t::bitsperpixel, bound, Con_DPrintf(), CON_ERROR, Con_Printf(), CON_WARN, viddef_mode_t::desktopfullscreen, viddef_mode_t::display, viddef_mode_t::fullscreen, viddef_mode_t::height, cvar_t::integer, mode, viddef_t::mode, NULL, viddef_mode_t::refreshrate, viddef_t::stencil, vid, vid_borderless, vid_info_displaycount, vid_resizable, vid_wmborder_waiting, vid_wmborderless, viddef_mode_t::width, window, viddef_t::xPos, and viddef_t::yPos.

Referenced by VID_ApplyDisplayMode_c(), and VID_InitModeGL().

◆ VID_ApplyDisplayMode_c()

static void VID_ApplyDisplayMode_c ( cvar_t * var)
static

Definition at line 1483 of file vid_sdl.c.

1484{
1486
1487 if (!window)
1488 return;
1489
1490 // Menu designs aren't suitable for instant hardware modesetting
1491 // they make players scroll through a list, setting the cvars at each step.
1492 if (key_dest == key_menu && !key_consoleactive // in menu, console closed
1493 && vid_fullscreen.integer && !vid_desktopfullscreen.integer) // modesetting enabled
1494 return;
1495
1496 Con_DPrintf("%s: applying %s \"%s\"\n", __func__, var->name, var->string);
1497
1498 mode.display = vid_display.integer;
1499 mode.fullscreen = vid_fullscreen.integer;
1500 mode.desktopfullscreen = vid_desktopfullscreen.integer;
1501 mode.width = vid_width.integer;
1502 mode.height = vid_height.integer;
1503 mode.bitsperpixel = vid_bitsperpixel.integer;
1504 mode.refreshrate = max(0, vid_refreshrate.integer);
1506}
#define max(A, B)
Definition mathlib.h:38
const char * name
Definition cvar.h:69
const char * string
Definition cvar.h:71
cvar_t vid_refreshrate
Definition vid_shared.c:140
cvar_t vid_display
Definition vid_shared.c:166
cvar_t vid_desktopfullscreen
Definition vid_shared.c:165
cvar_t vid_bitsperpixel
Definition vid_shared.c:138
cvar_t vid_fullscreen
Definition vid_shared.c:134
static void VID_ApplyDisplayMode(const viddef_mode_t *mode)
Applies display settings immediately (no vid_restart required).
Definition vid_sdl.c:1357

References Con_DPrintf(), cvar_t::integer, key_consoleactive, key_dest, key_menu, max, mode, cvar_t::name, cvar_t::string, VID_ApplyDisplayMode(), vid_bitsperpixel, vid_desktopfullscreen, vid_display, vid_fullscreen, vid_height, vid_refreshrate, vid_width, and window.

Referenced by VID_Init().

◆ VID_BuildJoyState()

void VID_BuildJoyState ( vid_joystate_t * joystate)

Definition at line 683 of file vid_sdl.c.

684{
686
687 if (vid_sdljoystick)
688 {
689 SDL_Joystick *joy = vid_sdljoystick;
690 int j;
691
693 {
694 for (j = 0; j <= SDL_CONTROLLER_AXIS_MAX; ++j)
695 {
696 joystate->axis[j] = SDL_GameControllerGetAxis(vid_sdlgamecontroller, (SDL_GameControllerAxis)j) * (1.0f / 32767.0f);
697 }
698 for (j = 0; j < SDL_CONTROLLER_BUTTON_MAX; ++j)
699 joystate->button[j] = SDL_GameControllerGetButton(vid_sdlgamecontroller, (SDL_GameControllerButton)j);
700 // emulate joy buttons for trigger "axes"
701 joystate->button[SDL_CONTROLLER_BUTTON_MAX] = VID_JoyState_GetAxis(joystate, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1, joy_sdl2_trigger_deadzone.value) > 0.0f;
702 joystate->button[SDL_CONTROLLER_BUTTON_MAX+1] = VID_JoyState_GetAxis(joystate, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1, joy_sdl2_trigger_deadzone.value) > 0.0f;
703 }
704 else
705
706 {
707 int numaxes;
708 int numbuttons;
709 numaxes = SDL_JoystickNumAxes(joy);
710 for (j = 0;j < numaxes;j++)
711 joystate->axis[j] = SDL_JoystickGetAxis(joy, j) * (1.0f / 32767.0f);
712 numbuttons = SDL_JoystickNumButtons(joy);
713 for (j = 0;j < numbuttons;j++)
714 joystate->button[j] = SDL_JoystickGetButton(joy, j);
715 }
716 }
717
719}
unsigned char button[MAXJOYBUTTON]
0 or 1
Definition vid.h:105
float axis[MAXJOYAXIS]
-1 to +1
Definition vid.h:104
void VID_Shared_BuildJoyState_Finish(vid_joystate_t *joystate)
Definition vid_shared.c:929
float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float sensitivity, float deadzone)
Definition vid_shared.c:854
void VID_Shared_BuildJoyState_Begin(vid_joystate_t *joystate)
Definition vid_shared.c:885
static SDL_GameController * vid_sdlgamecontroller
Definition vid_sdl.c:74
static cvar_t joy_sdl2_trigger_deadzone
Definition vid_sdl.c:75
static SDL_Joystick * vid_sdljoystick
Definition vid_sdl.c:73

References vid_joystate_t::axis, vid_joystate_t::button, joy_sdl2_trigger_deadzone, cvar_t::value, VID_JoyState_GetAxis(), vid_sdlgamecontroller, vid_sdljoystick, VID_Shared_BuildJoyState_Begin(), and VID_Shared_BuildJoyState_Finish().

Referenced by IN_Move(), and VID_JoyBlockEmulatedKeys().

◆ VID_EnableJoystick()

void VID_EnableJoystick ( qbool enable)

Definition at line 1583 of file vid_sdl.c.

1584{
1585 int index = joy_enable.integer > 0 ? joy_index.integer : -1;
1586 int numsdljoysticks;
1587 qbool success = false;
1588 int sharedcount = 0;
1589 int sdlindex = -1;
1590 sharedcount = VID_Shared_SetJoystick(index);
1591 if (index >= 0 && index < sharedcount)
1592 success = true;
1593 sdlindex = index - sharedcount;
1594
1595 numsdljoysticks = SDL_NumJoysticks();
1596 if (sdlindex < 0 || sdlindex >= numsdljoysticks)
1597 sdlindex = -1;
1598
1599 // update cvar containing count of XInput joysticks + SDL joysticks
1600 if (joy_detected.integer != sharedcount + numsdljoysticks)
1601 Cvar_SetValueQuick(&joy_detected, sharedcount + numsdljoysticks);
1602
1603 if (vid_sdljoystickindex != sdlindex)
1604 {
1605 vid_sdljoystickindex = sdlindex;
1606 // close SDL joystick if active
1607 if (vid_sdljoystick)
1608 {
1609 SDL_JoystickClose(vid_sdljoystick);
1611 }
1613 {
1614 SDL_GameControllerClose(vid_sdlgamecontroller);
1616 }
1617 if (sdlindex >= 0)
1618 {
1619 vid_sdljoystick = SDL_JoystickOpen(sdlindex);
1620 if (vid_sdljoystick)
1621 {
1622 const char *joystickname = SDL_JoystickName(vid_sdljoystick);
1623 if (SDL_IsGameController(vid_sdljoystickindex))
1624 {
1625 vid_sdlgamecontroller = SDL_GameControllerOpen(vid_sdljoystickindex);
1626 Con_DPrintf("Using SDL GameController mappings for Joystick %i\n", index);
1627 }
1628 Con_Printf("Joystick %i opened (SDL_Joystick %i is \"%s\" with %i axes, %i buttons, %i balls)\n", index, sdlindex, joystickname, (int)SDL_JoystickNumAxes(vid_sdljoystick), (int)SDL_JoystickNumButtons(vid_sdljoystick), (int)SDL_JoystickNumBalls(vid_sdljoystick));
1629 }
1630 else
1631 {
1632 Con_Printf(CON_ERROR "Joystick %i failed (SDL_JoystickOpen(%i) returned: %s)\n", index, sdlindex, SDL_GetError());
1633 sdlindex = -1;
1634 }
1635 }
1636 }
1637
1638 if (sdlindex >= 0)
1639 success = true;
1640
1641 if (joy_active.integer != (success ? 1 : 0))
1642 Cvar_SetValueQuick(&joy_active, success ? 1 : 0);
1643}
GLuint index
Definition glquake.h:629
cvar_t joy_active
Definition vid_shared.c:84
cvar_t joy_detected
Definition vid_shared.c:85
cvar_t joy_enable
Definition vid_shared.c:86
cvar_t joy_index
Definition vid_shared.c:87
int VID_Shared_SetJoystick(int index)
static int vid_sdljoystickindex
Definition vid_sdl.c:1582

References Con_DPrintf(), CON_ERROR, Con_Printf(), Cvar_SetValueQuick(), index, cvar_t::integer, joy_active, joy_detected, joy_enable, joy_index, NULL, vid_sdlgamecontroller, vid_sdljoystick, vid_sdljoystickindex, and VID_Shared_SetJoystick().

Referenced by Sys_SDL_HandleEvents(), and VID_Shutdown().

◆ VID_Finish()

void VID_Finish ( void )

Definition at line 1876 of file vid_sdl.c.

1877{
1879
1880 if (!vid_hidden)
1881 {
1882 switch(vid.renderpath)
1883 {
1884 case RENDERPATH_GL32:
1885 case RENDERPATH_GLES2:
1887 if (r_speeds.integer == 2 || gl_finish.integer)
1888 GL_Finish();
1889 SDL_GL_SwapWindow(window);
1890 break;
1891 }
1892 }
1893}
void GL_Finish(void)
Definition gl_backend.c:399
cvar_t r_speeds
Definition gl_rmain.c:111
#define CHECKGLERROR
Definition glquake.h:1059
renderpath_t renderpath
Definition vid.h:80
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37
void VID_UpdateGamma(void)
updates cachegamma variables and bumps vid_gammatables_serial if anything changed (ONLY to be called ...
cvar_t gl_finish
Definition vid_shared.c:156

References CHECKGLERROR, GL_Finish(), gl_finish, cvar_t::integer, r_speeds, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, vid, vid_hidden, VID_UpdateGamma(), and window.

Referenced by CL_UpdateScreen(), and VID_InitModeGL().

◆ VID_GetDesktopMode()

vid_mode_t VID_GetDesktopMode ( void )

Definition at line 1895 of file vid_sdl.c.

1896{
1897 SDL_DisplayMode mode;
1898 int bpp;
1899 Uint32 rmask, gmask, bmask, amask;
1900 vid_mode_t desktop_mode;
1901
1902 SDL_GetDesktopDisplayMode(vid.mode.display, &mode);
1903 SDL_PixelFormatEnumToMasks(mode.format, &bpp, &rmask, &gmask, &bmask, &amask);
1904 desktop_mode.width = mode.w;
1905 desktop_mode.height = mode.h;
1906 desktop_mode.bpp = bpp;
1907 desktop_mode.refreshrate = mode.refresh_rate;
1908 desktop_mode.pixelheight_num = 1;
1909 desktop_mode.pixelheight_denom = 1; // SDL does not provide this
1910 return desktop_mode;
1911}
int pixelheight_denom
Definition vid.h:244
int bpp
Definition vid.h:243
int refreshrate
Definition vid.h:243
int pixelheight_num
Definition vid.h:244
int width
Definition vid.h:243
int height
Definition vid.h:243

References vid_mode_t::bpp, viddef_mode_t::display, vid_mode_t::height, mode, viddef_t::mode, vid_mode_t::pixelheight_denom, vid_mode_t::pixelheight_num, vid_mode_t::refreshrate, vid, and vid_mode_t::width.

Referenced by VM_M_getresolution().

◆ VID_HasScreenKeyboardSupport()

qbool VID_HasScreenKeyboardSupport ( void )

Definition at line 338 of file vid_sdl.c.

339{
340 return SDL_HasScreenKeyboardSupport() != SDL_FALSE;
341}

◆ VID_Init()

void VID_Init ( void )

Called at startup.

Definition at line 1534 of file vid_sdl.c.

1535{
1536 SDL_version version;
1537
1538#ifndef __IPHONEOS__
1539#ifdef MACOSX
1540 Cvar_RegisterVariable(&apple_mouse_noaccel);
1541#endif
1542#endif
1543#ifdef DP_MOBILETOUCH
1545#endif
1547
1559
1560 // DPI scaling prevents use of the native resolution, causing blurry rendering
1561 // and/or mouse cursor problems and/or incorrect render area, so we need to opt-out.
1562 // Must be set before first SDL_INIT_VIDEO. Documented in SDL_hints.h.
1563#ifdef WIN32
1564 // make SDL coordinates == hardware pixels
1565 SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "0");
1566 // use best available awareness mode
1567 SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2");
1568#endif
1569
1570 if (SDL_Init(SDL_INIT_VIDEO) < 0)
1571 Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
1572 if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
1573 Con_Printf(CON_ERROR "Failed to init SDL joystick subsystem: %s\n", SDL_GetError());
1574
1575 SDL_GetVersion(&version);
1576 Con_Printf("Linked against SDL version %d.%d.%d\n"
1577 "Using SDL library version %d.%d.%d\n",
1578 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL,
1579 version.major, version.minor, version.patch);
1580}
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
void Cvar_RegisterCallback(cvar_t *variable, void(*callback)(cvar_t *))
Definition cvar.c:495
static int const char * version
Definition fs.c:479
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:724
cvar_t vid_minimize_on_focus_loss
Definition vid_shared.c:152
cvar_t vid_vsync
Definition vid_shared.c:149
cvar_t vid_mouse_clickthrough
Definition vid_shared.c:151
static void VID_SetVsync_c(cvar_t *var)
Definition vid_sdl.c:1508
static void VID_ApplyDisplayMode_c(cvar_t *var)
Definition vid_sdl.c:1483
static void VID_SetHints_c(cvar_t *var)
Definition vid_sdl.c:1528

References CON_ERROR, Con_Printf(), Cvar_RegisterCallback(), Cvar_RegisterVariable(), Cvar_SetValueQuick(), joy_sdl2_trigger_deadzone, Sys_Error(), version, VID_ApplyDisplayMode_c(), vid_borderless, vid_desktopfullscreen, vid_display, vid_fullscreen, vid_height, vid_minimize_on_focus_loss, vid_mouse_clickthrough, vid_refreshrate, vid_resizable, VID_SetHints_c(), VID_SetVsync_c(), vid_touchscreen, vid_vsync, and vid_width.

Referenced by CL_Init().

◆ VID_InitMode()

qbool VID_InitMode ( const viddef_mode_t * mode)

allocates and opens an appropriate OpenGL context (and its window)

Definition at line 1850 of file vid_sdl.c.

1851{
1852 // GAME_STEELSTORM specific
1853 steelstorm_showing_map = Cvar_FindVar(&cvars_all, "steelstorm_showing_map", ~0);
1854 steelstorm_showing_mousecursor = Cvar_FindVar(&cvars_all, "steelstorm_showing_mousecursor", ~0);
1855
1856 if (!SDL_WasInit(SDL_INIT_VIDEO) && SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
1857 Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
1858
1859 Cvar_SetValueQuick(&vid_touchscreen_supportshowkeyboard, SDL_HasScreenKeyboardSupport() ? 1 : 0);
1860 return VID_InitModeGL(mode);
1861}
cvar_state_t cvars_all
Definition cvar.c:28
cvar_t * Cvar_FindVar(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
Definition cvar.c:36
cvar_t vid_touchscreen_supportshowkeyboard
Definition vid_shared.c:162
static qbool VID_InitModeGL(const viddef_mode_t *mode)
Definition vid_sdl.c:1692

References Cvar_FindVar(), Cvar_SetValueQuick(), cvars_all, mode, steelstorm_showing_map, steelstorm_showing_mousecursor, Sys_Error(), VID_InitModeGL(), and vid_touchscreen_supportshowkeyboard.

Referenced by VID_Mode().

◆ VID_InitModeGL()

static qbool VID_InitModeGL ( const viddef_mode_t * mode)
static

Definition at line 1692 of file vid_sdl.c.

1693{
1694 int windowflags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
1695 int i;
1696 // SDL usually knows best
1697 const char *drivername = NULL;
1698
1699 // video display selection (multi-monitor)
1700 Cvar_SetValueQuick(&vid_info_displaycount, SDL_GetNumVideoDisplays());
1702 vid.xPos = SDL_WINDOWPOS_CENTERED_DISPLAY(vid.mode.display);
1703 vid.yPos = SDL_WINDOWPOS_CENTERED_DISPLAY(vid.mode.display);
1705
1707 windowflags |= SDL_WINDOW_RESIZABLE;
1708
1709#ifndef USE_GLES2
1710// COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
1711 i = Sys_CheckParm("-gl_driver");
1712 if (i && i < sys.argc - 1)
1713 drivername = sys.argv[i + 1];
1714 if (SDL_GL_LoadLibrary(drivername) < 0)
1715 {
1716 Con_Printf(CON_ERROR "Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
1717 return false;
1718 }
1719#endif
1720
1721#ifdef DP_MOBILETOUCH
1722 // mobile platforms are always fullscreen, we'll get the resolution after opening the window
1723 mode->fullscreen = true;
1724 // hide the menu with SDL_WINDOW_BORDERLESS
1725 windowflags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
1726#endif
1727
1728 // SDL_CreateWindow() supports only width and height modesetting,
1729 // so initially we use desktopfullscreen and perform a modeset later if necessary,
1730 // this way we do only one modeset to apply the full config.
1731 if (mode->fullscreen)
1732 {
1733 windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
1735 }
1736 else
1737 {
1739 windowflags |= SDL_WINDOW_BORDERLESS;
1740 else
1741 vid_wmborder_waiting = true; // waiting for border to be added
1742#ifdef WIN32
1743 if (!vid_ignore_taskbar.integer)
1744 {
1745 RECT rect;
1746 AdjustWindowBounds((viddef_mode_t *)mode, &rect);
1747 vid.xPos = rect.left;
1748 vid.xPos = rect.top;
1749 vid_wmborder_waiting = false;
1750 }
1751#endif
1753 }
1754
1756
1757 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
1758 SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
1759 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
1760 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
1761 SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 8);
1762 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24);
1763 SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8);
1764 if (mode->stereobuffer)
1765 {
1766 SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
1767 vid.mode.stereobuffer = true;
1768 }
1769 if (mode->samples > 1)
1770 {
1771 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1);
1772 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, mode->samples);
1773 }
1774
1775#ifdef USE_GLES2
1776 SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
1777 SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2);
1778 SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0);
1779#else
1780 SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
1781 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
1782 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
1783 /* Requesting a Core profile and 3.2 minimum is mandatory on macOS and older Mesa drivers.
1784 * It works fine on other drivers too except NVIDIA, see HACK below.
1785 */
1786#endif
1787
1788 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, (gl_debug.integer > 0 ? SDL_GL_CONTEXT_DEBUG_FLAG : 0));
1789
1790 window = SDL_CreateWindow(gamename, vid.xPos, vid.yPos, mode->width, mode->height, windowflags);
1791 if (window == NULL)
1792 {
1793 Con_Printf(CON_ERROR "Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
1794 VID_Shutdown();
1795 return false;
1796 }
1797
1798 context = SDL_GL_CreateContext(window);
1799 if (context == NULL)
1800 Sys_Error("Failed to initialize OpenGL context: %s\n", SDL_GetError());
1801
1803
1804#if !defined(USE_GLES2) && !defined(MACOSX)
1805 // NVIDIA hates the Core profile and limits the version to the minimum we specified.
1806 // HACK: to detect NVIDIA we first need a context, fortunately replacing it takes a few milliseconds
1807 gl_vendor = (const char *)qglGetString(GL_VENDOR);
1808 if (strncmp(gl_vendor, "NVIDIA", 6) == 0)
1809 {
1810 Con_DPrint("The Way It's Meant To Be Played: replacing OpenGL Core profile with Compatibility profile...\n");
1811 SDL_GL_DeleteContext(context);
1812 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
1813 context = SDL_GL_CreateContext(window);
1814 if (context == NULL)
1815 Sys_Error("Failed to initialize OpenGL context: %s\n", SDL_GetError());
1816 }
1817#endif
1818
1819 // apply vid_vsync
1821
1822 vid_hidden = false;
1823 vid_activewindow = true;
1824 vid_hasfocus = true;
1825 vid_usingmouse = false;
1826 vid_usinghidecursor = false;
1827
1828 // clear to black (loading plaque will be seen over this)
1830 VID_Finish(); // checks vid_hidden
1831
1832 GL_Setup();
1833
1834 // VorteX: set other info
1838 Cvar_SetQuick(&gl_info_driver, drivername ? drivername : "");
1839
1840 for (i = 0; i < vid_info_displaycount.integer; ++i)
1841 Con_Printf("Display %i: %s\n", i, SDL_GetDisplayName(i));
1842
1843 // Perform any hardware modesetting and update vid.mode
1844 // if modesetting fails desktopfullscreen continues to be used (see above).
1846
1847 return true;
1848}
const char * gamename
Definition com_game.c:27
void Con_DPrint(const char *msg)
A Con_Print that only shows up if the "developer" cvar is set.
Definition console.c:1531
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
void Cvar_Callback(cvar_t *var)
Definition cvar.c:372
void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue)
cvar_t gl_debug
Definition gl_backend.c:7
#define GL_COLOR_BUFFER_BIT
Definition glquake.h:171
const GLubyte *GLAPIENTRY * qglGetString(GLenum name)
#define GL_VENDOR
Definition glquake.h:138
int argc
Definition sys.h:146
const char ** argv
Definition sys.h:147
qbool stereobuffer
Definition vid.h:64
sys_t sys
Definition sys_shared.c:42
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327
const char * gl_vendor
brand of graphics chip
Definition vid_shared.c:190
void GL_Setup(void)
Definition vid_shared.c:712
cvar_t gl_info_version
Definition vid_shared.c:130
void GL_InitFunctions(void)
Definition vid_shared.c:684
cvar_t gl_info_renderer
Definition vid_shared.c:129
const char * gl_version
begins with 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, or 1.4.0
Definition vid_shared.c:194
cvar_t gl_info_driver
Definition vid_shared.c:132
const char * gl_renderer
graphics chip model and other information
Definition vid_shared.c:192
cvar_t gl_info_vendor
Definition vid_shared.c:128
static qbool vid_usinghidecursor
Definition vid_sdl.c:70
void VID_Finish(void)
Definition vid_sdl.c:1876
static SDL_GLContext context
Definition vid_sdl.c:80
void VID_Shutdown(void)
Called at shutdown.
Definition vid_sdl.c:1863

References sys_t::argc, sys_t::argv, bound, Con_DPrint(), CON_ERROR, Con_Printf(), context, Cvar_Callback(), Cvar_SetQuick(), Cvar_SetValueQuick(), viddef_mode_t::desktopfullscreen, viddef_mode_t::display, viddef_mode_t::fullscreen, gamename, GL_Clear(), GL_COLOR_BUFFER_BIT, gl_debug, gl_info_driver, gl_info_renderer, gl_info_vendor, gl_info_version, GL_InitFunctions(), gl_renderer, GL_Setup(), GL_VENDOR, gl_vendor, gl_version, i, cvar_t::integer, mode, viddef_t::mode, NULL, qglGetString(), viddef_mode_t::stereobuffer, sys, Sys_CheckParm(), Sys_Error(), vid, vid_activewindow, VID_ApplyDisplayMode(), vid_borderless, VID_Finish(), vid_hasfocus, vid_hidden, vid_info_displaycount, vid_resizable, VID_SetHints_c(), VID_Shutdown(), vid_usinghidecursor, vid_usingmouse, vid_vsync, vid_wmborder_waiting, vid_wmborderless, window, viddef_t::xPos, and viddef_t::yPos.

Referenced by VID_InitMode().

◆ VID_ListModes()

size_t VID_ListModes ( vid_mode_t * modes,
size_t maxcount )

Definition at line 1913 of file vid_sdl.c.

1914{
1915 size_t k = 0;
1916 int modenum;
1917 int nummodes = SDL_GetNumDisplayModes(vid.mode.display);
1918 SDL_DisplayMode mode;
1919 for (modenum = 0;modenum < nummodes;modenum++)
1920 {
1921 if (k >= maxcount)
1922 break;
1923 if (SDL_GetDisplayMode(vid.mode.display, modenum, &mode))
1924 continue;
1925 modes[k].width = mode.w;
1926 modes[k].height = mode.h;
1927 modes[k].bpp = SDL_BITSPERPIXEL(mode.format);
1928 modes[k].refreshrate = mode.refresh_rate;
1929 modes[k].pixelheight_num = 1;
1930 modes[k].pixelheight_denom = 1; // SDL does not provide this
1931 Con_DPrintf("Display %i mode %i: %ix%i %ibpp %ihz\n", vid.mode.display, modenum, modes[k].width, modes[k].height, modes[k].bpp, modes[k].refreshrate);
1932 k++;
1933 }
1934 return k;
1935}
static glmode_t modes[6]

References Con_DPrintf(), viddef_mode_t::display, mode, viddef_t::mode, modes, and vid.

Referenced by MR_Init().

◆ VID_SetHints_c()

static void VID_SetHints_c ( cvar_t * var)
static

Definition at line 1528 of file vid_sdl.c.

1529{
1530 SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, vid_mouse_clickthrough.integer ? "1" : "0");
1531 SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, vid_minimize_on_focus_loss.integer ? "1" : "0");
1532}

References cvar_t::integer, vid_minimize_on_focus_loss, and vid_mouse_clickthrough.

Referenced by VID_Init(), and VID_InitModeGL().

◆ VID_SetMouse()

static void VID_SetMouse ( qbool relative,
qbool hidecursor )
static

Definition at line 365 of file vid_sdl.c.

366{
367#ifndef DP_MOBILETOUCH
368#ifdef MACOSX
369 if(relative)
370 if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
371 VID_SetMouse(false, false); // ungrab first!
372#endif
373 if (vid_usingmouse != relative)
374 {
375 vid_usingmouse = relative;
377 vid_usingmouse_relativeworks = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE) == 0;
378// Con_Printf("VID_SetMouse(%i, %i) relativeworks = %i\n", (int)relative, (int)hidecursor, (int)vid_usingmouse_relativeworks);
379#ifdef MACOSX
380 if(relative)
381 {
382 // Save the status of mouse acceleration
383 originalMouseSpeed = -1.0; // in case of error
384 if(apple_mouse_noaccel.integer)
385 {
386 io_connect_t mouseDev = IN_GetIOHandle();
387 if(mouseDev != 0)
388 {
389 if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
390 {
391 Con_DPrintf("previous mouse acceleration: %f\n", originalMouseSpeed);
392 if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
393 {
394 Con_Print("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
395 Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
396 }
397 }
398 else
399 {
400 Con_Print("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
401 Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
402 }
403 IOServiceClose(mouseDev);
404 }
405 else
406 {
407 Con_Print("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
408 Cvar_SetValueQuick(&apple_mouse_noaccel, 0);
409 }
410 }
411
412 vid_usingnoaccel = !!apple_mouse_noaccel.integer;
413 }
414 else
415 {
416 if(originalMouseSpeed != -1.0)
417 {
418 io_connect_t mouseDev = IN_GetIOHandle();
419 if(mouseDev != 0)
420 {
421 Con_DPrintf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
422 if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
423 Con_Print("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
424 IOServiceClose(mouseDev);
425 }
426 else
427 Con_Print("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
428 }
429 }
430#endif
431 }
432 if (vid_usinghidecursor != hidecursor)
433 {
434 vid_usinghidecursor = hidecursor;
435 SDL_ShowCursor( hidecursor ? SDL_DISABLE : SDL_ENABLE);
436 }
437#endif
438}
int cl_ignoremousemoves
Definition cl_input.c:474

References cl_ignoremousemoves, Con_DPrintf(), Con_Print(), Cvar_SetValueQuick(), cvar_t::integer, VID_SetMouse(), vid_usinghidecursor, vid_usingmouse, and vid_usingmouse_relativeworks.

Referenced by Sys_SDL_HandleEvents(), VID_SetMouse(), and VID_Shutdown().

◆ VID_SetVsync_c()

static void VID_SetVsync_c ( cvar_t * var)
static

Definition at line 1508 of file vid_sdl.c.

1509{
1510 int vsyncwanted = cls.timedemo ? 0 : vid_vsync.integer;
1511
1512 if (!context)
1513 return;
1514/*
1515Can't check first: on Wayland SDL_GL_GetSwapInterval() may initially return 0 when vsync is on.
1516On Xorg it returns the correct value.
1517 if (SDL_GL_GetSwapInterval() == vsyncwanted)
1518 return;
1519*/
1520
1521 // __EMSCRIPTEN__ SDL_GL_SetSwapInterval() calls emscripten_set_main_loop_timing()
1522 if (SDL_GL_SetSwapInterval(vsyncwanted) >= 0)
1523 Con_DPrintf("Vsync %s\n", vsyncwanted ? "activated" : "deactivated");
1524 else
1525 Con_Printf(CON_ERROR "ERROR: can't %s vsync because %s\n", vsyncwanted ? "activate" : "deactivate", SDL_GetError());
1526}
qbool timedemo
Definition client.h:589

References cls, Con_DPrintf(), CON_ERROR, Con_Printf(), context, cvar_t::integer, client_static_t::timedemo, and vid_vsync.

Referenced by VID_Init().

◆ VID_ShowingKeyboard()

qbool VID_ShowingKeyboard ( void )

Definition at line 360 of file vid_sdl.c.

361{
362 return SDL_IsTextInputActive() != 0;
363}

Referenced by IN_Move_TouchScreen_Quake(), and IN_Move_TouchScreen_SteelStorm().

◆ VID_ShowKeyboard()

void VID_ShowKeyboard ( qbool show)

Definition at line 343 of file vid_sdl.c.

344{
345 if (!SDL_HasScreenKeyboardSupport())
346 return;
347
348 if (show)
349 {
350 if (!SDL_IsTextInputActive())
351 SDL_StartTextInput();
352 }
353 else
354 {
355 if (SDL_IsTextInputActive())
356 SDL_StopTextInput();
357 }
358}

Referenced by IN_Move(), and IN_Move_TouchScreen_Quake().

◆ VID_Shutdown()

void VID_Shutdown ( void )

Called at shutdown.

Definition at line 1863 of file vid_sdl.c.

1864{
1865 VID_EnableJoystick(false);
1866 VID_SetMouse(false, false);
1867
1868 SDL_GL_DeleteContext(context);
1869 context = NULL;
1870 SDL_DestroyWindow(window);
1871 window = NULL;
1872
1873 SDL_QuitSubSystem(SDL_INIT_VIDEO);
1874}

References context, NULL, VID_EnableJoystick(), VID_SetMouse(), and window.

Referenced by CL_Shutdown(), Sys_Error(), Sys_HandleCrash(), VID_InitModeGL(), and VID_Restart_f().

◆ VID_TouchscreenArea()

static qbool VID_TouchscreenArea ( int corner,
float px,
float py,
float pwidth,
float pheight,
const char * icon,
float textheight,
const char * text,
float * resultmove,
qbool * resultbutton,
keynum_t key,
const char * typedtext,
float deadzone,
float oversizepixels_x,
float oversizepixels_y,
qbool iamexclusive )
static

Definition at line 452 of file vid_sdl.c.

453{
454 int finger;
455 float fx, fy, fwidth, fheight;
456 float overfx, overfy, overfwidth, overfheight;
457 float rel[3];
458 float sqsum;
459 qbool button = false;
460 VectorClear(rel);
461 if (pwidth > 0 && pheight > 0)
462 {
463 if (corner & 1) px += vid_conwidth.value;
464 if (corner & 2) py += vid_conheight.value;
465 if (corner & 4) px += vid_conwidth.value * 0.5f;
466 if (corner & 8) py += vid_conheight.value * 0.5f;
467 if (corner & 16) {px *= vid_conwidth.value * (1.0f / 640.0f);py *= vid_conheight.value * (1.0f / 480.0f);pwidth *= vid_conwidth.value * (1.0f / 640.0f);pheight *= vid_conheight.value * (1.0f / 480.0f);}
468 fx = px / vid_conwidth.value;
469 fy = py / vid_conheight.value;
470 fwidth = pwidth / vid_conwidth.value;
471 fheight = pheight / vid_conheight.value;
472
473 // try to prevent oversizepixels_* from interfering with the iamexclusive cvar by not letting we start controlling from too far of the actual touch area (areas without resultbuttons should NEVER have the oversizepixels_* parameters set to anything other than 0)
474 if (resultbutton)
475 if (!(*resultbutton))
476 {
477 oversizepixels_x *= 0.2;
478 oversizepixels_y *= 0.2;
479 }
480
481 oversizepixels_x /= vid_conwidth.value;
482 oversizepixels_y /= vid_conheight.value;
483
484 overfx = fx - oversizepixels_x;
485 overfy = fy - oversizepixels_y;
486 overfwidth = fwidth + 2*oversizepixels_x;
487 overfheight = fheight + 2*oversizepixels_y;
488
489 for (finger = 0;finger < MAXFINGERS;finger++)
490 {
491 if (multitouchs[finger] && iamexclusive) // for this to work correctly, you must call touch areas in order of highest to lowest priority
492 continue;
493
494 if (multitouch[finger][0] && multitouch[finger][1] >= overfx && multitouch[finger][2] >= overfy && multitouch[finger][1] < overfx + overfwidth && multitouch[finger][2] < overfy + overfheight)
495 {
496 multitouchs[finger]++;
497
498 rel[0] = bound(-1, (multitouch[finger][1] - (fx + 0.5f * fwidth)) * (2.0f / fwidth), 1);
499 rel[1] = bound(-1, (multitouch[finger][2] - (fy + 0.5f * fheight)) * (2.0f / fheight), 1);
500 rel[2] = 0;
501
502 sqsum = rel[0]*rel[0] + rel[1]*rel[1];
503 // 2d deadzone
504 if (sqsum < deadzone*deadzone)
505 {
506 rel[0] = 0;
507 rel[1] = 0;
508 }
509 else if (sqsum > 1)
510 {
511 // ignore the third component
512 Vector2Normalize2(rel, rel);
513 }
514 button = true;
515 break;
516 }
517 }
518 if (scr_numtouchscreenareas < 128)
519 {
528 // the pics may have alpha too.
532 }
533 }
534 if (resultmove)
535 {
536 if (button)
537 VectorCopy(rel, resultmove);
538 else
539 VectorClear(resultmove);
540 }
541 if (resultbutton)
542 {
543 if (*resultbutton != button)
544 {
545 if ((int)key > 0)
546 Key_Event(key, 0, button);
547 if (typedtext && typedtext[0] && !*resultbutton)
548 {
549 // FIXME: implement UTF8 support - nothing actually specifies a UTF8 string here yet, but should support it...
550 int i;
551 for (i = 0;typedtext[i];i++)
552 {
553 Key_Event(K_TEXT, typedtext[i], true);
554 Key_Event(K_TEXT, typedtext[i], false);
555 }
556 }
557 }
558 *resultbutton = button;
559 }
560 return button;
561}
scr_touchscreenarea_t scr_touchscreenareas[128]
Definition cl_screen.c:1505
#define Vector2Normalize2(v, dest)
Definition mathlib.h:78
#define VectorClear(a)
Definition mathlib.h:97
#define VectorCopy(in, out)
Definition mathlib.h:101
vec2 px
const char * text
Definition screen.h:81
const char * pic
Definition screen.h:80

References scr_touchscreenarea_t::active, scr_touchscreenarea_t::activealpha, bound, i, scr_touchscreenarea_t::inactivealpha, K_TEXT, Key_Event(), MAXFINGERS, multitouch, multitouchs, scr_touchscreenarea_t::pic, px, scr_touchscreenarea_t::rect, scr_numtouchscreenareas, scr_touchscreenareas, scr_touchscreenarea_t::text, scr_touchscreenarea_t::textheight, cvar_t::value, Vector2Normalize2, VectorClear, VectorCopy, vid_conheight, and vid_conwidth.

Referenced by IN_Move_TouchScreen_Quake(), and IN_Move_TouchScreen_SteelStorm().

◆ VID_TouchscreenCursor()

static void VID_TouchscreenCursor ( float px,
float py,
float pwidth,
float pheight,
qbool * resultbutton,
keynum_t key )
static

resultbutton != button &&

Definition at line 565 of file vid_sdl.c.

566{
567 int finger;
568 float fx, fy, fwidth, fheight;
569 qbool button = false;
570 static int cursorfinger = -1;
571 static int cursorfreemovement = false;
572 static int canclick = false;
573 static int clickxy[2];
574 static int relclickxy[2];
575 static double clickrealtime = 0;
576
578 if (pwidth > 0 && pheight > 0)
579 {
580 fx = px / vid_conwidth.value;
581 fy = py / vid_conheight.value;
582 fwidth = pwidth / vid_conwidth.value;
583 fheight = pheight / vid_conheight.value;
584 for (finger = 0;finger < MAXFINGERS;finger++)
585 {
586 if (multitouch[finger][0] && multitouch[finger][1] >= fx && multitouch[finger][2] >= fy && multitouch[finger][1] < fx + fwidth && multitouch[finger][2] < fy + fheight)
587 {
588 if (cursorfinger == -1)
589 {
590 clickxy[0] = multitouch[finger][1] * vid_width.value - 0.5f * pwidth;
591 clickxy[1] = multitouch[finger][2] * vid_height.value - 0.5f * pheight;
592 relclickxy[0] = (multitouch[finger][1] - fx) * vid_width.value - 0.5f * pwidth;
593 relclickxy[1] = (multitouch[finger][2] - fy) * vid_height.value - 0.5f * pheight;
594 }
595 cursorfinger = finger;
596 button = true;
597 canclick = true;
598 cursorfreemovement = false;
599 break;
600 }
601 }
602 if (scr_numtouchscreenareas < 128)
603 {
604 if (clickrealtime + 1 > host.realtime)
605 {
606 scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_click.tga";
607 }
608 else if (button)
609 {
610 scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_touch.tga";
611 }
612 else
613 {
614 switch ((int)host.realtime * 10 % 20)
615 {
616 case 0:
617 scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_touch.tga";
618 break;
619 default:
620 scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_idle.tga";
621 }
622 }
633 }
634 }
635
636 if (cursorfinger != -1)
637 {
638 if (multitouch[cursorfinger][0])
639 {
640 if (multitouch[cursorfinger][1] * vid_width.value - 0.5f * pwidth < clickxy[0] - 1 ||
641 multitouch[cursorfinger][1] * vid_width.value - 0.5f * pwidth > clickxy[0] + 1 ||
642 multitouch[cursorfinger][2] * vid_height.value - 0.5f * pheight< clickxy[1] - 1 ||
643 multitouch[cursorfinger][2] * vid_height.value - 0.5f * pheight> clickxy[1] + 1) // finger drifted more than the allowed amount
644 {
645 cursorfreemovement = true;
646 }
647 if (cursorfreemovement)
648 {
649 // in_windowmouse_x* is in screen resolution coordinates, not console resolution
650 in_windowmouse_x = multitouch[cursorfinger][1] * vid_width.value - 0.5f * pwidth - relclickxy[0];
651 in_windowmouse_y = multitouch[cursorfinger][2] * vid_height.value - 0.5f * pheight - relclickxy[1];
652 }
653 }
654 else
655 {
656 cursorfinger = -1;
657 }
658 }
659
660 if (resultbutton)
661 {
662 if ((int)key > 0)
663 {
664 if (!button && !cursorfreemovement && canclick)
665 {
666 Key_Event(key, 0, true);
667 canclick = false;
668 clickrealtime = host.realtime;
669 }
670
671 // SS:BR can't qc can't cope with presses and releases on the same frame
672 if (clickrealtime && clickrealtime + 0.1 < host.realtime)
673 {
674 Key_Event(key, 0, false);
675 clickrealtime = 0;
676 }
677 }
678
679 *resultbutton = button;
680 }
681}
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46

References scr_touchscreenarea_t::active, scr_touchscreenarea_t::activealpha, host, in_windowmouse_x, in_windowmouse_y, scr_touchscreenarea_t::inactivealpha, cvar_t::integer, Key_Event(), MAXFINGERS, multitouch, scr_touchscreenarea_t::pic, px, host_static_t::realtime, scr_touchscreenarea_t::rect, scr_numtouchscreenareas, scr_touchscreenareas, steelstorm_showing_mousecursor, scr_touchscreenarea_t::text, scr_touchscreenarea_t::textheight, cvar_t::value, vid_conheight, vid_conwidth, vid_height, and vid_width.

Referenced by IN_Move_TouchScreen_SteelStorm().

Variable Documentation

◆ buttonremap

keynum_t buttonremap[]
static
Initial value:
=
{
}
float K_MOUSE13
Definition keycodes.qc:143
float K_MOUSE16
Definition keycodes.qc:146
float K_MOUSE15
Definition keycodes.qc:145
float K_MOUSE8
Definition keycodes.qc:138
float K_MOUSE7
Definition keycodes.qc:137
float K_MOUSE10
Definition keycodes.qc:140
float K_MOUSE14
Definition keycodes.qc:144
float K_MOUSE11
Definition keycodes.qc:141
float K_MOUSE6
Definition keycodes.qc:136
float K_MOUSE12
Definition keycodes.qc:142
float K_MOUSE9
Definition keycodes.qc:139

Definition at line 1022 of file vid_sdl.c.

1023{
1024 K_MOUSE1,
1025 K_MOUSE3,
1026 K_MOUSE2,
1027 K_MOUSE4,
1028 K_MOUSE5,
1029 K_MOUSE6,
1030 K_MOUSE7,
1031 K_MOUSE8,
1032 K_MOUSE9,
1033 K_MOUSE10,
1034 K_MOUSE11,
1035 K_MOUSE12,
1036 K_MOUSE13,
1037 K_MOUSE14,
1038 K_MOUSE15,
1039 K_MOUSE16,
1040};

Referenced by Sys_SDL_HandleEvents().

◆ cl_available

int cl_available = true

Definition at line 64 of file vid_sdl.c.

Referenced by Host_Init(), and SV_ServerOptions().

◆ context

SDL_GLContext context
static

Definition at line 80 of file vid_sdl.c.

Referenced by VID_InitModeGL(), VID_SetVsync_c(), and VID_Shutdown().

◆ joy_sdl2_trigger_deadzone

cvar_t joy_sdl2_trigger_deadzone = {CF_ARCHIVE | CF_CLIENT, "joy_sdl2_trigger_deadzone", "0.5", "deadzone for triggers to be registered as key presses"}
static

Definition at line 75 of file vid_sdl.c.

75{CF_ARCHIVE | CF_CLIENT, "joy_sdl2_trigger_deadzone", "0.5", "deadzone for triggers to be registered as key presses"};
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by VID_BuildJoyState(), and VID_Init().

◆ multitouch

◆ multitouchs

int multitouchs[MAXFINGERS]

◆ steelstorm_showing_map

cvar_t* steelstorm_showing_map = NULL
static

Definition at line 77 of file vid_sdl.c.

Referenced by IN_Move_TouchScreen_SteelStorm(), and VID_InitMode().

◆ steelstorm_showing_mousecursor

cvar_t* steelstorm_showing_mousecursor = NULL
static

Definition at line 78 of file vid_sdl.c.

Referenced by IN_Move_TouchScreen_SteelStorm(), VID_InitMode(), and VID_TouchscreenCursor().

◆ vid_hasfocus

qbool vid_hasfocus = false
static

Definition at line 71 of file vid_sdl.c.

Referenced by Sys_SDL_HandleEvents(), and VID_InitModeGL().

◆ vid_sdlgamecontroller

SDL_GameController* vid_sdlgamecontroller = NULL
static

Definition at line 74 of file vid_sdl.c.

Referenced by VID_BuildJoyState(), and VID_EnableJoystick().

◆ vid_sdljoystick

SDL_Joystick* vid_sdljoystick = NULL
static

Definition at line 73 of file vid_sdl.c.

Referenced by VID_BuildJoyState(), and VID_EnableJoystick().

◆ vid_sdljoystickindex

int vid_sdljoystickindex = -1
static

Definition at line 1582 of file vid_sdl.c.

Referenced by VID_EnableJoystick().

◆ vid_supportrefreshrate

qbool vid_supportrefreshrate = false

Definition at line 66 of file vid_sdl.c.

◆ vid_usinghidecursor

qbool vid_usinghidecursor = false
static

Definition at line 70 of file vid_sdl.c.

Referenced by VID_InitModeGL(), and VID_SetMouse().

◆ vid_usingmouse

qbool vid_usingmouse = false
static

Definition at line 68 of file vid_sdl.c.

Referenced by IN_Move(), VID_InitModeGL(), and VID_SetMouse().

◆ vid_usingmouse_relativeworks

qbool vid_usingmouse_relativeworks = false
static

Definition at line 69 of file vid_sdl.c.

Referenced by IN_Move(), and VID_SetMouse().

◆ vid_wmborder_waiting

qbool vid_wmborder_waiting
static

Definition at line 72 of file vid_sdl.c.

Referenced by Sys_SDL_HandleEvents(), VID_ApplyDisplayMode(), and VID_InitModeGL().

◆ vid_wmborderless

qbool vid_wmborderless
static

Definition at line 72 of file vid_sdl.c.

Referenced by Sys_SDL_HandleEvents(), VID_ApplyDisplayMode(), and VID_InitModeGL().

◆ window

SDL_Window* window
static