* adding accel-neutral-settings API proposal
[libnomaccel] / src / accel-neutral-settings_p.c
diff --git a/src/accel-neutral-settings_p.c b/src/accel-neutral-settings_p.c
new file mode 100644 (file)
index 0000000..98dc872
--- /dev/null
@@ -0,0 +1,85 @@
+/* ============================================================================
+    Copyright (C) 2010 nomrasco
+    Nom Rasco <nomrasco@gmail.com>
+
+    This file is part of libnomaccel.
+
+    libnomaccel is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Lesser General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    libnomaccel is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with libnomaccel.  If not, see <http://www.gnu.org/licenses/>.
+============================================================================ */
+#include "../accel-neutral-settings.h"
+#include "global_p.h"
+
+NomAccelNeutralSetting nom_accel_nsettings_get_current ()
+{
+       return _accel_settings_current;
+}
+
+void  nom_accel_nsettings_set_current (NomAccelNeutralSetting settings)
+{
+       if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
+       _accel_settings_current = settings;
+}
+
+void  nom_accel_nsettings_set_neutral_pitch ( NomAccelNeutralSetting settings,
+                                              angle new_pitch )
+{
+       if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
+       if (settings <= NOM_ACCEL_ZERO_NEUTRAL) return;
+       _accel_settings[settings].pitch_neutral = new_pitch;
+
+       if (settings == NOM_ACCEL_SYSTEM_NEUTRAL) _accel_nsettings_save_system ();
+}
+
+void  nom_accel_nsettings_set_neutral_roll  ( NomAccelNeutralSetting settings,
+                                              angle new_roll )
+{
+       if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
+       if (settings <= NOM_ACCEL_ZERO_NEUTRAL) return;
+       _accel_settings[settings].roll_neutral = new_roll;
+
+       if (settings == NOM_ACCEL_SYSTEM_NEUTRAL) _accel_nsettings_save_system ();
+}
+
+angle nom_accel_nsettings_get_neutral_pitch (NomAccelNeutralSetting settings)
+{
+       if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
+       return _accel_settings[settings].pitch_neutral;
+}
+
+angle nom_accel_nsettings_get_neutral_roll  (NomAccelNeutralSetting settings)
+{
+       if (settings >= NOM_ACCEL_SETTINGS_NUMBER) return;
+       return _accel_settings[settings].roll_neutral;
+}
+
+void
+_accel_nsettings_read_system ()
+{
+       // load system settings from conf file (if not exists, set to zero settings)
+       // TODO: pseudo-implement this
+
+       // set system settings as a current local settings
+       _accel_settings[NOM_ACCEL_LOCAL_NEUTRAL] = _accel_settings[NOM_ACCEL_SYSTEM_NEUTRAL];
+
+       // set zero settings
+       _accel_settings[NOM_ACCEL_ZERO_NEUTRAL].pitch_offset = 0.0;
+       _accel_settings[NOM_ACCEL_ZERO_NEUTRAL].roll_offset = 0.0;
+}
+
+void
+_accel_nsettings_save_system ()
+{
+       // set system settings as a current local settings
+       // TODO: pseudo-implement this
+}