blob: 640bf1f6932f9375ddfcfefaf2f40931076e009d [file] [log] [blame]
Siarhei Vishniakou7b7c8f62018-12-12 16:09:20 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _LIBINPUT_TOUCHVIDEOFRAME_H
18#define _LIBINPUT_TOUCHVIDEOFRAME_H
19
20#include <stdint.h>
21#include <sys/time.h>
22#include <vector>
23
24namespace android {
25
26/**
27 * Represents data from a single scan of the touchscreen device.
28 * Similar in concept to a video frame, but the touch strength is used as
29 * the values instead.
30 */
31class TouchVideoFrame {
32public:
33 TouchVideoFrame(uint32_t width, uint32_t height, std::vector<int16_t> data,
34 const struct timeval& timestamp) :
35 mWidth(width), mHeight(height), mData(std::move(data)), mTimestamp(timestamp) {
36 }
37
Siarhei Vishniakou473174e2017-12-27 16:44:42 -080038 bool operator==(const TouchVideoFrame& rhs) const {
39 return mWidth == rhs.mWidth
40 && mHeight == rhs.mHeight
41 && mData == rhs.mData
42 && mTimestamp.tv_sec == rhs.mTimestamp.tv_sec
43 && mTimestamp.tv_usec == rhs.mTimestamp.tv_usec;
44 }
45
Siarhei Vishniakou7b7c8f62018-12-12 16:09:20 -080046 /**
47 * Width of the frame
48 */
49 uint32_t getWidth() const { return mWidth; }
50 /**
51 * Height of the frame
52 */
53 uint32_t getHeight() const { return mHeight; }
54 /**
55 * The touch strength data.
56 * The array is a 2-D row-major matrix, with dimensions (height, width).
57 * Total size of the array should equal getHeight() * getWidth().
58 * Data is allowed to be negative.
59 */
60 const std::vector<int16_t>& getData() const { return mData; }
61 /**
62 * Time at which the heatmap was taken.
63 */
64 const struct timeval& getTimestamp() const { return mTimestamp; }
65
66private:
67 uint32_t mWidth;
68 uint32_t mHeight;
69 std::vector<int16_t> mData;
70 struct timeval mTimestamp;
71};
72
73} // namespace android
74
75#endif // _LIBINPUT_TOUCHVIDEOFRAME_H