Index: content/browser/gamepad/gamepad_platform_data_fetcher_mac.h |
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h b/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h |
index 8bcc9c2f0232be376db3de0bc0519e6ed02331a5..e12d03c21c2caac05a505398b881319f77d721a5 100644 |
--- a/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h |
+++ b/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h |
@@ -8,10 +8,13 @@ |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
#include "base/mac/scoped_cftyperef.h" |
+#include "base/memory/scoped_ptr.h" |
#include "build/build_config.h" |
#include "content/browser/gamepad/gamepad_data_fetcher.h" |
#include "content/browser/gamepad/gamepad_standard_mappings.h" |
+#include "content/browser/gamepad/xbox_data_fetcher_mac.h" |
#include "content/common/gamepad_hardware_buffer.h" |
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h" |
#include <CoreFoundation/CoreFoundation.h> |
#include <IOKit/hid/IOHIDManager.h> |
@@ -24,7 +27,8 @@ class NSArray; |
namespace content { |
-class GamepadPlatformDataFetcherMac : public GamepadDataFetcher { |
+class GamepadPlatformDataFetcherMac : public GamepadDataFetcher, |
+ public XboxDataFetcher::Delegate { |
public: |
GamepadPlatformDataFetcherMac(); |
virtual ~GamepadPlatformDataFetcherMac(); |
@@ -50,27 +54,47 @@ class GamepadPlatformDataFetcherMac : public GamepadDataFetcher { |
void* sender, |
IOHIDValueRef ref); |
+ size_t GetEmptySlot(); |
+ size_t GetSlotForDevice(IOHIDDeviceRef device); |
+ size_t GetSlotForXboxDevice(XboxController* device); |
+ |
void DeviceAdd(IOHIDDeviceRef device); |
void AddButtonsAndAxes(NSArray* elements, size_t slot); |
void DeviceRemove(IOHIDDeviceRef device); |
void ValueChanged(IOHIDValueRef value); |
+ virtual void XboxDeviceAdd(XboxController* device) OVERRIDE; |
+ virtual void XboxDeviceRemove(XboxController* device) OVERRIDE; |
+ virtual void XboxValueChanged(XboxController* device, |
+ const XboxController::Data& data) OVERRIDE; |
+ |
void RegisterForNotifications(); |
void UnregisterFromNotifications(); |
+ scoped_ptr<XboxDataFetcher> xbox_fetcher_; |
+ |
WebKit::WebGamepads data_; |
// Side-band data that's not passed to the consumer, but we need to maintain |
// to update data_. |
struct AssociatedData { |
- IOHIDDeviceRef device_ref; |
- IOHIDElementRef button_elements[WebKit::WebGamepad::buttonsLengthCap]; |
- IOHIDElementRef axis_elements[WebKit::WebGamepad::buttonsLengthCap]; |
- CFIndex axis_minimums[WebKit::WebGamepad::axesLengthCap]; |
- CFIndex axis_maximums[WebKit::WebGamepad::axesLengthCap]; |
- // Function to map from device data to standard layout, if available. May |
- // be null if no mapping is available. |
- GamepadStandardMappingFunction mapper; |
+ bool is_xbox; |
+ union { |
+ struct { |
+ IOHIDDeviceRef device_ref; |
+ IOHIDElementRef button_elements[WebKit::WebGamepad::buttonsLengthCap]; |
+ IOHIDElementRef axis_elements[WebKit::WebGamepad::buttonsLengthCap]; |
+ CFIndex axis_minimums[WebKit::WebGamepad::axesLengthCap]; |
+ CFIndex axis_maximums[WebKit::WebGamepad::axesLengthCap]; |
+ // Function to map from device data to standard layout, if available. |
+ // May be null if no mapping is available. |
+ GamepadStandardMappingFunction mapper; |
+ } hid; |
+ struct { |
+ XboxController* device; |
+ UInt32 location_id; |
+ } xbox; |
+ }; |
}; |
AssociatedData associated_[WebKit::WebGamepads::itemsLengthCap]; |