summaryrefslogtreecommitdiff
path: root/src/backends/native/meta-input-device-native.h
blob: e76aade71b00b36501f82639dc22cba06a60cfcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Clutter.
 *
 * An OpenGL based 'interactive canvas' library.
 *
 * Copyright (C) 2010 Intel Corp.
 * Copyright (C) 2014 Jonas Ådahl
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Damien Lespiau <damien.lespiau@intel.com>
 * Author: Jonas Ådahl <jadahl@gmail.com>
 */

#ifndef META_INPUT_DEVICE_NATIVE_H
#define META_INPUT_DEVICE_NATIVE_H

#include <glib-object.h>

#include "backends/meta-input-device-private.h"
#include "backends/meta-input-settings-private.h"
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter-mutter.h"

#define META_TYPE_INPUT_DEVICE_NATIVE meta_input_device_native_get_type()

#define META_INPUT_DEVICE_NATIVE(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
  META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNative))

#define META_INPUT_DEVICE_NATIVE_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), \
  META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNativeClass))

#define META_IS_INPUT_DEVICE_NATIVE(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
  META_TYPE_INPUT_DEVICE_NATIVE))

#define META_IS_INPUT_DEVICE_NATIVE_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
  META_TYPE_INPUT_DEVICE_NATIVE))

#define META_INPUT_DEVICE_NATIVE_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
  META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNativeClass))

typedef enum
{
  META_INPUT_DEVICE_MAPPING_ABSOLUTE,
  META_INPUT_DEVICE_MAPPING_RELATIVE,
} MetaInputDeviceMapping;

typedef struct _MetaInputDeviceNative MetaInputDeviceNative;
typedef struct _MetaInputDeviceNativeClass MetaInputDeviceNativeClass;

struct _MetaInputDeviceNative
{
  ClutterInputDevice parent;

  struct libinput_device *libinput_device;
  MetaSeatImpl *seat_impl;
  ClutterInputDeviceTool *last_tool;

  cairo_matrix_t device_matrix;
  double device_aspect_ratio; /* w:h */
  double output_ratio;        /* w:h */
  MetaInputDeviceMapping mapping_mode;

  /* Pointer position */
  float pointer_x;
  float pointer_y;

  /* Keyboard a11y */
  MetaKeyboardA11yFlags a11y_flags;
  GList *slow_keys_list;
  guint debounce_timer;
  uint16_t debounce_key;
  xkb_mod_mask_t stickykeys_depressed_mask;
  xkb_mod_mask_t stickykeys_latched_mask;
  xkb_mod_mask_t stickykeys_locked_mask;
  guint toggle_slowkeys_timer;
  uint16_t shift_count;
  uint32_t last_shift_time;
  int mousekeys_btn;
  gboolean mousekeys_btn_states[3];
  uint32_t mousekeys_first_motion_time; /* ms */
  uint32_t mousekeys_last_motion_time; /* ms */
  guint mousekeys_init_delay;
  guint mousekeys_accel_time;
  guint mousekeys_max_speed;
  double mousekeys_curve_factor;
  guint move_mousekeys_timer;
  uint16_t last_mousekeys_key;
};

struct _MetaInputDeviceNativeClass
{
  ClutterInputDeviceClass parent_class;
};

GType                     meta_input_device_native_get_type        (void) G_GNUC_CONST;

ClutterInputDevice *      meta_input_device_native_new             (MetaSeatImpl            *seat_impl,
                                                                    struct libinput_device  *libinput_device);

ClutterInputDevice *      meta_input_device_native_new_virtual     (MetaSeatImpl            *seat_impl,
                                                                    ClutterInputDeviceType   type,
                                                                    ClutterInputMode         mode);

MetaSeatImpl *            meta_input_device_native_get_seat_impl   (MetaInputDeviceNative   *device);

void                      meta_input_device_native_update_leds     (MetaInputDeviceNative   *device,
                                                                    enum libinput_led        leds);

ClutterInputDeviceType    meta_input_device_native_determine_type  (struct libinput_device  *libinput_device);


void                      meta_input_device_native_translate_coordinates (ClutterInputDevice *device,
                                                                          MetaViewportInfo   *viewports,
                                                                          float              *x,
                                                                          float              *y);

MetaInputDeviceMapping    meta_input_device_native_get_mapping_mode (ClutterInputDevice     *device);
void                      meta_input_device_native_set_mapping_mode (ClutterInputDevice     *device,
                                                                     MetaInputDeviceMapping  mapping);

void                      meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device,
                                                                            MetaKbdA11ySettings   *settings);

void                      meta_input_device_native_a11y_maybe_notify_toggle_keys  (MetaInputDeviceNative *device_evdev);

struct libinput_device * meta_input_device_native_get_libinput_device (ClutterInputDevice *device);

void                     meta_input_device_native_set_coords (MetaInputDeviceNative *device_native,
                                                              float                  x,
                                                              float                  y);
void                     meta_input_device_native_get_coords (MetaInputDeviceNative *device_native,
                                                              float                 *x,
                                                              float                 *y);

#endif /* META_INPUT_DEVICE_NATIVE_H */