1
/*****************************************************************************
3
* utouch-frame - Touch Frame Library
5
* Copyright (C) 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
****************************************************************************/
31
UFTouch::UFTouch(UFTouchState state, UFTouchId id, float x, float y,
37
value = new Value(state);
38
InsertProperty(UFTouchPropertyState, value);
40
value = new Value(id);
41
InsertProperty(UFTouchPropertyId, value);
44
InsertProperty(UFTouchPropertyWindowX, value);
47
InsertProperty(UFTouchPropertyWindowY, value);
49
value = new Value(time);
50
InsertProperty(UFTouchPropertyTime, value);
52
if (state == UFTouchStateBegin) {
53
value = new Value(time);
54
InsertProperty(UFTouchPropertyStartTime, value);
58
UFTouch::UFTouch(const UFTouch& touch, UFTouchState new_state)
62
values_(touch.values_) {
63
const Value* value = new Value(new_state);
64
InsertProperty(UFTouchPropertyState, value);
67
void UFTouch::SetValue(UFAxisType type, float value) {
68
values_[type] = value;
71
UFStatus UFTouch::GetValue(UFAxisType type, float* value) const {
72
auto it = values_.find(type);
73
if (it == values_.end())
74
return UFStatusErrorInvalidAxis;
78
return UFStatusSuccess;
86
UFStatus frame_touch_get_property(UFTouch touch, UFTouchProperty property,
88
const utouch::frame::UFTouch* uftouch =
89
static_cast<const utouch::frame::UFTouch*>(touch);
90
return uftouch->GetProperty(property, data);
93
UFStatus frame_touch_get_value(UFTouch touch, UFAxisType type, float* value) {
94
const utouch::frame::UFTouch* uftouch =
95
static_cast<const utouch::frame::UFTouch*>(touch);
96
return uftouch->GetValue(type, value);
99
UFTouchId frame_touch_get_id(UFTouch touch) {
101
const utouch::frame::UFTouch* uftouch =
102
static_cast<const utouch::frame::UFTouch*>(touch);
103
UFStatus status = uftouch->GetProperty(UFTouchPropertyId, &touch_id);
104
assert(status == UFStatusSuccess);
108
UFTouchState frame_touch_get_state(UFTouch touch) {
110
const utouch::frame::UFTouch* uftouch =
111
static_cast<const utouch::frame::UFTouch*>(touch);
112
UFStatus status = uftouch->GetProperty(UFTouchPropertyState, &state);
113
assert(status == UFStatusSuccess);
117
float frame_touch_get_window_x(UFTouch touch) {
119
const utouch::frame::UFTouch* uftouch =
120
static_cast<const utouch::frame::UFTouch*>(touch);
121
UFStatus status = uftouch->GetProperty(UFTouchPropertyWindowX, &x);
122
assert(status == UFStatusSuccess);
126
float frame_touch_get_window_y(UFTouch touch) {
128
const utouch::frame::UFTouch* uftouch =
129
static_cast<const utouch::frame::UFTouch*>(touch);
130
UFStatus status = uftouch->GetProperty(UFTouchPropertyWindowY, &y);
131
assert(status == UFStatusSuccess);
135
float frame_touch_get_device_x(UFTouch touch) {
137
const utouch::frame::UFTouch* uftouch =
138
static_cast<const utouch::frame::UFTouch*>(touch);
139
UFStatus status = uftouch->GetValue(UFAxisTypeX, &x);
140
assert(status == UFStatusSuccess);
144
float frame_touch_get_device_y(UFTouch touch) {
146
const utouch::frame::UFTouch* uftouch =
147
static_cast<const utouch::frame::UFTouch*>(touch);
148
UFStatus status = uftouch->GetValue(UFAxisTypeY, &y);
149
assert(status == UFStatusSuccess);
153
uint64_t frame_touch_get_time(UFTouch touch) {
155
const utouch::frame::UFTouch* uftouch =
156
static_cast<const utouch::frame::UFTouch*>(touch);
157
UFStatus status = uftouch->GetProperty(UFTouchPropertyTime, &time);
158
assert(status == UFStatusSuccess);
162
uint64_t frame_touch_get_start_time(UFTouch touch) {
164
const utouch::frame::UFTouch* uftouch =
165
static_cast<const utouch::frame::UFTouch*>(touch);
166
UFStatus status = uftouch->GetProperty(UFTouchPropertyStartTime, &start_time);
167
assert(status == UFStatusSuccess);