Skip to content

Commit 7e1f218

Browse files
committed
xrEngine/xr_input.h|cpp: cleanup
Renamed timeStamp -> mouseTImeStamp Renamed KBState -> keyboardState Removed timeSave (unused) Layers/xrRenderDX10/dx10HW.cpp: removed redundant %s
1 parent 65a17b2 commit 7e1f218

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
125125
}
126126
}
127127
else
128-
Log("Couldn't get window information: %s", SDL_GetError());
128+
Log("Couldn't get window information: ", SDL_GetError());
129129
sd.Windowed = bWindowed;
130130

131131
// Depth/stencil (DX10 don't need this?)

src/xrEngine/xr_input.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ CInput::CInput(bool exclusive, int deviceForInit)
4646
MouseDelta = 25;
4747

4848
ZeroMemory(mouseState, sizeof(mouseState));
49-
ZeroMemory(KBState, sizeof(KBState));
50-
ZeroMemory(timeStamp, sizeof(timeStamp));
51-
ZeroMemory(timeSave, sizeof(timeStamp));
49+
ZeroMemory(keyboardState, sizeof(keyboardState));
50+
ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp));
5251
ZeroMemory(offs, sizeof(offs));
5352

5453
//===================== Dummy pack
@@ -111,8 +110,8 @@ void CInput::MouseUpdate()
111110
{
112111
case SDL_MOUSEMOTION:
113112
mouseMoved = true;
114-
timeStamp[0] = dwCurTime + event.motion.timestamp;
115-
timeStamp[1] = dwCurTime + event.motion.timestamp;
113+
mouseTimeStamp[0] = dwCurTime + event.motion.timestamp;
114+
mouseTimeStamp[1] = dwCurTime + event.motion.timestamp;
116115
offs[0] += event.motion.xrel;
117116
offs[1] += event.motion.yrel;
118117
break;
@@ -126,8 +125,8 @@ void CInput::MouseUpdate()
126125
break;
127126
case SDL_MOUSEWHEEL:
128127
mouseMoved = true;
129-
timeStamp[2] = dwCurTime + event.wheel.timestamp;
130-
timeStamp[3] = dwCurTime + event.wheel.timestamp;
128+
mouseTimeStamp[2] = dwCurTime + event.wheel.timestamp;
129+
mouseTimeStamp[3] = dwCurTime + event.wheel.timestamp;
131130
offs[2] += event.wheel.y;
132131
offs[3] += event.wheel.x;
133132
break;
@@ -158,10 +157,10 @@ void CInput::MouseUpdate()
158157
}
159158
else
160159
{
161-
if (timeStamp[1] && dwCurTime - timeStamp[1] >= MouseDelta)
162-
cbStack.back()->IR_OnMouseStop(0, timeStamp[1] = 0);
163-
if (timeStamp[0] && dwCurTime - timeStamp[0] >= MouseDelta)
164-
cbStack.back()->IR_OnMouseStop(0, timeStamp[0] = 0);
160+
if (mouseTimeStamp[1] && dwCurTime - mouseTimeStamp[1] >= MouseDelta)
161+
cbStack.back()->IR_OnMouseStop(0, mouseTimeStamp[1] = 0);
162+
if (mouseTimeStamp[0] && dwCurTime - mouseTimeStamp[0] >= MouseDelta)
163+
cbStack.back()->IR_OnMouseStop(0, mouseTimeStamp[0] = 0);
165164
}
166165
}
167166

@@ -175,19 +174,19 @@ void CInput::KeyUpdate()
175174
case SDL_KEYDOWN:
176175
if (event.key.repeat)
177176
continue;
178-
KBState[event.key.keysym.scancode] = true;
177+
keyboardState[event.key.keysym.scancode] = true;
179178
cbStack.back()->IR_OnKeyboardPress(event.key.keysym.scancode);
180179
break;
181180

182181
case SDL_KEYUP:
183-
KBState[event.key.keysym.scancode] = false;
182+
keyboardState[event.key.keysym.scancode] = false;
184183
cbStack.back()->IR_OnKeyboardRelease(event.key.keysym.scancode);
185184
break;
186185
}
187186
}
188187

189188
for (u32 i = 0; i < COUNT_KB_BUTTONS; ++i)
190-
if (KBState[i])
189+
if (keyboardState[i])
191190
cbStack.back()->IR_OnKeyboardHold(i);
192191
}
193192

@@ -201,7 +200,7 @@ bool CInput::get_key_name(int dik, LPSTR dest_str, int dest_sz)
201200
Msg("! cant convert dik_name for dik[%d]", dik);
202201
return false;
203202
}
204-
strcpy_s(dest_str, dest_sz, keyname);
203+
xr_strcpy(dest_str, dest_sz, keyname);
205204
}
206205

207206
return true;
@@ -213,7 +212,7 @@ bool CInput::get_key_name(int dik, LPSTR dest_str, int dest_sz)
213212
bool CInput::iGetAsyncKeyState(int dik)
214213
{
215214
if (dik < COUNT_KB_BUTTONS)
216-
return KBState[dik];
215+
return keyboardState[dik];
217216

218217
if (dik >= MOUSE_1 && dik <= MOUSE_8)
219218
{
@@ -255,8 +254,7 @@ void CInput::iCapture(IInputReceiver* p)
255254
cbStack.back()->IR_OnActivate();
256255

257256
// prepare for _new_ controller
258-
ZeroMemory(timeStamp, sizeof(timeStamp));
259-
ZeroMemory(timeSave, sizeof(timeStamp));
257+
ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp));
260258
ZeroMemory(offs, sizeof(offs));
261259
}
262260

@@ -290,9 +288,8 @@ void CInput::OnAppActivate(void)
290288

291289
SetAllAcquire(true);
292290
ZeroMemory(mouseState, sizeof(mouseState));
293-
ZeroMemory(KBState, sizeof(KBState));
294-
ZeroMemory(timeStamp, sizeof(timeStamp));
295-
ZeroMemory(timeSave, sizeof(timeStamp));
291+
ZeroMemory(keyboardState, sizeof(keyboardState));
292+
ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp));
296293
ZeroMemory(offs, sizeof(offs));
297294
}
298295

@@ -303,9 +300,8 @@ void CInput::OnAppDeactivate(void)
303300

304301
SetAllAcquire(false);
305302
ZeroMemory(mouseState, sizeof(mouseState));
306-
ZeroMemory(KBState, sizeof(KBState));
307-
ZeroMemory(timeStamp, sizeof(timeStamp));
308-
ZeroMemory(timeSave, sizeof(timeStamp));
303+
ZeroMemory(keyboardState, sizeof(keyboardState));
304+
ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp));
309305
ZeroMemory(offs, sizeof(offs));
310306
}
311307

src/xrEngine/xr_input.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ class ENGINE_API CInput
3939
private:
4040
BENCH_SEC_SCRAMBLEMEMBER1
4141

42-
u32 timeStamp[COUNT_MOUSE_AXIS];
43-
u32 timeSave[COUNT_MOUSE_AXIS];
42+
u32 mouseTimeStamp[COUNT_MOUSE_AXIS];
4443

4544
int offs[COUNT_MOUSE_AXIS];
4645

4746
bool mouseState[COUNT_MOUSE_BUTTONS];
48-
bool KBState[COUNT_KB_BUTTONS];
47+
bool keyboardState[COUNT_KB_BUTTONS];
4948

5049
xr_vector<IInputReceiver*> cbStack;
5150

0 commit comments

Comments
 (0)