version 0.3.1
[expresskeys.git] / src-expresskeys / globals.c
1 /*
2  globals.c -- Support ExpressKeys & Touch Strips on a Wacom Intuos3 tablet.
3
4  Copyright (C) 2005-2006 - Mats Johannesson
5
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
19 */
20
21 #include "globals.h"
22
23 Display *display;
24 XDeviceInfo *pad1_info_block;
25 XDeviceInfo *stylus1_info_block;
26 XDeviceInfo *pad1_info;
27 XDeviceInfo *stylus1_info;
28 XDevice *pad1_device;
29 XDevice *stylus1_device;
30
31 char *configstring = "ConfigVersion"; /* Searchable string in the config file */
32 char *configversion = "3"; /* Our version. Remember to change it if necessary! */
33 char *pad1idstring = "Identifier1Pad";          /* Marker to bind tablet and config file */
34 char *stylus1idstring = "Identifier1Sty";       /* Marker that can't bind... */
35 char *our_prog_version = "0.3.1"; /* Our version. Remember to change it! */
36 char *our_prog_name;
37 char *pad1_name = 0;
38 char *pad1_autoname = "pad";
39 char *stylus1_name = 0;
40 char *stylus1_autoname = "stylus";
41 char *total_config_dir;
42 char *total_config_file;
43 char *total_pid_file;
44 char *total_error_file;
45 char *total_status_file;
46 char *config_dir = "/.expresskeys";     /* This is where in the user home */
47 char *config_file = 0;                          /* directory we'd like to reside, */
48 char *pid_file = "/expresskeys.pid";    /* and what our different status */
49 char *error_file = "/error.log";        /* files should be called */
50 char *status_file = "/status.log";
51 char *config_file_padless = "/padless.conf1";
52 char *config_file_intuos3 = "/intuos3.conf1";
53 char *config_file_graphire4 = "/graphire4.conf1";
54
55 int userconfigversion = 0; /* Keep track of which format the user has */
56 int config3headerfields = 3; /* Number of fields in the header of a configversion 3 file */
57 int configheaderfields = 0; /* How many header fields to actually parse in each file */
58 int config3fields = 27; /* Number of fields in a configversion 3 record */
59 int config3gr4fields = 11; /* Number of fields if tablet is a Graphire4 */
60 int configfields = 0; /* How many fields to actually parse in each record */
61 int screen;                     /* Active screen. An X thing */
62 int is_graphire4 = 0;   /* Only flag if it is so */
63 int just_exit = 0;      /* Do not terminate the program immediately */
64 int go_daemon = 0;      /* Do not become a daemon without a command */
65 int be_verbose = 0; /* Run silently per default */
66 int reread_config = 0;  /* No memory should be freed on the first read */
67 int stylus1_mode = 1;   /* Pen initially in Absolute mode. Real value discovered later */
68 int padstylus1_presscurve = 4; /* Stylus default Sensitivity. Sample xsetwacom usage */
69
70 int motion_type = NON_VALID;
71 int button_press_type = NON_VALID;
72 int button_release_type = NON_VALID;
73 int proximity_in_type = NON_VALID;
74
75 struct program *default_program; /* Pointer to the "default" program record */
76
77 /* Allocate space for a list of program definitions (config file based)
78    Also initialize a small list that is written out if no config file exists */
79
80 struct program external_list [MAXRECORDS];
81 struct program internal_list[] = {
82 /*      Name    stylus1_presscurve      handle_touch */
83 {"default",     "0 0 100 100",  1,
84 /*              l_touch_up      l_touch_up_plus l_touch_down    l_touch_down_plus */
85                 994,            0,              995,            0,
86 /*              r_touch_up      r_touch_up_plus r_touch_down    r_touch_down_plus */
87                 102,            0,              100,            0,
88 /*              key_9           key_9_plus      key_10          key_10_plus */
89                 50,             0,              64,             0,
90 /*              key_11          key_11_plus     key_12          key_12_plus */
91                 37,             0,              65,             0,
92 /*              key_13          key_13_plus     key_14          key_14_plus */
93                 50,             0,              64,             0,
94 /*              key_15          key_15_plus     key_16          key_16_plus */
95                 37,             0,              65,             0       },
96
97 /*      Name    stylus1_presscurve      handle_touch */
98 {"Gimp", "0 0 100 100", 1,
99 /*              l_touch_up      l_touch_up_plus l_touch_down    l_touch_down_plus */
100                 20,             0,              61,             0,
101 /*              r_touch_up      r_touch_up_plus r_touch_down    r_touch_down_plus */
102                 64,             20,             64,             61,
103 /*              key_9           key_9_plus      key_10          key_10_plus */
104                 50,             0,              64,             0,
105 /*              key_11          key_11_plus     key_12          key_12_plus */
106                 37,             0,              65,             0,
107 /*              key_13          key_13_plus     key_14          key_14_plus */
108                 37,             29,             37,             52,
109 /*              key_15          key_15_plus     key_16          key_16_plus */
110                 999,            0,              65,             0       },
111
112 /*      Name    stylus1_presscurve      handle_touch */
113 {"Blender",     "0 0 100 100",  1,
114 /*              l_touch_up      l_touch_up_plus l_touch_down    l_touch_down_plus */
115                 102,            0,              100,            0,
116 /*              r_touch_up      r_touch_up_plus r_touch_down    r_touch_down_plus */
117                 98,             0,              104,            0,
118 /*              key_9           key_9_plus      key_10          key_10_plus */
119                 37,             0,              9,              0,
120 /*              key_11          key_11_plus     key_12          key_12_plus */
121                 50,             0,              23,             0,
122 /*              key_13          key_13_plus     key_14          key_14_plus */
123                 37,             29,             37,             52,
124 /*              key_15          key_15_plus     key_16          key_16_plus */
125                 999,            0,              65,             0       },
126
127 /*      Name    stylus1_presscurve      handle_touch */
128 {"XTerm",       "0 0 100 100",  0,
129 /*              l_touch_up      l_touch_up_plus l_touch_down    l_touch_down_plus */
130                 0,              0,              0,              0,
131 /*              r_touch_up      r_touch_up_plus r_touch_down    r_touch_down_plus */
132                 0,              0,              0,              0,
133 /*              key_9           key_9_plus      key_10          key_10_plus */
134                 0,              0,              0,              0,
135 /*              key_11          key_11_plus     key_12          key_12_plus */
136                 0,              0,              0,              0,
137 /*              key_13          key_13_plus     key_14          key_14_plus */
138                 0,              0,              0,              0,
139 /*              key_15          key_15_plus     key_16          key_16_plus */
140                 999,            0,              0,              0       }
141 };
142 /* The number of programs (num_list) must be computed here. After the struct */
143 int num_list = (sizeof internal_list / sizeof internal_list[0]);
144
145 /* These are the keywords prefacing a value in the Intuos3 config file */
146 struct configstrings human_readable[] = {
147 {"ProgramName", "Stylus1PressCurve", "HandleTouchStrips",
148 "LeftPadTouchUp", "LeftPadTouchUpPlus",
149 "LeftPadTouchDown", "LeftPadTouchDownPlus",
150 "RightPadTouchUp", "RightPadTouchUpPlus",
151 "RightPadTouchDown", "RightPadTouchDownPlus",
152 "LeftPadButton9", "LeftPadButton9Plus",
153 "LeftPadButton10", "LeftPadButton10Plus",
154 "LeftPadButton11", "LeftPadButton11Plus",
155 "LeftPadButton12", "LeftPadButton12Plus",
156 "RightPadButton13", "RightPadButton13Plus",
157 "RightPadButton14", "RightPadButton14Plus",
158 "RightPadButton15", "RightPadButton15Plus",
159 "RightPadButton16", "RightPadButton16Plus" }
160 };
161
162 /* These are the keywords prefacing a value in the Graphire4 config file */
163 struct configstrings gr4_human_readable[] = {
164 {"ProgramName", "Stylus1PressCurve", "HandleScrollWheel",
165 "ScrollWheelUp", "ScrollWheelUpPlus",
166 "ScrollWheelDown", "ScrollWheelDownPlus",
167 "dummy", "dummy", "dummy", "dummy", "LeftButton", "LeftButtonPlus",
168 "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "RightButton", "RightButtonPlus",
169 "dummy", "dummy", "dummy", "dummy", "dummy", "dummy" }
170 };
171
172 /* End Code */
173