UFO: Alien Invasion
cl_input.cpp
Go to the documentation of this file.
1
18/*
19All original material Copyright (C) 2002-2022 UFO: Alien Invasion.
20
21Original file from Quake 2 v3.21: quake2-2.31/client/cl_input.c
22Copyright (C) 1997-2001 Id Software, Inc.
23
24This program is free software; you can redistribute it and/or
25modify it under the terms of the GNU General Public License
26as published by the Free Software Foundation; either version 2
27of the License, or (at your option) any later version.
28
29This program is distributed in the hope that it will be useful,
30but WITHOUT ANY WARRANTY; without even the implied warranty of
31MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
32
33See the GNU General Public License for more details.
34
35You should have received a copy of the GNU General Public License
36along with this program; if not, write to the Free Software
37Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38
39*/
40
41#include "../client.h"
42#include "cl_input.h"
43#include "cl_keys.h"
44#include "cl_joystick.h"
45#include "../battlescape/cl_localentity.h"
46#include "../battlescape/cl_hud.h"
47#include "../cl_console.h"
48#include "../cl_screen.h"
49#include "../battlescape/cl_actor.h"
50#include "../battlescape/cl_view.h"
51#include "../battlescape/cl_parse.h"
52#include "../ui/ui_main.h"
53#include "../ui/ui_input.h"
54#include "../ui/node/ui_node_abstractnode.h"
55#include "../../shared/utf8.h"
56
57#include "../../common/tracing.h"
58#include "../renderer/r_misc.h"
59
60/* power of two please */
61#define MAX_KEYQ 64
62
63#if SDL_VERSION_ATLEAST(2,0,0)
64#define SDL_keysym SDL_Keysym
65#endif
66
67static struct {
68 unsigned int key;
69 unsigned short unicode;
70 int down;
72
73static int keyq_head = 0;
74static int keyq_tail = 0;
75
78
82
86enum {
89};
90
91/*
92===============================================================================
93KEY BUTTONS
94===============================================================================
95*/
96
97typedef struct {
98 int down[2];
99 unsigned downtime;
100 unsigned msec;
101 int state;
102} kbutton_t;
103
109
117static void IN_KeyDown (kbutton_t* b)
118{
119 int k;
120 const char* c = Cmd_Argv(1);
121
122 if (c[0])
123 k = atoi(c);
124 else
125 /* typed manually at the console for continuous down */
126 k = -1;
127
128 /* repeating key */
129 if (k == b->down[0] || k == b->down[1])
130 return;
131
132 if (!b->down[0])
133 b->down[0] = k;
134 else if (!b->down[1])
135 b->down[1] = k;
136 else {
137 Com_Printf("Three keys down for a button!\n");
138 return;
139 }
140
141 /* still down */
142 if (b->state)
143 return;
144
145 /* save timestamp */
146 c = Cmd_Argv(2);
147 b->downtime = atoi(c);
148 if (!b->downtime)
149 b->downtime = CL_Milliseconds() - 100;
150
151 /* down */
152 b->state = 1;
153}
154
163static void IN_KeyUp (kbutton_t* b)
164{
165 int k;
166 const char* c = Cmd_Argv(1);
167
168 if (c[0])
169 k = atoi(c);
170 /* typed manually at the console, assume for unsticking, so clear all */
171 else {
172 b->down[0] = b->down[1] = 0;
173 return;
174 }
175
176 if (b->down[0] == k)
177 b->down[0] = 0;
178 else if (b->down[1] == k)
179 b->down[1] = 0;
180 /* key up without corresponding down (menu pass through) */
181 else
182 return;
183
184 /* some other key is still holding it down */
185 if (b->down[0] || b->down[1])
186 return;
187
188 /* still up (this should not happen) */
189 if (!b->state)
190 return;
191
192 /* save timestamp */
193 c = Cmd_Argv(2);
194 const unsigned uptime = atoi(c);
195 if (uptime)
196 b->msec = uptime - b->downtime;
197 else
198 b->msec = 10;
199
200 /* now up */
201 b->state = 0;
202}
203
204static void IN_TurnLeftDown_f (void)
205{
207}
208static void IN_TurnLeftUp_f (void)
209{
211}
212static void IN_TurnRightDown_f (void)
213{
215}
216static void IN_TurnRightUp_f (void)
217{
219}
220static void IN_TurnUpDown_f (void)
221{
223}
224static void IN_TurnUpUp_f (void)
225{
227}
228static void IN_TurnDownDown_f (void)
229{
231}
232static void IN_TurnDownUp_f (void)
233{
235}
236static void IN_PanTiltDown_f (void)
237{
238 if (IN_GetMouseSpace() != MS_WORLD)
239 return;
241}
242static void IN_PanTiltUp_f (void)
243{
245}
246static void IN_ShiftLeftDown_f (void)
247{
249}
250static void IN_ShiftLeftUp_f (void)
251{
253}
254static void IN_ShiftLeftUpDown_f (void)
255{
258}
259static void IN_ShiftLeftUpUp_f (void)
260{
263}
264static void IN_ShiftLeftDownDown_f (void)
265{
268}
269static void IN_ShiftLeftDownUp_f (void)
270{
273}
274static void IN_ShiftRightDown_f (void)
275{
277}
278static void IN_ShiftRightUp_f (void)
279{
281}
282static void IN_ShiftRightUpDown_f (void)
283{
286}
287static void IN_ShiftRightUpUp_f (void)
288{
291}
292static void IN_ShiftRightDownDown_f (void)
293{
296}
297static void IN_ShiftRightDownUp_f (void)
298{
301}
302static void IN_ShiftUpDown_f (void)
303{
305}
306static void IN_ShiftUpUp_f (void)
307{
309}
310static void IN_ShiftDownDown_f (void)
311{
313}
314static void IN_ShiftDownUp_f (void)
315{
317}
318static void IN_ZoomInDown_f (void)
319{
321}
322static void IN_ZoomInUp_f (void)
323{
325}
326static void IN_ZoomOutDown_f (void)
327{
329}
330static void IN_ZoomOutUp_f (void)
331{
333}
334
335
339static void CL_LevelUp_f (void)
340{
341 if (!CL_OnBattlescape())
342 return;
343 Cvar_SetValue("cl_worldlevel", (cl_worldlevel->integer < cl.mapMaxLevel - 1) ? cl_worldlevel->integer + 1 : cl.mapMaxLevel - 1);
344}
345
349static void CL_LevelDown_f (void)
350{
351 if (!CL_OnBattlescape())
352 return;
353 Cvar_SetValue("cl_worldlevel", (cl_worldlevel->integer > 0) ? cl_worldlevel->integer - 1 : 0);
354}
355
356static void CL_ZoomInQuant_f (void)
357{
359}
360
361static void CL_ZoomOutQuant_f (void)
362{
364}
365
366static void CL_WheelDown_f (void)
367{
368 UI_MouseScroll(0, 1);
369}
370
371static void CL_WheelUp_f (void)
372{
373 UI_MouseScroll(0, -1);
374}
375
379static void CL_SelectDown_f (void)
380{
383 return;
388}
389
390static void CL_SelectUp_f (void)
391{
392#ifdef ANDROID
393 /* Android input quirk - when user tries to zoom/rotate, and touches the screen with a second finger,
394 * SDL will send left mouse button up event, and right mouse button down event immediately after that,
395 * so we need to cancel the mouse click action, and let the user zoom/rotate as she wants */
396 if ((SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(SDL_BUTTON_RIGHT)) == 0)
397#endif
402 if (IN_GetMouseSpace() == MS_UI)
403 return;
405}
406
407static void CL_ProcessMouseDragging (void)
408{
410 return;
411
416
419}
420
424static void CL_ActionDown_f (void)
425{
426 if (!CL_OnBattlescape())
427 return;
429}
430
431static void CL_ActionUp_f (void)
432{
434 if (IN_GetMouseSpace() == MS_UI)
435 return;
436 if (in_pantilt.msec < 250)
439}
440
444static void CL_TurnDown_f (void)
445{
446 if (IN_GetMouseSpace() == MS_UI)
447 return;
448 if (IN_GetMouseSpace() == MS_WORLD)
450}
451
452static void CL_TurnUp_f (void)
453{
454 if (IN_GetMouseSpace() == MS_UI)
455 return;
457}
458
462static void CL_HudRadarDown_f (void)
463{
465 return;
466 UI_PushWindow("radarmenu");
467}
468
472static void CL_HudRadarUp_f (void)
473{
475 return;
476 UI_CloseWindow("radarmenu");
477}
478
482static void CL_RightClickDown_f (void)
483{
484 if (IN_GetMouseSpace() == MS_UI) {
486 }
487}
488
492static void CL_RightClickUp_f (void)
493{
494 if (IN_GetMouseSpace() == MS_UI) {
496 }
497}
498
502static void CL_MiddleClickDown_f (void)
503{
504 if (IN_GetMouseSpace() == MS_UI) {
506 }
507}
508
512static void CL_MiddleClickUp_f (void)
513{
514 if (IN_GetMouseSpace() == MS_UI) {
516 }
517}
518
522static void CL_LeftClickDown_f (void)
523{
524 if (IN_GetMouseSpace() == MS_UI) {
526 }
527}
528
532static void CL_LeftClickUp_f (void)
533{
534 if (IN_GetMouseSpace() == MS_UI) {
536 }
537}
538
539#define SCROLL_BORDER 4
540#define MOUSE_YAW_SCALE 0.1
541#define MOUSE_PITCH_SCALE 0.1
542
546float CL_GetKeyMouseState (int dir)
547{
548 float value;
549
550 switch (dir) {
551 case STATE_FORWARD:
552 /* sum directions, 'true' is use as '1' */
554 break;
555 case STATE_RIGHT:
556 /* sum directions, 'true' is use as '1' */
558 break;
559 case STATE_ZOOM:
560 value = (in_zoomin.state & 1) - (in_zoomout.state & 1);
561 break;
562 case STATE_ROT:
563 value = (in_turnleft.state & 1) - (in_turnright.state & 1);
564 if (in_pantilt.state)
565 value -= (float) (mousePosX - oldMousePosX) * MOUSE_YAW_SCALE;
566 break;
567 case STATE_TILT:
568 value = (in_turnup.state & 1) - (in_turndown.state & 1);
569 if (in_pantilt.state)
570 value += (float) (mousePosY - oldMousePosY) * MOUSE_PITCH_SCALE;
571 break;
572 default:
573 value = 0.0;
574 break;
575 }
576
577 return value;
578}
579
584static void IN_Parse (void)
585{
587
588 /* standard menu and world mouse handling */
589 if (UI_IsMouseOnWindow()) {
591 return;
592 }
593
594 if (cls.state != ca_active)
595 return;
596
598 return;
599
600 if (CL_ActorMouseTrace()) {
601 /* mouse is in the world */
603 }
604}
605
609static inline void IN_PrintKey (const SDL_Event* event, int down)
610{
611 if (in_debug->integer) {
612 Com_Printf("key name: %s (down: %i)", SDL_GetKeyName(event->key.keysym.sym), down);
613#if SDL_VERSION_ATLEAST(2,0,0)
614 const int unicode = event->key.keysym.sym;
615#else
616 const int unicode = event->key.keysym.unicode;
617#endif
618 if (unicode) {
619 Com_Printf(" unicode: %x", unicode);
620 if (unicode >= '0' && unicode <= '~') /* printable? */
621 Com_Printf(" (%c)", (unsigned char)(unicode));
622 }
623 Com_Printf("\n");
624 }
625}
626
630static bool IN_TranslateKey (const unsigned int keycode, unsigned int* ascii)
631{
632 bool translated = true;
633 switch (keycode) {
634 case SDLK_PAGEUP:
635 *ascii = K_PGUP;
636 break;
637#if SDL_VERSION_ATLEAST(2,0,0)
638 case SDLK_KP_0:
639 *ascii = K_KP_INS;
640 translated = !Key_IsNumlock();
641 break;
642 case SDLK_KP_1:
643 *ascii = K_KP_END;
644 translated = !Key_IsNumlock();
645 break;
646 case SDLK_KP_2:
647 *ascii = K_KP_DOWNARROW;
648 translated = !Key_IsNumlock();
649 break;
650 case SDLK_KP_3:
651 *ascii = K_KP_PGDN;
652 translated = !Key_IsNumlock();
653 break;
654 case SDLK_KP_4:
655 *ascii = K_KP_LEFTARROW;
656 translated = !Key_IsNumlock();
657 break;
658 case SDLK_KP_5:
659 *ascii = K_KP_5;
660 translated = !Key_IsNumlock();
661 break;
662 case SDLK_KP_6:
663 *ascii = K_KP_RIGHTARROW;
664 translated = !Key_IsNumlock();
665 break;
666 case SDLK_KP_7:
667 *ascii = K_KP_HOME;
668 translated = !Key_IsNumlock();
669 break;
670 case SDLK_KP_8:
671 *ascii = K_KP_UPARROW;
672 translated = !Key_IsNumlock();
673 break;
674 case SDLK_KP_9:
675 *ascii = K_KP_PGUP;
676 translated = !Key_IsNumlock();
677 break;
678 case SDLK_PRINTSCREEN:
679 *ascii = K_PRINT;
680 break;
681 case SDLK_SCROLLLOCK:
682 *ascii = K_SCROLLOCK;
683 break;
684#else
685 case SDLK_KP0:
686 *ascii = K_KP_INS;
687 translated = !Key_IsNumlock();
688 break;
689 case SDLK_KP1:
690 *ascii = K_KP_END;
691 translated = !Key_IsNumlock();
692 break;
693 case SDLK_KP2:
694 *ascii = K_KP_DOWNARROW;
695 translated = !Key_IsNumlock();
696 break;
697 case SDLK_KP3:
698 *ascii = K_KP_PGDN;
699 translated = !Key_IsNumlock();
700 break;
701 case SDLK_KP4:
702 *ascii = K_KP_LEFTARROW;
703 translated = !Key_IsNumlock();
704 break;
705 case SDLK_KP5:
706 *ascii = K_KP_5;
707 translated = !Key_IsNumlock();
708 break;
709 case SDLK_KP6:
710 *ascii = K_KP_RIGHTARROW;
711 translated = !Key_IsNumlock();
712 break;
713 case SDLK_KP7:
714 *ascii = K_KP_HOME;
715 translated = !Key_IsNumlock();
716 break;
717 case SDLK_KP8:
718 *ascii = K_KP_UPARROW;
719 translated = !Key_IsNumlock();
720 break;
721 case SDLK_KP9:
722 *ascii = K_KP_PGUP;
723 translated = !Key_IsNumlock();
724 break;
725 case SDLK_LSUPER:
726 case SDLK_RSUPER:
727 *ascii = K_SUPER;
728 break;
729 case SDLK_COMPOSE:
730 *ascii = K_COMPOSE;
731 break;
732 case SDLK_PRINT:
733 *ascii = K_PRINT;
734 break;
735 case SDLK_BREAK:
736 *ascii = K_BREAK;
737 break;
738 case SDLK_EURO:
739 *ascii = K_EURO;
740 break;
741 case SDLK_SCROLLOCK:
742 *ascii = K_SCROLLOCK;
743 break;
744 case SDLK_NUMLOCK:
745 *ascii = K_KP_NUMLOCK;
746 break;
747#endif
748 case SDLK_PAGEDOWN:
749 *ascii = K_PGDN;
750 break;
751 case SDLK_HOME:
752 *ascii = K_HOME;
753 break;
754 case SDLK_END:
755 *ascii = K_END;
756 break;
757 case SDLK_LEFT:
758 *ascii = K_LEFTARROW;
759 break;
760 case SDLK_RIGHT:
761 *ascii = K_RIGHTARROW;
762 break;
763 case SDLK_DOWN:
764 *ascii = K_DOWNARROW;
765 break;
766 case SDLK_UP:
767 *ascii = K_UPARROW;
768 break;
769 case SDLK_ESCAPE:
770 *ascii = K_ESCAPE;
771 break;
772 case SDLK_KP_ENTER:
773 *ascii = K_KP_ENTER;
774 break;
775 case SDLK_RETURN:
776 *ascii = K_ENTER;
777 break;
778 case SDLK_TAB:
779 *ascii = K_TAB;
780 break;
781 case SDLK_F1:
782 *ascii = K_F1;
783 break;
784 case SDLK_F2:
785 *ascii = K_F2;
786 break;
787 case SDLK_F3:
788 *ascii = K_F3;
789 break;
790 case SDLK_F4:
791 *ascii = K_F4;
792 break;
793 case SDLK_F5:
794 *ascii = K_F5;
795 break;
796 case SDLK_F6:
797 *ascii = K_F6;
798 break;
799 case SDLK_F7:
800 *ascii = K_F7;
801 break;
802 case SDLK_F8:
803 *ascii = K_F8;
804 break;
805 case SDLK_F9:
806 *ascii = K_F9;
807 break;
808 case SDLK_F10:
809 *ascii = K_F10;
810 break;
811 case SDLK_F11:
812 *ascii = K_F11;
813 break;
814 case SDLK_F12:
815 *ascii = K_F12;
816 break;
817 case SDLK_F13:
818 *ascii = K_F13;
819 break;
820 case SDLK_F14:
821 *ascii = K_F14;
822 break;
823 case SDLK_F15:
824 *ascii = K_F15;
825 break;
826 case SDLK_BACKSPACE:
827 *ascii = K_BACKSPACE;
828 break;
829 case SDLK_KP_PERIOD:
830 *ascii = K_KP_DEL;
831 translated = !Key_IsNumlock();
832 break;
833 case SDLK_DELETE:
834 *ascii = K_DEL;
835 break;
836 case SDLK_PAUSE:
837 *ascii = K_PAUSE;
838 break;
839 case SDLK_LSHIFT:
840 case SDLK_RSHIFT:
841 *ascii = K_SHIFT;
842 break;
843 case SDLK_LCTRL:
844 case SDLK_RCTRL:
845 *ascii = K_CTRL;
846 break;
847 case SDLK_LALT:
848 case SDLK_RALT:
849 *ascii = K_ALT;
850 break;
851 case SDLK_INSERT:
852 *ascii = K_INS;
853 break;
854 case SDLK_KP_PLUS:
855 *ascii = K_KP_PLUS;
856 translated = !Key_IsNumlock();
857 break;
858 case SDLK_KP_MINUS:
859 *ascii = K_KP_MINUS;
860 translated = !Key_IsNumlock();
861 break;
862 case SDLK_KP_DIVIDE:
863 *ascii = K_KP_SLASH;
864 translated = !Key_IsNumlock();
865 break;
866 case SDLK_KP_MULTIPLY:
867 *ascii = K_KP_MULTIPLY;
868 translated = !Key_IsNumlock();
869 break;
870 case SDLK_MODE:
871 *ascii = K_MODE;
872 break;
873 case SDLK_HELP:
874 *ascii = K_HELP;
875 break;
876 case SDLK_SYSREQ:
877 *ascii = K_SYSREQ;
878 break;
879 case SDLK_MENU:
880 *ascii = K_MENU;
881 break;
882 case SDLK_POWER:
883 *ascii = K_POWER;
884 break;
885 case SDLK_UNDO:
886 *ascii = K_UNDO;
887 break;
888 case SDLK_CAPSLOCK:
889 *ascii = K_CAPSLOCK;
890 break;
891 case SDLK_SPACE:
892 *ascii = K_SPACE;
893 break;
894 default:
895 translated = false;
896 if (UTF8_encoded_len(keycode) == 1 && isprint(keycode))
897 *ascii = keycode;
898 else
899 *ascii = 0;
900 break;
901 }
902 return translated;
903}
904
905void IN_EventEnqueue (unsigned int keyNum, unsigned short keyUnicode, bool keyDown)
906{
907 if (keyNum > 0 || keyUnicode > 0) {
908 if (in_debug->integer)
909 Com_Printf("Enqueue: %s (%i) (down: %i)\n", Key_KeynumToString(keyNum), keyNum, keyDown);
910 keyq[keyq_head].down = keyDown;
911 keyq[keyq_head].unicode = keyUnicode;
912 keyq[keyq_head].key = keyNum;
913 keyq_head = (keyq_head + 1) & (MAX_KEYQ - 1);
914 }
915}
916
917static bool IN_ToggleFullscreen (const bool full)
918{
919#if SDL_VERSION_ATLEAST(2,0,0)
920 const int mask = full ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP;
921 const bool isFullScreen = SDL_GetWindowFlags(cls.window) & mask;
922 SDL_SetWindowFullscreen(cls.window, isFullScreen ? 0 : mask);
923 return SDL_GetWindowFlags(cls.window) & mask;
924#else
925#ifdef _WIN32
926 return false;
927#else
928 SDL_Surface* surface = SDL_GetVideoSurface();
929 if (!SDL_WM_ToggleFullScreen(surface)) {
930 const int flags = surface->flags ^= SDL_FULLSCREEN;
931 SDL_SetVideoMode(surface->w, surface->h, 0, flags);
932 }
933
934 return surface->flags & SDL_FULLSCREEN;
935#endif
936#endif
937}
938
946void IN_Frame (void)
947{
948 int mouse_buttonstate;
949 unsigned short unicode;
950 unsigned int key;
951 SDL_Event event;
952
953 IN_Parse();
954
956
958
959 if (vid_grabmouse->modified) {
960 vid_grabmouse->modified = false;
961
962 if (!vid_grabmouse->integer) {
963 /* ungrab the pointer */
964 Com_Printf("Switch grab input off\n");
965#if SDL_VERSION_ATLEAST(2,0,0)
966 SDL_SetWindowGrab(cls.window, SDL_FALSE);
967#else
968 SDL_WM_GrabInput(SDL_GRAB_OFF);
969#endif
970 } else {
971 /* grab the pointer */
972 Com_Printf("Switch grab input on\n");
973#if SDL_VERSION_ATLEAST(2,0,0)
974 SDL_SetWindowGrab(cls.window, SDL_TRUE);
975#else
976 SDL_WM_GrabInput(SDL_GRAB_ON);
977#endif
978 }
979 }
980
983
984 while (SDL_PollEvent(&event)) {
985 switch (event.type) {
986#if SDL_VERSION_ATLEAST(2,0,0)
987 case SDL_MOUSEWHEEL:
988 mouse_buttonstate = event.wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP;
989 IN_EventEnqueue(mouse_buttonstate, 0, true);
990 break;
991 case SDL_TEXTEDITING:
993 break;
994 case SDL_TEXTINPUT: {
995 if (!SDL_IsTextInputActive())
996 break;
997
998 const char* text = event.text.text;
999 const char** str = &text;
1000 for (;;) {
1001 const int characterUnicode = UTF8_next(str);
1002 if (characterUnicode == -1) {
1003 break;
1004 }
1005 unicode = characterUnicode;
1006 IN_TranslateKey(characterUnicode, &key);
1007 IN_EventEnqueue(key, unicode, true);
1008 IN_EventEnqueue(key, unicode, false);
1009 }
1010 break;
1011 }
1012#endif
1013 case SDL_MOUSEBUTTONDOWN:
1014 case SDL_MOUSEBUTTONUP:
1015 switch (event.button.button) {
1016 case SDL_BUTTON_LEFT:
1017 mouse_buttonstate = K_MOUSE1;
1018 break;
1019 case SDL_BUTTON_MIDDLE:
1020 mouse_buttonstate = K_MOUSE3;
1021 break;
1022 case SDL_BUTTON_RIGHT:
1023 mouse_buttonstate = K_MOUSE2;
1024 break;
1025#if SDL_VERSION_ATLEAST(2,0,0)
1026 case SDL_BUTTON_X1:
1027 mouse_buttonstate = K_MOUSE4;
1028 break;
1029 case SDL_BUTTON_X2:
1030 mouse_buttonstate = K_MOUSE5;
1031 break;
1032#else
1033 case SDL_BUTTON_WHEELUP:
1034 mouse_buttonstate = K_MWHEELUP;
1035 break;
1036 case SDL_BUTTON_WHEELDOWN:
1037 mouse_buttonstate = K_MWHEELDOWN;
1038 break;
1039 case 6:
1040 mouse_buttonstate = K_MOUSE4;
1041 break;
1042 case 7:
1043 mouse_buttonstate = K_MOUSE5;
1044 break;
1045#endif
1046 default:
1047 mouse_buttonstate = K_AUX1 + (event.button.button - 8) % 16;
1048 break;
1049 }
1050 IN_EventEnqueue(mouse_buttonstate, 0, (event.type == SDL_MOUSEBUTTONDOWN));
1051 break;
1052
1053 case SDL_MOUSEMOTION:
1054 SDL_GetMouseState(&mousePosX, &mousePosY);
1055 mousePosX /= viddef.rx;
1056 mousePosY /= viddef.ry;
1057 break;
1058
1059 case SDL_KEYDOWN:
1060 IN_PrintKey(&event, 1);
1061 if ((event.key.keysym.mod & KMOD_ALT) && event.key.keysym.sym == SDLK_RETURN) {
1062 Com_Printf("try to toggle fullscreen\n");
1063 if (IN_ToggleFullscreen(false)) {
1064 Cvar_SetValue("vid_fullscreen", 1);
1065 /* make sure, that input grab is deactivated in fullscreen mode */
1066 Cvar_SetValue("vid_grabmouse", 0);
1067 } else {
1068 Cvar_SetValue("vid_fullscreen", 0);
1069 }
1070 vid_fullscreen->modified = false; /* we just changed it with SDL. */
1071 break; /* ignore this key */
1072 }
1073
1074 if ((event.key.keysym.mod & KMOD_CTRL) && event.key.keysym.sym == SDLK_RETURN) {
1075 Com_Printf("try to toggle fullscreen\n");
1076 if (IN_ToggleFullscreen(true)) {
1077 Cvar_SetValue("vid_fullscreen", 2);
1078 } else {
1079 Cvar_SetValue("vid_fullscreen", 0);
1080 }
1081 vid_fullscreen->modified = false; /* we just changed it with SDL. */
1082 break; /* ignore this key */
1083 }
1084
1085 if ((event.key.keysym.mod & KMOD_CTRL) && event.key.keysym.sym == SDLK_g) {
1086#if SDL_VERSION_ATLEAST(2,0,0)
1087 const bool grab = SDL_GetWindowGrab(cls.window);
1088 Cvar_SetValue("vid_grabmouse", grab ? 0 : 1);
1089#else
1090 SDL_GrabMode gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
1091 Cvar_SetValue("vid_grabmouse", (gm == SDL_GRAB_ON) ? 0 : 1);
1092#endif
1093 Com_Printf("toggled mouse grab (%s)\n", vid_grabmouse->integer == 1 ? "true" : "false");
1094 break; /* ignore this key */
1095 }
1096
1097 /* console key is hardcoded, so the user can never unbind it */
1098 if ((event.key.keysym.mod & KMOD_SHIFT) && event.key.keysym.sym == SDLK_ESCAPE) {
1100 break;
1101 }
1102
1103#if SDL_VERSION_ATLEAST(2,0,0)
1104 /* SDL_TEXTINPUT above will handle normal text for sdl2 */
1105 if (IN_TranslateKey(event.key.keysym.sym, &key) || !SDL_IsTextInputActive())
1106 IN_EventEnqueue(key, 0, true);
1107#else
1108 unicode = event.key.keysym.unicode;
1109 IN_TranslateKey(event.key.keysym.sym, &key);
1110 IN_EventEnqueue(key, unicode, true);
1111#endif
1112 break;
1113
1114 case SDL_KEYUP:
1115 IN_PrintKey(&event, 0);
1116#if SDL_VERSION_ATLEAST(2,0,0)
1117 /* SDL_TEXTINPUT above will handle normal text for sdl2 */
1118 if (IN_TranslateKey(event.key.keysym.sym, &key) || !SDL_IsTextInputActive())
1119 IN_EventEnqueue(key, 0, false);
1120#else
1121 unicode = event.key.keysym.unicode;
1122 IN_TranslateKey(event.key.keysym.sym, &key);
1123 IN_EventEnqueue(key, unicode, false);
1124#endif
1125 break;
1126
1127#if SDL_VERSION_ATLEAST(2,0,0)
1129 case SDL_WINDOWEVENT:
1130 switch (event.window.type) {
1131 case SDL_WINDOWEVENT_FOCUS_LOST:
1133 break;
1134 case SDL_WINDOWEVENT_RESIZED:
1135 /* make sure that SDL_SetVideoMode is called again after we changed the size
1136 * otherwise the mouse will make problems */
1137 vid_mode->modified = true;
1138 break;
1139 default:
1140 break;
1141 }
1142 break;
1143#else
1144 case SDL_VIDEOEXPOSE:
1145 break;
1146
1147 case SDL_ACTIVEEVENT:
1148 /* make sure the menu no more captures the input when the game window loses focus */
1149 if (event.active.state == SDL_APPINPUTFOCUS && event.active.gain == 0)
1151 break;
1152
1153 case SDL_VIDEORESIZE:
1154 /* make sure that SDL_SetVideoMode is called again after we changed the size
1155 * otherwise the mouse will make problems */
1156 vid_mode->modified = true;
1157#ifdef ANDROID
1158 /* On Android the OpenGL context is destroyed after we've received a resize event,
1159 * so wee need to re-init OpenGL state machine and re-upload all textures */
1161#endif
1162 break;
1163#endif
1164
1165 case SDL_QUIT:
1166 Cmd_ExecuteString("quit");
1167 break;
1168 }
1169 }
1170}
1171
1175static void CL_PressKey_f (void)
1176{
1177 if (Cmd_Argc() != 2) {
1178 Com_Printf("Usage: %s <key> : simulate press of a key\n", Cmd_Argv(0));
1179 return;
1180 }
1181
1182 const unsigned int keyNum = Key_StringToKeynum(Cmd_Argv(1));
1183 /* @todo unicode value is wrong */
1184 IN_EventEnqueue(keyNum, '?', true);
1185 IN_EventEnqueue(keyNum, '?', false);
1186}
1187
1188typedef struct cursorChange_s {
1192
1194
1196{
1197 if (mspace != MS_NULL) {
1198 if (mspace != cursorChange.prevSpace) {
1200 }
1201 }
1204 cursorChange.cursor = Cvar_GetValue("cursor");
1205 }
1206 mouseSpace = mspace;
1207}
1208
1212void IN_Init (void)
1213{
1214 Com_Printf("\n------- input initialization -------\n");
1215
1216 /* cvars */
1217 in_debug = Cvar_Get("in_debug", "0", 0, "Show input key codes on game console");
1218 cl_isometric = Cvar_Get("r_isometric", "0", CVAR_ARCHIVE, "Draw the world in isometric mode");
1219
1220 /* commands */
1221 Cmd_AddCommand("+turnleft", IN_TurnLeftDown_f, N_("Rotate battlescape camera anti-clockwise"));
1222 Cmd_AddCommand("-turnleft", IN_TurnLeftUp_f);
1223 Cmd_AddCommand("+turnright", IN_TurnRightDown_f, N_("Rotate battlescape camera clockwise"));
1224 Cmd_AddCommand("-turnright", IN_TurnRightUp_f);
1225 Cmd_AddCommand("+turnup", IN_TurnUpDown_f, N_("Tilt battlescape camera up"));
1226 Cmd_AddCommand("-turnup", IN_TurnUpUp_f);
1227 Cmd_AddCommand("+turndown", IN_TurnDownDown_f, N_("Tilt battlescape camera down"));
1228 Cmd_AddCommand("-turndown", IN_TurnDownUp_f);
1229 Cmd_AddCommand("+pantilt", IN_PanTiltDown_f, N_("Move battlescape camera"));
1230 Cmd_AddCommand("-pantilt", IN_PanTiltUp_f);
1231 Cmd_AddCommand("+shiftleft", IN_ShiftLeftDown_f, N_("Move battlescape camera left"));
1232 Cmd_AddCommand("-shiftleft", IN_ShiftLeftUp_f);
1233 Cmd_AddCommand("+shiftleftup", IN_ShiftLeftUpDown_f, N_("Move battlescape camera top left"));
1234 Cmd_AddCommand("-shiftleftup", IN_ShiftLeftUpUp_f);
1235 Cmd_AddCommand("+shiftleftdown", IN_ShiftLeftDownDown_f, N_("Move battlescape camera bottom left"));
1236 Cmd_AddCommand("-shiftleftdown", IN_ShiftLeftDownUp_f);
1237 Cmd_AddCommand("+shiftright", IN_ShiftRightDown_f, N_("Move battlescape camera right"));
1238 Cmd_AddCommand("-shiftright", IN_ShiftRightUp_f);
1239 Cmd_AddCommand("+shiftrightup", IN_ShiftRightUpDown_f, N_("Move battlescape camera top right"));
1240 Cmd_AddCommand("-shiftrightup", IN_ShiftRightUpUp_f);
1241 Cmd_AddCommand("+shiftrightdown", IN_ShiftRightDownDown_f, N_("Move battlescape camera bottom right"));
1242 Cmd_AddCommand("-shiftrightdown", IN_ShiftRightDownUp_f);
1243 Cmd_AddCommand("+shiftup", IN_ShiftUpDown_f, N_("Move battlescape camera forward"));
1244 Cmd_AddCommand("-shiftup", IN_ShiftUpUp_f);
1245 Cmd_AddCommand("+shiftdown", IN_ShiftDownDown_f, N_("Move battlescape camera backward"));
1246 Cmd_AddCommand("-shiftdown", IN_ShiftDownUp_f);
1247 Cmd_AddCommand("+zoomin", IN_ZoomInDown_f, N_("Zoom in"));
1248 Cmd_AddCommand("-zoomin", IN_ZoomInUp_f);
1249 Cmd_AddCommand("+zoomout", IN_ZoomOutDown_f, N_("Zoom out"));
1250 Cmd_AddCommand("-zoomout", IN_ZoomOutUp_f);
1251
1252 Cmd_AddCommand("+leftmouse", CL_LeftClickDown_f, N_("Left mouse button click (menu)"));
1253 Cmd_AddCommand("-leftmouse", CL_LeftClickUp_f);
1254 Cmd_AddCommand("+middlemouse", CL_MiddleClickDown_f, N_("Middle mouse button click (menu)"));
1255 Cmd_AddCommand("-middlemouse", CL_MiddleClickUp_f);
1256 Cmd_AddCommand("+rightmouse", CL_RightClickDown_f, N_("Right mouse button click (menu)"));
1257 Cmd_AddCommand("-rightmouse", CL_RightClickUp_f);
1258 Cmd_AddCommand("wheelupmouse", CL_WheelUp_f, N_("Mouse wheel up"));
1259 Cmd_AddCommand("wheeldownmouse", CL_WheelDown_f, N_("Mouse wheel down"));
1260 Cmd_AddCommand("+select", CL_SelectDown_f, N_("Select objects/Walk to a square/In fire mode, fire etc"));
1261 Cmd_AddCommand("-select", CL_SelectUp_f);
1262 Cmd_AddCommand("+action", CL_ActionDown_f, N_("Rotate Battlescape/In fire mode, cancel action"));
1263 Cmd_AddCommand("-action", CL_ActionUp_f);
1264 Cmd_AddCommand("+turn", CL_TurnDown_f, N_("Turn soldier toward mouse pointer"));
1265 Cmd_AddCommand("-turn", CL_TurnUp_f);
1266 Cmd_AddCommand("+hudradar", CL_HudRadarDown_f, N_("Toggles the hud radar mode"));
1267 Cmd_AddCommand("-hudradar", CL_HudRadarUp_f);
1268
1269 Cmd_AddCommand("levelup", CL_LevelUp_f, N_("Slice through terrain at a higher level"));
1270 Cmd_AddCommand("leveldown", CL_LevelDown_f, N_("Slice through terrain at a lower level"));
1271 Cmd_AddCommand("zoominquant", CL_ZoomInQuant_f, N_("Zoom in"));
1272 Cmd_AddCommand("zoomoutquant", CL_ZoomOutQuant_f, N_("Zoom out"));
1273
1274 Cmd_AddCommand("press", CL_PressKey_f, "Press a key from a command");
1275
1276 mousePosX = mousePosY = 0.0;
1277
1279}
1280
1285{
1286 while (keyq_head != keyq_tail) {
1288 keyq_tail = (keyq_tail + 1) & (MAX_KEYQ - 1);
1289 }
1290}
void CL_ActorSelectMouse(void)
Selects an actor using the mouse.
Definition: cl_actor.cpp:1197
void CL_ActorTurnMouse(void)
Turns the actor around without moving.
Definition: cl_actor.cpp:1074
void CL_BattlescapeMouseDragging(void)
Scroll battlescape touchscreen-style, by clicking and dragging away.
Definition: cl_actor.cpp:1467
bool CL_ActorMouseTrace(void)
Battlescape cursor positioning.
Definition: cl_actor.cpp:1373
void CL_InitBattlescapeMouseDragging(void)
Scroll battlescape touchscreen-style, by clicking and dragging away.
Definition: cl_actor.cpp:1459
void CL_ActorActionMouse(void)
initiates action with mouse.
Definition: cl_actor.cpp:1266
clientBattleScape_t cl
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
bool CL_BattlescapeRunning(void)
Check whether we already have actors spawned on the battlefield.
void CL_CameraZoomIn(void)
Zooms the scene of the battlefield in.
Definition: cl_camera.cpp:302
void CL_CameraZoomOut(void)
Zooms the scene of the battlefield out.
Definition: cl_camera.cpp:325
void Con_ToggleConsole_f(void)
Definition: cl_console.cpp:138
cvar_t * cl_worldlevel
Definition: cl_hud.cpp:46
static void CL_LevelUp_f(void)
Switch one worldlevel up.
Definition: cl_input.cpp:339
static void IN_TurnUpDown_f(void)
Definition: cl_input.cpp:220
int mousePosY
Definition: cl_input.cpp:80
static void IN_ShiftLeftDownUp_f(void)
Definition: cl_input.cpp:269
static void IN_ShiftRightDown_f(void)
Definition: cl_input.cpp:274
static void CL_ActionDown_f(void)
Middle mouse click.
Definition: cl_input.cpp:424
static cvar_t * in_debug
Definition: cl_input.cpp:76
static int battlescapeMouseDraggingX
Definition: cl_input.cpp:83
static void IN_ShiftLeftUpDown_f(void)
Definition: cl_input.cpp:254
static int keyq_tail
Definition: cl_input.cpp:74
static void IN_TurnUpUp_f(void)
Definition: cl_input.cpp:224
static void IN_ZoomInDown_f(void)
Definition: cl_input.cpp:318
static kbutton_t in_turnleft
Definition: cl_input.cpp:104
static void IN_ZoomOutDown_f(void)
Definition: cl_input.cpp:326
#define MOUSE_YAW_SCALE
Definition: cl_input.cpp:540
static void CL_HudRadarUp_f(void)
Definition: cl_input.cpp:472
static void CL_ZoomOutQuant_f(void)
Definition: cl_input.cpp:361
static kbutton_t in_shiftdown
Definition: cl_input.cpp:105
static void CL_MiddleClickUp_f(void)
Middle mouse button is freed in menu.
Definition: cl_input.cpp:512
static bool battlescapeMouseDraggingActive
Definition: cl_input.cpp:85
static void CL_PressKey_f(void)
Definition: cl_input.cpp:1175
static void IN_ShiftUpUp_f(void)
Definition: cl_input.cpp:306
static void IN_ShiftRightUp_f(void)
Definition: cl_input.cpp:278
static void CL_WheelUp_f(void)
Definition: cl_input.cpp:371
@ BATTLESCAPE_MOUSE_DRAGGING_TRIGGER_Y
Definition: cl_input.cpp:88
@ BATTLESCAPE_MOUSE_DRAGGING_TRIGGER_X
Definition: cl_input.cpp:87
static void IN_PanTiltUp_f(void)
Definition: cl_input.cpp:242
void IN_Frame(void)
Handle input events like key presses and joystick movement as well as window events.
Definition: cl_input.cpp:946
#define MOUSE_PITCH_SCALE
Definition: cl_input.cpp:541
#define MAX_KEYQ
Definition: cl_input.cpp:61
float CL_GetKeyMouseState(int dir)
Definition: cl_input.cpp:546
static void IN_ShiftLeftUpUp_f(void)
Definition: cl_input.cpp:259
static void IN_KeyUp(kbutton_t *b)
Handles the release of a kbutton_t state.
Definition: cl_input.cpp:163
static kbutton_t in_shiftright
Definition: cl_input.cpp:104
static bool IN_ToggleFullscreen(const bool full)
Definition: cl_input.cpp:917
static void IN_ZoomOutUp_f(void)
Definition: cl_input.cpp:330
static void IN_TurnLeftUp_f(void)
Definition: cl_input.cpp:208
static bool IN_TranslateKey(const unsigned int keycode, unsigned int *ascii)
Translate the keys to ufo keys.
Definition: cl_input.cpp:630
static void IN_KeyDown(kbutton_t *b)
Handles the catch of a kbutton_t state.
Definition: cl_input.cpp:117
static kbutton_t in_pantilt
Definition: cl_input.cpp:108
mouseSpace_t mouseSpace
Definition: cl_input.cpp:79
static void CL_TurnUp_f(void)
Definition: cl_input.cpp:452
void IN_Init(void)
Definition: cl_input.cpp:1212
unsigned int key
Definition: cl_input.cpp:68
static void CL_SelectUp_f(void)
Definition: cl_input.cpp:390
static int oldMousePosX
Definition: cl_input.cpp:81
#define SCROLL_BORDER
Definition: cl_input.cpp:539
static kbutton_t in_zoomout
Definition: cl_input.cpp:106
static void CL_SelectDown_f(void)
Left mouse click.
Definition: cl_input.cpp:379
static void IN_ShiftRightUpUp_f(void)
Definition: cl_input.cpp:287
static void CL_WheelDown_f(void)
Definition: cl_input.cpp:366
static void CL_LeftClickDown_f(void)
Left mouse button is hit in menu.
Definition: cl_input.cpp:522
static void CL_LevelDown_f(void)
Switch one worldlevel down.
Definition: cl_input.cpp:349
static void IN_TurnRightDown_f(void)
Definition: cl_input.cpp:212
static void IN_ShiftRightUpDown_f(void)
Definition: cl_input.cpp:282
static kbutton_t in_zoomin
Definition: cl_input.cpp:106
static kbutton_t in_shiftleft
Definition: cl_input.cpp:104
static void IN_ZoomInUp_f(void)
Definition: cl_input.cpp:322
static void IN_TurnDownDown_f(void)
Definition: cl_input.cpp:228
void IN_EventEnqueue(unsigned int keyNum, unsigned short keyUnicode, bool keyDown)
Definition: cl_input.cpp:905
static void IN_ShiftLeftDownDown_f(void)
Definition: cl_input.cpp:264
static void CL_RightClickDown_f(void)
Right mouse button is hit in menu.
Definition: cl_input.cpp:482
static void IN_ShiftRightDownUp_f(void)
Definition: cl_input.cpp:297
int down
Definition: cl_input.cpp:70
static struct @9 keyq[MAX_KEYQ]
static void CL_RightClickUp_f(void)
Right mouse button is freed in menu.
Definition: cl_input.cpp:492
static void IN_Parse(void)
Called every frame to parse the input.
Definition: cl_input.cpp:584
static void IN_ShiftDownDown_f(void)
Definition: cl_input.cpp:310
static int keyq_head
Definition: cl_input.cpp:73
static kbutton_t in_turnup
Definition: cl_input.cpp:107
static void CL_ActionUp_f(void)
Definition: cl_input.cpp:431
static void IN_TurnDownUp_f(void)
Definition: cl_input.cpp:232
static void IN_ShiftRightDownDown_f(void)
Definition: cl_input.cpp:292
static cursorChange_t cursorChange
Definition: cl_input.cpp:1193
static void CL_LeftClickUp_f(void)
Left mouse button is freed in menu.
Definition: cl_input.cpp:532
unsigned short unicode
Definition: cl_input.cpp:69
int mousePosX
Definition: cl_input.cpp:80
static void IN_TurnLeftDown_f(void)
Definition: cl_input.cpp:204
static void CL_HudRadarDown_f(void)
Definition: cl_input.cpp:462
static void CL_ProcessMouseDragging(void)
Definition: cl_input.cpp:407
static void IN_TurnRightUp_f(void)
Definition: cl_input.cpp:216
void IN_SetMouseSpace(mouseSpace_t mspace)
Definition: cl_input.cpp:1195
static int oldMousePosY
Definition: cl_input.cpp:81
static void CL_ZoomInQuant_f(void)
Definition: cl_input.cpp:356
static void CL_MiddleClickDown_f(void)
Middle mouse button is hit in menu.
Definition: cl_input.cpp:502
static kbutton_t in_turndown
Definition: cl_input.cpp:107
static void IN_ShiftLeftUp_f(void)
Definition: cl_input.cpp:250
static void IN_PrintKey(const SDL_Event *event, int down)
Debug function to print sdl key events.
Definition: cl_input.cpp:609
static kbutton_t in_shiftup
Definition: cl_input.cpp:105
static void IN_ShiftLeftDown_f(void)
Definition: cl_input.cpp:246
static void CL_TurnDown_f(void)
Turn button is hit.
Definition: cl_input.cpp:444
static void IN_ShiftDownUp_f(void)
Definition: cl_input.cpp:314
static bool battlescapeMouseDraggingPossible
Definition: cl_input.cpp:85
void IN_SendKeyEvents(void)
Definition: cl_input.cpp:1284
static int battlescapeMouseDraggingY
Definition: cl_input.cpp:84
static void IN_ShiftUpDown_f(void)
Definition: cl_input.cpp:302
static kbutton_t in_turnright
Definition: cl_input.cpp:104
static void IN_PanTiltDown_f(void)
Definition: cl_input.cpp:236
cvar_t * cl_isometric
Definition: cl_input.cpp:77
External (non-keyboard) input devices.
#define STATE_FORWARD
Definition: cl_input.h:39
#define STATE_RIGHT
Definition: cl_input.h:40
#define STATE_TILT
Definition: cl_input.h:43
#define IN_GetMouseSpace()
Definition: cl_input.h:48
mouseSpace_t
Definition: cl_input.h:31
@ MS_WORLD
Definition: cl_input.h:34
@ MS_UI
Definition: cl_input.h:33
@ MS_NULL
Definition: cl_input.h:32
#define STATE_ZOOM
Definition: cl_input.h:41
#define STATE_ROT
Definition: cl_input.h:42
void IN_StartupJoystick(void)
Init available joysticks.
void IN_JoystickMove(void)
Definition: cl_joystick.cpp:75
static bool keyDown[K_KEY_SIZE]
Definition: cl_keys.cpp:67
bool Key_IsNumlock(void)
Definition: cl_keys.cpp:221
const char * Key_KeynumToString(int keynum)
Convert a given keynum to string.
Definition: cl_keys.cpp:485
void Key_Event(unsigned int key, unsigned short unicode, bool down, unsigned time)
Called by the system between frames for both key up and key down events.
Definition: cl_keys.cpp:845
int Key_StringToKeynum(const char *str)
Convert to given string to keynum.
Definition: cl_keys.cpp:462
Header file for keyboard handler.
@ K_F2
Definition: cl_keys.h:82
@ K_F1
Definition: cl_keys.h:81
@ K_MOUSE4
Definition: cl_keys.h:51
@ K_SHIFT
Definition: cl_keys.h:97
@ K_KP_5
Definition: cl_keys.h:59
@ K_F12
Definition: cl_keys.h:92
@ K_KP_RIGHTARROW
Definition: cl_keys.h:60
@ K_DEL
Definition: cl_keys.h:44
@ K_KP_MINUS
Definition: cl_keys.h:67
@ K_F6
Definition: cl_keys.h:86
@ K_F4
Definition: cl_keys.h:84
@ K_KP_PGDN
Definition: cl_keys.h:57
@ K_EURO
Definition: cl_keys.h:161
@ K_MOUSE5
Definition: cl_keys.h:52
@ K_KP_DEL
Definition: cl_keys.h:64
@ K_KP_PGUP
Definition: cl_keys.h:63
@ K_MENU
Definition: cl_keys.h:160
@ K_KP_UPARROW
Definition: cl_keys.h:62
@ K_KP_INS
Definition: cl_keys.h:54
@ K_KP_PLUS
Definition: cl_keys.h:68
@ K_COMPOSE
Definition: cl_keys.h:153
@ K_ALT
Definition: cl_keys.h:99
@ K_MWHEELUP
Definition: cl_keys.h:50
@ K_KP_END
Definition: cl_keys.h:55
@ K_F13
Definition: cl_keys.h:93
@ K_SUPER
Definition: cl_keys.h:152
@ K_ENTER
Definition: cl_keys.h:40
@ K_F9
Definition: cl_keys.h:89
@ K_F14
Definition: cl_keys.h:94
@ K_MOUSE2
Definition: cl_keys.h:47
@ K_MOUSE1
Definition: cl_keys.h:46
@ K_MODE
Definition: cl_keys.h:154
@ K_UPARROW
Definition: cl_keys.h:72
@ K_F8
Definition: cl_keys.h:88
@ K_ESCAPE
Definition: cl_keys.h:42
@ K_F5
Definition: cl_keys.h:85
@ K_UNDO
Definition: cl_keys.h:162
@ K_POWER
Definition: cl_keys.h:166
@ K_SYSREQ
Definition: cl_keys.h:157
@ K_PGUP
Definition: cl_keys.h:79
@ K_PAUSE
Definition: cl_keys.h:41
@ K_KP_DOWNARROW
Definition: cl_keys.h:56
@ K_KP_NUMLOCK
Definition: cl_keys.h:70
@ K_AUX1
Definition: cl_keys.h:134
@ K_BACKSPACE
Definition: cl_keys.h:38
@ K_CAPSLOCK
Definition: cl_keys.h:165
@ K_KP_SLASH
Definition: cl_keys.h:65
@ K_HELP
Definition: cl_keys.h:155
@ K_MOUSE3
Definition: cl_keys.h:48
@ K_END
Definition: cl_keys.h:78
@ K_F15
Definition: cl_keys.h:95
@ K_SCROLLOCK
Definition: cl_keys.h:158
@ K_INS
Definition: cl_keys.h:96
@ K_F10
Definition: cl_keys.h:90
@ K_KP_ENTER
Definition: cl_keys.h:69
@ K_CTRL
Definition: cl_keys.h:98
@ K_KP_LEFTARROW
Definition: cl_keys.h:58
@ K_MWHEELDOWN
Definition: cl_keys.h:49
@ K_F11
Definition: cl_keys.h:91
@ K_KP_MULTIPLY
Definition: cl_keys.h:66
@ K_SPACE
Definition: cl_keys.h:43
@ K_HOME
Definition: cl_keys.h:77
@ K_PRINT
Definition: cl_keys.h:156
@ K_TAB
Definition: cl_keys.h:39
@ K_RIGHTARROW
Definition: cl_keys.h:74
@ K_F3
Definition: cl_keys.h:83
@ K_F7
Definition: cl_keys.h:87
@ K_DOWNARROW
Definition: cl_keys.h:73
@ K_KP_HOME
Definition: cl_keys.h:61
@ K_BREAK
Definition: cl_keys.h:159
@ K_PGDN
Definition: cl_keys.h:80
@ K_LEFTARROW
Definition: cl_keys.h:75
client_static_t cls
Definition: cl_main.cpp:83
int CL_Milliseconds(void)
Definition: cl_main.cpp:1207
#define VID_NORM_WIDTH
Definition: cl_renderer.h:40
#define VID_NORM_HEIGHT
Definition: cl_renderer.h:41
void SCR_ChangeCursor(int cursor)
Definition: cl_screen.cpp:370
#define N_(String)
Definition: cl_shared.h:46
@ ca_active
Definition: cl_shared.h:80
cvar_t * vid_grabmouse
Definition: cl_video.cpp:39
cvar_t * vid_fullscreen
Definition: cl_video.cpp:37
viddef_t viddef
Definition: cl_video.cpp:34
cvar_t * vid_mode
Definition: cl_video.cpp:38
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition: cmd.cpp:1007
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition: cmd.cpp:505
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition: cmd.cpp:744
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
float Cvar_GetValue(const char *varName)
Returns the float value of a cvar.
Definition: cvar.cpp:125
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition: cvar.cpp:342
#define CVAR_ARCHIVE
Definition: cvar.h:40
void R_ReinitOpenglContext(void)
Re-initializes OpenGL state machine, all textures and renderer variables, this needed when applicatio...
Definition: r_misc.cpp:349
connstate_t state
Definition: client.h:55
mouseSpace_t prevSpace
Definition: cl_input.cpp:1189
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
bool modified
Definition: cvar.h:79
int integer
Definition: cvar.h:81
unsigned msec
Definition: cl_input.cpp:100
int down[2]
Definition: cl_input.cpp:98
unsigned downtime
Definition: cl_input.cpp:99
float ry
Definition: cl_video.h:72
int viewHeight
Definition: cl_video.h:76
int x
Definition: cl_video.h:76
int viewWidth
Definition: cl_video.h:76
int y
Definition: cl_video.h:76
float rx
Definition: cl_video.h:71
void UI_MouseUp(int x, int y, int button)
Called when we are in UI mode and up a mouse button.
Definition: ui_input.cpp:839
void UI_MouseScroll(int deltaX, int deltaY)
Called when we are in UI mode and scroll via mousewheel.
Definition: ui_input.cpp:756
void UI_ReleaseInput(void)
Release all captured input (keyboard or mouse)
Definition: ui_input.cpp:496
void UI_MouseDown(int x, int y, int button)
Called when we are in UI mode and down a mouse button.
Definition: ui_input.cpp:801
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
Definition: ui_windows.cpp:170
void UI_CloseWindow(const char *name)
Definition: ui_windows.cpp:435
bool UI_IsMouseOnWindow(void)
Check if a point is over a window from the stack.
Definition: ui_windows.cpp:538
int UTF8_next(const char **str)
Get the next utf-8 character from the given string.
Definition: utf8.cpp:132
int UTF8_encoded_len(int c)
Definition: utf8.cpp:188