engine: reject mbf21 and shit24 wads. there is no way to know if it is safe to ignore...
[k8vavoom.git] / source / input.h
blob8353f934e3de37221d5a8166e6d780a347e10970
1 //**************************************************************************
2 //**
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
9 //**
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
21 //**
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 #ifndef VAVOOM_INPUT_HEADER
27 #define VAVOOM_INPUT_HEADER
30 // input device class, handles actual reading of the input
31 class VInputDevice : public VInterface {
32 public:
33 // VInputDevice interface
34 virtual void ReadInput() = 0;
35 virtual void RegrabMouse () = 0; // called by UI when mouse cursor is turned off
37 virtual void SetClipboardText (VStr text) = 0;
38 virtual bool HasClipboardText () = 0;
39 virtual VStr GetClipboardText () = 0;
41 // implemented in corresponding system module
42 static VInputDevice *CreateDevice ();
46 // input subsystem, handles all input events
47 class VInputPublic : public VInterface {
48 public:
49 enum { MAX_KBCHEAT_LENGTH = 128 };
51 struct CheatCode {
52 VStr keys;
53 VStr concmd;
56 public:
57 int ShiftDown;
58 int CtrlDown;
59 int AltDown;
60 static TArray<CheatCode> kbcheats;
61 static char currkbcheat[MAX_KBCHEAT_LENGTH+1];
63 VInputPublic () : ShiftDown(0), CtrlDown(0), AltDown(0) { currkbcheat[0] = 0; }
65 // system device related functions
66 virtual void Init () = 0;
67 virtual void Shutdown () = 0;
69 // input event handling
70 bool PostKeyEvent (int key, int press, vuint32 modflags);
71 virtual void ProcessEvents () = 0;
72 virtual int ReadKey () = 0;
74 // handling of key bindings
75 virtual void ClearBindings () = 0; // but not automap
76 virtual void ClearAutomapBindings () = 0;
77 // `isActive`: bit 0 for key1, bit 1 for key2
78 virtual void GetBindingKeys (VStr Binding, int &Key1, int &Key2, VStr modSection, int strifemode, int *isActive) = 0;
79 virtual void GetBindingKeysEx (VStr Binding, TArray<int> &keylist, VStr modSection, int strifemode) = 0;
80 virtual void GetDefaultModBindingKeys (VStr Binding, TArray<int> &keylist, VStr modSection) = 0;
81 virtual void GetBinding (int KeyNum, VStr &Down, VStr &Up) = 0; // for current game mode
82 virtual void SetBinding (int KeyNum, VStr Down, VStr Up, VStr modSection, int strifemode, bool allowOverride=true) = 0;
83 virtual void WriteBindings (VStream *st) = 0;
84 virtual void AddActiveMod (VStr modSection) = 0;
85 virtual void SetAutomapActive (bool active) = 0;
87 // returns translated ASCII char, or unchanged keycode
88 // it is safe to call this with any keycode
89 // note that only ASCII chars are supported
90 virtual int TranslateKey (int keycode) = 0;
92 virtual int KeyNumForName (VStr Name) = 0;
93 virtual VStr KeyNameForNum (int KeyNr) = 0;
95 virtual void RegrabMouse () = 0; // called by UI when mouse cursor is turned off
97 virtual void SetClipboardText (VStr text) = 0;
98 virtual bool HasClipboardText () = 0;
99 virtual VStr GetClipboardText () = 0;
101 static void KBCheatClearAll ();
102 static void KBCheatAppend (VStr keys, VStr concmd);
103 static bool KBCheatProcessor (event_t *ev);
105 static void UnpressAll ();
107 virtual void UnpressAllInternal () = 0;
109 static VInputPublic *Create ();
113 // global input handler
114 extern VInputPublic *GInput;
117 #endif