1/*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_HDI_MOTION_V1_0_MOTIONTYPES_H
17#define OHOS_HDI_MOTION_V1_0_MOTIONTYPES_H
18
19#include <cstdbool>
20#include <cstdint>
21#include <vector>
22
23#ifndef HDI_BUFF_MAX_SIZE
24#define HDI_BUFF_MAX_SIZE (1024 * 200)
25#endif
26
27#ifndef HDI_CHECK_VALUE_RETURN
28#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
29    if ((lv) compare (rv)) { \
30        return ret; \
31    } \
32} while (false)
33#endif
34
35#ifndef HDI_CHECK_VALUE_RET_GOTO
36#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
37    if ((lv) compare (rv)) { \
38        ret = value; \
39        goto table; \
40    } \
41} while (false)
42#endif
43
44namespace OHOS {
45class MessageParcel;
46}
47
48namespace OHOS {
49namespace HDI {
50namespace Motion {
51namespace V1_0 {
52
53using namespace OHOS;
54
55enum HdfMotionTypeTag : int32_t {
56    HDF_MOTION_TYPE_PICKUP = 0,
57    HDF_MOTION_TYPE_FLIP,
58    HDF_MOTION_CLOSE_TO_EAR,
59    HDF_MOTION_TYPE_SHAKE,
60    HDF_MOTION_TYPE_ROTATION,
61    HDF_MOTION_TYPE_POCKET_MODE,
62    HDF_MOTION_TYPE_LEAVE_EAR,
63    HDF_MOTION_TYPE_WRIST_UP,
64    HDF_MOTION_TYPE_WRIST_DOWN,
65    HDF_MOTION_TYPE_WAVE,
66    HDF_MOTION_TYPE_STEP_COUNTER,
67    HDF_MOTION_TYPE_MAX,
68};
69
70struct HdfMotionEvent {
71    int32_t motion;
72    int32_t result;
73    int32_t status;
74    int32_t datalen;
75    std::vector<int32_t> data;
76};
77
78bool HdfMotionEventBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Motion::V1_0::HdfMotionEvent& dataBlock);
79
80bool HdfMotionEventBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Motion::V1_0::HdfMotionEvent& dataBlock);
81
82} // V1_0
83} // Motion
84} // HDI
85} // OHOS
86
87#endif // OHOS_HDI_MOTION_V1_0_MOTIONTYPES_H
88
89