4#include "ui_SConsole.h"
5#include "qwt_dial_needle.h"
8#include "qpushbutton.h"
10#include "qwt_analog_clock.h"
27 for(
int i=0; i<3; i++){
28 ThrusterActive[i] = 0;
36 for(
int i=0; i<32; i++){
37 permval.rgbButtons[i] = 0;
42 void SetSocket(
int _fd )
47 void SetMSPanelID(
long long id)
52 void SetShipConsoleID(
long long id)
60 QwtDialSimpleNeedle *needle =
new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow,
true, Qt::red, QColor(Qt::gray).light(130));
61 MainEngineRight->setRange(-1.0,1.,0.01);
62 MainEngineRight->setNeedle(needle);
63 MainEngineLeft->setRange(-1.0,1.,0.01);
64 MainEngineLeft->setNeedle(needle);
65 Rudder->setRange(-1.0,1.,0.01);
66 Rudder->setNeedle(needle);
68 MainEngineRight->setScaleArc(-150.0, 150.0);
69 MainEngineLeft->setScaleArc(-150.0, 150.0);
70 Rudder->setScaleArc(-150.0, 150);
72 EngineButtonLeft->setCheckable(
true);
73 EngineButtonRight->setCheckable(
true);
75 EngineButtonLeft->setChecked(
false);
76 EngineButtonLeft->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
77 EngineButtonLeft->setText(
"Off");
79 EngineButtonRight->setChecked(
false);
80 EngineButtonRight->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
81 EngineButtonRight->setText(
"Off");
83 DiffLeft->setRange(-1.0, 1.0, 0.01);
84 DiffRight->setRange(-1.0, 1.0, 0.01);
85 DiffRudder->setRange(-1.0, 1.0, 0.01);
87 ThrusterSlider1->setHandleSize( 30, 16 );
88 ThrusterSlider1->setRange(-1.0, 1.0, 1.0, 0);
89 ThrusterSlider2->setHandleSize( 30, 16 );
90 ThrusterSlider2->setRange(-1.0, 1.0, 1.0, 0);
91 ThrusterSlider3->setHandleSize( 30, 16 );
92 ThrusterSlider3->setRange(-1.0, 1.0, 1.0, 0);
94 ThrusterButton1->setCheckable(
true);
95 ThrusterButton2->setCheckable(
true);
96 ThrusterButton3->setCheckable(
true);
98 ThrusterButton1->setChecked(
false);
99 ThrusterButton1->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
100 ThrusterButton1->setText(
"Off");
102 ThrusterButton2->setChecked(
false);
103 ThrusterButton2->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
104 ThrusterButton2->setText(
"Off");
106 ThrusterButton3->setChecked(
false);
107 ThrusterButton3->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
108 ThrusterButton3->setText(
"Off");
113 void JoystickUpdated(
long long id,
joyData_t data);
119 if(EngineButtonLeft->isChecked())
120 MainEngineLeft->setValue(FHSimData.mainengine[0]);
121 else MainEngineLeft->setValue(0.0);
123 if(EngineButtonRight->isChecked())
124 MainEngineRight->setValue( FHSimData.mainengine[1] );
125 else MainEngineRight->setValue(0.0);
128 Rudder->setValue(FHSimData.mainengine[2] );
132 DiffLeft->setValue(permval.rotAxis[2]/1000.0-FHSimData.mainengine[0]);
133 DiffRight->setValue(permval.rglSlider[0]/1000.0-FHSimData.mainengine[1]);
134 DiffRudder->setValue(permval.rotAxis[0]/1000.0-FHSimData.mainengine[2]);
138 void UpdateAndSend( )
140 std::map<long long,joyData_t>::iterator it;
141 std::map<long long,myStruct_t>::iterator it2;
142 UpdateInputState(this->winId());
145 for( it = Joysticks.begin(); it != Joysticks.end(); it++)
147 LPDIRECTINPUTDEVICE8 dev = it->second.dev;
150 emit JoystickUpdated(it->first,it->second);
159 void UpdateJoystickData(
long long id,
joyData_t data)
161 if(
id == ShipConsoleID){
163permval.GuidData1 = data.data.GuidData1;
164 for(
int i=0; i<3; i++)
165 permval.rotAxis[i]= data.data.rotAxis[i];
166 for(
int i=0; i<2; i++)
167 permval.rglSlider[i] = data.data.rglSlider[i];
171 for(
int i=0; i<32; i++){
173 if(data.data.rgbButtons[i]){
174 permval.rgbButtons[i] = 128*(!permval.rgbButtons[i]);
182 for(
int i=0; i<3; i++)
183 ThrusterActive[i] = data.data.rgbButtons[i+19];
185 ThrusterUp[0] = data.data.rgbButtons[3];
186 ThrusterUp[1] = data.data.rgbButtons[5];
187 ThrusterUp[2] = data.data.rgbButtons[9];
189 ThrusterDown[0] = data.data.rgbButtons[2];
190 ThrusterDown[1] = data.data.rgbButtons[4];
191 ThrusterDown[2] = data.data.rgbButtons[10];
193 for(
int i=0; i<3; i++){
195 if(ThrusterUp[i] == 128)
196 ThrusterValue[i]+=0.05;
199 if(ThrusterDown[i] == 128)
200 ThrusterValue[i]-=0.05;
204 if(data.data.rgbButtons[19]/128 == 1){
206 if(ThrusterButton1->isChecked()){
207 ThrusterButton1->setChecked(
false);
208 ThrusterButton1->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
209 ThrusterButton1->setText(
"Off");
213 ThrusterButton1->setChecked(
true);
214 ThrusterButton1->setStyleSheet(
"* { background-color: rgb(0,255,0) }");
215 ThrusterButton1->setText(
"On");
220 if(data.data.rgbButtons[20]/128 == 1){
222 if(ThrusterButton2->isChecked()){
223 ThrusterButton2->setChecked(
false);
224 ThrusterButton2->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
225 ThrusterButton2->setText(
"Off");
229 ThrusterButton2->setChecked(
true);
230 ThrusterButton2->setStyleSheet(
"* { background-color: rgb(0,255,0) }");
231 ThrusterButton2->setText(
"On");
237 if(data.data.rgbButtons[21]/128 == 1){
239 if(ThrusterButton3->isChecked()){
240 ThrusterButton3->setChecked(
false);
241 ThrusterButton3->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
242 ThrusterButton3->setText(
"Off");
246 ThrusterButton3->setChecked(
true);
247 ThrusterButton3->setStyleSheet(
"* { background-color: rgb(0,255,0) }");
248 ThrusterButton3->setText(
"On");
254 if(ThrusterButton1->isChecked())
256 ThrusterSlider1->setValue(ThrusterValue[0]);
257 permval.Thruster[0] = ThrusterValue[0];
261 ThrusterSlider1->setValue(0.0);
262 permval.Thruster[0] = 0.0;
267 if(ThrusterButton2->isChecked())
269 ThrusterSlider2->setValue(ThrusterValue[1]);
270 permval.Thruster[1] = ThrusterValue[1];
274 ThrusterSlider2->setValue(0.0);
275 permval.Thruster[1] = 0.0;
280 if(ThrusterButton3->isChecked())
282 ThrusterSlider3->setValue(ThrusterValue[2]);
283 permval.Thruster[2] = ThrusterValue[2];
287 ThrusterSlider3->setValue(0.0);
288 permval.Thruster[2] = 0.0;
296 if(data.data.rgbButtons[6]/128 == 1){
298 if(EngineButtonLeft->isChecked()){
299 EngineButtonLeft->setChecked(
false);
300 EngineButtonLeft->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
301 EngineButtonLeft->setText(
"Off");
305 EngineButtonLeft->setChecked(
true);
306 EngineButtonLeft->setStyleSheet(
"* { background-color: rgb(0,255,0) }");
307 EngineButtonLeft->setText(
"On");
312 if(data.data.rgbButtons[7]/128 == 1){
314 if(EngineButtonRight->isChecked()){
315 EngineButtonRight->setChecked(
false);
316 EngineButtonRight->setStyleSheet(
"* { background-color: rgb(255,0,0) }");
317 EngineButtonRight->setText(
"Off");
321 EngineButtonRight->setChecked(
true);
322 EngineButtonRight->setStyleSheet(
"* { background-color: rgb(0,255,0) }");
323 EngineButtonRight->setText(
"On");
331 send(sockfd,(
const char *) &permval,
sizeof(
myStruct), 0);
337 long long ShipConsoleID;
339 double ThrusterActive[3], ThrusterUp[3], ThrusterDown[3], ThrusterValue[3];
Definition: program2.h:14
Definition: Joystick.h:78
Definition: myOutputStruct.h:5