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

Side by Side Diff: content/browser/gamepad/gamepad_provider.cc

Issue 135523006: Implemented Gamepad support via Raw Input on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Features, fixes, and cleanups Created 6 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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 <cmath> 5 #include <cmath>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 size_t data_size = sizeof(GamepadHardwareBuffer); 106 size_t data_size = sizeof(GamepadHardwareBuffer);
107 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 107 base::SystemMonitor* monitor = base::SystemMonitor::Get();
108 if (monitor) 108 if (monitor)
109 monitor->AddDevicesChangedObserver(this); 109 monitor->AddDevicesChangedObserver(this);
110 bool res = gamepad_shared_memory_.CreateAndMapAnonymous(data_size); 110 bool res = gamepad_shared_memory_.CreateAndMapAnonymous(data_size);
111 CHECK(res); 111 CHECK(res);
112 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); 112 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer();
113 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer)); 113 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer));
114 114
115 polling_thread_.reset(new base::Thread("Gamepad polling thread")); 115 polling_thread_.reset(new base::Thread("Gamepad polling thread"));
116 #if defined(OS_MACOSX) 116 #if defined(OS_LINUX)
117 // On Linux, the data fetcher needs to watch file descriptors, so the message
118 // loop needs to be a libevent loop.
119 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO;
120 #else
117 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the 121 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the
118 // message loop needs to be a UI-type loop. 122 // message loop needs to be a UI-type loop. On Windows it doesn't matter what the
scottmg 2014/01/31 20:51:10 Is there some reason this needed to change? If so,
123 // loop is.
119 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; 124 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI;
120 #else
121 // On Linux, the data fetcher needs to watch file descriptors, so the message
122 // loop needs to be a libevent loop. On Windows it doesn't matter what the
123 // loop is.
124 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO;
125 #endif 125 #endif
126 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); 126 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0));
127 127
128 polling_thread_->message_loop()->PostTask( 128 polling_thread_->message_loop()->PostTask(
129 FROM_HERE, 129 FROM_HERE,
130 base::Bind(&GamepadProvider::DoInitializePollingThread, 130 base::Bind(&GamepadProvider::DoInitializePollingThread,
131 base::Unretained(this), 131 base::Unretained(this),
132 base::Passed(&fetcher))); 132 base::Passed(&fetcher)));
133 } 133 }
134 134
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) { 211 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) {
212 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { 212 for (size_t i = 0; i < user_gesture_observers_.size(); i++) {
213 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, 213 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE,
214 user_gesture_observers_[i].closure); 214 user_gesture_observers_[i].closure);
215 } 215 }
216 user_gesture_observers_.clear(); 216 user_gesture_observers_.clear();
217 } 217 }
218 } 218 }
219 219
220 } // namespace content 220 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698