MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / KeyUpdate

Method KeyUpdate

ogsr_engine/xr_3da/Xr_input.cpp:130–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128BOOL b_altF4 = FALSE;
129
130void CInput::KeyUpdate()
131{
132 HRESULT hr;
133 DWORD dwElements = KEYBOARDBUFFERSIZE;
134 DIDEVICEOBJECTDATA od[KEYBOARDBUFFERSIZE];
135 DWORD key = 0;
136
137 VERIFY(pKeyboard);
138
139 hr = pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0);
140 if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
141 {
142 hr = pKeyboard->Acquire();
143 if (hr != S_OK)
144 return;
145 hr = pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0);
146 if (hr != S_OK)
147 return;
148 }
149 u32 i = 0;
150 for (i = 0; i < dwElements; i++)
151 {
152 key = od[i].dwOfs;
153 KBState[key] = od[i].dwData & 0x80;
154 if (KBState[key])
155 {
156 if (this->is_exclusive_mode && (key == DIK_LSHIFT || key == DIK_RSHIFT) && (this->iGetAsyncKeyState(DIK_LMENU) || this->iGetAsyncKeyState(DIK_RMENU)))
157 PostMessage(gGameWindow, WM_INPUTLANGCHANGEREQUEST, 2, 0); //Переключили язык. В эксклюзивном режиме это обязательно для правильной работы функции DikToChar
158
159 cbStack.back()->IR_OnKeyboardPress(key);
160 }
161 else
162 {
163 cbStack.back()->IR_OnKeyboardRelease(key);
164 }
165 }
166 for (i = 0; i < COUNT_KB_BUTTONS; i++)
167 if (KBState[i])
168 cbStack.back()->IR_OnKeyboardHold(i);
169
170 if (!b_altF4 && iGetAsyncKeyState(DIK_F4) && (iGetAsyncKeyState(DIK_RMENU) || iGetAsyncKeyState(DIK_LMENU)))
171 {
172 b_altF4 = TRUE;
173 Engine.Event.Defer("KERNEL:disconnect");
174 Engine.Event.Defer("KERNEL:quit");
175 }
176}
177
178bool CInput::get_dik_name(int dik, LPSTR dest_str, int dest_sz) const
179{

Callers

nothing calls this directly

Calls 6

iGetAsyncKeyStateMethod · 0.95
DeferMethod · 0.80
IR_OnKeyboardPressMethod · 0.45
backMethod · 0.45
IR_OnKeyboardReleaseMethod · 0.45
IR_OnKeyboardHoldMethod · 0.45

Tested by

no test coverage detected