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
32#define VSF_INPUT_MOUSE_RELATIVE 1
33#define VSF_INPUT_MOUSE_ABSOLUTE 0
34
35/*============================ MACROFIED FUNCTIONS ===========================*/
36
37#define vsf_input_mouse_evt_move_set(__evt,__x, __y, __abs0_rel1) \
38 do { \
39 (__evt)->id = VSF_INPUT_MOUSE_EVT_MOVE | ((__abs0_rel1) << 16); \
40 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
41 } while (0)
42
43// wheel is relative value
44#define vsf_input_mouse_evt_wheel_set(__evt, __x, __y) \
45 do { \
46 (__evt)->id = VSF_INPUT_MOUSE_EVT_WHEEL | (1 << 16); \
47 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
48 } while (0)
49
50#define vsf_input_mouse_evt_button_set(__evt, __button, __is_down, __x, __y, __abs0_rel1)\
51 do { \
52 (__evt)->id = VSF_INPUT_MOUSE_EVT_BUTTON \
53 | ((__button) << 8) | ((__is_down) << 12) \
54 | ((__abs0_rel1) << 16); \
55 (__evt)->cur.valu32 = ((__x) | ((__y) << 16)); \
56 } while (0)
57
58// result is VSF_INPUT_MOUSE_EVT_(MOVE/BUTTON/WHEEL)
59#define vsf_input_mouse_evt_get(__evt) \
60 ((__evt)->id & 0xFF)
61#define vsf_input_mouse_is_relative(__evt) \
62 (!!(((__evt)->id >> 16) & 1))
63#define vsf_input_mouse_is_absolute(__evt) \
64 (!vsf_input_mouse_is_relative(__evt))
65
66// for button events
67#define vsf_input_mouse_evt_button_get(__evt) \
68 (int)(((__evt)->id >> 8) & 0x03)
69#define vsf_input_mouse_evt_button_is_down(__evt) \
70 (!!(((__evt)->id >> 12) & 1))
71
72// for move/button/wheel events
73#define vsf_input_mouse_evt_get_x(__evt) \
74 ((int16_t)(((__evt)->cur.valu32 >> 0) & 0xFFFF))
75#define vsf_input_mouse_evt_get_y(__evt) \
76 ((int16_t)(((__evt)->cur.valu32 >> 16) & 0xFFFF))
77
78/*============================ TYPES =========================================*/
79
80enum {
82};
83
84enum {
88};
89
90enum {
94};
95
96typedef struct vk_mouse_evt_t {
97 implement(vk_input_evt_t)
99
100/*============================ GLOBAL VARIABLES ==============================*/
101/*============================ LOCAL VARIABLES ===============================*/
102/*============================ PROTOTYPES ====================================*/
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif
109/* EOF */
Definition vsf_input.h:94
Definition vsf_input_mouse.h:96
#define VSF_INPUT_USER_TYPE
Definition vsf_input_get_type_1bit.h:103
@ VSF_INPUT_MOUSE_EVT_BUTTON
Definition vsf_input_mouse.h:86
@ VSF_INPUT_MOUSE_EVT_MOVE
Definition vsf_input_mouse.h:85
@ VSF_INPUT_MOUSE_EVT_WHEEL
Definition vsf_input_mouse.h:87
@ VSF_INPUT_MOUSE_BUTTON_RIGHT
Definition vsf_input_mouse.h:93
@ VSF_INPUT_MOUSE_BUTTON_MIDDLE
Definition vsf_input_mouse.h:92
@ VSF_INPUT_MOUSE_BUTTON_LEFT
Definition vsf_input_mouse.h:91
@ VSF_INPUT_TYPE_MOUSE
Definition vsf_input_mouse.h:81
Generated from commit: vsfteam/vsf@b2e9e8a