summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
blob: 0a4454e40a88a73ee38f6208748dbf3a04788f11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/********************************************************************************
* FaceTrackNoIR		This program is a private project of some enthusiastic		*
*					gamers from Holland, who don't like to pay much for			*
*					head-tracking.												*
*																				*
* Copyright (C) 2012	Wim Vriend (Developing)									*
*						Ron Hendriks (Researching and Testing)					*
* Homepage:			http://facetracknoir.sourceforge.net/home/default.htm		*
*																				*
* Copyright (C) 2012	FuraX49 (HAT Tracker plugins)	    	     			*
* Homepage:			http://hatire.sourceforge.net								*
*																				*
* This program is free software; you can redistribute it and/or modify it		*
* under the terms of the GNU General Public License as published by the			*
* Free Software Foundation; either version 3 of the License, or (at your		*
* option) any later version.													*
*																				*
* This program 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 General Public License for	*
* more details.																	*
*																				*
* You should have received a copy of the GNU General Public License along		*
* with this program; if not, see <http://www.gnu.org/licenses/>.				*
*																				*
********************************************************************************/
#include <QCoreApplication>
#include <QSettings>
#include <QVariant>

#include "ftnoir_tracker_hat_settings.h"
#ifdef OPENTRACK_API
#include "opentrack/options.hpp"
#endif

void TrackerSettings::load_ini()
{
#ifndef OPENTRACK_API
    QSettings settings(OPENTRACK_ORG);	// Registry settings (in HK_USER)
    QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
#else
    QString currentFile = options::group::ini_pathname();
#endif
	QSettings iniFile( currentFile, QSettings::IniFormat );		// Application settings (in INI-file)

	iniFile.beginGroup( "HAT" );

    SerialPortName=iniFile.value ( "PortName" ).toString();

	EnableRoll = iniFile.value( "EnableRoll", 1 ).toBool();
	EnablePitch = iniFile.value( "EnablePitch", 1 ).toBool();
	EnableYaw = iniFile.value( "EnableYaw", 1 ).toBool();
	EnableX = iniFile.value( "EnableX", 0 ).toBool();
	EnableY = iniFile.value( "EnableY", 0 ).toBool();
	EnableZ = iniFile.value( "EnableZ", 0 ).toBool();
	EnableLogging = iniFile.value( "EnableLogging", 0).toBool();
	
	InvertRoll = iniFile.value( "InvertRoll", 1 ).toBool();
	InvertPitch = iniFile.value( "InvertPitch", 1 ).toBool();
	InvertYaw = iniFile.value( "InvertYaw", 1 ).toBool();
	InvertX = iniFile.value( "InvertX", 0 ).toBool();
	InvertY = iniFile.value( "InvertY", 0 ).toBool();
	InvertZ = iniFile.value( "InvertZ", 0 ).toBool();


	RollAxe=iniFile.value("RollAxe",1).toInt();
	PitchAxe=iniFile.value("PitchAxe",2).toInt();
	YawAxe=iniFile.value("YawAxe",0).toInt();
	XAxe=iniFile.value("XAxe",1).toInt();
	YAxe=iniFile.value("YAxe",2).toInt();
	ZAxe=iniFile.value("ZAxe",0).toInt();


    CmdStart=iniFile.value ( "CmdStart").toString();
    CmdStop=iniFile.value ( "CmdStop" ).toString();
    CmdInit=iniFile.value ( "CmdInit" ).toString();
    CmdReset=iniFile.value ( "CmdReset" ).toString();
    CmdCenter=iniFile.value ( "CmdCenter" ).toString();
    CmdZero=iniFile.value ( "CmdZero" ).toString();

	DelayInit=iniFile.value("DelayInit",0).toInt();
	DelayStart=iniFile.value("DelayStart",0).toInt();
	DelaySeq=iniFile.value("DelaySeq",0).toInt();

#ifdef OPENTRACK_API
    FPSArduino=iniFile.value("FPSArduino",30).toInt();
#endif
	BigEndian=iniFile.value("BigEndian",0).toBool();


	pBaudRate=static_cast<QSerialPort::BaudRate>(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt());
	pDataBits=static_cast<QSerialPort::DataBits>(iniFile.value("DataBits",QSerialPort::Data8).toInt());
	pParity=static_cast<QSerialPort::Parity>(iniFile.value("Parity",QSerialPort::NoParity).toInt());
	pStopBits=static_cast<QSerialPort::StopBits>(iniFile.value("StopBits",QSerialPort::OneStop).toInt());
	pFlowControl=static_cast<QSerialPort::FlowControl>(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt());

	iniFile.endGroup();
}

void TrackerSettings::save_ini() const
{

#ifndef OPENTRACK_API
    QSettings settings(OPENTRACK_ORG);	// Registry settings (in HK_USER)
    QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
#else
    QString currentFile = options::group::ini_pathname();
#endif
	QSettings iniFile( currentFile, QSettings::IniFormat );		// Application settings (in INI-file)

	iniFile.beginGroup ( "HAT" );

	iniFile.setValue ( "PortName",SerialPortName );

    iniFile.setValue( "EnableRoll", EnableRoll );
	iniFile.setValue( "EnablePitch", EnablePitch );
	iniFile.setValue( "EnableYaw", EnableYaw );
	iniFile.setValue( "EnableX", EnableX );
	iniFile.setValue( "EnableY", EnableY );
	iniFile.setValue( "EnableZ", EnableZ );
	iniFile.setValue( "EnableLogging", EnableLogging );

    iniFile.setValue( "InvertRoll", InvertRoll );
	iniFile.setValue( "InvertPitch", InvertPitch );
	iniFile.setValue( "InvertYaw", InvertYaw );
	iniFile.setValue( "InvertX", InvertX );
	iniFile.setValue( "InvertY", InvertY );
	iniFile.setValue( "InvertZ", InvertZ );

	iniFile.setValue ( "RollAxe", RollAxe );
	iniFile.setValue ( "PitchAxe", PitchAxe );
	iniFile.setValue ( "YawAxe",YawAxe );
	iniFile.setValue ( "XAxe", XAxe );
	iniFile.setValue ( "YAxe", YAxe );
	iniFile.setValue ( "ZAxe", ZAxe );

	iniFile.setValue ( "CmdStart",CmdStart.toLatin1());
	iniFile.setValue ( "CmdStop",CmdStop.toLatin1());
	iniFile.setValue ( "CmdInit",CmdInit.toLatin1());
	iniFile.setValue ( "CmdReset",CmdReset.toLatin1());
	iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() );
	iniFile.setValue ( "CmdZero",CmdZero.toLatin1() );

	iniFile.setValue ( "DelayInit",DelayInit);
	iniFile.setValue ( "DelayStart",DelayStart);
	iniFile.setValue ( "DelaySeq",DelaySeq);

#ifdef OPENTRACK_API
    iniFile.setValue ( "FPSArduino", FPSArduino );
#endif
    iniFile.setValue("BigEndian",BigEndian);

	iniFile.setValue("BaudRate",pBaudRate);
	iniFile.setValue("DataBits",pDataBits);
	iniFile.setValue("Parity",pParity);
	iniFile.setValue("StopBits",pStopBits);
	iniFile.setValue("FlowControl",pFlowControl);


	iniFile.endGroup();
}