Debian Codegraph @

ddio/lnxkey.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/ddio_lnx/lnxkey.cpp $
21 * $Revision: 1.3 $
22 * $Date: 2004/02/25 00:04:06 $
23 * $Author: ryan $
24 *
25 * Linux keyboard routines
26 *
27 * $Log: lnxkey.cpp,v $
28 * Revision 1.3 2004/02/25 00:04:06 ryan
29 * Removed loki_utils dependency and ported to MacOS X (runs, but incomplete).
30 *
31 * Revision 1.2 2000/04/27 11:17:07 icculus
32 * Removed some keyboard drivers, added SDL hooks.
33 *
34 * Revision 1.1.1.1 2000/04/18 00:00:33 icculus
35 * initial checkin
36 *
37 *
38 * 13 7/14/99 9:06p Jeff
39 * added comment header
40 *
41 * $NoKeywords: $
42 */
43
44 /*
45 * Linux Keyboard Interface, Non-SVGALIB Implementation
46 * $NoKeywords: $
47 */
48
49 // ----------------------------------------------------------------------------
50 // Keyboard Interface
51 // ----------------------------------------------------------------------------
52 #include "application.h"cxx . . $ `<file>/lib/application.h`/
53 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
54 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
55
56 volatile struct tLnxKeyscxx . . $ tLnxKeys# {
57 unioncxx . . $ tLnxKeys#$anonymous_type_0# {
58 int up_tickscxx . . $ tLnxKeys#$anonymous_type_0#up_ticks.;
59 float up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time.;
60 };
61 unioncxx . . $ tLnxKeys#$anonymous_type_1# {
62 int down_tickscxx . . $ tLnxKeys#$anonymous_type_1#down_ticks.;
63 float down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time.;
64 };
65 bool statuscxx . . $ tLnxKeys#status.;
66 } LKeyscxx . . $ LKeys.[DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!];
67
68 // null mode ddio
69 bool ddio_null_InternalKeyInitcxx . . $ ddio_null_InternalKeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info);
70 void ddio_null_InternalKeyClosecxx . . $ ddio_null_InternalKeyClose(49f6e7a06ebc5aa8).();
71 bool ddio_null_InternalKeyStatecxx . . $ ddio_null_InternalKeyState(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# key);
72 void ddio_null_InternalKeySuspendcxx . . $ ddio_null_InternalKeySuspend(49f6e7a06ebc5aa8).();
73 void ddio_null_InternalKeyResumecxx . . $ ddio_null_InternalKeyResume(49f6e7a06ebc5aa8).();
74 float ddio_null_InternalKeyDownTimecxx . . $ ddio_null_InternalKeyDownTime(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# key);
75 void ddio_null_InternalResetKeycxx . . $ ddio_null_InternalResetKey(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# key);
76 bool ddio_null_KeyFramecxx . . $ ddio_null_KeyFrame(c9857a73d68e59ba).();
77 void ddio_null_InternalKeyFramecxx . . $ ddio_null_InternalKeyFrame(49f6e7a06ebc5aa8).(void);
78
79 // sdl mode ddio
80 bool ddio_sdl_InternalKeyInitcxx . . $ ddio_sdl_InternalKeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info);
81 void ddio_sdl_InternalKeyClosecxx . . $ ddio_sdl_InternalKeyClose(49f6e7a06ebc5aa8).();
82 bool ddio_sdl_InternalKeyStatecxx . . $ ddio_sdl_InternalKeyState(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# key);
83 void ddio_sdl_InternalKeySuspendcxx . . $ ddio_sdl_InternalKeySuspend(49f6e7a06ebc5aa8).();
84 void ddio_sdl_InternalKeyResumecxx . . $ ddio_sdl_InternalKeyResume(49f6e7a06ebc5aa8).();
85 float ddio_sdl_InternalKeyDownTimecxx . . $ ddio_sdl_InternalKeyDownTime(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# key);
86 void ddio_sdl_InternalResetKeycxx . . $ ddio_sdl_InternalResetKey(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# key);
87 bool ddio_sdl_KeyFramecxx . . $ ddio_sdl_KeyFrame(c9857a73d68e59ba).();
88 void ddio_sdl_InternalKeyFramecxx . . $ ddio_sdl_InternalKeyFrame(49f6e7a06ebc5aa8).(void);
89
90 enumcxx . . $ $anonymous_type_e06bb3cbe96de5a5_2# {
91 Input_nullcxx . . $ Input_null.,
92 Input_sdlcxx . . $ Input_sdl. // Input_svga,Input_xwin
93 } Keyboard_modecxx . . $ Keyboard_mode.;
94
95 // ----------------------------------------------------------------------------
96 // Initialization of keyboard device.
97 // ----------------------------------------------------------------------------
98
99 bool ddio_InternalKeyInitcxx . . $ ddio_InternalKeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info) {
100 oeLnxApplicationcxx . . $ oeLnxApplication# *app = (oeLnxApplicationcxx . . $ oeLnxApplication# *)init_info->objcxx . . $ ddio_init_info#obj.;
101 tLnxAppInfocxx . . $ tLnxAppInfo# app_info;
102
103 if (!app) {
104 return false;
105 }
106
107 app->get_infocxx . . $ oeLnxApplication#get_info(5d22bdacc48458e8).(&app_info);
108
109 // determine if we are to use SDL or null mode
110 Keyboard_modecxx . . $ Keyboard_mode. = (app_info.flagscxx . . $ tLnxAppInfo#flags. & APPFLAG_USESERVICEcxx . . $ `linux/lnxapp.h:27:9`!) ? Input_nullcxx . . $ Input_null. : Input_sdlcxx . . $ Input_sdl.;
111
112 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
113 case Input_nullcxx . . $ Input_null.:
114 return ddio_null_InternalKeyInitcxx . . $ ddio_null_InternalKeyInit(4aa02e9b14a147be).(init_info);
115 case Input_sdlcxx . . $ Input_sdl.:
116 return ddio_sdl_InternalKeyInitcxx . . $ ddio_sdl_InternalKeyInit(4aa02e9b14a147be).(init_info);
117 }
118
119 return false;
120 }
121
122 void ddio_InternalKeyClosecxx . . $ ddio_InternalKeyClose(49f6e7a06ebc5aa8).() {
123 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
124 case Input_nullcxx . . $ Input_null.:
125 return ddio_null_InternalKeyClosecxx . . $ ddio_null_InternalKeyClose(49f6e7a06ebc5aa8).();
126 case Input_sdlcxx . . $ Input_sdl.:
127 return ddio_sdl_InternalKeyClosecxx . . $ ddio_sdl_InternalKeyClose(49f6e7a06ebc5aa8).();
128 }
129 }
130
131 bool ddio_InternalKeyStatecxx . . $ ddio_InternalKeyState(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# key) {
132 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
133 case Input_nullcxx . . $ Input_null.:
134 return ddio_null_InternalKeyStatecxx . . $ ddio_null_InternalKeyState(cef82f9be00a201a).(key);
135 case Input_sdlcxx . . $ Input_sdl.:
136 return ddio_sdl_InternalKeyStatecxx . . $ ddio_sdl_InternalKeyState(cef82f9be00a201a).(key);
137 }
138
139 return false;
140 }
141
142 void ddio_InternalKeySuspendcxx . . $ ddio_InternalKeySuspend(49f6e7a06ebc5aa8).() {
143 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
144 case Input_nullcxx . . $ Input_null.:
145 ddio_null_InternalKeySuspendcxx . . $ ddio_null_InternalKeySuspend(49f6e7a06ebc5aa8).();
146 break;
147 case Input_sdlcxx . . $ Input_sdl.:
148 return ddio_sdl_InternalKeySuspendcxx . . $ ddio_sdl_InternalKeySuspend(49f6e7a06ebc5aa8).();
149 }
150 }
151
152 void ddio_InternalKeyResumecxx . . $ ddio_InternalKeyResume(49f6e7a06ebc5aa8).() {
153 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
154 case Input_nullcxx . . $ Input_null.:
155 ddio_null_InternalKeyResumecxx . . $ ddio_null_InternalKeyResume(49f6e7a06ebc5aa8).();
156 break;
157 case Input_sdlcxx . . $ Input_sdl.:
158 return ddio_sdl_InternalKeyResumecxx . . $ ddio_sdl_InternalKeyResume(49f6e7a06ebc5aa8).();
159 }
160 }
161
162 float ddio_InternalKeyDownTimecxx . . $ ddio_InternalKeyDownTime(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# key) {
163 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
164 case Input_nullcxx . . $ Input_null.:
165 return ddio_null_InternalKeyDownTimecxx . . $ ddio_null_InternalKeyDownTime(ef46aeb7cc924ea7).(key);
166 case Input_sdlcxx . . $ Input_sdl.:
167 return ddio_sdl_InternalKeyDownTimecxx . . $ ddio_sdl_InternalKeyDownTime(ef46aeb7cc924ea7).(key);
168 }
169
170 return 0.0f;
171 }
172
173 void ddio_InternalResetKeycxx . . $ ddio_InternalResetKey(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# key) {
174 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
175 case Input_nullcxx . . $ Input_null.:
176 ddio_null_InternalResetKeycxx . . $ ddio_null_InternalResetKey(ac50b47256ae7414).(key);
177 break;
178 case Input_sdlcxx . . $ Input_sdl.:
179 return ddio_sdl_InternalResetKeycxx . . $ ddio_sdl_InternalResetKey(ac50b47256ae7414).(key);
180 }
181 }
182
183 bool ddio_KeyFramecxx . . $ ddio_KeyFrame(c9857a73d68e59ba).() {
184 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
185 case Input_sdlcxx . . $ Input_sdl.:
186 break;
187 case Input_nullcxx . . $ Input_null.:
188 return ddio_null_KeyFramecxx . . $ ddio_null_KeyFrame(c9857a73d68e59ba).();
189 }
190
191 return true;
192 }
193
194 void ddio_InternalKeyFramecxx . . $ ddio_InternalKeyFrame(49f6e7a06ebc5aa8).(void) {
195 switch (Keyboard_modecxx . . $ Keyboard_mode.) {
196 case Input_nullcxx . . $ Input_null.:
197 ddio_null_InternalKeyFramecxx . . $ ddio_null_InternalKeyFrame(49f6e7a06ebc5aa8).();
198 break;
199 case Input_sdlcxx . . $ Input_sdl.:
200 return ddio_sdl_InternalKeyFramecxx . . $ ddio_sdl_InternalKeyFrame(49f6e7a06ebc5aa8).();
201 }
202 }
203
204 void ddio_SetKeyboardLanguagecxx . . $ ddio_SetKeyboardLanguage(d4f767463ce0a6b3).(int) {}