summaryrefslogtreecommitdiff
path: root/plugins/wacom/gsd-wacom-device.h
blob: 327b4886d0eabc94a0fa7a9a3afd862489cb3007 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Author: Bastien Nocera <hadess@hadess.net>
 *
 */

#ifndef __GSD_WACOM_DEVICE_MANAGER_H
#define __GSD_WACOM_DEVICE_MANAGER_H

#include <glib-object.h>

G_BEGIN_DECLS

#define NUM_ELEMS_MATRIX 9

#define GSD_TYPE_WACOM_DEVICE         (gsd_wacom_device_get_type ())
#define GSD_WACOM_DEVICE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_WACOM_DEVICE, GsdWacomDevice))
#define GSD_WACOM_DEVICE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_WACOM_DEVICE, GsdWacomDeviceClass))
#define GSD_IS_WACOM_DEVICE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_WACOM_DEVICE))
#define GSD_IS_WACOM_DEVICE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_WACOM_DEVICE))
#define GSD_WACOM_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_WACOM_DEVICE, GsdWacomDeviceClass))

typedef struct GsdWacomDevicePrivate GsdWacomDevicePrivate;

typedef struct
{
        GObject                parent;
        GsdWacomDevicePrivate *priv;
} GsdWacomDevice;

typedef struct
{
        GObjectClass   parent_class;
} GsdWacomDeviceClass;

#define GSD_TYPE_WACOM_STYLUS         (gsd_wacom_stylus_get_type ())
#define GSD_WACOM_STYLUS(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_WACOM_STYLUS, GsdWacomStylus))
#define GSD_WACOM_STYLUS_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_WACOM_STYLUS, GsdWacomStylusClass))
#define GSD_IS_WACOM_STYLUS(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_WACOM_STYLUS))
#define GSD_IS_WACOM_STYLUS_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_WACOM_STYLUS))
#define GSD_WACOM_STYLUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_WACOM_STYLUS, GsdWacomStylusClass))

typedef struct GsdWacomStylusPrivate GsdWacomStylusPrivate;

typedef struct
{
        GObject                parent;
        GsdWacomStylusPrivate *priv;
} GsdWacomStylus;

typedef struct
{
        GObjectClass   parent_class;
} GsdWacomStylusClass;

typedef enum {
	WACOM_STYLUS_TYPE_UNKNOWN,
	WACOM_STYLUS_TYPE_GENERAL,
	WACOM_STYLUS_TYPE_INKING,
	WACOM_STYLUS_TYPE_AIRBRUSH,
	WACOM_STYLUS_TYPE_CLASSIC,
	WACOM_STYLUS_TYPE_MARKER,
	WACOM_STYLUS_TYPE_STROKE,
	WACOM_STYLUS_TYPE_PUCK
} GsdWacomStylusType;

GType            gsd_wacom_stylus_get_type       (void);
GSettings      * gsd_wacom_stylus_get_settings   (GsdWacomStylus *stylus);
const char     * gsd_wacom_stylus_get_name       (GsdWacomStylus *stylus);
const char     * gsd_wacom_stylus_get_icon_name  (GsdWacomStylus *stylus);
GsdWacomDevice * gsd_wacom_stylus_get_device     (GsdWacomStylus *stylus);
gboolean         gsd_wacom_stylus_get_has_eraser (GsdWacomStylus *stylus);
guint            gsd_wacom_stylus_get_num_buttons(GsdWacomStylus *stylus);
int              gsd_wacom_stylus_get_id         (GsdWacomStylus *stylus);
GsdWacomStylusType gsd_wacom_stylus_get_stylus_type (GsdWacomStylus *stylus);

/* Tablet Buttons */
typedef enum {
	WACOM_TABLET_BUTTON_TYPE_NORMAL,
	WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
	WACOM_TABLET_BUTTON_TYPE_HARDCODED
} GsdWacomTabletButtonType;

#define MAX_GROUP_ID 4

typedef struct
{
	char                     *name;
	char                     *id;
	GSettings                *settings;
	GsdWacomTabletButtonType  type;
	int                       group_id, idx;
} GsdWacomTabletButton;

void                  gsd_wacom_tablet_button_free (GsdWacomTabletButton *button);
GsdWacomTabletButton *gsd_wacom_tablet_button_copy (GsdWacomTabletButton *button);

/* Device types to apply a setting to */
typedef enum {
	WACOM_TYPE_INVALID =     0,
        WACOM_TYPE_STYLUS  =     (1 << 1),
        WACOM_TYPE_ERASER  =     (1 << 2),
        WACOM_TYPE_CURSOR  =     (1 << 3),
        WACOM_TYPE_PAD     =     (1 << 4),
        WACOM_TYPE_TOUCH   =     (1 << 5),
        WACOM_TYPE_ALL     =     WACOM_TYPE_STYLUS | WACOM_TYPE_ERASER | WACOM_TYPE_CURSOR | WACOM_TYPE_PAD | WACOM_TYPE_TOUCH
} GsdWacomDeviceType;

GType gsd_wacom_device_get_type     (void);

void     gsd_wacom_device_set_display         (GsdWacomDevice    *device,
                                               int                monitor);
gint     gsd_wacom_device_get_display_monitor (GsdWacomDevice *device);
gboolean gsd_wacom_device_get_display_matrix  (GsdWacomDevice *device,
                                               float           matrix[NUM_ELEMS_MATRIX]);

GsdWacomDevice * gsd_wacom_device_new              (GdkDevice *device);
GList          * gsd_wacom_device_list_styli       (GsdWacomDevice *device);
const char     * gsd_wacom_device_get_name         (GsdWacomDevice *device);
const char     * gsd_wacom_device_get_path         (GsdWacomDevice *device);
const char     * gsd_wacom_device_get_icon_name    (GsdWacomDevice *device);
const char     * gsd_wacom_device_get_tool_name    (GsdWacomDevice *device);
gboolean         gsd_wacom_device_reversible       (GsdWacomDevice *device);
gboolean         gsd_wacom_device_is_screen_tablet (GsdWacomDevice *device);
GSettings      * gsd_wacom_device_get_settings     (GsdWacomDevice *device);
void             gsd_wacom_device_set_current_stylus (GsdWacomDevice *device,
						      int             stylus_id);
GsdWacomStylus * gsd_wacom_device_get_stylus_for_type (GsdWacomDevice     *device,
						       GsdWacomStylusType  type);

GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
gint           * gsd_wacom_device_get_area          (GsdWacomDevice *device);
const char     * gsd_wacom_device_type_to_string    (GsdWacomDeviceType type);
GList          * gsd_wacom_device_get_buttons       (GsdWacomDevice *device);
GsdWacomTabletButton *gsd_wacom_device_get_button   (GsdWacomDevice   *device,
						     int               button,
						     GtkDirectionType *dir);
int gsd_wacom_device_set_next_mode                  (GsdWacomDevice *device,
						     int             group_id);

/* Helper and debug functions */
GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType  type,
					       const char         *name,
					       const char         *tool_name);

GList * gsd_wacom_device_create_fake_cintiq   (void);
GList * gsd_wacom_device_create_fake_bt       (void);
GList * gsd_wacom_device_create_fake_x201     (void);
GList * gsd_wacom_device_create_fake_intuos4  (void);

G_END_DECLS

#endif /* __GSD_WACOM_DEVICE_MANAGER_H */