OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_win.h" | 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_win.h" |
6 | 6 |
7 #include <dinput.h> | 7 #include <dinput.h> |
8 #include <dinputd.h> | 8 #include <dinputd.h> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 } // namespace | 210 } // namespace |
211 | 211 |
212 GamepadPlatformDataFetcherWin::GamepadPlatformDataFetcherWin() | 212 GamepadPlatformDataFetcherWin::GamepadPlatformDataFetcherWin() |
213 : xinput_dll_(base::FilePath(FILE_PATH_LITERAL("xinput1_3.dll"))), | 213 : xinput_dll_(base::FilePath(FILE_PATH_LITERAL("xinput1_3.dll"))), |
214 xinput_available_(GetXInputDllFunctions()) { | 214 xinput_available_(GetXInputDllFunctions()) { |
215 // TODO(teravest): http://crbug.com/260187 for Windows XP. | 215 // TODO(teravest): http://crbug.com/260187 for Windows XP. |
216 // TODO(teravest): http://crbug.com/305267 for later versions of windows. | 216 // TODO(teravest): http://crbug.com/305267 for later versions of windows. |
217 directinput_available_ = false; | 217 directinput_available_ = false; |
218 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) | 218 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) |
219 pad_state_[i].status = DISCONNECTED; | 219 pad_state_[i].status = DISCONNECTED; |
220 | |
221 raw_input_fetcher_.reset(new RawInputDataFetcher()); | |
222 raw_input_fetcher_->StartMonitor(); | |
220 } | 223 } |
221 | 224 |
222 GamepadPlatformDataFetcherWin::~GamepadPlatformDataFetcherWin() { | 225 GamepadPlatformDataFetcherWin::~GamepadPlatformDataFetcherWin() { |
223 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 226 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
224 if (pad_state_[i].status == DIRECTINPUT_CONNECTED) | 227 if (pad_state_[i].status == DIRECTINPUT_CONNECTED) |
225 pad_state_[i].directinput_gamepad->Release(); | 228 pad_state_[i].directinput_gamepad->Release(); |
226 } | 229 } |
230 | |
231 raw_input_fetcher_->StopMonitor(); | |
227 } | 232 } |
228 | 233 |
229 int GamepadPlatformDataFetcherWin::FirstAvailableGamepadId() const { | 234 int GamepadPlatformDataFetcherWin::FirstAvailableGamepadId() const { |
230 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 235 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
231 if (pad_state_[i].status == DISCONNECTED) | 236 if (pad_state_[i].status == DISCONNECTED) |
232 return i; | 237 return i; |
233 } | 238 } |
234 return -1; | 239 return -1; |
235 } | 240 } |
236 | 241 |
237 bool GamepadPlatformDataFetcherWin::HasXInputGamepad(int index) const { | 242 bool GamepadPlatformDataFetcherWin::HasXInputGamepad(int index) const { |
238 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 243 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
239 if (pad_state_[i].status == XINPUT_CONNECTED && | 244 if (pad_state_[i].status == XINPUT_CONNECTED && |
240 pad_state_[i].xinput_index == index) | 245 pad_state_[i].xinput_index == index) |
241 return true; | 246 return true; |
242 } | 247 } |
243 return false; | 248 return false; |
244 } | 249 } |
245 | 250 |
246 bool GamepadPlatformDataFetcherWin::HasDirectInputGamepad( | 251 bool GamepadPlatformDataFetcherWin::HasDirectInputGamepad( |
247 const GUID& guid) const { | 252 const GUID& guid) const { |
248 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 253 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
249 if (pad_state_[i].status == DIRECTINPUT_CONNECTED && | 254 if (pad_state_[i].status == DIRECTINPUT_CONNECTED && |
250 pad_state_[i].guid == guid) | 255 pad_state_[i].guid == guid) |
251 return true; | 256 return true; |
252 } | 257 } |
253 return false; | 258 return false; |
254 } | 259 } |
255 | 260 |
261 bool GamepadPlatformDataFetcherWin::HasRawInputGamepad( | |
262 const HANDLE handle) const { | |
263 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | |
264 if (pad_state_[i].status == RAWINPUT_CONNECTED && | |
265 pad_state_[i].handle == handle) | |
266 return true; | |
267 } | |
268 return false; | |
269 } | |
270 | |
256 void GamepadPlatformDataFetcherWin::EnumerateDevices( | 271 void GamepadPlatformDataFetcherWin::EnumerateDevices( |
257 WebGamepads* pads) { | 272 WebGamepads* pads) { |
258 TRACE_EVENT0("GAMEPAD", "EnumerateDevices"); | 273 TRACE_EVENT0("GAMEPAD", "EnumerateDevices"); |
259 | 274 |
260 // Mark all disconnected pads DISCONNECTED. | 275 // Mark all disconnected pads DISCONNECTED. |
261 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 276 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
262 if (!pads->items[i].connected) | 277 if (!pads->items[i].connected) |
263 pad_state_[i].status = DISCONNECTED; | 278 pad_state_[i].status = DISCONNECTED; |
264 } | 279 } |
265 | 280 |
266 for (size_t i = 0; i < XUSER_MAX_COUNT; ++i) { | 281 for (size_t i = 0; i < XUSER_MAX_COUNT; ++i) { |
267 if (HasXInputGamepad(i)) | 282 if (HasXInputGamepad(i)) |
268 continue; | 283 continue; |
269 int pad_index = FirstAvailableGamepadId(); | 284 int pad_index = FirstAvailableGamepadId(); |
270 if (pad_index == -1) | 285 if (pad_index == -1) |
271 return; // We can't add any more gamepads. | 286 return; // We can't add any more gamepads. |
272 WebGamepad& pad = pads->items[pad_index]; | 287 WebGamepad& pad = pads->items[pad_index]; |
273 if (xinput_available_ && GetXInputPadConnectivity(i, &pad)) { | 288 if (xinput_available_ && GetXInputPadConnectivity(i, &pad)) { |
274 pad_state_[pad_index].status = XINPUT_CONNECTED; | 289 pad_state_[pad_index].status = XINPUT_CONNECTED; |
275 pad_state_[pad_index].xinput_index = i; | 290 pad_state_[pad_index].xinput_index = i; |
291 pad_state_[pad_index].mapper = NULL; | |
292 pads->length++; | |
276 } | 293 } |
277 } | 294 } |
278 | 295 |
279 if (directinput_available_) { | 296 if (directinput_available_) { |
280 struct EnumDevicesContext context; | 297 struct EnumDevicesContext context; |
281 std::vector<InternalDirectInputDevice> directinput_gamepads; | 298 std::vector<InternalDirectInputDevice> directinput_gamepads; |
282 context.directinput_interface = directinput_interface_; | 299 context.directinput_interface = directinput_interface_; |
283 context.directinput_devices = &directinput_gamepads; | 300 context.directinput_devices = &directinput_gamepads; |
284 | 301 |
285 directinput_interface_->EnumDevices( | 302 directinput_interface_->EnumDevices( |
(...skipping 10 matching lines...) Expand all Loading... | |
296 if (pad_index == -1) | 313 if (pad_index == -1) |
297 return; | 314 return; |
298 WebGamepad& pad = pads->items[pad_index]; | 315 WebGamepad& pad = pads->items[pad_index]; |
299 pad.connected = true; | 316 pad.connected = true; |
300 wcscpy_s(pad.id, WebGamepad::idLengthCap, directinput_gamepads[i].id); | 317 wcscpy_s(pad.id, WebGamepad::idLengthCap, directinput_gamepads[i].id); |
301 PadState& state = pad_state_[pad_index]; | 318 PadState& state = pad_state_[pad_index]; |
302 state.status = DIRECTINPUT_CONNECTED; | 319 state.status = DIRECTINPUT_CONNECTED; |
303 state.guid = directinput_gamepads[i].guid; | 320 state.guid = directinput_gamepads[i].guid; |
304 state.directinput_gamepad = directinput_gamepads[i].gamepad; | 321 state.directinput_gamepad = directinput_gamepads[i].gamepad; |
305 state.mapper = directinput_gamepads[i].mapper; | 322 state.mapper = directinput_gamepads[i].mapper; |
323 pads->length++; | |
324 } | |
325 } | |
326 | |
327 if (raw_input_fetcher_->Available()) { | |
328 std::vector<RawJoystickInfo*> raw_inputs = | |
329 raw_input_fetcher_->EnumerateDevices(); | |
330 for (size_t i = 0; i < raw_inputs.size(); ++i) { | |
331 RawJoystickInfo* joystick = raw_inputs[i]; | |
332 if (HasRawInputGamepad(joystick->handle)) | |
333 continue; | |
334 int pad_index = FirstAvailableGamepadId(); | |
335 if (pad_index == -1) | |
336 return; | |
337 WebGamepad& pad = pads->items[pad_index]; | |
338 pad.connected = true; | |
339 PadState& state = pad_state_[pad_index]; | |
340 state.status = RAWINPUT_CONNECTED; | |
341 state.handle = joystick->handle; | |
342 | |
343 std::string vendor = base::StringPrintf("%04x", joystick->vendor_id); | |
344 std::string product = base::StringPrintf("%04x", joystick->product_id); | |
345 state.mapper = GetGamepadStandardMappingFunction(vendor, product); | |
346 | |
347 swprintf(pad.id, WebGamepad::idLengthCap, | |
348 L"%ls (%lsVendor: %04x Product: %04x)", | |
349 joystick->id, state.mapper ? L"STANDARD GAMEPAD " : L"", | |
350 joystick->vendor_id, joystick->product_id); | |
351 pads->length++; | |
306 } | 352 } |
307 } | 353 } |
308 } | 354 } |
309 | 355 |
310 | 356 |
311 void GamepadPlatformDataFetcherWin::GetGamepadData(WebGamepads* pads, | 357 void GamepadPlatformDataFetcherWin::GetGamepadData(WebGamepads* pads, |
312 bool devices_changed_hint) { | 358 bool devices_changed_hint) { |
313 TRACE_EVENT0("GAMEPAD", "GetGamepadData"); | 359 TRACE_EVENT0("GAMEPAD", "GetGamepadData"); |
314 | 360 |
315 if (!xinput_available_ && !directinput_available_) { | 361 if (!xinput_available_ && |
362 !directinput_available_ && | |
363 !raw_input_fetcher_->Available()) { | |
316 pads->length = 0; | 364 pads->length = 0; |
317 return; | 365 return; |
318 } | 366 } |
319 | 367 |
320 // A note on XInput devices: | 368 // A note on XInput devices: |
321 // If we got notification that system devices have been updated, then | 369 // If we got notification that system devices have been updated, then |
322 // run GetCapabilities to update the connected status and the device | 370 // run GetCapabilities to update the connected status and the device |
323 // identifier. It can be slow to do to both GetCapabilities and | 371 // identifier. It can be slow to do to both GetCapabilities and |
324 // GetState on unconnected devices, so we want to avoid a 2-5ms pause | 372 // GetState on unconnected devices, so we want to avoid a 2-5ms pause |
325 // here by only doing this when the devices are updated (despite | 373 // here by only doing this when the devices are updated (despite |
326 // documentation claiming it's OK to call it any time). | 374 // documentation claiming it's OK to call it any time). |
327 if (devices_changed_hint) | 375 if (devices_changed_hint) |
328 EnumerateDevices(pads); | 376 EnumerateDevices(&data_); |
329 | 377 |
378 pads->length = data_.length; | |
330 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 379 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
331 WebGamepad& pad = pads->items[i]; | 380 // We rely on device_changed and GetCapabilities to tell us that |
381 // something's been connected, but we will mark as disconnected if | |
382 // Get___PadState returns that we've lost the pad. | |
383 if (!data_.items[i].connected) | |
384 continue; | |
385 | |
332 if (pad_state_[i].status == XINPUT_CONNECTED) | 386 if (pad_state_[i].status == XINPUT_CONNECTED) |
333 GetXInputPadData(i, &pad); | 387 GetXInputPadData(i, &data_.items[i]); |
334 else if (pad_state_[i].status == DIRECTINPUT_CONNECTED) | 388 else if (pad_state_[i].status == DIRECTINPUT_CONNECTED) |
335 GetDirectInputPadData(i, &pad); | 389 GetDirectInputPadData(i, &data_.items[i]); |
390 else if (pad_state_[i].status == RAWINPUT_CONNECTED) | |
391 GetRawInputPadData(i, &data_.items[i]); | |
392 | |
393 // Copy to the current state to the output buffer, using the mapping | |
394 // function, if there is one available. | |
395 if (pad_state_[i].mapper) | |
396 pad_state_[i].mapper(data_.items[i], &pads->items[i]); | |
397 else | |
398 pads->items[i] = data_.items[i]; | |
scottmg
2014/01/31 20:51:10
this seems kind of silly for xinput
| |
336 } | 399 } |
337 pads->length = WebGamepads::itemsLengthCap; | 400 } |
401 | |
402 void GamepadPlatformDataFetcherWin::PauseHint(bool pause) { | |
403 if (pause) | |
404 raw_input_fetcher_->StopMonitor(); | |
405 else | |
406 raw_input_fetcher_->StartMonitor(); | |
338 } | 407 } |
339 | 408 |
340 bool GamepadPlatformDataFetcherWin::GetXInputPadConnectivity( | 409 bool GamepadPlatformDataFetcherWin::GetXInputPadConnectivity( |
341 int i, | 410 int i, |
342 WebGamepad* pad) const { | 411 WebGamepad* pad) const { |
343 DCHECK(pad); | 412 DCHECK(pad); |
344 TRACE_EVENT1("GAMEPAD", "GetXInputPadConnectivity", "id", i); | 413 TRACE_EVENT1("GAMEPAD", "GetXInputPadConnectivity", "id", i); |
345 XINPUT_CAPABILITIES caps; | 414 XINPUT_CAPABILITIES caps; |
346 DWORD res = xinput_get_capabilities_(i, XINPUT_FLAG_GAMEPAD, &caps); | 415 DWORD res = xinput_get_capabilities_(i, XINPUT_FLAG_GAMEPAD, &caps); |
347 if (res == ERROR_DEVICE_NOT_CONNECTED) { | 416 if (res == ERROR_DEVICE_NOT_CONNECTED) { |
348 pad->connected = false; | 417 pad->connected = false; |
349 return false; | 418 return false; |
350 } else { | 419 } else { |
351 pad->connected = true; | 420 pad->connected = true; |
352 swprintf(pad->id, | 421 swprintf(pad->id, |
353 WebGamepad::idLengthCap, | 422 WebGamepad::idLengthCap, |
354 L"Xbox 360 Controller (XInput STANDARD %ls)", | 423 L"Xbox 360 Controller (XInput STANDARD %ls)", |
355 GamepadSubTypeName(caps.SubType)); | 424 GamepadSubTypeName(caps.SubType)); |
356 return true; | 425 return true; |
357 } | 426 } |
358 } | 427 } |
359 | 428 |
360 void GamepadPlatformDataFetcherWin::GetXInputPadData( | 429 void GamepadPlatformDataFetcherWin::GetXInputPadData( |
361 int i, | 430 int i, |
362 WebGamepad* pad) { | 431 WebGamepad* pad) { |
363 // We rely on device_changed and GetCapabilities to tell us that | |
364 // something's been connected, but we will mark as disconnected if | |
365 // GetState returns that we've lost the pad. | |
366 if (!pad->connected) | |
367 return; | |
368 | |
369 XINPUT_STATE state; | 432 XINPUT_STATE state; |
370 memset(&state, 0, sizeof(XINPUT_STATE)); | 433 memset(&state, 0, sizeof(XINPUT_STATE)); |
371 TRACE_EVENT_BEGIN1("GAMEPAD", "XInputGetState", "id", i); | 434 TRACE_EVENT_BEGIN1("GAMEPAD", "XInputGetState", "id", i); |
372 DWORD dwResult = xinput_get_state_(pad_state_[i].xinput_index, &state); | 435 DWORD dwResult = xinput_get_state_(pad_state_[i].xinput_index, &state); |
373 TRACE_EVENT_END1("GAMEPAD", "XInputGetState", "id", i); | 436 TRACE_EVENT_END1("GAMEPAD", "XInputGetState", "id", i); |
374 | 437 |
375 if (dwResult == ERROR_SUCCESS) { | 438 if (dwResult == ERROR_SUCCESS) { |
376 pad->timestamp = state.dwPacketNumber; | 439 pad->timestamp = state.dwPacketNumber; |
377 pad->buttonsLength = 0; | 440 pad->buttonsLength = 0; |
378 #define ADD(b) pad->buttons[pad->buttonsLength++] = \ | 441 #define ADD(b) pad->buttons[pad->buttonsLength++] = \ |
(...skipping 22 matching lines...) Expand all Loading... | |
401 pad->axes[pad->axesLength++] = NormalizeXInputAxis(state.Gamepad.sThumbRX); | 464 pad->axes[pad->axesLength++] = NormalizeXInputAxis(state.Gamepad.sThumbRX); |
402 pad->axes[pad->axesLength++] = -NormalizeXInputAxis(state.Gamepad.sThumbRY); | 465 pad->axes[pad->axesLength++] = -NormalizeXInputAxis(state.Gamepad.sThumbRY); |
403 } else { | 466 } else { |
404 pad->connected = false; | 467 pad->connected = false; |
405 } | 468 } |
406 } | 469 } |
407 | 470 |
408 void GamepadPlatformDataFetcherWin::GetDirectInputPadData( | 471 void GamepadPlatformDataFetcherWin::GetDirectInputPadData( |
409 int index, | 472 int index, |
410 WebGamepad* pad) { | 473 WebGamepad* pad) { |
411 if (!pad->connected) | |
412 return; | |
413 | |
414 IDirectInputDevice8* gamepad = pad_state_[index].directinput_gamepad; | 474 IDirectInputDevice8* gamepad = pad_state_[index].directinput_gamepad; |
415 if (FAILED(gamepad->Poll())) { | 475 if (FAILED(gamepad->Poll())) { |
416 // Polling didn't work, try acquiring the gamepad. | 476 // Polling didn't work, try acquiring the gamepad. |
417 if (FAILED(gamepad->Acquire())) { | 477 if (FAILED(gamepad->Acquire())) { |
418 pad->buttonsLength = 0; | 478 pad->buttonsLength = 0; |
419 pad->axesLength = 0; | 479 pad->axesLength = 0; |
420 return; | 480 return; |
421 } | 481 } |
422 // Try polling again. | 482 // Try polling again. |
423 if (FAILED(gamepad->Poll())) { | 483 if (FAILED(gamepad->Poll())) { |
424 pad->buttonsLength = 0; | 484 pad->buttonsLength = 0; |
425 pad->axesLength = 0; | 485 pad->axesLength = 0; |
426 return; | 486 return; |
427 } | 487 } |
428 } | 488 } |
429 JoyData state; | 489 JoyData state; |
430 if (FAILED(gamepad->GetDeviceState(sizeof(JoyData), &state))) { | 490 if (FAILED(gamepad->GetDeviceState(sizeof(JoyData), &state))) { |
431 pad->connected = false; | 491 pad->connected = false; |
432 return; | 492 return; |
433 } | 493 } |
434 | 494 |
435 WebGamepad raw; | 495 pad->connected = true; |
436 raw.connected = true; | |
437 for (int i = 0; i < 16; i++) | 496 for (int i = 0; i < 16; i++) |
438 raw.buttons[i] = (state.buttons[i] & 0x80) ? 1.0 : 0.0; | 497 pad->buttons[i] = (state.buttons[i] & 0x80) ? 1.0 : 0.0; |
439 | 498 |
440 // We map the POV (often a D-pad) into the buttons 16-19. | 499 // We map the POV (often a D-pad) into the buttons 16-19. |
441 // DirectInput gives pov measurements in hundredths of degrees, | 500 // DirectInput gives pov measurements in hundredths of degrees, |
442 // clockwise from "North". | 501 // clockwise from "North". |
443 // We use 22.5 degree slices so we can handle diagonal D-raw presses. | 502 // We use 22.5 degree slices so we can handle diagonal D-raw presses. |
444 static const int arc_segment = 2250; // 22.5 degrees = 1/16 circle | 503 static const int arc_segment = 2250; // 22.5 degrees = 1/16 circle |
445 if (state.pov > arc_segment && state.pov < 7 * arc_segment) | 504 if (state.pov > arc_segment && state.pov < 7 * arc_segment) |
446 raw.buttons[19] = 1.0; | 505 pad->buttons[19] = 1.0; |
447 else | 506 else |
448 raw.buttons[19] = 0.0; | 507 pad->buttons[19] = 0.0; |
449 | 508 |
450 if (state.pov > 5 * arc_segment && state.pov < 11 * arc_segment) | 509 if (state.pov > 5 * arc_segment && state.pov < 11 * arc_segment) |
451 raw.buttons[17] = 1.0; | 510 pad->buttons[17] = 1.0; |
452 else | 511 else |
453 raw.buttons[17] = 0.0; | 512 pad->buttons[17] = 0.0; |
454 | 513 |
455 if (state.pov > 9 * arc_segment && state.pov < 15 * arc_segment) | 514 if (state.pov > 9 * arc_segment && state.pov < 15 * arc_segment) |
456 raw.buttons[18] = 1.0; | 515 pad->buttons[18] = 1.0; |
457 else | 516 else |
458 raw.buttons[18] = 0.0; | 517 pad->buttons[18] = 0.0; |
459 | 518 |
460 if (state.pov < 3 * arc_segment || | 519 if (state.pov < 3 * arc_segment || |
461 (state.pov > 13 * arc_segment && state.pov < 36000)) | 520 (state.pov > 13 * arc_segment && state.pov < 36000)) |
462 raw.buttons[16] = 1.0; | 521 pad->buttons[16] = 1.0; |
463 else | 522 else |
464 raw.buttons[16] = 0.0; | 523 pad->buttons[16] = 0.0; |
465 | 524 |
466 for (int i = 0; i < 10; i++) | 525 for (int i = 0; i < 10; i++) |
467 raw.axes[i] = state.axes[i]; | 526 pad->axes[i] = state.axes[i]; |
468 pad_state_[index].mapper(raw, pad); | 527 } |
528 | |
529 void GamepadPlatformDataFetcherWin::GetRawInputPadData( | |
530 int index, | |
531 WebGamepad* pad) { | |
532 RawJoystickInfo* joystick = raw_input_fetcher_->GetJoystickInfo( | |
533 pad_state_[index].handle); | |
534 if (!joystick) { | |
535 pad->connected = false; | |
536 return; | |
537 } | |
538 | |
539 pad->timestamp = joystick->report_id; | |
540 pad->buttonsLength = joystick->buttons_length; | |
541 pad->axesLength = joystick->axes_length; | |
542 | |
543 for (unsigned int i = 0; i < pad->buttonsLength; i++) | |
544 pad->buttons[i] = joystick->buttons[i] ? 1.0 : 0.0; | |
545 | |
546 for (unsigned int i = 0; i < pad->axesLength; i++) | |
547 pad->axes[i] = joystick->axes[i].value; | |
469 } | 548 } |
470 | 549 |
471 bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() { | 550 bool GamepadPlatformDataFetcherWin::GetXInputDllFunctions() { |
472 xinput_get_capabilities_ = NULL; | 551 xinput_get_capabilities_ = NULL; |
473 xinput_get_state_ = NULL; | 552 xinput_get_state_ = NULL; |
474 xinput_enable_ = reinterpret_cast<XInputEnableFunc>( | 553 xinput_enable_ = reinterpret_cast<XInputEnableFunc>( |
475 xinput_dll_.GetFunctionPointer("XInputEnable")); | 554 xinput_dll_.GetFunctionPointer("XInputEnable")); |
476 if (!xinput_enable_) | 555 if (!xinput_enable_) |
477 return false; | 556 return false; |
478 xinput_get_capabilities_ = reinterpret_cast<XInputGetCapabilitiesFunc>( | 557 xinput_get_capabilities_ = reinterpret_cast<XInputGetCapabilitiesFunc>( |
479 xinput_dll_.GetFunctionPointer("XInputGetCapabilities")); | 558 xinput_dll_.GetFunctionPointer("XInputGetCapabilities")); |
480 if (!xinput_get_capabilities_) | 559 if (!xinput_get_capabilities_) |
481 return false; | 560 return false; |
482 xinput_get_state_ = reinterpret_cast<XInputGetStateFunc>( | 561 xinput_get_state_ = reinterpret_cast<XInputGetStateFunc>( |
483 xinput_dll_.GetFunctionPointer("XInputGetState")); | 562 xinput_dll_.GetFunctionPointer("XInputGetState")); |
484 if (!xinput_get_state_) | 563 if (!xinput_get_state_) |
485 return false; | 564 return false; |
486 xinput_enable_(true); | 565 xinput_enable_(true); |
487 return true; | 566 return true; |
488 } | 567 } |
489 | 568 |
490 } // namespace content | 569 } // namespace content |
OLD | NEW |