VSF Documented
vsf_input_touchscreen.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
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
18
19
20#ifndef __VSF_INPUT_TOUCHSCREEN_H__
21#define __VSF_INPUT_TOUCHSCREEN_H__
22
23/*============================ INCLUDES ======================================*/
24#include "../vsf_input_cfg.h"
25
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*============================ MACROS ========================================*/
33/*============================ MACROFIED FUNCTIONS ===========================*/
34
35// cur.valu64: x[0:15], y[16:31], pressure[32:47], xy_valid[48].
36// prototype: vsf_input_touchscreen_set(vk_touchscreen_evt_t *evt, uint8_t id,
37// bool is_down, uint16_t pressure, uint16_t x, uint16_t y,
38// bool xy_valid = true);
39// pressure must be 0 for UP events(is_down == false).
40#define __vsf_input_touchscreen_set6(__evt, __id, __is_down, __pressure, __x, __y) \
41 __vsf_input_touchscreen_set7( \
42 __evt, __id, __is_down, __pressure, __x, __y, true)
43#define __vsf_input_touchscreen_set7(__evt, __id, __is_down, __pressure, __x, __y, __xy_valid) \
44 do { \
45 (__evt)->id = ((__id) | (!!(__is_down) << 8)); \
46 (__evt)->cur.valu64 = (__x) | ((__y) << 16) \
47 | ((uint64_t)(__pressure) << 32) \
48 | ((uint64_t)(!!(__xy_valid)) << 48); \
49 } while (0)
50#define vsf_input_touchscreen_set(__evt, __id, __is_down, __pressure, __x, __y, ...) \
51 __PLOOC_EVAL(__vsf_input_touchscreen_set, \
52 (__evt), (__id), (__is_down), (__pressure), (__x), (__y), ##__VA_ARGS__) \
53 ((__evt), (__id), (__is_down), (__pressure), (__x), (__y), ##__VA_ARGS__)
54
55#define vsf_input_touchscreen_get_id(__evt) \
56 ((uint8_t)(((__evt)->id >> 0) & 0xFF))
57#define vsf_input_touchscreen_is_down(__evt) \
58 (!!(((__evt)->id >> 8) & 0xFF))
59#define vsf_input_touchscreen_get_x(__evt) \
60 ((uint16_t)(((__evt)->cur.valu64 >> 0) & 0xFFFF))
61#define vsf_input_touchscreen_get_y(__evt) \
62 ((uint16_t)(((__evt)->cur.valu64 >> 16) & 0xFFFF))
63#define vsf_input_touchscreen_get_pressure(__evt) \
64 ((uint16_t)(((__evt)->cur.valu64 >> 32) & 0xFFFF))
65#define vsf_input_touchscreen_is_xy_valid(__evt) \
66 (!!(((__evt)->cur.valu64 >> 48) & 1))
67
68/*============================ TYPES =========================================*/
69
70enum {
72};
73
78
83
84/*============================ GLOBAL VARIABLES ==============================*/
85/*============================ LOCAL VARIABLES ===============================*/
86/*============================ PROTOTYPES ====================================*/
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
93/* EOF */
unsigned short uint16_t
Definition stdint.h:7
Definition vsf_input.h:94
Definition vsf_input_touchscreen.h:79
vk_input_evt_t vk_touchscreen_info_t info
Definition vsf_input_touchscreen.h:81
Definition vsf_input_touchscreen.h:74
uint16_t width
Definition vsf_input_touchscreen.h:75
uint16_t height
Definition vsf_input_touchscreen.h:76
#define VSF_INPUT_USER_TYPE
Definition vsf_input_get_type_1bit.h:103
struct vk_touchscreen_info_t vk_touchscreen_info_t
@ VSF_INPUT_TYPE_TOUCHSCREEN
Definition vsf_input_touchscreen.h:71
Generated from commit: vsfteam/vsf@2a137b0