* adding accel-neutral-settings API proposal
[libnomaccel] / src / accel_p.c
1 /* ============================================================================
2     Copyright (C) 2010 nomrasco
3     Nom Rasco <nomrasco@gmail.com>
4
5     This file is part of libnomaccel.
6
7     libnomaccel is free software: you can redistribute it and/or modify
8     it under the terms of the GNU Lesser General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11
12     libnomaccel is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU Lesser General Public License for more details.
16
17     You should have received a copy of the GNU Lesser General Public License
18     along with libnomaccel.  If not, see <http://www.gnu.org/licenses/>.
19 ============================================================================ */
20 #include "../include/accel.h"
21 #include "global_p.h"
22
23 value
24 nom_accel_get_x () {
25         _accel_read_real_values ();
26         return _accel_proxy.x;
27 }
28
29 value
30 nom_accel_get_y () {
31         _accel_read_real_values ();
32         return _accel_proxy.y;
33 }
34
35 value
36 nom_accel_get_z () {
37         _accel_read_real_values ();
38         return _accel_proxy.z;
39 }
40
41 void
42 nom_accel_get_xyz (value* x, value* y, value* z) {
43         _accel_read_real_values ();
44         *x = _accel_proxy.x;
45         *y = _accel_proxy.y;
46         *z = _accel_proxy.z;
47 }
48
49 angle
50 nom_accel_get_pitch () {
51         _accel_read_real_values ();
52         _accel_recalculate_pitch ();
53         return _accel_proxy.pitch;
54 }
55
56 angle
57 nom_accel_get_roll  () {
58         _accel_read_real_values ();
59         _accel_recalculate_roll ();
60         return _accel_proxy.roll;
61 }
62
63 void
64 nom_accel_get_pitch_roll (angle* pitch, angle* roll) {
65         _accel_read_real_values ();
66         _accel_recalculate_pitch_roll ();
67         *pitch = _accel_proxy.pitch;
68          *roll = _accel_proxy.roll;
69 }
70
71 void
72 nom_accel_get_all (value* x, value* y, value* z,
73                    angle* pitch, angle* roll)
74 {
75         _accel_read_real_values ();
76         _accel_recalculate_pitch_roll ();
77         *pitch = _accel_proxy.pitch;
78          *roll = _accel_proxy.roll;
79             *x = _accel_proxy.x;
80             *y = _accel_proxy.y;
81             *z = _accel_proxy.z;
82 }
83
84 void nom_accel_get_cache (NomAccelCache* target)
85 {
86         nom_accel_get_all ( &(target->x),
87                             &(target->y),
88                             &(target->z),
89                             &(target->pitch),
90                             &(target->roll) );
91 }