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"
53 #include "ddio.h"
54 #include "mono.h"
55
56 volatile struct tLnxKeys {
57 union {
58 int up_ticks;
59 float up_time;
60 };
61 union {
62 int down_ticks;
63 float down_time;
64 };
65 bool status;
66 } LKeys[DDIO_MAX_KEYS];
67
68 // null mode ddio
69 bool ddio_null_InternalKeyInit(ddio_init_info *init_info);
70 void ddio_null_InternalKeyClose();
71 bool ddio_null_InternalKeyState(uint8_t key);
72 void ddio_null_InternalKeySuspend();
73 void ddio_null_InternalKeyResume();
74 float ddio_null_InternalKeyDownTime(uint8_t key);
75 void ddio_null_InternalResetKey(uint8_t key);
76 bool ddio_null_KeyFrame();
77 void ddio_null_InternalKeyFrame(void);
78
79 // sdl mode ddio
80 bool ddio_sdl_InternalKeyInit(ddio_init_info *init_info);
81 void ddio_sdl_InternalKeyClose();
82 bool ddio_sdl_InternalKeyState(uint8_t key);
83 void ddio_sdl_InternalKeySuspend();
84 void ddio_sdl_InternalKeyResume();
85 float ddio_sdl_InternalKeyDownTime(uint8_t key);
86 void ddio_sdl_InternalResetKey(uint8_t key);
87 bool ddio_sdl_KeyFrame();
88 void ddio_sdl_InternalKeyFrame(void);
89
90 enum {
91 Input_null,
92 Input_sdl // Input_svga,Input_xwin
93 } Keyboard_mode;
94
95 // ----------------------------------------------------------------------------
96 // Initialization of keyboard device.
97 // ----------------------------------------------------------------------------
98
99 bool ddio_InternalKeyInit(ddio_init_info *init_info) {
100 oeLnxApplication *app = (oeLnxApplication *)init_info->obj;
101 tLnxAppInfo app_info;
102
103 if (!app) {
104 return false;
105 }
106
107 app->get_info(&app_info);
108
109 // determine if we are to use SDL or null mode
110 Keyboard_mode = (app_info.flags & APPFLAG_USESERVICE) ? Input_null : Input_sdl;
111
112 switch (Keyboard_mode) {
113 case Input_null:
114 return ddio_null_InternalKeyInit(init_info);
115 case Input_sdl:
116 return ddio_sdl_InternalKeyInit(init_info);
117 }
118
119 return false;
120 }
121
122 void ddio_InternalKeyClose() {
123 switch (Keyboard_mode) {
124 case Input_null:
125 return ddio_null_InternalKeyClose();
126 case Input_sdl:
127 return ddio_sdl_InternalKeyClose();
128 }
129 }
130
131 bool ddio_InternalKeyState(uint8_t key) {
132 switch (Keyboard_mode) {
133 case Input_null:
134 return ddio_null_InternalKeyState(key);
135 case Input_sdl:
136 return ddio_sdl_InternalKeyState(key);
137 }
138
139 return false;
140 }
141
142 void ddio_InternalKeySuspend() {
143 switch (Keyboard_mode) {
144 case Input_null:
145 ddio_null_InternalKeySuspend();
146 break;
147 case Input_sdl:
148 return ddio_sdl_InternalKeySuspend();
149 }
150 }
151
152 void ddio_InternalKeyResume() {
153 switch (Keyboard_mode) {
154 case Input_null:
155 ddio_null_InternalKeyResume();
156 break;
157 case Input_sdl:
158 return ddio_sdl_InternalKeyResume();
159 }
160 }
161
162 float ddio_InternalKeyDownTime(uint8_t key) {
163 switch (Keyboard_mode) {
164 case Input_null:
165 return ddio_null_InternalKeyDownTime(key);
166 case Input_sdl:
167 return ddio_sdl_InternalKeyDownTime(key);
168 }
169
170 return 0.0f;
171 }
172
173 void ddio_InternalResetKey(uint8_t key) {
174 switch (Keyboard_mode) {
175 case Input_null:
176 ddio_null_InternalResetKey(key);
177 break;
178 case Input_sdl:
179 return ddio_sdl_InternalResetKey(key);
180 }
181 }
182
183 bool ddio_KeyFrame() {
184 switch (Keyboard_mode) {
185 case Input_sdl:
186 break;
187 case Input_null:
188 return ddio_null_KeyFrame();
189 }
190
191 return true;
192 }
193
194 void ddio_InternalKeyFrame(void) {
195 switch (Keyboard_mode) {
196 case Input_null:
197 ddio_null_InternalKeyFrame();
198 break;
199 case Input_sdl:
200 return ddio_sdl_InternalKeyFrame();
201 }
202 }
203
204 void ddio_SetKeyboardLanguage(int) {}