Debian Codegraph @

ddio/ddio.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_common/ddio.cpp $
21 * $Revision: 18 $
22 * $Date: 10/21/99 9:27p $
23 * $Author: Jeff $
24 *
25 * Common DDIO Initialization
26 *
27 * $Log: /DescentIII/Main/ddio_common/ddio.cpp $
28 *
29 * 18 10/21/99 9:27p Jeff
30 * B.A. Macintosh code merge
31 *
32 * 17 8/11/99 3:09p Samir
33 * win32 as well calls ddioInternalJoyFrame.
34 *
35 * 16 7/28/99 5:18p Kevin
36 * Mac merge fixes
37 *
38 * 15 7/28/99 3:33p Kevin
39 * Mac!
40 *
41 * 14 4/22/99 1:56a Jeff
42 * pass in ddio_init_info to keyboard handlers
43 *
44 * 13 4/09/99 12:02p Samir
45 * joystick changes (Win32 DirectInput support)
46 *
47 * 12 2/21/99 6:38p Samir
48 * mouse and key input better. buffered mouse.
49 *
50 * 11 1/25/99 6:47p Samir
51 * allow slow keyboard
52 *
53 * 10 10/20/98 12:58a Jeff
54 * added a way to force a lo-resolution timer
55 *
56 * 9 10/16/98 1:03p Samir
57 * fixed timer issue when closing ddio, should not close timer.
58 *
59 * 8 6/30/98 4:20p Samir
60 * added ddio_Close as standalone. ddio_Init will no longer close
61 * itself.
62 *
63 * 7 6/29/98 6:46p Samir
64 * MouseInit no longer takes in required number of mouse buttons.
65 *
66 * 6 12/09/97 2:08p Samir
67 * Non preemptive keyboard as of now?
68 *
69 * 5 10/23/97 2:58p Samir
70 * Took out extranneous messages.
71 *
72 * 4 10/17/97 5:18p Samir
73 * ddio_Init now does mouse opening and closing, where it should be.
74 *
75 * 3 10/17/97 5:03p Samir
76 * Default to preemptive keyboard handler (not under NT).
77 *
78 * 2 10/16/97 2:28p Samir
79 * move keyboard init into ddio_init and added preemptive select for
80 * keyboard.
81 *
82 * 2 5/12/97 1:21p Samir
83 * Commented out timer hook function calls.
84 *
85 * 1 5/08/97 1:54p Samir
86 * Created skeletal initialization functions.
87 *
88 * $NoKeywords: $
89 */
90 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
91 #include "joystick.h"cxx . . $ `<file>/lib/joystick.h`/
92 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
93 #include <stdlib.h>
94 static bool DDIO_initializedcxx . . $ DDIO_initialized. = false;
95 // ----------------------------------------------------------------------------
96 // Common initialization
97 // ----------------------------------------------------------------------------
98 // Initializes DDIO system
99 bool ddio_Initcxx . . $ ddio_Init(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info) {
100 static bool first_time = true;
101 bool res;
102 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!DDIO_initialized);
103 if (first_time) {
104 atexit(ddio_Closecxx . . $ ddio_Close(49f6e7a06ebc5aa8).);
105 }
106 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "DDIO system initializing...\n");
107 res = ddio_InternalInitcxx . . $ ddio_InternalInit(4aa02e9b14a147be).(init_info);
108 if (res) {
109 if (first_time) { // initialize once and only once.
110 timer_Initcxx . . $ `ddio/ddio.h:235:9`!();
111 }
112 if (!ddio_KeyInitcxx . . $ ddio_KeyInit(4aa02e9b14a147be).(init_info))
113 Errorcxx . . $ Error(326aeb464d16410c).("Failed to initialize keyboard system.");
114 ddio_MouseInitcxx . . $ ddio_MouseInit(c9857a73d68e59ba).();
115 }
116 first_time = false;
117 DDIO_initializedcxx . . $ DDIO_initialized. = true;
118 joy_Initcxx . . $ joy_Init(efaadfb7dc14930a).(init_info->joy_emulationcxx . . $ ddio_init_info#joy_emulation.);
119 return res;
120 }
121 void ddio_Closecxx . . $ ddio_Close(49f6e7a06ebc5aa8).() {
122 if (DDIO_initializedcxx . . $ DDIO_initialized.) {
123 joy_Closecxx . . $ joy_Close(49f6e7a06ebc5aa8).();
124 ddio_MouseClosecxx . . $ ddio_MouseClose(49f6e7a06ebc5aa8).();
125 ddio_KeyClosecxx . . $ ddio_KeyClose(49f6e7a06ebc5aa8).();
126 ddio_InternalClosecxx . . $ ddio_InternalClose(49f6e7a06ebc5aa8).();
127 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "DDIO system closed.\n");
128 DDIO_initializedcxx . . $ DDIO_initialized. = false;
129 }
130 }
131 void ddio_Suspendcxx . . $ ddio_Suspend(49f6e7a06ebc5aa8).() {
132 ddio_InternalKeySuspendcxx . . $ ddio_InternalKeySuspend(49f6e7a06ebc5aa8).();
133 ddio_InternalMouseSuspendcxx . . $ ddio_InternalMouseSuspend(49f6e7a06ebc5aa8).();
134 }
135 void ddio_Resumecxx . . $ ddio_Resume(49f6e7a06ebc5aa8).() {
136 ddio_InternalKeyResumecxx . . $ ddio_InternalKeyResume(49f6e7a06ebc5aa8).();
137 ddio_InternalMouseResumecxx . . $ ddio_InternalMouseResume(49f6e7a06ebc5aa8).();
138 }
139 // handles buffered input from devices once per frame.
140 void ddio_Framecxx . . $ ddio_Frame(49f6e7a06ebc5aa8).() {
141 ddio_InternalKeyFramecxx . . $ ddio_InternalKeyFrame(49f6e7a06ebc5aa8).();
142 ddio_InternalMouseFramecxx . . $ ddio_InternalMouseFrame(49f6e7a06ebc5aa8).();
143 ddio_InternalJoyFramecxx . . $ ddio_InternalJoyFrame(49f6e7a06ebc5aa8).();
144 }