Call into ViewTargeter from View::HitTestRect()
[chromium-blink-merge.git] / third_party / sudden_motion_sensor / sudden_motion_sensor_mac.h
blobba70b398e058ccbefd4b3bd7df67d8929d758c2e
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
3 // found in the LICENSE file.
4 //
5 // This file is based on the SMSLib library.
6 //
7 // SMSLib Sudden Motion Sensor Access Library
8 // Copyright (c) 2010 Suitable Systems
9 // All rights reserved.
11 // Developed by: Daniel Griscom
12 // Suitable Systems
13 // http://www.suitable.com
15 // Permission is hereby granted, free of charge, to any person obtaining a
16 // copy of this software and associated documentation files (the
17 // "Software"), to deal with the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // - Redistributions of source code must retain the above copyright notice,
24 // this list of conditions and the following disclaimers.
26 // - Redistributions in binary form must reproduce the above copyright
27 // notice, this list of conditions and the following disclaimers in the
28 // documentation and/or other materials provided with the distribution.
30 // - Neither the names of Suitable Systems nor the names of its
31 // contributors may be used to endorse or promote products derived from
32 // this Software without specific prior written permission.
34 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
35 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
37 // IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
38 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
39 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40 // SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
42 // For more information about SMSLib, see
43 // <http://www.suitable.com/tools/smslib.html>
44 // or contact
45 // Daniel Griscom
46 // Suitable Systems
47 // 1 Centre Street, Suite 204
48 // Wakefield, MA 01880
49 // (781) 665-0053
51 #ifndef SUDDEN_MOTION_SENSOR_H_
52 #define SUDDEN_MOTION_SENSOR_H_
53 #pragma once
55 #include <vector>
57 #include <IOKit/IOKitLib.h>
59 // Provides an easy-to-use interface to retrieve data
60 // from the MacBook family accelerometer.
61 class SuddenMotionSensor {
62 public:
63 static SuddenMotionSensor* Create();
64 bool ReadSensorValues(float axes[3]);
65 ~SuddenMotionSensor();
67 private:
68 SuddenMotionSensor();
69 bool Init();
71 // Extend the sign of an integer of size bytes to a 32-bit one.
72 static int ExtendSign(int value, size_t size);
74 struct GenericMacbookSensor;
75 struct SensorDescriptor;
76 struct AxisData;
78 // Generic sensor data and list of supported sensors.
79 static const GenericMacbookSensor kGenericSensor;
80 static const SensorDescriptor kSupportedSensors[];
82 // Local sensor if supported, else NULL.
83 const SensorDescriptor* sensor_;
85 // IOKit connection to the local sensor.
86 io_connect_t io_connection_;
88 // Input memory used for sensor I/O.
89 std::vector<char> input_record_;
91 // Output memory used for sensor I/O.
92 std::vector<char> output_record_;
95 #endif // SUDDEN_MOTION_SENSOR_H_