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

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

Issue 8899017: Add gamepad data fetcher for Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again, bots all updated Created 8 years, 11 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | content/browser/gamepad/data_fetcher_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/mac/scoped_cftyperef.h"
12 #include "content/browser/gamepad/data_fetcher.h"
13 #include "content/common/gamepad_hardware_buffer.h"
14
15 #include <CoreFoundation/CoreFoundation.h>
16 #include <IOKit/hid/IOHIDManager.h>
17
18 #if defined(__OBJC__)
19 @class NSArray;
20 #else
21 class NSArray;
22 #endif
23
24 namespace content {
25
26 class GamepadDataFetcherMac : public GamepadDataFetcher {
27 public:
28 GamepadDataFetcherMac();
29 virtual ~GamepadDataFetcherMac();
30 virtual void GetGamepadData(WebKit::WebGamepads* pads,
31 bool devices_changed_hint) OVERRIDE;
32 virtual void PauseHint(bool paused) OVERRIDE;
33 private:
34 bool enabled_;
35 base::mac::ScopedCFTypeRef<IOHIDManagerRef> hid_manager_ref_;
36
37 static GamepadDataFetcherMac* InstanceFromContext(void* context);
38 static void DeviceAddCallback(void* context,
39 IOReturn result,
40 void* sender,
41 IOHIDDeviceRef ref);
42 static void DeviceRemoveCallback(void* context,
43 IOReturn result,
44 void* sender,
45 IOHIDDeviceRef ref);
46 static void ValueChangedCallback(void* context,
47 IOReturn result,
48 void* sender,
49 IOHIDValueRef ref);
50
51 void DeviceAdd(IOHIDDeviceRef device);
52 void AddButtonsAndAxes(NSArray* elements, size_t slot);
53 void DeviceRemove(IOHIDDeviceRef device);
54 void ValueChanged(IOHIDValueRef value);
55
56 void RegisterForNotifications();
57 void UnregisterFromNotifications();
58
59 WebKit::WebGamepads data_;
60
61 // Side-band data that's not passed to the consumer, but we need to maintain
62 // to update data_.
63 struct AssociatedData {
64 IOHIDDeviceRef device_ref;
65 IOHIDElementRef button_elements[WebKit::WebGamepad::buttonsLengthCap];
66 IOHIDElementRef axis_elements[WebKit::WebGamepad::buttonsLengthCap];
67 CFIndex axis_minimums[WebKit::WebGamepad::axesLengthCap];
68 CFIndex axis_maximums[WebKit::WebGamepad::axesLengthCap];
69 };
70 AssociatedData associated_[WebKit::WebGamepads::itemsLengthCap];
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | content/browser/gamepad/data_fetcher_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698