~elementary-os/ubuntu-package-imports/unity-control-center-bionic

« back to all changes in this revision

Viewing changes to panels/wacom/calibrator/calibrator.h

  • Committer: RabbitBot
  • Date: 2018-02-05 15:02:54 UTC
  • Revision ID: rabbitbot@elementary.io-20180205150254-zx3a61nme21tva75
Initial import, version 15.04.0+17.10.20171225-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2009 Tias Guns
 
3
 * Copyright (c) 2009 Soren Hauberg
 
4
 *
 
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
 * of this software and associated documentation files (the "Software"), to deal
 
7
 * in the Software without restriction, including without limitation the rights
 
8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
 * copies of the Software, and to permit persons to whom the Software is
 
10
 * furnished to do so, subject to the following conditions:
 
11
 *
 
12
 * The above copyright notice and this permission notice shall be included in
 
13
 * all copies or substantial portions of the Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
21
 * THE SOFTWARE.
 
22
 */
 
23
 
 
24
#ifndef _calibrator_h
 
25
#define _calibrator_h
 
26
 
 
27
#include <glib.h>
 
28
#include "gui_gtk.h"
 
29
 
 
30
/*
 
31
 * Number of blocks. We partition the screen into 'num_blocks' x 'num_blocks'
 
32
 * rectangles of equal size. We then ask the user to press points that are
 
33
 * located at the corner closes to the center of the four blocks in the corners
 
34
 * of the screen. The following ascii art illustrates the situation. We partition
 
35
 * the screen into 8 blocks in each direction. We then let the user press the
 
36
 * points marked with 'O'.
 
37
 *
 
38
 *   +--+--+--+--+--+--+--+--+
 
39
 *   |  |  |  |  |  |  |  |  |
 
40
 *   +--O--+--+--+--+--+--O--+
 
41
 *   |  |  |  |  |  |  |  |  |
 
42
 *   +--+--+--+--+--+--+--+--+
 
43
 *   |  |  |  |  |  |  |  |  |
 
44
 *   +--+--+--+--+--+--+--+--+
 
45
 *   |  |  |  |  |  |  |  |  |
 
46
 *   +--+--+--+--+--+--+--+--+
 
47
 *   |  |  |  |  |  |  |  |  |
 
48
 *   +--+--+--+--+--+--+--+--+
 
49
 *   |  |  |  |  |  |  |  |  |
 
50
 *   +--+--+--+--+--+--+--+--+
 
51
 *   |  |  |  |  |  |  |  |  |
 
52
 *   +--O--+--+--+--+--+--O--+
 
53
 *   |  |  |  |  |  |  |  |  |
 
54
 *   +--+--+--+--+--+--+--+--+
 
55
 */
 
56
#define NUM_BLOCKS 8
 
57
 
 
58
/* Names of the points */
 
59
enum
 
60
{
 
61
        UL = 0, /* Upper-left  */
 
62
        UR = 1, /* Upper-right */
 
63
        LL = 2, /* Lower-left  */
 
64
        LR = 3  /* Lower-right */
 
65
};
 
66
 
 
67
struct Calib
 
68
{
 
69
    /* original axis values */
 
70
    XYinfo old_axis;
 
71
 
 
72
    /* Geometry of the calibration window */
 
73
    GdkRectangle geometry;
 
74
 
 
75
    /* nr of clicks registered */
 
76
    int num_clicks;
 
77
 
 
78
    /* click coordinates */
 
79
    int clicked_x[4], clicked_y[4];
 
80
 
 
81
    /* Threshold to keep the same point from being clicked twice.
 
82
     * Set to zero if you don't want this check
 
83
     */
 
84
    int threshold_doubleclick;
 
85
 
 
86
    /* Threshold to detect mis-clicks (clicks not along axes)
 
87
     * A lower value forces more precise calibration
 
88
     * Set to zero if you don't want this check
 
89
     */
 
90
    int threshold_misclick;
 
91
};
 
92
 
 
93
void reset      (struct Calib *c);
 
94
gboolean add_click  (struct Calib *c,
 
95
                 int           x,
 
96
                 int           y);
 
97
gboolean finish     (struct Calib *c,
 
98
                 XYinfo       *new_axis,
 
99
                 gboolean         *swap);
 
100
 
 
101
#endif /* _calibrator_h */