VSF Documented
vsf_input_mouse.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#ifndef __VSF_INPUT_MOUSE_H__
19#define __VSF_INPUT_MOUSE_H__
20
21/*============================ INCLUDES ======================================*/
22#include "../vsf_input_cfg.h"
23
24#include "../vsf_input_get_type.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31/*============================ MACROFIED FUNCTIONS ===========================*/
32
33#define vsf_input_mouse_evt_move_set(__evt,__x, __y) \
34 do { \
35 (__evt)->id = VSF_INPUT_MOUSE_EVT_MOVE; \
36 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
37 } while (0)
38
39#define vsf_input_mouse_evt_wheel_set(__evt, __x, __y) \
40 do { \
41 (__evt)->id = VSF_INPUT_MOUSE_EVT_WHEEL; \
42 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
43 } while (0)
44
45#define vsf_input_mouse_evt_button_set(__evt, __button, __is_down, __x, __y) \
46 do { \
47 (__evt)->id = VSF_INPUT_MOUSE_EVT_BUTTON | ((__button) << 8) | ((__is_down) << 12);\
48 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
49 } while (0)
50
51// result is VSF_INPUT_MOUSE_EVT_(MOVE/BUTTON/WHEEL)
52#define vsf_input_mouse_evt_get(__evt) \
53 ((__evt)->id & 0xFF)
54
55// for button events
56#define vsf_input_mouse_evt_button_get(__evt) \
57 (int)(((__evt)->id >> 8) & 0x03)
58#define vsf_input_mouse_evt_button_is_down(__evt) \
59 (!!(((__evt)->id >> 12) & 1))
60
61// for move/button/wheel events
62#define vsf_input_mouse_evt_get_x(__evt) \
63 ((int16_t)(((__evt)->cur.valu32 >> 0) & 0xFFFF))
64#define vsf_input_mouse_evt_get_y(__evt) \
65 ((int16_t)(((__evt)->cur.valu32 >> 16) & 0xFFFF))
66
67/*============================ TYPES =========================================*/
68
69enum {
71};
72
73enum {
77};
78
79enum {
83};
84
85typedef struct vk_mouse_evt_t {
86 implement(vk_input_evt_t)
88
89/*============================ GLOBAL VARIABLES ==============================*/
90/*============================ LOCAL VARIABLES ===============================*/
91/*============================ PROTOTYPES ====================================*/
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif
98/* EOF */
Definition vsf_input.h:94
Definition vsf_input_mouse.h:85
#define VSF_INPUT_USER_TYPE
Definition vsf_input_get_type_1bit.h:103
@ VSF_INPUT_MOUSE_EVT_BUTTON
Definition vsf_input_mouse.h:75
@ VSF_INPUT_MOUSE_EVT_MOVE
Definition vsf_input_mouse.h:74
@ VSF_INPUT_MOUSE_EVT_WHEEL
Definition vsf_input_mouse.h:76
@ VSF_INPUT_MOUSE_BUTTON_RIGHT
Definition vsf_input_mouse.h:82
@ VSF_INPUT_MOUSE_BUTTON_MIDDLE
Definition vsf_input_mouse.h:81
@ VSF_INPUT_MOUSE_BUTTON_LEFT
Definition vsf_input_mouse.h:80
@ VSF_INPUT_TYPE_MOUSE
Definition vsf_input_mouse.h:70