* adding accel-neutral-settings API proposal
[libnomaccel] / src / accel-neutral-settings_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 "../accel-neutral-settings.h"
21 #include "global_p.h"
22
23 NomAccelNeutralSetting nom_accel_nsettings_get_current ()
24 {
25         return _accel_settings_current;
26 }
27
28 void  nom_accel_nsettings_set_current (NomAccelNeutralSetting settings)
29 {
30         if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
31         _accel_settings_current = settings;
32 }
33
34 void  nom_accel_nsettings_set_neutral_pitch ( NomAccelNeutralSetting settings,
35                                               angle new_pitch )
36 {
37         if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
38         if (settings <= NOM_ACCEL_ZERO_NEUTRAL) return;
39         _accel_settings[settings].pitch_neutral = new_pitch;
40
41         if (settings == NOM_ACCEL_SYSTEM_NEUTRAL) _accel_nsettings_save_system ();
42 }
43
44 void  nom_accel_nsettings_set_neutral_roll  ( NomAccelNeutralSetting settings,
45                                               angle new_roll )
46 {
47         if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
48         if (settings <= NOM_ACCEL_ZERO_NEUTRAL) return;
49         _accel_settings[settings].roll_neutral = new_roll;
50
51         if (settings == NOM_ACCEL_SYSTEM_NEUTRAL) _accel_nsettings_save_system ();
52 }
53
54 angle nom_accel_nsettings_get_neutral_pitch (NomAccelNeutralSetting settings)
55 {
56         if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
57         return _accel_settings[settings].pitch_neutral;
58 }
59
60 angle nom_accel_nsettings_get_neutral_roll  (NomAccelNeutralSetting settings)
61 {
62         if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
63         return _accel_settings[settings].roll_neutral;
64 }
65
66 void
67 _accel_nsettings_read_system ()
68 {
69         // load system settings from conf file (if not exists, set to zero settings)
70         // TODO: pseudo-implement this
71
72         // set system settings as a current local settings
73         _accel_settings[NOM_ACCEL_LOCAL_NEUTRAL] = _accel_settings[NOM_ACCEL_SYSTEM_NEUTRAL];
74
75         // set zero settings
76         _accel_settings[NOM_ACCEL_ZERO_NEUTRAL].pitch_offset = 0.0;
77         _accel_settings[NOM_ACCEL_ZERO_NEUTRAL].roll_offset = 0.0;
78 }
79
80 void
81 _accel_nsettings_save_system ()
82 {
83         // set system settings as a current local settings
84         // TODO: pseudo-implement this
85 }