| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
| 6 * | 6 * |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 template <typename GamepadType, typename ListType> | 54 template <typename GamepadType, typename ListType> |
| 55 static void sampleGamepads(ListType* into) { | 55 static void sampleGamepads(ListType* into) { |
| 56 WebGamepads gamepads; | 56 WebGamepads gamepads; |
| 57 | 57 |
| 58 GamepadDispatcher::instance().sampleGamepads(gamepads); | 58 GamepadDispatcher::instance().sampleGamepads(gamepads); |
| 59 | 59 |
| 60 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 60 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
| 61 WebGamepad& webGamepad = gamepads.items[i]; | 61 WebGamepad& webGamepad = gamepads.items[i]; |
| 62 if (i < gamepads.length && webGamepad.connected) { | 62 if (webGamepad.connected) { |
| 63 GamepadType* gamepad = into->item(i); | 63 GamepadType* gamepad = into->item(i); |
| 64 if (!gamepad) | 64 if (!gamepad) |
| 65 gamepad = GamepadType::create(); | 65 gamepad = GamepadType::create(); |
| 66 sampleGamepad(i, *gamepad, webGamepad); | 66 sampleGamepad(i, *gamepad, webGamepad); |
| 67 into->set(i, gamepad); | 67 into->set(i, gamepad); |
| 68 } else { | 68 } else { |
| 69 into->set(i, 0); | 69 into->set(i, 0); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 } | 72 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { | 266 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { |
| 267 m_pendingEvents.append(newGamepad); | 267 m_pendingEvents.append(newGamepad); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 if (!m_pendingEvents.isEmpty()) | 271 if (!m_pendingEvents.isEmpty()) |
| 272 m_dispatchOneEventRunner->runAsync(); | 272 m_dispatchOneEventRunner->runAsync(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |