~robertcarr/qtubuntu/mirclient-with-input

« back to all changes in this revision

Viewing changes to src/platforms/ubuntu/input/input_stack_compatibility_layer.h

  • Committer: Robert Carr
  • Date: 2013-04-01 22:13:20 UTC
  • Revision ID: robert.carr@canonical.com-20130401221320-ac2bu8up9ttlrrqp
Skeleton mirclient build

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voss <thomas.voss@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef INPUT_STACK_COMPATIBILITY_LAYER_H_
 
20
#define INPUT_STACK_COMPATIBILITY_LAYER_H_
 
21
 
 
22
#ifdef __cplusplus
 
23
extern "C" {
 
24
#endif
 
25
 
 
26
#include <stdint.h>
 
27
 
 
28
    static const size_t MAX_POINTER_COUNT = 16;
 
29
 
 
30
    typedef int64_t nsecs_t;
 
31
 
 
32
    typedef enum
 
33
    {
 
34
        KEY_EVENT_TYPE,
 
35
        MOTION_EVENT_TYPE,
 
36
        HW_SWITCH_EVENT_TYPE
 
37
    } EventType;
 
38
 
 
39
    struct Event
 
40
    {
 
41
        // Generic event properties
 
42
        EventType type;
 
43
        int32_t device_id;
 
44
        int32_t source_id;
 
45
        int32_t action;
 
46
        int32_t flags;
 
47
        int32_t meta_state;
 
48
        // Information specific to key/motion event types
 
49
        union
 
50
        {
 
51
            struct HardwareSwitchEvent
 
52
            {
 
53
                nsecs_t event_time;
 
54
                uint32_t policy_flags;
 
55
                int32_t switch_values;
 
56
                int32_t switch_mask;
 
57
            } hw_switch;
 
58
            struct KeyEvent
 
59
            {
 
60
                int32_t key_code;
 
61
                int32_t scan_code;
 
62
                int32_t repeat_count;
 
63
                nsecs_t down_time;
 
64
                nsecs_t event_time;
 
65
                bool is_system_key;
 
66
            } key;
 
67
            struct MotionEvent
 
68
            {
 
69
                int32_t edge_flags;
 
70
                int32_t button_state;
 
71
                float x_offset;
 
72
                float y_offset;
 
73
                float x_precision;
 
74
                float y_precision;
 
75
                nsecs_t down_time;
 
76
                nsecs_t event_time;
 
77
 
 
78
                size_t pointer_count;
 
79
                struct PointerCoordinates
 
80
                {
 
81
                    int id;
 
82
                    float x, raw_x;
 
83
                    float y, raw_y;
 
84
                    float touch_major;
 
85
                    float touch_minor;
 
86
                    float size;
 
87
                    float pressure;
 
88
                    float orientation;
 
89
                };
 
90
                PointerCoordinates pointer_coordinates[MAX_POINTER_COUNT];
 
91
            } motion;
 
92
        } details;
 
93
    };
 
94
 
 
95
    struct AndroidEventListener
 
96
    {
 
97
        typedef void (*on_new_event_callback)(Event* event, void* context);
 
98
 
 
99
        on_new_event_callback on_new_event;
 
100
        void* context;
 
101
    };
 
102
 
 
103
    struct InputStackConfiguration
 
104
    {
 
105
        bool enable_touch_point_visualization;
 
106
        int default_layer_for_touch_point_visualization;
 
107
    };
 
108
 
 
109
    void android_input_stack_initialize(
 
110
        AndroidEventListener* listener,
 
111
        InputStackConfiguration* input_stack_configuration);
 
112
 
 
113
    void android_input_stack_loop_once();
 
114
    void android_input_stack_start();
 
115
    void android_input_stack_start_waiting_for_flag(bool* flag);
 
116
    void android_input_stack_stop();
 
117
    void android_input_stack_shutdown();
 
118
 
 
119
#ifdef __cplusplus
 
120
}
 
121
#endif
 
122
 
 
123
#endif // INPUT_STACK_COMPATIBILITY_LAYER_H_