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

Unified Diff: device/gamepad/xbox_data_fetcher_mac.h

Issue 2129003002: Refactored gamepad polling to support dynamic sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test issue and Mac XBoxDataFetcher constructor Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: device/gamepad/xbox_data_fetcher_mac.h
diff --git a/device/gamepad/xbox_data_fetcher_mac.h b/device/gamepad/xbox_data_fetcher_mac.h
index 13303d10632a86fb3187349cb3bafc71b09339f7..1e7f9f647955b7840aa26a511feb0290e663e8d7 100644
--- a/device/gamepad/xbox_data_fetcher_mac.h
+++ b/device/gamepad/xbox_data_fetcher_mac.h
@@ -17,6 +17,12 @@
#include "base/mac/scoped_ioobject.h"
#include "base/mac/scoped_ioplugininterface.h"
#include "base/macros.h"
+#include "device/gamepad/gamepad_data_fetcher.h"
+
+struct IOUSBDeviceStruct320;
+struct IOUSBInterfaceStruct300;
+
+namespace device {
class XboxController {
public:
@@ -101,11 +107,11 @@ class XboxController {
// Handle for the USB device. IOUSBDeviceStruct320 is the latest version of
// the device API that is supported on Mac OS 10.6.
- base::mac::ScopedIOPluginInterface<struct IOUSBDeviceStruct320> device_;
+ base::mac::ScopedIOPluginInterface<IOUSBDeviceStruct320> device_;
// Handle for the interface on the device which sends button and analog data.
// The other interfaces (for the ChatPad and headset) are ignored.
- base::mac::ScopedIOPluginInterface<struct IOUSBInterfaceStruct300> interface_;
+ base::mac::ScopedIOPluginInterface<IOUSBInterfaceStruct300> interface_;
bool device_is_open_;
bool interface_is_open_;
@@ -136,18 +142,19 @@ class XboxController {
DISALLOW_COPY_AND_ASSIGN(XboxController);
};
-class XboxDataFetcher : public XboxController::Delegate {
+class XboxDataFetcher : public GamepadDataFetcher,
+ public XboxController::Delegate {
public:
- class Delegate {
- public:
- virtual void XboxDeviceAdd(XboxController* device) = 0;
- virtual void XboxDeviceRemove(XboxController* device) = 0;
- virtual void XboxValueChanged(XboxController* device,
- const XboxController::Data& data) = 0;
- };
+ typedef GamepadDataFetcherFactoryImpl<XboxDataFetcher,
+ GAMEPAD_SOURCE_MAC_XBOX>
+ Factory;
- explicit XboxDataFetcher(Delegate* delegate);
- virtual ~XboxDataFetcher();
+ XboxDataFetcher();
+ ~XboxDataFetcher() override;
+
+ GamepadSource source() override;
+
+ void GetGamepadData(bool devices_changed_hint) override;
bool RegisterForNotifications();
bool RegisterForDeviceNotifications(
@@ -162,6 +169,7 @@ class XboxDataFetcher : public XboxController::Delegate {
private:
static void DeviceAdded(void* context, io_iterator_t iterator);
static void DeviceRemoved(void* context, io_iterator_t iterator);
+ void OnAddedToProvider() override;
void AddController(XboxController* controller);
void RemoveController(XboxController* controller);
void RemoveControllerByLocationID(uint32_t id);
@@ -169,8 +177,6 @@ class XboxDataFetcher : public XboxController::Delegate {
const XboxController::Data& data) override;
void XboxControllerError(XboxController* controller) override;
- Delegate* delegate_;
-
std::set<XboxController*> controllers_;
bool listening_;
@@ -187,4 +193,6 @@ class XboxDataFetcher : public XboxController::Delegate {
DISALLOW_COPY_AND_ASSIGN(XboxDataFetcher);
};
+} // namespace device
+
#endif // DEVICE_GAMEPAD_XBOX_DATA_FETCHER_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698