blob: 17f158c9e17c0ecf3d3ec4264232feab2ad55622 [file] [log] [blame]
Prabir Pradhan186d5b52019-08-30 15:27:05 -07001/*
2 * Copyright (C) 2019 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 _UI_INPUTREADER_STYLUS_STATE_H
18#define _UI_INPUTREADER_STYLUS_STATE_H
19
20#include <input/Input.h>
21
22#include <limits.h>
23
24namespace android {
25
26struct StylusState {
27 /* Time the stylus event was received. */
28 nsecs_t when;
29 /* Pressure as reported by the stylus, normalized to the range [0, 1.0]. */
30 float pressure;
31 /* The state of the stylus buttons as a bitfield (e.g. AMOTION_EVENT_BUTTON_SECONDARY). */
32 uint32_t buttons;
33 /* Which tool type the stylus is currently using (e.g. AMOTION_EVENT_TOOL_TYPE_ERASER). */
34 int32_t toolType;
35
36 void copyFrom(const StylusState& other) {
37 when = other.when;
38 pressure = other.pressure;
39 buttons = other.buttons;
40 toolType = other.toolType;
41 }
42
43 void clear() {
44 when = LLONG_MAX;
45 pressure = 0.f;
46 buttons = 0;
47 toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
48 }
49};
50
51} // namespace android
52
53#endif // _UI_INPUTREADER_STYLUS_STATE_H