1
/*****************************************************************************
3
* utouch-frame - Touch Frame Library
5
* Copyright (C) 2010-2011 Canonical Ltd.
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation, either version 3 of the License, or (at your
10
* option) any later version.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
****************************************************************************/
22
#include "common/device.h"
26
void get_axis_info(UFAxis axis, UFAxisType *type, const char **name, float *min,
27
float *max, float *res) {
28
*type = frame_axis_get_type(axis);
39
case UFAxisTypeTouchMajor:
40
*name = "Touch major";
43
case UFAxisTypeTouchMinor:
44
*name = "Touch minor";
47
case UFAxisTypeWidthMajor:
48
*name = "Width major";
51
case UFAxisTypeWidthMinor:
52
*name = "Width minor";
55
case UFAxisTypeOrientation:
56
*name = "Orientation";
63
case UFAxisTypeBlobId:
67
case UFAxisTypeTrackingId:
68
*name = "Tracking ID";
71
case UFAxisTypePressure:
75
case UFAxisTypeDistance:
84
*min = frame_axis_get_minimum(axis);
85
*max = frame_axis_get_maximum(axis);
86
*res = frame_axis_get_resolution(axis);
89
void print_device_added(UFHandle handle, UFEvent event) {
97
status = frame_event_get_property(event, UFEventPropertyDevice, &device);
98
if (status != UFStatusSuccess) {
99
fprintf(stderr, "Error: failed to get device from event\n");
103
printf("Device added:\n");
105
printf(" Time: %ju ms\n", frame_event_get_time(event));
107
status = frame_device_get_property(device, UFDevicePropertyName, &string);
108
if (status != UFStatusSuccess)
109
fprintf(stderr, "Error: failed to get name from device\n");
111
printf(" Name: %s\n", string);
113
status = frame_device_get_property(device, UFDevicePropertyDirect, &integer);
114
if (status != UFStatusSuccess)
115
fprintf(stderr, "Error: failed to get direct property from device\n");
117
printf(" Direct: %s\n", integer ? "yes" : "no");
119
status = frame_device_get_property(device, UFDevicePropertyIndependent,
121
if (status != UFStatusSuccess)
122
fprintf(stderr, "Error: failed to get independent property from device\n");
124
printf(" Independent: %s\n", integer ? "yes" : "no");
126
status = frame_device_get_property(device, UFDevicePropertySemiMT, &integer);
127
if (status != UFStatusSuccess)
128
fprintf(stderr, "Error: failed to get semi-MT property from device\n");
130
printf(" Semi-MT: %s\n", integer ? "yes" : "no");
132
status = frame_device_get_property(device, UFDevicePropertyMaxTouches,
134
if (status != UFStatusSuccess)
135
fprintf(stderr, "Error: failed to get max touches from device\n");
137
printf(" Maximum touches: %d\n", integer);
139
num_axes = frame_device_get_num_axes(device);
140
printf(" Number of axes: %d\n", num_axes);
142
for (i = 0; i < num_axes; ++i) {
150
printf(" Axis %d:\n", i);
152
status = frame_device_get_axis_by_index(device, i, &axis);
153
if (status != UFStatusSuccess) {
154
fprintf(stderr, "Error: failed to get axis %d from device\n", i);
158
get_axis_info(axis, &type, &name, &min, &max, &res);
159
printf(" Type: %s\n", name);
160
printf(" Minimum: %f\n", min);
161
printf(" Maximum: %f\n", max);
162
printf(" Resolution: %f\n", res);
168
void print_device_removed(UFHandle handle, UFEvent event) {
173
status = frame_event_get_property(event, UFEventPropertyDevice, &device);
174
if (status != UFStatusSuccess) {
175
fprintf(stderr, "Error: failed to get device from event\n");
179
printf("Device removed:\n");
181
printf(" Time: %ju ms\n", frame_event_get_time(event));
183
status = frame_device_get_property(device, UFDevicePropertyName, &string);
184
if (status != UFStatusSuccess)
185
fprintf(stderr, "Error: failed to get name from device\n");
187
printf(" Name: %s\n", string);