Wing Commander
Reconstructed Win32 source (1996)
Toggle main menu visibility
Loading...
Searching...
No Matches
input.c
Go to the documentation of this file.
1
/**
2
* @file
3
* @ingroup shell
4
* @brief Joystick transitions and menu input polling.
5
*
6
* Address range 430710-430bbf.
7
*/
8
#include "
wc1.h
"
9
10
short
nInputDoubleClickInterval
= 1;
/* 0x0046af54 */
11
short
nMenuPointerSpeed
= 2;
/* 0x0046af58 */
12
13
14
/* Linker commons defined here; LINK orders them by identifier hash. */
15
unsigned
short
ausVduModeStack
[16];
/* 0x0059d500 */
16
char
acShipSequence
[10];
/* 0x0059d520 */
17
short
nTargetFacingValue
;
/* 0x0059d52a */
18
FixedVector
aShipDestinationsArray
[10];
/* 0x0059d530 */
19
short
aasShipShield
[10][2];
/* 0x0059d5b0 */
20
enum
ShipTactic
aeShipTacticArray
[12];
/* 0x0059d5e0 */
21
signed
char
abShipExhaustHeatList
[10];
/* 0x0059d610 */
22
short
nRenderedSpaceFrame
;
/* 0x0059d61a */
23
short
nEyePitchTargetValue
;
/* 0x0059d61c */
24
25
/* Function start: 0x430710 */
26
short
__stdcall
UpdateInputDeviceTransitions
(
short
raw)
27
{
28
short
device;
29
30
device =
nCurrentActiveInputDevice
;
31
if
(raw == 0)
32
ReadCalibratedJoystick
();
33
else
34
SampleJoystickDevice
(&
aInputDevSamples
[device], device, 0);
35
36
asInputButton2DoubleClick
[device] = 0;
37
asInputButton1DoubleClicksList
[device] = 0;
38
asInputButton2ChangedTable
[device] = 0;
39
asInputBtn1ChangedTable
[device] = 0;
40
if
((
short
)
aInputDevSamples
[device].buttons !=
41
asPreviousInputButtons
[device]) {
42
if
((((
unsigned
short
)
aInputDevSamples
[device].buttons ^
43
(
unsigned
short
)
asPreviousInputButtons
[device]) & 1) != 0) {
44
asInputBtn1ChangedTable
[device] = 1;
45
if
(((
unsigned
short
)
aInputDevSamples
[device].buttons & 1) != 0) {
46
if
(
nTickCount60Hz
-
anInputButton1PressTimes
[device] <=
47
nInputDoubleClickInterval
*
nInputTickScale
)
48
asInputButton1DoubleClicksList
[device] = 1;
49
anInputButton1PressTimes
[device] =
nTickCount60Hz
;
50
}
51
}
52
if
((((
unsigned
short
)
aInputDevSamples
[device].buttons ^
53
(
unsigned
short
)
asPreviousInputButtons
[device]) & 2) != 0) {
54
asInputButton2ChangedTable
[device] = 1;
55
if
(((
unsigned
short
)
aInputDevSamples
[device].buttons & 2) != 0) {
56
if
(
nTickCount60Hz
-
anInputButton2PressTime
[device] <=
57
nInputDoubleClickInterval
*
nInputTickScale
)
58
asInputButton2DoubleClick
[device] = 1;
59
anInputButton2PressTime
[device] =
nTickCount60Hz
;
60
}
61
}
62
asPreviousInputButtons
[device] =
63
(short)
aInputDevSamples
[device].buttons;
64
}
65
return
1;
66
}
67
68
/* Function start: 0x430830 */
69
/* Empty, and nothing in the shipped executable calls it, so its purpose
70
* cannot be recovered; it sits among the joystick input routines. */
71
void
JoystickInputHook
(
void
)
72
{
73
}
74
75
/* Function start: 0x430840 */
76
void
PollJoystickButtonEvents
(
void
)
77
{
78
short
doubleClick;
79
80
if
(
nCurrentActiveInputDevice
== -1)
81
return
;
82
if
(
bInputPollingGuard
!= 0)
83
return
;
84
bInputPollingGuard
++;
85
UpdateInputDeviceTransitions
(1);
86
if
(
asInputBtn1ChangedTable
[
nCurrentActiveInputDevice
] != 0) {
87
doubleClick = 0;
88
if
(
asInputButton1DoubleClicksList
[
nCurrentActiveInputDevice
] != 0)
89
doubleClick = 3;
90
QueueInputEventAtCursor
(
91
(
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons & 1) + 1,
92
0, doubleClick);
93
}
94
if
(
asInputButton2ChangedTable
[
nCurrentActiveInputDevice
] != 0) {
95
doubleClick = 0;
96
if
(
asInputButton2DoubleClick
[
nCurrentActiveInputDevice
] != 0)
97
doubleClick = 3;
98
QueueInputEventAtCursor
(
99
((
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons >> 1) &
100
1) + 1,
101
1, doubleClick);
102
}
103
stHostMouseState
.
secondaryButton
=
104
(
unsigned
char)
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons;
105
stHostMouseState
.
primaryButton
=
stHostMouseState
.
secondaryButton
;
106
bInputPollingGuard
--;
107
}
108
109
/* Function start: 0x430920 */
110
void
PollMenuInputDevices
(
void
)
111
{
112
signed
char
doubleClick;
113
unsigned
char
changes;
114
115
changes = 0;
116
if
(
nCurrentActiveInputDevice
== -1)
117
return
;
118
stHostMouseState
.
x
=
stMouseCursorState
.
x
;
119
stHostMouseState
.
y
=
stMouseCursorState
.
y
;
120
if
(
bInputPollingGuard
== 0) {
121
bInputPollingGuard
++;
122
UpdateInputDeviceTransitions
(0);
123
124
if
(
asInputBtn1ChangedTable
[
nCurrentActiveInputDevice
] != 0) {
125
stHostMouseState
.
x
+=
126
aInputDevSamples
[
nCurrentActiveInputDevice
].
x
*
127
nMenuPointerSpeed
;
128
stHostMouseState
.
y
+=
129
aInputDevSamples
[
nCurrentActiveInputDevice
].
y
*
130
nMenuPointerSpeed
;
131
doubleClick = 0;
132
if
(
asInputButton1DoubleClicksList
[
nCurrentActiveInputDevice
] != 0)
133
doubleClick = 3;
134
QueueInputEventAtCursor
(
135
(
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons & 1) + 1,
136
0, (
short
)doubleClick);
137
changes++;
138
}
139
if
(
asInputButton2ChangedTable
[
nCurrentActiveInputDevice
] != 0) {
140
stHostMouseState
.
x
+=
141
aInputDevSamples
[
nCurrentActiveInputDevice
].
x
*
142
nMenuPointerSpeed
;
143
stHostMouseState
.
y
+=
144
aInputDevSamples
[
nCurrentActiveInputDevice
].
y
*
145
nMenuPointerSpeed
;
146
doubleClick = 0;
147
if
(
asInputButton1DoubleClicksList
[
nCurrentActiveInputDevice
] != 0)
148
doubleClick = 3;
149
QueueInputEventAtCursor
(
150
((
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons >> 1) &
151
1) + 1,
152
1, (
short
)doubleClick);
153
changes++;
154
}
155
if
(changes == 0) {
156
stHostMouseState
.
x
+=
157
aInputDevSamples
[
nCurrentActiveInputDevice
].
x
*
158
nMenuPointerSpeed
;
159
stHostMouseState
.
y
+=
160
aInputDevSamples
[
nCurrentActiveInputDevice
].
y
*
161
nMenuPointerSpeed
;
162
changes = (
unsigned
char)(
163
aInputDevSamples
[
nCurrentActiveInputDevice
].y |
164
aInputDevSamples
[
nCurrentActiveInputDevice
].x);
165
if
(changes != 0) {
166
FlushInputEvents
();
167
stHostMouseState
.
x
=
stHostMouseState
.
x
> 0 ?
168
stHostMouseState
.
x
: 0;
169
stHostMouseState
.
x
=
stHostMouseState
.
x
< 319 ?
170
stHostMouseState
.
x
: 319;
171
stHostMouseState
.
y
=
stHostMouseState
.
y
> 0 ?
172
stHostMouseState
.
y
: 0;
173
stHostMouseState
.
y
=
stHostMouseState
.
y
< 199 ?
174
stHostMouseState
.
y
: 199;
175
SetMousePosition
(
stHostMouseState
.
x
,
stHostMouseState
.
y
);
176
}
177
}
178
179
stHostMouseState
.
secondaryButton
=
180
(
unsigned
char)
aInputDevSamples
[
nCurrentActiveInputDevice
].buttons;
181
stHostMouseState
.
primaryButton
=
stHostMouseState
.
secondaryButton
;
182
stHostMouseState
.
x
=
stHostMouseState
.
x
> 0 ?
183
stHostMouseState
.
x
: 0;
184
stHostMouseState
.
x
=
stHostMouseState
.
x
< 319 ?
185
stHostMouseState
.
x
: 319;
186
stHostMouseState
.
y
=
stHostMouseState
.
y
> 0 ?
187
stHostMouseState
.
y
: 0;
188
stHostMouseState
.
y
=
stHostMouseState
.
y
< 199 ?
189
stHostMouseState
.
y
: 199;
190
if
(changes != 0) {
191
LeaveAllocationScope
();
192
stMouseCursorState
.
x
=
stHostMouseState
.
x
;
193
stMouseCursorState
.
y
=
stHostMouseState
.
y
;
194
stMouseCursorState
.
primaryButton
=
stHostMouseState
.
primaryButton
;
195
stMouseCursorState
.
secondaryButton
=
stHostMouseState
.
secondaryButton
;
196
stMouseCursorState
.
flags
=
stHostMouseState
.
flags
;
197
EnterAllocationScope
();
198
}
199
bInputPollingGuard
--;
200
}
201
}
aInputDevSamples
InputDeviceSample aInputDevSamples[2]
Definition
nav.c:78
asPreviousInputButtons
short asPreviousInputButtons[2]
Definition
view.c:32
aeShipTacticArray
enum ShipTactic aeShipTacticArray[12]
Definition
input.c:20
anInputButton1PressTimes
int anInputButton1PressTimes[2]
Definition
view.c:33
abShipExhaustHeatList
signed char abShipExhaustHeatList[10]
Definition
input.c:21
asInputButton1DoubleClicksList
short asInputButton1DoubleClicksList[2]
Definition
view.c:29
nRenderedSpaceFrame
short nRenderedSpaceFrame
Definition
input.c:22
nInputDoubleClickInterval
short nInputDoubleClickInterval
Definition
input.c:10
nInputTickScale
int nInputTickScale
Definition
data.c:245
ausVduModeStack
unsigned short ausVduModeStack[16]
Definition
input.c:15
aShipDestinationsArray
FixedVector aShipDestinationsArray[10]
Definition
input.c:18
asInputButton2DoubleClick
short asInputButton2DoubleClick[2]
Definition
damage.c:46
anInputButton2PressTime
int anInputButton2PressTime[2]
Definition
view.c:28
nMenuPointerSpeed
short nMenuPointerSpeed
Definition
input.c:11
stHostMouseState
MouseCursorState stHostMouseState
Definition
data.c:243
nEyePitchTargetValue
short nEyePitchTargetValue
Definition
input.c:23
bInputPollingGuard
unsigned char bInputPollingGuard
Definition
main.c:44
stMouseCursorState
MouseCursorState stMouseCursorState
Definition
strdos.c:19
aasShipShield
short aasShipShield[10][2]
Definition
input.c:19
nTickCount60Hz
int nTickCount60Hz
Definition
mathfp.c:23
nTargetFacingValue
short nTargetFacingValue
Definition
input.c:17
asInputButton2ChangedTable
short asInputButton2ChangedTable[2]
Definition
view.c:31
nCurrentActiveInputDevice
short nCurrentActiveInputDevice
Definition
nav.c:60
acShipSequence
char acShipSequence[10]
Definition
input.c:16
asInputBtn1ChangedTable
short asInputBtn1ChangedTable[2]
Definition
view.c:30
JoystickInputHook
void JoystickInputHook(void)
Definition
input.c:71
FixedVector
Definition
wcdata.h:321
InputDeviceSample::x
int x
Definition
wc1base.h:150
InputDeviceSample::y
int y
Definition
wc1base.h:151
MouseCursorState::y
short y
Definition
wc1base.h:102
MouseCursorState::flags
unsigned short flags
Definition
wc1base.h:106
MouseCursorState::secondaryButton
unsigned char secondaryButton
Definition
wc1base.h:104
MouseCursorState::x
short x
Definition
wc1base.h:101
MouseCursorState::primaryButton
unsigned char primaryButton
Definition
wc1base.h:103
wc1.h
Umbrella header for the game core.
LeaveAllocationScope
void LeaveAllocationScope(void)
Definition
eventmgr.c:556
QueueInputEventAtCursor
void QueueInputEventAtCursor(unsigned short type, short primaryButton, short secondaryButton)
Definition
eventmgr.c:63
PollJoystickButtonEvents
void PollJoystickButtonEvents(void)
Definition
input.c:76
SetMousePosition
void SetMousePosition(int x, int y)
Definition
winsys.c:56
FlushInputEvents
void FlushInputEvents(void)
Definition
eventmgr.c:381
EnterAllocationScope
void EnterAllocationScope(void)
Definition
eventmgr.c:550
ReadCalibratedJoystick
short ReadCalibratedJoystick(void)
Definition
joycal.c:159
UpdateInputDeviceTransitions
short __stdcall UpdateInputDeviceTransitions(short raw)
Definition
input.c:26
PollMenuInputDevices
void PollMenuInputDevices(void)
Definition
input.c:110
SampleJoystickDevice
int __stdcall SampleJoystickDevice(InputDeviceSample *samples, short joystick, unsigned short fallback)
Definition
mission.c:958
ShipTactic
ShipTactic
Definition
wcdata.h:150
src
input.c
Generated by
1.18.0