Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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. | |
| 10 // | |
| 11 // Developed by: Daniel Griscom | |
| 12 // Suitable Systems | |
| 13 // http://www.suitable.com | |
| 14 // | |
| 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: | |
| 22 // | |
| 23 // - Redistributions of source code must retain the above copyright notice, | |
| 24 // this list of conditions and the following disclaimers. | |
| 25 // | |
| 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. | |
|
Steve Block
2012/03/19 14:33:36
We should probably move this third-party code to t
| |
| 29 // | |
| 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. | |
| 33 // | |
| 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. | |
| 41 // | |
| 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 | |
| 50 | |
| 51 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_ACCELEROMETER_MAC_H_ | |
| 52 #define CHROME_BROWSER_DEVICE_ORIENTATION_ACCELEROMETER_MAC_H_ | |
| 53 #pragma once | |
| 54 | |
| 55 #include <vector> | |
| 56 | |
| 57 #include <IOKit/IOKitLib.h> | |
| 58 | |
| 59 #include "chrome/browser/device_orientation/data_fetcher.h" | |
| 60 | |
| 61 namespace device_orientation { | |
| 62 | |
| 63 // Provides an easy-to-use interface to retrieve data | |
| 64 // from the MacBook family accelerometer. | |
| 65 class AccelerometerMac : public DataFetcher { | |
| 66 public: | |
| 67 static DataFetcher* Create(); | |
| 68 | |
| 69 // Implement DataFetcher. | |
| 70 virtual bool GetOrientation(Orientation* orientation); | |
| 71 | |
| 72 virtual ~AccelerometerMac(); | |
| 73 | |
| 74 private: | |
| 75 AccelerometerMac(); | |
| 76 bool Init(); | |
| 77 | |
| 78 // Extend the sign of an integer of size bytes to a 32-bit one. | |
| 79 static int ExtendSign(int value, size_t size); | |
| 80 | |
| 81 struct SensorDescriptor; | |
| 82 struct AxisData; | |
| 83 | |
| 84 // List of supported sensors. | |
| 85 static const SensorDescriptor kSupportedSensors[]; | |
| 86 | |
| 87 // Local sensor if supported, else NULL. | |
| 88 const SensorDescriptor* sensor_; | |
| 89 | |
| 90 // IOKit connection to the local sensor. | |
| 91 io_connect_t io_connection_; | |
| 92 | |
| 93 // Input memory used for sensor I/O. | |
| 94 std::vector<char> input_record_; | |
| 95 | |
| 96 // Output memory used for sensor I/O. | |
| 97 std::vector<char> output_record_; | |
| 98 }; | |
| 99 | |
| 100 } // namespace device_orientation | |
| 101 | |
| 102 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_ACCELEROMETER_MAC_H_ | |
| OLD | NEW |