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

Side by Side Diff: content/browser/gamepad/data_fetcher_mac.h

Issue 8799022: Add Mac implementation of data_fetcher for gamepad. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: some renaming per usb hid spec Created 9 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_MAC_H_
6 #define CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_MAC_H_
7
8 #include "build/build_config.h"
9
10 #include "base/compiler_specific.h"
11 #include "content/browser/gamepad/data_fetcher.h"
12 #include "content/common/gamepad_hardware_buffer.h"
13
14 #include <CoreFoundation/CoreFoundation.h>
15 #include <IOKit/hid/IOHIDManager.h>
16
17 namespace content {
18
19 class GamepadDataFetcherMac : public GamepadDataFetcher {
20 public:
21 GamepadDataFetcherMac();
22 virtual ~GamepadDataFetcherMac();
23 virtual void GetGamepadData(WebKit::WebGamepads* pads,
24 bool devices_changed_hint) OVERRIDE;
25 private:
26 bool enabled_;
27 IOHIDManagerRef hid_manager_ref_;
Avi (use Gerrit) 2011/12/06 04:54:19 scoped_cftyperef
scottmg 2011/12/07 01:20:50 Done.
28
29 static GamepadDataFetcherMac* InstanceFromContext(void* context);
30 static void DeviceAddCallback(void* context,
31 IOReturn result,
32 void* sender,
33 IOHIDDeviceRef ref);
34 static void DeviceRemoveCallback(void* context,
35 IOReturn result,
36 void* sender,
37 IOHIDDeviceRef ref);
38 static void ValueChangedCallback(void* context,
39 IOReturn result,
40 void* sender,
41 IOHIDValueRef ref);
42
43 void DeviceAdd(IOHIDDeviceRef device);
44 void AddButtonsAndAxes(CFArrayRef elements, unsigned slot);
45 void DeviceRemove(IOHIDDeviceRef device);
46 void ValueChanged(IOHIDValueRef value);
47
48 WebKit::WebGamepads data_;
49
50 // Side-band data that's not passed to the consumer, but we need to maintain
51 // to update data_.
52 struct AssociatedData {
53 IOHIDDeviceRef device_ref;
54 IOHIDElementRef button_elements[WebKit::WebGamepad::buttonsLengthCap];
55 IOHIDElementRef axis_elements[WebKit::WebGamepad::buttonsLengthCap];
56 CFIndex axis_minimums[WebKit::WebGamepad::axesLengthCap];
57 CFIndex axis_maximums[WebKit::WebGamepad::axesLengthCap];
58 };
59 AssociatedData associated_[WebKit::WebGamepads::itemsLengthCap];
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698