Rise
The Vieneo Province
joystick.cpp
Go to the documentation of this file.
1 #include "joystick.h"
2 #include "Viewscreen.h"
3 #include "../Dialogs/InformationDialog.h"
4 #include "../MathUtilities.h"
5 
7 {
8  viewscreen = ptr;
9  logger = ptr->logger;
10  hDlg = nullptr;
11 }
12 
13 HRESULT joystick::Poll(InputConfig* config, long* value, DIJOYSTATE* js) const
14 {
15  if (!config->g_pJoystick) // no device
16  return E_FAIL;
17 
18  HRESULT hr;
19  char msg[199];
20 
21  // Poll the device to read the current state
22  if (FAILED(config->g_pJoystick->Poll()))
23  {
24  if (FAILED(hr = config->g_pJoystick->Acquire()))
25  {
26  sprintf_s(msg, 199, "Failed to Poll and failed to Acquire device: %s (%x)", config->friendlyName.c_str(), hr);
27  logger->Log(msg, Logger::Level::Warn);
28  }
29  }
30 
31  // Get the input's device state
32  if (FAILED(hr = config->g_pJoystick->GetDeviceState(sizeof DIJOYSTATE, js)))
33  {
34  sprintf_s(msg, 199, "joystick::GetOrPoll failed to GetDeviceState DIJOYSTICK: %s (%x)", config->friendlyName.c_str(), hr);
35  logger->Log(msg, Logger::Level::Warn);
37  sprintf_s(msg, 199, "It appears a game controller was unplugged or stolen by another application: %s", config->friendlyName.c_str());
38  MessageBoxA(DXUTGetHWND(), msg, "Lost Joystick Connection", MB_ICONWARNING | MB_OK);
39  SAFE_RELEASE(config->g_pJoystick);
40  return hr;
41  }
42 
43  // map axes
44  switch (config->axis)
45  {
46  case 0: *value = js->lX; break;
47  case 1: *value = js->lY; break;
48  case 2: *value = js->lZ; break;
49  case 3: *value = js->lRx; break;
50  case 4: *value = js->lRy; break;
51  case 5: *value = js->lRz; break;
52  case 6: *value = js->rglSlider[0]; break;
53  case 7: *value = js->rglSlider[1]; break;
54  default: *value = 0; break;
55  }
56 
57  if (abs(*value) > 2000)
58  {
59  sprintf_s(msg, 199, "Value was out-of-range for game controller: %i", *value);
60  logger->Log(msg, Logger::Level::Error);
61  return E_FAIL;
62  }
63 
64  if (config->invert)
65  *value = -(*value);
66 
67  // 500 to 1000 for accelerator
68  if (config->split)
69  {
70  *value = (*value + 500) * 2;
71  if (*value > 1000)
72  *value = 1000;
73  }
74 
75  if (config->oldValue != *value)
76  config->hasMoved = true;
77 
78  if (!config->hasMoved)
79  return E_FAIL;
80 
81  return S_OK;
82 }
83 
84 void joystick::Update(float fElapsedTime) const
85 {
86  logger->AddToCallStack("joystick::Update");
87 
88  long value;
89  DIJOYSTATE js;
90 
91  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigLookLateral, &value, &js)))
92  {
93  if (abs(value) > nullzone)
94  {
95  if (value > 0)
96  viewscreen->targetLeftright = powf(static_cast<float>(value)*0.001f, 2.0f)*viewscreen->rightlimit;
97  else
98  viewscreen->targetLeftright = powf(static_cast<float>(value)*0.001f, 2.0f)*viewscreen->leftlimit;
99  if (abs(value) > 400)
100  {
103  }
104  }
105  else
106  viewscreen->targetLeftright = 0.0f;
107  }
108  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigLookVertical, &value, &js)))
109  {
110  if (abs(value) > nullzone)
111  {
112  if (value > 0)
113  viewscreen->targetUpdown = powf(static_cast<float>(value)*0.001f, 2.0f)*viewscreen->uplimit;
114  else
115  viewscreen->targetUpdown = powf(static_cast<float>(value)*0.001f, 2.0f)*viewscreen->downlimit;
116  if (abs(value) > 400)
117  {
120  }
121  }
122  else
123  viewscreen->targetUpdown = 0.0f;
124  }
125 
126  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigWalkLateral, &value, &js)))
127  {
128  if (abs(value) > nullzone)
129  ourcockpit.turnin = static_cast<float>(value)*0.001f;
130  if (abs(value) > 400)
131  {
134  }
135  }
136  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigWalkVertical, &value, &js)))
137  {
138  if (abs(value) > nullzone)
139  ourcockpit.moving = -static_cast<float>(value)*0.001f;
140  if (abs(value) > 400)
141  {
144  }
145  }
146 
147  if (!ourcockpit.gndvehicle)
148  {
149  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigPitch, &value, &js)))
150  {
152  {
153  if (labs(value) > nullzone) // null zone
154  viewscreen->pitchInput = static_cast<float>(value)*0.001f;
155  else
156  viewscreen->pitchInput = 0.0f;
157  }
158  else if (labs(value) > 400)
160 
161  if (js.rgdwPOV[0] == 0 || js.rgdwPOV[0] == 31500 || js.rgdwPOV[0] == 4500)
163  else if (js.rgdwPOV[0] == 18000 || js.rgdwPOV[0] == 13500 || js.rgdwPOV[0] == 22500)
165 
166  if (js.rgdwPOV[0] == 9000 || js.rgdwPOV[0] == 4500 || js.rgdwPOV[0] == 13500)
168  else if (js.rgdwPOV[0] == 27000 || js.rgdwPOV[0] == 22500 || js.rgdwPOV[0] == 31500)
170  }
171 
172  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigPitchTrim, &value, &js)))
173  {
174  if (abs(value) > 400 && viewscreen->gameclass->bus->AFCS.AutopilotEngaged)
176  viewscreen->gameclass->bus->PitchTrimScalar += fElapsedTime * 0.06f * trimlimiterC * static_cast<float>(value) * 0.001f;
178  }
179  }
180  else
181  viewscreen->pitchInput = 0.0f;
182 
183  if (!ourcockpit.gndvehicle)
184  {
185  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigRoll, &value, &js)))
186  {
188  {
189  if (labs(value) > nullzone)
190  viewscreen->rollInput = static_cast<float>(value)*0.001f;
191  else
192  viewscreen->rollInput = 0.0f;
193  }
194  else if (labs(value) > 400)
196  }
197  }
198  else
199  viewscreen->rollInput = 0.0f;
200 
201  if (!ourcockpit.gndvehicle)
202  {
203  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigYaw, &value, &js)))
204  {
205  if (!ourcockpit.wheeled || playerships[0].reference != REF_ONGROUND)
206  {
207  if (labs(value) > nullzone)
208  viewscreen->yawInput = static_cast<float>(value)*0.001f;
209  else
210  viewscreen->yawInput = 0.0f;
211  }
212  else
213  {
214  viewscreen->yawInput = static_cast<float>(value)*0.001f * fabsf(static_cast<float>(value)*0.001f);
215  }
216  }
217  }
218  else // ground vehicle
219  {
220  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigSteer, &value, &js)))
221  {
222  viewscreen->yawInput = static_cast<float>(value)*0.001f * fabsf(static_cast<float>(value)*0.001f);
223  if (fabsf(viewscreen->yawInput) > 0.4f)
224  {
227  }
228 
229  static unsigned char oldButton4 = 0, oldButton5 = 0;
230  if (oldButton4 != js.rgbButtons[4] && js.rgbButtons[4])
232  if (oldButton5 != js.rgbButtons[5] && js.rgbButtons[5])
234  oldButton4 = js.rgbButtons[4];
235  oldButton5 = js.rgbButtons[5];
236  }
237  }
238 
239  if (!ourcockpit.gndvehicle)
240  {
241  if (ourcockpit.engines > 0 && SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigThrustLeft, &value, &js)))
242  {
244  viewscreen->gameclass->bus->EngineThrustLever[0] = static_cast<float>(-value + 1000) / 2000.0f;
245  else
246  viewscreen->gameclass->bus->AFCS.DesiredClosingSpeed = powf(static_cast<float>(-value + 1000) / 2000.0f, 4.0f)*12.0f; // 12 km/s
247  }
248  if (ourcockpit.engines > 1 && SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigThrustRight, &value, &js)))
249  {
251  {
252  if (ourcockpit.engines == 2)
253  viewscreen->gameclass->bus->EngineThrustLever[1] = static_cast<float>(-value + 1000) / 2000.0f;
254  else if (ourcockpit.engines == 3)
255  viewscreen->gameclass->bus->EngineThrustLever[2] = static_cast<float>(-value + 1000) / 2000.0f;
256  }
257  }
258  }
259  else
260  {
261  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigGas, &value, &js)))
262  {
263  viewscreen->gameclass->bus->EngineThrustLever[0] = static_cast<float>(-value + 1000) / 2000.0f;
264  if (viewscreen->gameclass->bus->EngineThrustLever[0] > 0.40f)
265  {
268  }
269  }
270  }
271 
272  if (!ourcockpit.gndvehicle)
273  {
274  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigLeftToeBrake, &value, &js)))
275  {
276  viewscreen->gameclass->bus->LeftBrake = static_cast<float>(-value + 1000) / 2000.0f;
277  }
278  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigRightToeBrake, &value, &js)))
279  {
280  viewscreen->gameclass->bus->RightBrake = static_cast<float>(-value + 1000) / 2000.0f;
281  }
282  }
283  else
284  {
285  if (SUCCEEDED(Poll(&viewscreen->gameclass->config.inputConfigBrake, &value, &js)))
286  {
287  viewscreen->gameclass->bus->LeftBrake = viewscreen->gameclass->bus->RightBrake = static_cast<float>(-value + 1000) / 2000.0f;
288  if (viewscreen->gameclass->bus->RightBrake > 0.4f)
289  {
292  }
293  }
294  }
295 
296  /*
297  // These were copied out of propulsion!
298  // Force-Feedback
299  if (viewscreen->gameclass->config.g_bFeedback && viewscreen->advanceframe)
300  {
301  if (FAILED(viewscreen->SetDeviceForcesXY()))
302  {
303  viewscreen->gameclass->config.g_bFeedback = false;
304  }
305  }
306  // Force-feedback
307  if (viewscreen->gameclass->config.g_bFeedback && viewscreen->advanceframe)
308  {
309  if (viewscreen->gameclass->bus->IndicatedAirspeedKms > 0.04f)
310  viewscreen->g_nXForce = (int)(viewscreen->ptrPropulsion->qz*viewscreen->roll*300.0f); // qz figured in vertical translation area
311  else
312  viewscreen->g_nXForce = (int)(viewscreen->roll*195493.0f);
313  }
314  // Force-feedback
315  if (viewscreen->gameclass->config.g_bFeedback && viewscreen->advanceframe)
316  {
317  if (viewscreen->gameclass->bus->IndicatedAirspeedKms > 0.04f)
318  viewscreen->g_nYForce = (int)(viewscreen->ptrPropulsion->qz*viewscreen->pitch*300.0f);
319  else
320  viewscreen->g_nYForce = (int)(viewscreen->pitch*195493.0f);
321  }
322  */
323 }
324 
325 void joystick::Initialize(HWND prmHWND)
326 {
327  hDlg = prmHWND;
328 
329  logger->AddToCallStack("joystick::Initialize");
330 
331  EnumDevices(); // only need to do again if something about the peripheral configuration changes
332 
348 }
349 
351 {
352  logger->AddToCallStack("joystick::EnumDevices");
353 
354  HRESULT hr;
355 
356  deviceList.clear();
357 
358  logger->Log("joystick::EnumDevices Starting...");
359  if (FAILED(hr = viewscreen->g_pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, &EnumDevicesCallback, this, DIEDFL_ATTACHEDONLY)))
360  {
361  logger->Log("joystick::EnumDevices() failed!", Logger::Level::Warn);
362  return hr;
363  }
364 
365  logger->Log("joystick::EnumDevices Done!");
366  return S_OK;
367 }
368 
369 void joystick::InitializeDevice(InputConfig* config, std::string control)
370 {
371  logger->AddToCallStack("joystick::InitializeDevice");
372 
373  config->friendlyName = control;
374 
375  // Because we can configure it on the fly, we have to release them
376  char msg[199];
377  sprintf_s(msg, 199, "joystick::InitializeDevice Releasing %s", control.c_str());
378  logger->Log(msg);
379  SAFE_RELEASE(config->g_pJoystick);
380 
381  if (config->guid == MYGUID_DEFAULT) // not yet configured, no client.cfg
382  {
383  if (!deviceList.empty())
384  {
385  int priority = 10;
386  for (size_t device = 0; device < deviceList.size(); device++)
387  {
388  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
389  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
390  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
391  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
392  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
393  control == "Look Lateral")
394  {
395  config->guid = deviceList.at(device).guidInstance;
396  config->axis = 3; // X Rotation
397  }
398  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
399  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
400  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
401  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
402  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
403  control == "Look Vertical")
404  {
405  config->guid = deviceList.at(device).guidInstance;
406  config->axis = 4; // Y Rotation
407  }
408  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
409  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
410  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
411  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
412  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
413  control == "Turn")
414  {
415  config->guid = deviceList.at(device).guidInstance;
416  config->axis = 0; // X Axis
417  }
418  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
419  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
420  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
421  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
422  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
423  control == "Walk")
424  {
425  config->guid = deviceList.at(device).guidInstance;
426  config->axis = 1; // Y Axis
427  }
428  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-55 Rhino Stick") == 0 ||
429  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-56 Rhino Stick") == 0 ||
430  wcscmp(deviceList.at(device).tszInstanceName, L"WingMan Force 3D") == 0 ||
431  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech WingMan Force 3D USB") == 0 ||
432  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Cyborg USB Stick") == 0 ||
433  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech Extreme 3D") == 0 ||
434  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek ST290 Pro") == 0 ||
435  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas X") == 0 ||
436  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas") == 0 ||
437  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas 4") == 0) &&
438  control == "Pitch" && priority > 1)
439  {
440  config->guid = deviceList.at(device).guidInstance;
441  config->axis = 1; // Y Axis
442  priority = 1;
443  }
444  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
445  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
446  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
447  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
448  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
449  control == "Pitch" && priority > 9)
450  {
451  config->guid = deviceList.at(device).guidInstance;
452  config->axis = 1; // Y Axis
453  priority = 9;
454  }
455  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-55 Rhino Stick") == 0 ||
456  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-56 Rhino Stick") == 0 ||
457  wcscmp(deviceList.at(device).tszInstanceName, L"WingMan Force 3D") == 0 ||
458  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech WingMan Force 3D USB") == 0 ||
459  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Cyborg USB Stick") == 0 ||
460  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech Extreme 3D") == 0 ||
461  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek ST290 Pro") == 0 ||
462  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas X") == 0 ||
463  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas") == 0 ||
464  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas 4") == 0) &&
465  control == "Roll" && priority > 1)
466  {
467  config->guid = deviceList.at(device).guidInstance;
468  config->axis = 0; // X Axis
469  priority = 1;
470  }
471  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
472  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
473  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
474  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
475  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
476  control == "Roll" && priority > 9)
477  {
478  config->guid = deviceList.at(device).guidInstance;
479  config->axis = 0; // X Axis
480  priority = 9;
481  }
482  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-55 Rhino Stick") == 0 ||
483  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-56 Rhino Stick") == 0 ||
484  wcscmp(deviceList.at(device).tszInstanceName, L"WingMan Force 3D") == 0 ||
485  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech WingMan Force 3D USB") == 0 ||
486  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Cyborg USB Stick") == 0 ||
487  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech Extreme 3D") == 0 ||
488  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek ST290 Pro") == 0 ||
489  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas X") == 0 ||
490  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas") == 0 ||
491  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas 4") == 0) &&
492  control == "Yaw" && priority > 1)
493  {
494  config->guid = deviceList.at(device).guidInstance;
495  config->axis = 5; // Z Rotation
496  priority = 1;
497  }
498  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-55 Rhino Throttle") == 0 ||
499  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-56 Rhino Throttle") == 0) &&
500  control == "Left Thrust" && priority > 1)
501  {
502  config->guid = deviceList.at(device).guidInstance;
503  config->axis = 0; // X Axis
504  priority = 1;
505  }
506  if ((wcscmp(deviceList.at(device).tszInstanceName, L"WingMan Force 3D") == 0 ||
507  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech WingMan Force 3D USB") == 0) &&
508  control == "Left Thrust" && priority > 2)
509  {
510  config->guid = deviceList.at(device).guidInstance;
511  config->axis = 6; // Slider 1
512  priority = 2;
513  }
514  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Cyborg USB Stick") == 0 ||
515  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech Extreme 3D") == 0 ||
516  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek ST290 Pro") == 0 ||
517  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas X") == 0 ||
518  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas") == 0 ||
519  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas 4") == 0) &&
520  control == "Left Thrust" && priority > 2)
521  {
522  config->guid = deviceList.at(device).guidInstance;
523  config->axis = 2; // Z Axis
524  priority = 2;
525  }
526  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
527  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
528  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
529  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
530  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
531  control == "Left Thrust" && priority > 9)
532  {
533  config->guid = deviceList.at(device).guidInstance;
534  config->axis = 2; // Z Axis
535  config->split = true;
536  priority = 9;
537  }
538  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-55 Rhino Throttle") == 0 ||
539  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Pro Flight X-56 Rhino Throttle") == 0) &&
540  control == "Right Thrust" && priority > 1)
541  {
542  config->guid = deviceList.at(device).guidInstance;
543  config->axis = 1; // Y Axis
544  priority = 1;
545  }
546  if ((wcscmp(deviceList.at(device).tszInstanceName, L"WingMan Force 3D") == 0 ||
547  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech WingMan Force 3D USB") == 0) &&
548  control == "Right Thrust" && priority > 2)
549  {
550  config->guid = deviceList.at(device).guidInstance;
551  config->axis = 6; // Slider 1
552  priority = 2;
553  }
554  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Saitek Cyborg USB Stick") == 0 ||
555  wcscmp(deviceList.at(device).tszInstanceName, L"Logitech Extreme 3D") == 0 ||
556  wcscmp(deviceList.at(device).tszInstanceName, L"Saitek ST290 Pro") == 0 ||
557  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas X") == 0 ||
558  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas") == 0 ||
559  wcscmp(deviceList.at(device).tszInstanceName, L"T.Flight Hotas 4") == 0) &&
560  control == "Right Thrust" && priority > 2)
561  {
562  config->guid = deviceList.at(device).guidInstance;
563  config->axis = 2; // Z Axis
564  priority = 2;
565  }
566  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
567  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
568  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
569  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
570  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
571  control == "Right Thrust" && priority > 9)
572  {
573  config->guid = deviceList.at(device).guidInstance;
574  config->axis = 2; // Z Axis
575  config->split = true;
576  priority = 9;
577  }
578  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
579  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
580  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
581  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
582  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
583  control == "Left Toe Brake" && priority > 9)
584  {
585  config->guid = deviceList.at(device).guidInstance;
586  config->axis = 2; // Z Axis
587  config->split = true;
588  config->invert = true;
589  priority = 9;
590  }
591  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
592  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
593  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
594  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
595  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
596  control == "Right Toe Brake" && priority > 9)
597  {
598  config->guid = deviceList.at(device).guidInstance;
599  config->axis = 2; // Z Axis
600  config->split = true;
601  config->invert = true;
602  priority = 9;
603  }
604  if (wcscmp(deviceList.at(device).tszInstanceName, L"Controller (PXN-V3II)") == 0 && control == "Steering" && priority > 1)
605  {
606  config->guid = deviceList.at(device).guidInstance;
607  config->axis = 0;
608  priority = 1;
609  }
610  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
611  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
612  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
613  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
614  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
615  control == "Steering" && priority > 9)
616  {
617  config->guid = deviceList.at(device).guidInstance;
618  config->axis = 0; // X Axis
619  priority = 9;
620  }
621  if (wcscmp(deviceList.at(device).tszInstanceName, L"Controller (PXN-V3II)") == 0 && control == "Gas" && priority > 1)
622  {
623  config->guid = deviceList.at(device).guidInstance;
624  config->axis = 2; // Z Axis
625  config->split = true;
626  priority = 1;
627  }
628  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
629  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
630  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
631  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
632  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
633  control == "Gas" && priority > 9)
634  {
635  config->guid = deviceList.at(device).guidInstance;
636  config->axis = 2; // Z Axis
637  config->split = true;
638  priority = 9;
639  }
640  if (wcscmp(deviceList.at(device).tszInstanceName, L"Controller (PXN-V3II)") == 0 && control == "Brake" && priority > 1)
641  {
642  config->guid = deviceList.at(device).guidInstance;
643  config->axis = 2; // Z Axis
644  config->split = true;
645  config->invert = true;
646  priority = 1;
647  }
648  if ((wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox One For Windows)") == 0 ||
649  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (XBOX 360 For Windows)") == 0 ||
650  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (ZD Game For Windows)") == 0 ||
651  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Gamepad for Xbox 360)") == 0 ||
652  wcscmp(deviceList.at(device).tszInstanceName, L"Controller (Xbox 360 Wireless Receiver for Windows)") == 0) &&
653  control == "Brake" && priority > 9)
654  {
655  config->guid = deviceList.at(device).guidInstance;
656  config->axis = 2; // Z Axis
657  config->split = true;
658  config->invert = true;
659  priority = 9;
660  }
661  }
662  // but then we would take for example the flight controllers for flight mappings, throttle for throttle mappings ... steering wheel if they have steering wheel
663  // here is where we would find and use an appropriate device
664  // so if they have a Saitek Pro Flight X-55 Rhino Stick or Saitek Pro Flight X-56 Rhino Stick or Saitek Cyborg Evo
665  if (config->guid == MYGUID_DEFAULT) // still not assigned
666  {
667  config->guid = MYGUID_NULL; // keyboard and mouse
668  config->axis = 0;
669  }
670  }
671  else
672  {
673  config->guid = MYGUID_NULL;
674  }
675  }
676 
677  if (config->guid == MYGUID_NULL)
678  return;
679 
680  HRESULT hr;
681 
682  // Obtain an interface to the enumerated force feedback device.
683  if (FAILED(viewscreen->g_pDI->CreateDevice(config->guid, &config->g_pJoystick, NULL)))
684  // If it failed, then we can't use this device for some
685  // bizarre reason. (Maybe the user unplugged it while we
686  // were in the middle of enumerating it.) So continue enumerating
687  {
688  char msg[199];
689  sprintf_s(msg, 199, "Could not find the game controller assigned to: %s", control.c_str());
690  viewscreen->logger->Log(msg);
692  MessageBoxA(DXUTGetHWND(), msg, "Initialize Game Controller", MB_ICONWARNING | MB_OK);
693  return;
694  }
695 
696  // Set the data format to "simple joystick" - a predefined data format. A
697  // data format specifies which controls on a device we are interested in,
698  // and how they should be reported.
699  //
700  // This tells DirectInput that we will be passing a DIJOYSTATE structure to
701  // IDirectInputDevice8::GetDeviceState(). Even though we won't actually do
702  // it in this sample. But setting the data format is important so that the
703  // DIJOFS_* values work properly.
704  logger->Log("joystick::InitializeDevice Calling SetDataFormat...");
705  if (FAILED(hr = config->g_pJoystick->SetDataFormat(&c_dfDIJoystick)))
706  {
707  logger->Log("joystick::InitializeDevice SetDataFormat() failed!", Logger::Level::Warn);
708  return;
709  }
710  logger->Log("joystick::InitializeDevice Done with SetDataFormat!");
711 
712  // Set the cooperative level to let DInput know how this device should
713  // interact with the system and with other DInput applications.
714  // Exclusive access is required in order to perform force feedback.
715  logger->Log("joystick::InitializeDevice Calling SetCooperativeLevel...");
716  if (FAILED(hr = config->g_pJoystick->SetCooperativeLevel(hDlg, DISCL_EXCLUSIVE | DISCL_BACKGROUND)))
717  {
718  logger->Log("joystick::InitializeDevice SetCooperativeLevel() failed!", Logger::Level::Warn);
719  return;
720  }
721  logger->Log("joystick::InitializeDevice Done with SetCooperativeLevel!");
722 
723  // Enumerate and count the axes of the joystick
724  logger->Log("joystick::InitializeDevice Calling EnumObjects for axes...");
725  Wrapper wrapper;
726  wrapper.config = config;
727  wrapper.logger = logger;
728  wrapper.game = viewscreen->gameclass;
729  if (FAILED(hr = config->g_pJoystick->EnumObjects(&EnumAxesCallback, &wrapper, DIDFT_ALL))) // DIDFT_AXIS
730  {
731  logger->Log("joystick::InitializeDevice EnumObjects() failed!", Logger::Level::Warn);
732  return;
733  }
734  logger->Log("joystick::InitializeDevice Done with EnumObjects!");
735 
736  /*
737  if (config->forceFeedback)
738  {
739  // This simple sample only supports one or two axis joysticks
740 
741  if (viewscreen->g_dwNumForceFeedbackAxis < 2)
742  {
743  logger->Log("Unsupported number of force feedback axes...", Logger::Level::Warn);
744  return E_FAIL;
745  }
746 
747  viewscreen->g_dwNumForceFeedbackAxis = 2;
748 
749  // This application needs only one effect: Applying raw forces.
750  DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y };
751  LONG rglDirection[2] = { 0, 0 };
752  DICONSTANTFORCE cf = { 0 };
753 
754  DIEFFECT eff;
755  ZeroMemory(&eff, sizeof DIEFFECT);
756  eff.dwSize = sizeof(DIEFFECT);
757  eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
758  eff.dwDuration = INFINITE;
759  eff.dwSamplePeriod = 0;
760  eff.dwGain = DI_FFNOMINALMAX;
761  eff.dwTriggerButton = DIEB_NOTRIGGER;
762  eff.dwTriggerRepeatInterval = 0;
763  eff.cAxes = viewscreen->g_dwNumForceFeedbackAxis;
764  eff.rgdwAxes = rgdwAxes;
765  eff.rglDirection = rglDirection;
766  eff.lpEnvelope = 0;
767  eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
768  eff.lpvTypeSpecificParams = &cf;
769  eff.dwStartDelay = 0;
770 
771  // Create the prepared effect
772  logger->Log("Calling CreateEffect for FF...");
773  if (FAILED(hr = config->g_pJoystick->CreateEffect(GUID_ConstantForce, &eff, &viewscreen->g_pEffectCF, NULL)))
774  {
775  if (hr == DIERR_DEVICEFULL)
776  logger->Log("CreateEffect(GUID_ConstantForce) failed! The device is full.", Logger::Level::Warn);
777  else if (hr == DIERR_DEVICENOTREG)
778  logger->Log("CreateEffect(GUID_ConstantForce) failed! The device or device instance is not registered with Microsoft® DirectInput®.", Logger::Level::Warn);
779  else if (hr == DIERR_INVALIDPARAM)
780  logger->Log("CreateEffect(GUID_ConstantForce) failed! An invalid parameter was passed.", Logger::Level::Warn);
781  else if (hr == DIERR_NOTINITIALIZED)
782  logger->Log("CreateEffect(GUID_ConstantForce) failed! The object has not been initialized.", Logger::Level::Warn);
783  else
784  {
785  char msg[99];
786  sprintf_s(msg, sizeof(msg), "CreateEffect(GUID_ConstantForce) failed! Unknown cause: %X", hr);
787  logger->Log(msg, Logger::Level::Warn);
788  }
789  return;
790  }
791  logger->Log("Done with CreateEffect!");
792 
793  if (config->g_pEffectCF == nullptr)
794  {
795  logger->Log("viewscreen->g_pEffectCF is nullptr!", Logger::Level::Warn);
796  return E_FAIL;
797  }
798 
799 
800 
801  DIPERIODIC ss = { 0, 0, 0, 30000 };
802  rglDirection[0] = 1; rglDirection[1] = 0;
803 
804  eff.dwSize = sizeof(DIEFFECT);
805  eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
806  eff.dwDuration = INFINITE;
807  eff.dwSamplePeriod = 0;
808  eff.dwGain = DI_FFNOMINALMAX;
809  eff.dwTriggerButton = DIEB_NOTRIGGER;
810  eff.dwTriggerRepeatInterval = 0;
811  eff.cAxes = viewscreen->g_dwNumForceFeedbackAxis;
812  eff.rgdwAxes = rgdwAxes;
813  eff.rglDirection = rglDirection;
814  eff.lpEnvelope = 0;
815  eff.cbTypeSpecificParams = sizeof(DIPERIODIC);
816  eff.lpvTypeSpecificParams = &ss;
817  eff.dwStartDelay = 0;
818 
819  // Create the prepared effect
820  logger->Log("Calling CreateEffect (round 2)...");
821  if (FAILED(hr = config->g_pJoystick->CreateEffect(GUID_Square, &eff, &viewscreen->g_pEffectSS, NULL)))
822  {
823  if (hr == DIERR_DEVICEFULL)
824  logger->Log("CreateEffect(GUID_Square) failed! The device is full.", Logger::Level::Warn);
825  else if (hr == DIERR_DEVICENOTREG)
826  logger->Log("CreateEffect(GUID_Square) failed! The device or device instance is not registered with Microsoft® DirectInput®.", Logger::Level::Warn);
827  else if (hr == DIERR_INVALIDPARAM)
828  logger->Log("CreateEffect(GUID_Square) failed! An invalid parameter was passed.", Logger::Level::Warn);
829  else if (hr == DIERR_NOTINITIALIZED)
830  logger->Log("CreateEffect(GUID_Square) failed! The object has not been initialized.", Logger::Level::Warn);
831  else
832  {
833  char msg[99];
834  sprintf_s(msg, sizeof(msg), "CreateEffect(GUID_Square) failed! Unknown cause: %X", hr);
835  logger->Log(msg, Logger::Level::Warn);
836  }
837  return hr;
838  }
839  logger->Log("Done with CreateEffect (round 2)!");
840  if (viewscreen->g_pEffectSS == nullptr)
841  {
842  logger->Log("viewscreen->g_pEffectSS is nullptr!", Logger::Level::Warn);
843  return E_FAIL;
844  }
845 
846  viewscreen->g_pJoystick->Acquire();
847  if (viewscreen->g_pEffectCF)
848  viewscreen->g_pEffectCF->Start(1, 0); // Start the effect
849  if (viewscreen->g_pEffectSS)
850  viewscreen->g_pEffectSS->Start(1, 0); // Start the effect
851 
852  } // End of force-feedback section
853  */
854 
855  logger->AddToCallStack("joystick::InitializeDevice DONE");
856 }
857 
858 BOOL CALLBACK joystick::EnumAxesCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext)
859 {
860  Wrapper* wrapper = static_cast<Wrapper*>(pContext);
861  //InputConfig* config = static_cast<InputConfig*>(pContext);
862 
863  /*
864  DWORD* pdwNumForceFeedbackAxis = &instance->g_dwNumForceFeedbackAxis;
865 
866  if ((pdidoi->dwFlags & DIDOI_FFACTUATOR) != 0)
867  (*pdwNumForceFeedbackAxis)++;
868  */
869 
870  // For axes that are returned, set the DIPROP_RANGE property for the
871  // enumerated axis in order to scale min/max values.
872  if (pdidoi->dwType & DIDFT_AXIS)
873  {
874  DIPROPRANGE diprg;
875  diprg.diph.dwSize = sizeof(DIPROPRANGE);
876  diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
877  diprg.diph.dwHow = DIPH_BYID;
878  diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis
879  // ReSharper disable once CppAssignedValueIsNeverUsed
880  diprg.lMin = -1000;
881  // ReSharper disable once CppAssignedValueIsNeverUsed
882  diprg.lMax = +1000;
883 
884  // Set the range for the axis
885  HRESULT hr;
886  if (FAILED(hr = wrapper->config->g_pJoystick->SetProperty(DIPROP_RANGE, &diprg.diph)))
887  {
888  char msg[199];
889  sprintf_s(msg, 199, "Failed to SetProperty of DIPROP_RANGE on %S: %i", pdidoi->tszName, hr);
890  wrapper->logger->Log(msg, Logger::Level::Error);
891  wrapper->game->ToggleFullScreen(false);
892  MessageBoxA(nullptr, msg, "Could not EnumAxesCallback", MB_ICONERROR | MB_OK);
893  }
894  }
895 
896  return DIENUM_CONTINUE;
897 }
898 
899 BOOL CALLBACK joystick::EnumDevicesCallback(const DIDEVICEINSTANCE* pInst, VOID* pContext)
900 {
901  joystick* instance = static_cast<joystick*>(pContext);
902  instance->logger->AddToCallStack("joystick::EnumFFDevicesCallback");
903 
904  if (!instance->viewscreen->g_pDI)
905  {
906  instance->logger->Log("viewscreen->g_pDI is nullptr!", Logger::Level::Error);
907  return DIENUM_CONTINUE;
908  }
909 
910  if (!pInst)
911  {
912  instance->logger->Log("pInst is nullptr!", Logger::Level::Error);
913  return DIENUM_CONTINUE;
914  }
915 
916  try
917  {
918  // Obtain an interface to the enumerated force feedback device.
919  LPDIRECTINPUTDEVICE8 pDevice;
920  if (FAILED(instance->viewscreen->g_pDI->CreateDevice(pInst->guidInstance, &pDevice, NULL)))
921  // If it failed, then we can't use this device for some
922  // bizarre reason. (Maybe the user unplugged it while we
923  // were in the middle of enumerating it.) So continue enumerating
924  {
925  instance->logger->Log("This one failed, continue enumerating...");
926  return DIENUM_CONTINUE;
927  }
928  }
929  catch (const std::exception& e)
930  {
931  instance->logger->Log(const_cast<char *>(e.what()), Logger::Level::Error);
932  }
933 
934  char msg[999];
935  sprintf_s(msg, 999, "Found a good device, adding to list: %S", pInst->tszInstanceName);
936  instance->logger->Log(msg);
937 
938  instance->deviceList.emplace_back(*pInst);
939 
940  return DIENUM_CONTINUE;
941 }
942 
943 /*
944 HRESULT joystick::SetDeviceForcesXY() const
945 {
946  logger->AddToCallStack("joystick::SetDeviceForcesXY");
947 
948  HRESULT hr;
949  LONG rglDirection[2];
950  //DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y };
951  DICONSTANTFORCE cf;
952 
953  if (g_dwNumForceFeedbackAxis == 1)
954  {
955  cf.lMagnitude = g_nXForce;
956  rglDirection[0] = rglDirection[1] = 0;
957  }
958  else
959  {
960  rglDirection[0] = g_nXForce;
961  rglDirection[1] = g_nYForce;
962  cf.lMagnitude = (DWORD)sqrt(pow((double)g_nXForce, 2) + pow((double)g_nYForce, 2));
963  }
964 
965  if (cf.lMagnitude > DI_FFNOMINALMAX)
966  cf.lMagnitude = DI_FFNOMINALMAX;
967  if (rglDirection[0] > DI_FFNOMINALMAX)
968  rglDirection[0] = DI_FFNOMINALMAX;
969 
970 
971  DIEFFECT eff;
972  eff.dwSize = sizeof(DIEFFECT);
973  eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
974  eff.cAxes = g_dwNumForceFeedbackAxis;
975  eff.rglDirection = rglDirection;
976  eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
977  eff.lpvTypeSpecificParams = &cf;
978 
979  if (g_pEffectCF == nullptr)
980  {
981 
982  return E_FAIL;
983  }
984 
985  if (FAILED(hr = g_pEffectCF->SetParameters(&eff, DIEP_DIRECTION | DIEP_TYPESPECIFICPARAMS)))
986  {
987  return hr;
988  }
989 
990 
991  DIPERIODIC ss;
992 
993  if (gameclass->bus->IndicatedAirspeedKms > 0.02f) // Greater than stall speed
994  {
995  float f_temp = fabsf(D3DXToDegree(aoa));
996  if (f_temp > 9.0f && f_temp < 15.0f)
997  ss.dwMagnitude = (unsigned long)((f_temp - 9.0f)*1666.7f);
998  else if (f_temp >= 15.0f)
999  ss.dwMagnitude = 10000L;
1000  else
1001  ss.dwMagnitude = 0L;
1002  }
1003  else
1004  ss.dwMagnitude = 0L;
1005 
1006  ss.dwPeriod = 30000L;
1007  ss.dwPhase = 0L;
1008  ss.lOffset = 0L;
1009 
1010  eff.cbTypeSpecificParams = sizeof(DIPERIODIC);
1011  eff.lpvTypeSpecificParams = &ss;
1012 
1013  if (FAILED(hr = g_pEffectSS->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS)))
1014  return hr;
1015 }
1016 */
HRESULT EnumDevices()
Definition: joystick.cpp:350
InputConfig inputConfigLeftToeBrake
Definition: config.h:35
void Initialize(HWND prmHWND)
Definition: joystick.cpp:325
bool DismissHelp(int helpId, int nControlID=GUI_UNDERSTOOD)
Scockpit ourcockpit
Definition: globals.cpp:176
float yawInput
Definition: Viewscreen.h:237
float PitchTrimScalar
Definition: Bus.h:316
InputConfig * config
Definition: joystick.h:37
Logger * logger
Definition: joystick.h:32
std::vector< DIDEVICEINSTANCE > deviceList
Definition: joystick.h:27
struct Bus::Afcs AFCS
float targetLeftright
Definition: Viewscreen.h:311
float RightBrake
Definition: Bus.h:289
Config config
Definition: GameClass.h:102
HRESULT Poll(InputConfig *config, long *value, DIJOYSTATE *js) const
Definition: joystick.cpp:13
GameClass * gameclass
Definition: Viewscreen.h:292
void InitializeDevice(InputConfig *config, std::string control)
Definition: joystick.cpp:369
bool wheeled
Definition: globals.h:605
InformationDialog * informationDialog
Definition: gui.h:789
HWND hDlg
Definition: joystick.h:33
void AutopilotDisconnect() const
Definition: GameClass.cpp:2233
s_network_objects playerships[MAX_SCAN]
Definition: globals.cpp:174
bool DorOn
Definition: Bus.h:130
float rollInput
Definition: Viewscreen.h:237
std::string friendlyName
Definition: InputConfig.h:24
void Update(float fElapsedTime) const
Definition: joystick.cpp:84
InputConfig inputConfigGas
Definition: config.h:33
float rcsThrustRequestY
Definition: Viewscreen.h:239
InputConfig inputConfigRoll
Definition: config.h:27
InputConfig inputConfigLookVertical
Definition: config.h:38
void GearUpShift() const
Definition: GameClass.cpp:2070
float leftlimit
Definition: Viewscreen.h:314
void ToggleFullScreen(bool goFullScreen)
Definition: GameClass.cpp:269
unsigned char axis
Definition: InputConfig.h:14
joystick(Viewscreen *ptr)
Definition: joystick.cpp:6
float turnin
Definition: globals.h:661
float uplimit
Definition: Viewscreen.h:314
InputConfig inputConfigThrustLeft
Definition: config.h:29
float moving
Definition: globals.h:660
LPDIRECTINPUTDEVICE8 g_pJoystick
Definition: InputConfig.h:22
InputConfig inputConfigThrustRight
Definition: config.h:30
float DesiredClosingSpeed
Definition: Bus.h:127
const GUID MYGUID_DEFAULT
Definition: Guids.h:5
float targetUpdown
Definition: Viewscreen.h:312
InputConfig inputConfigPitchTrim
Definition: config.h:39
float Clamp(float val, float min, float max)
Definition: MathUtilities.h:3
InputConfig inputConfigPitch
Definition: config.h:26
char engines
Definition: globals.h:627
bool hasMoved
Definition: InputConfig.h:23
float pitchInput
Definition: Viewscreen.h:237
Logger * logger
Definition: joystick.h:38
InputConfig inputConfigBrake
Definition: config.h:34
float rightlimit
Definition: Viewscreen.h:314
Viewscreen * viewscreen
Definition: joystick.h:31
float uptranslimit
Definition: globals.h:610
float lrtranslimit
Definition: globals.h:610
static BOOL CALLBACK EnumDevicesCallback(const DIDEVICEINSTANCE *pInst, VOID *pContext)
Definition: joystick.cpp:899
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
const GUID MYGUID_NULL
Definition: Guids.h:3
LPDIRECTINPUT8 g_pDI
Definition: Viewscreen.h:96
InputConfig inputConfigRightToeBrake
Definition: config.h:36
float rcsThrustRequestX
Definition: Viewscreen.h:239
bool TvmOn
Definition: Bus.h:126
float downlimit
Definition: Viewscreen.h:314
HMI * GUI
Definition: GameClass.h:110
InputConfig inputConfigWalkVertical
Definition: config.h:41
#define trimlimiterC
Definition: globals.h:33
bool AutopilotEngaged
Definition: Bus.h:74
InputConfig inputConfigWalkLateral
Definition: config.h:40
float LeftBrake
Definition: Bus.h:289
bool gndvehicle
Definition: globals.h:604
InputConfig inputConfigYaw
Definition: config.h:28
void AddToCallStack(const char *msg)
Definition: Logger.cpp:86
static BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE *pdidoi, VOID *pContext)
Definition: joystick.cpp:858
Bus * bus
Definition: GameClass.h:112
GameClass * game
Definition: joystick.h:39
void GearDownShift() const
Definition: GameClass.cpp:2133
float dntranslimit
Definition: globals.h:610
long oldValue
Definition: InputConfig.h:25
InputConfig inputConfigSteer
Definition: config.h:32
Logger * logger
Definition: Viewscreen.h:293
InputConfig inputConfigLookLateral
Definition: config.h:37
float EngineThrustLever[MAX_ENGINES]
Definition: Bus.h:264
const int nullzone
Definition: joystick.h:28