Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp

Issue 2572323002: Delete WebGamepads::length. (Closed)
Patch Set: Bring back active_state clearing in exo Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { 267 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) {
268 m_pendingEvents.append(newGamepad); 268 m_pendingEvents.append(newGamepad);
269 } 269 }
270 } 270 }
271 271
272 if (!m_pendingEvents.isEmpty()) 272 if (!m_pendingEvents.isEmpty())
273 m_dispatchOneEventRunner->runAsync(); 273 m_dispatchOneEventRunner->runAsync();
274 } 274 }
275 275
276 } // namespace blink 276 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698