Debian Codegraph @

ddio/ddio.h

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/Lib/ddio.h $
21 * $Revision: 30 $
22 * $Date: 7/12/99 6:44p $
23 * $Author: Jeff $
24 *
25 * Device Dependent IO system header
26 *
27 * $Log: /DescentIII/Main/Lib/ddio.h $
28 *
29 * 30 7/12/99 6:44p Jeff
30 * added directory lock file API functions
31 *
32 * 29 4/24/99 5:41p Samir
33 * moved key to ascii, ascii to key to the ddio_common library.
34 *
35 * 28 4/22/99 2:03a Jeff
36 * pass ddio_init_info through to keyboard handlers
37 *
38 * 27 4/01/99 11:26a Samir
39 * ddio_MouseGetCaps returns the button mask containing valid buttons.
40 *
41 * 26 3/23/99 9:05p Samir
42 * implemented mouse z axis (for Win32, mouse wheel.) and added functions
43 * to get binding text values.
44 *
45 * 25 2/21/99 6:38p Samir
46 * mouse and key input better. buffered mouse.
47 *
48 * 24 2/16/99 5:24p Kevin
49 * Converted timer to use 64bit int.
50 *
51 * 23 2/05/99 1:16p Samir
52 * reset low level keys when flushing keyboard in the high level. added a
53 * function to the low level to reset the status of a key, called from
54 * high level key flush.
55 *
56 * 22 2/04/99 11:19a Kevin
57 * Added function to find a CD drive letter based on it's volume name
58 *
59 * 21 1/25/99 6:47p Samir
60 * allow slow keyboard
61 *
62 * 20 1/25/99 11:02a Samir
63 * revamped mouse and key controls.
64 *
65 * 19 12/08/98 12:17p Jeff
66 * added 3 functions (similar to ddio_FindFiles) for finding directories
67 * in a path
68 *
69 * 18 11/19/98 5:40p Kevin
70 * Demo system
71 *
72 * 17 10/21/98 12:02p Samir
73 * properly update odd keys when they are released throug
74 * ddio_KeyGetDownTime.
75 *
76 * 16 10/20/98 12:58a Jeff
77 * added a way to force a lo-resolution timer
78 *
79 * 15 10/16/98 11:55a Kevin
80 * Made dlls loadable in a hog
81 *
82 * 14 8/19/98 2:18p Jeff
83 * changed ddio_CleanPath
84 *
85 * 13 8/15/98 3:42p Matt
86 * Added new function, ddio_GetFullPath()
87 *
88 * 12 7/29/98 5:38p Jeff
89 * added ddio functions to get parent path, and to clean a path name into
90 * the real path
91 *
92 * 11 7/28/98 6:05p Jeff
93 * added functions to get root directories (aka drives in windows/dos)
94 *
95 * 10 7/28/98 5:05p Samir
96 * added drive retrieval functions for Jeff.
97 *
98 * 9 7/01/98 4:55p Samir
99 * new simplified mouse system.
100 *
101 * 8 6/29/98 6:46p Samir
102 * MouseInit no longer takes in required number of mouse buttons.
103 *
104 * 7 3/19/98 3:18p Samir
105 * enforce constant char* arguments when needed. done in CFILE and bitmap
106 * libraries as well as ddio.
107 *
108 * 6 2/25/98 6:11p Samir
109 * Added functions to better deal with key flushing.
110 *
111 * 5 1/02/98 12:52p Samir
112 * Added function to translate keycode to ascii values.
113 *
114 * 4 10/16/97 2:29p Samir
115 * Changed DirectInput Keyboard to FOREGROUND
116 *
117 * 3 8/15/97 6:31p Samir
118 * Added findfile functions.
119 *
120 * 2 7/28/97 2:54p Samir
121 * Temp fix for absolute mouse position return values (Uses GetCursorPos.)
122 * Added Show and Hide cursor too.
123 *
124 * 1 6/23/97 9:25p Samir
125 * added because source safe sucks
126 *
127 * 26 6/11/97 1:07p Samir
128 * The removal of gameos and replaced with oeApplication, oeDatabase
129 *
130 * 25 5/12/97 1:21p Samir
131 * Commented out timer hook function calls.
132 *
133 * 24 5/08/97 1:55p Samir
134 * Moved a bunch of functions to ddio_common.h
135 *
136 * 23 5/06/97 4:23p Samir
137 * Ha ha. Jeremy's fault....
138 *
139 * 22 5/6/97 4:24 PM Jeremy
140 * fixed a bug in ddio_MakePath
141 *
142 * 21 5/6/97 3:05 PM Jeremy
143 * added prototype for ddio_makepath
144 *
145 * 20 5/6/97 12:06 PM Jeremy
146 * changed comments to reflect convention for split path to be in local
147 * file system syntax
148 *
149 * 19 5/6/97 11:45 AM Jeremy
150 * changed split path to only look for path, filename, extension instead
151 * of including directory name as well, added prototypes for save/restore
152 * working dir and changed conventions for relative/absolute nature of
153 * directory calls
154 *
155 * 18 4/25/97 6:17p Jason
156 * added ddio_Deletefile function
157 *
158 * 17 4/16/97 11:32a Samir
159 * Added z axis support.
160 *
161 * 16 4/03/97 4:34p Jason
162 * added CopyFileTime to the cfile, ddio libs
163 *
164 * 15 3/20/97 11:08a Samir
165 * Added function to peek for keys in queue without removing them.
166 *
167 * 14 3/14/97 6:54 PM Jeremy
168 * added prototypes of ddio_FileDiff, ddio_GetFileLength, ddio_SplitPath
169 *
170 * 13 3/13/97 11:09a Samir
171 * Moved file stuff from gameos to ddio library
172 *
173 * 12 1/30/97 6:08p Samir
174 * Reflect new osObject type instead of gameos_object
175 *
176 * 11 1/23/97 2:23p Samir
177 * Added some more keyboard constants
178 *
179 * 10 1/20/97 3:48p Samir
180 * RCS check in
181 *
182 * $NoKeywords: $
183 */
184
185 // ----------------------------------------------------------------------------
186 // Device Dependent IO System Main Library Interface - functions here are located
187 // in the ddio_??? system where ??? is the os.
188 // ----------------------------------------------------------------------------
189
190 #ifndef DDIO_H
191 #define DDIO_Hcxx . . $ `ddio/ddio.h:191:9`!
192
193 #include <cstdio>
194 #include <cstdint>
195 #include <filesystem>
196
197 #include "chrono_timer.h"cxx . . $ `<file>/ddio/chrono_timer.h`/
198 #include "ddio_common.h"cxx . . $ `<file>/ddio/ddio_common.h`/
199 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
200
201 // ----------------------------------------------------------------------------
202 // Initialization and destruction functions
203 // ----------------------------------------------------------------------------
204
205 // preemptive = 1 for thread based IO. Initializes the IO system
206 bool ddio_InternalInitcxx . . $ ddio_InternalInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info);
207 void ddio_InternalClosecxx . . $ ddio_InternalClose(49f6e7a06ebc5aa8).();
208
209 // ----------------------------------------------------------------------------
210 // Keyboard Interface
211 // ----------------------------------------------------------------------------
212
213 // used by ddio system to initialize machine specific key code.
214 bool ddio_InternalKeyInitcxx . . $ ddio_InternalKeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info);
215 void ddio_InternalKeyClosecxx . . $ ddio_InternalKeyClose(49f6e7a06ebc5aa8).();
216
217 // handled internally if keyboard system needs additional processing per frame
218 void ddio_InternalKeyFramecxx . . $ ddio_InternalKeyFrame(49f6e7a06ebc5aa8).();
219 void ddio_InternalKeySuspendcxx . . $ ddio_InternalKeySuspend(49f6e7a06ebc5aa8).();
220 void ddio_InternalKeyResumecxx . . $ ddio_InternalKeyResume(49f6e7a06ebc5aa8).();
221
222 // returns if key is up or down
223 bool ddio_InternalKeyStatecxx . . $ ddio_InternalKeyState(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# key);
224
225 // returns internal key down time
226 float ddio_InternalKeyDownTimecxx . . $ ddio_InternalKeyDownTime(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# key);
227
228 // flush a key internally
229 void ddio_InternalResetKeycxx . . $ ddio_InternalResetKey(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# key);
230
231 // ----------------------------------------------------------------------------
232 // Device Dependent Timer Interface
233 // ----------------------------------------------------------------------------
234
235 #define timer_Initcxx . . $ `ddio/ddio.h:235:9`! D3::ChronoTimer::Initialize
236 #define timer_GetTimecxx . . $ `ddio/ddio.h:236:9`! D3::ChronoTimer::GetTime
237 #define timer_GetMSTimecxx . . $ `ddio/ddio.h:237:9`! D3::ChronoTimer::GetTimeMS
238
239 // ----------------------------------------------------------------------------
240 // Device Dependent Mouse Interface
241 // ----------------------------------------------------------------------------
242
243 #define MOUSE_LBcxx . . $ `ddio/ddio.h:243:9`! 1 // mouse button masks
244 #define MOUSE_RBcxx . . $ `ddio/ddio.h:244:9`! 2
245 #define MOUSE_CBcxx . . $ `ddio/ddio.h:245:9`! 4
246 #define MOUSE_B4cxx . . $ `ddio/ddio.h:246:9`! 8
247 #define MOUSE_B5cxx . . $ `ddio/ddio.h:247:9`! 16
248 #define MOUSE_B6cxx . . $ `ddio/ddio.h:248:9`! 32
249 #define MOUSE_B7cxx . . $ `ddio/ddio.h:249:9`! 64
250 #define MOUSE_B8cxx . . $ `ddio/ddio.h:250:9`! 128
251
252 #define N_MSEBTNScxx . . $ `ddio/ddio.h:252:9`! 8
253
254 // initializes mouse.
255 bool ddio_MouseInitcxx . . $ ddio_MouseInit(c9857a73d68e59ba).();
256 void ddio_MouseClosecxx . . $ ddio_MouseClose(49f6e7a06ebc5aa8).();
257
258 // get device caps
259 int ddio_MouseGetCapscxx . . $ ddio_MouseGetCaps(aa23d0250da59a45).(int *btn, int *axis);
260
261 // use these extensions to set exclusive or standard mouse modes
262 #define MOUSE_STANDARD_MODEcxx . . $ `ddio/ddio.h:262:9`! 1 // uses absolute coordinates and simple buttons
263 #define MOUSE_EXCLUSIVE_MODEcxx . . $ `ddio/ddio.h:263:9`! 2 // uses relative coordinates and advanced button information
264 void ddio_MouseModecxx . . $ ddio_MouseMode(d4f767463ce0a6b3).(int mode);
265
266 // resets position of mouse to center, resets virtual coord system to equal screen coordinate system
267 void ddio_MouseResetcxx . . $ ddio_MouseReset(49f6e7a06ebc5aa8).();
268
269 // resets mouse queue and button info only.
270 void ddio_MouseQueueFlushcxx . . $ ddio_MouseQueueFlush(49f6e7a06ebc5aa8).();
271
272 // handled internally if mouse system needs additional processing per frame
273 void ddio_InternalMouseFramecxx . . $ ddio_InternalMouseFrame(49f6e7a06ebc5aa8).();
274
275 // used to prevent mouse input from being registered
276 void ddio_InternalMouseSuspendcxx . . $ ddio_InternalMouseSuspend(49f6e7a06ebc5aa8).();
277 void ddio_InternalMouseResumecxx . . $ ddio_InternalMouseResume(49f6e7a06ebc5aa8).();
278
279 // returns absolute position of mouse, button state and mouse deltas.
280 /* x, y = absolute mouse position
281 dx, dy = mouse deltas since last call
282 return value is mouse button mask. values not needed should pass NULL pointers.
283 */
284 int ddio_MouseGetStatecxx . . $ ddio_MouseGetState(150f8a26046a094b).(int *x, int *y, int *dx, int *dy, int *z = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, int *dz = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
285
286 // gets a mouse button event, returns false if none.
287 bool ddio_MouseGetEventcxx . . $ ddio_MouseGetEvent(ee4fd70245e09a47).(int *btn, bool *state);
288
289 // returns string to binding.
290 const char *ddio_MouseGetBtnTextcxx . . $ ddio_MouseGetBtnText(f7ae7e56280f18ae).(int btn);
291 const char *ddio_MouseGetAxisTextcxx . . $ ddio_MouseGetAxisText(f7ae7e56280f18ae).(int axis);
292
293 // return mouse button down time.
294 float ddio_MouseBtnDownTimecxx . . $ ddio_MouseBtnDownTime(5cde91ea12d43f46).(int btn);
295
296 // return mouse button down time
297 int ddio_MouseBtnDownCountcxx . . $ ddio_MouseBtnDownCount(7864480464b09eea).(int btn);
298
299 // return mouse button up count
300 int ddio_MouseBtnUpCountcxx . . $ ddio_MouseBtnUpCount(7864480464b09eea).(int btn);
301
302 // set bounds for system polling of coordinates
303 void ddio_MouseSetLimitscxx . . $ ddio_MouseSetLimits(4df37d5d0c1dcce).(int left, int top, int right, int bottom, int zmin = 0, int zmax = 0);
304 void ddio_MouseGetLimitscxx . . $ ddio_MouseGetLimits(883f425df92af248).(int *left, int *top, int *right, int *bottom, int *zmin = 0, int *zmax = 0);
305
306 // virtual coordinate system for mouse (match to video resolution set for optimal mouse usage.
307 void ddio_MouseSetVCoordscxx . . $ ddio_MouseSetVCoords(3e454b8ccf442868).(int width, int height);
308
309 // ---------------------------------------------------------------------------
310 // File Operations
311 // ---------------------------------------------------------------------------
312
313 // Gets the full path of the executable file
314 bool ddio_GetBinaryPathcxx . . $ ddio_GetBinaryPath(ccee65ad8ce1f171).(char *exec_path, size_t len);
315
316 // deletes a file. Returns 1 if successful, 0 on failure
317 // This pathname is *RELATIVE* not fully qualified
318 int ddio_DeleteFilecxx . . $ ddio_DeleteFile(5c4306d8553b3696).(const char *name);
319
320 // retrieve the current working folder where file operation will occur.
321 // Note ---> The path in Get/Set working directory is in the *LOCAL* file system's syntax
322 // This pathname is relative *OR* fully qualified
323 void ddio_GetWorkingDircxx . . $ ddio_GetWorkingDir(a07d8cccb7673f5a).(char *path, int len);
324 bool ddio_SetWorkingDircxx . . $ ddio_SetWorkingDir(c5f7da30cbc0f4e9).(const char *path);
325
326 // get a file length of a FILE
327 int ddio_GetFileLengthcxx . . $ ddio_GetFileLength(89bc1efcdac0ca22).(FILEcxx . . $ FILE# *filePtr);
328
329 // check if two files are different
330 // This pathname is *RELATIVE* not fully qualified
331 bool ddio_FileDiffcxx . . $ ddio_FileDiff(1b1fb50d0437e4a5).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &path1, const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &path2);
332
333 // copies one files timestamp to another
334 void ddio_CopyFileTimecxx . . $ ddio_CopyFileTime(df5f3ffd01de66e0).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &dest, const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &src);
335
336 // Split a pathname into its component parts
337 // The path in splitpath is in the *LOCAL* file system's syntax
338 void ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(const char *srcPath, char *path, char *filename, char *ext);
339
340 // pass in a pathname (could be from ddio_SplitPath), root_path will have the drive name.
341 void ddio_GetRootFromPathcxx . . $ ddio_GetRootFromPath(611124a97efc52dd).(const char *srcPath, char *root_path);
342
343 // retrieve root names, free up roots array (allocated with malloc) after use
344 int ddio_GetFileSysRootscxx . . $ ddio_GetFileSysRoots(9654734fd31b2328).(char **roots, int max_roots);
345
346 // Constructs a path in the local file system's syntax
347 // builtPath: stores the constructed path
348 // absolutePathHeader: absolute path on which the sub directories will be appended
349 // (specified in local file system syntax)
350 // subdir: the first subdirectory
351 // takes a variable number of additional subdirectories which will be concatenated on to the path
352 // the last argument in the list of sub dirs *MUST* be NULL to terminate the list
353 void ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(char *newPath, const char *absolutePathHeader, const char *subDir, ...);
354
355 // These functions allow one to find a file
356 // You use FindFileStart by giving it a wildcard (like *.*, *.txt, u??.*, whatever). It returns
357 // a filename in namebuf.
358 // Use FindNextFile to get the next file found with the wildcard given in FindFileStart.
359 // Use FindFileClose to end your search.
360 bool ddio_FindFileStartcxx . . $ ddio_FindFileStart(84e74a5521f49206).(const char *wildcard, char *namebuf);
361 bool ddio_FindNextFilecxx . . $ ddio_FindNextFile(c6b7e35ff6de5671).(char *namebuf);
362 void ddio_FindFileClosecxx . . $ ddio_FindFileClose(49f6e7a06ebc5aa8).();
363
364 // given a path (with no filename), it will return the parent path
365 // srcPath is the source given path
366 // dest is where the parent path will be placed
367 // returns true on success
368 // dest should be at least _MAX_PATH in length
369 bool ddio_GetParentPathcxx . . $ ddio_GetParentPath(9efbdc942cde3d3d).(char *dest, const char *srcPath);
370
371 // given a path, it cleans it up (if the path is c:\windows\..\dos it would make it c:\dos)
372 // srcPath is the original path
373 // dest is the finished cleaned path.
374 // dest should be at least _MAX_PATH in size
375 void ddio_CleanPathcxx . . $ ddio_CleanPath(72c91e5e80d20bae).(char *dest, const char *srcPath);
376
377 // Finds a full path from a relative path
378 // Parameters: full_path - filled in with the fully-specified path. Buffer must be at least _MAX_PATH bytes long
379 // rel_path - a path specification, either relative or absolute
380 // Returns TRUE if successful, FALSE if an error
381 bool ddio_GetFullPathcxx . . $ ddio_GetFullPath(9efbdc942cde3d3d).(char *full_path, const char *rel_path);
382
383 // Generates a temporary filename based on the prefix, and basedir
384 // Parameters:
385 // basedir - directory to put the files
386 // prefix - prefix for the temp filename
387 // filename - buffer to hold generated filename (must be at least _MAX_PATH in length)
388 //
389 // Returns TRUE if successful, FALSE if an error
390 bool ddio_GetTempFileNamecxx . . $ ddio_GetTempFileName(dfb34736e99ce5d).(const char *basedir, const char *prefix, char *filename);
391
392 /**
393 * Check process existence by PID
394 * @param pid PID of requested process
395 * @return true if process exists, false otherwise
396 */
397 bool ddio_CheckProcesscxx . . $ ddio_CheckProcess(83c267b20bac841a).(int pid);
398
399 /**
400 * Get PID of current process
401 * @return
402 */
403 int ddio_GetPIDcxx . . $ ddio_GetPID(b126dc7c1de90089).();
404
405 /**
406 * Creates a lock file in the specified directory. Before creation function
407 * checks if lockfile already created by another process.
408 * @param dir Directory for which the lock file should be created in
409 * @return true if lock file successfully created, false otherwise (unable to
410 * create, lock file already created by another process etc).
411 */
412 bool ddio_CreateLockFilecxx . . $ ddio_CreateLockFile(c53a6ef3278968b1).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#& dir);
413
414 /**
415 * Deletes a lock file (for the current process) in the specified directory
416 * @param dir Directory for which the lock file should be deleted from
417 * @return true if lock file successfully deleted, false otherwise
418 */
419 bool ddio_DeleteLockFilecxx . . $ ddio_DeleteLockFile(c53a6ef3278968b1).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#& dir);
420
421 #endif