Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flykeyboard.cpp
Go to the documentation of this file.
1 #include "in_joystick.h"
2 #include "flykeyboard.h"
3 #include "cmd/unit_generic.h"
4 #include "navigation.h"
5 #include "autodocking.h"
6 #include "config_xml.h"
7 #include "xml_support.h"
8 #include "vs_globals.h"
9 #include "gfx/cockpit.h"
10 #include "networking/netclient.h"
11 #include "lin_time.h"
12 
14 {
15  bool switchmode;
16  bool setunvel;
17  bool setnulvel;
18  bool matchspeed;
19  bool jumpkey;
20  signed char axial;
21  signed char vertical;
22  signed char horizontal;
25  int uppress; //negative if not pressed last
26  int uprelease;
27  int downpress;
29  int leftpress;
33  int ABpress;
34  int ABrelease;
53  bool stoppress;
54  bool startpress;
55  bool dirty; //it wasn't updated...
56  bool autopilot;
58  bool ASAP;
60  bool realauto;
61  bool startcomm;
72  void UnDirty()
73  {
83  axial = vertical = horizontal = 0;
84  }
86  {
87  UnDirty();
88  }
89 };
90 
91 static vector< StarShipControlKeyboard >starshipcontrolkeys;
92 
94 {
95  while ( starshipcontrolkeys.size() <= (unsigned int) _Universe->CurrentCockpit() )
98 }
99 
100 extern void JoyStickToggleDisable();
101 FlyByKeyboard::FlyByKeyboard( unsigned int whichplayer ) : FlyByWire()
102  , axis_key( 0, 0, 0 )
103 {
104  this->last_jumped = 0;
105  this->whichplayer = whichplayer;
106  while (starshipcontrolkeys.size() <= whichplayer)
108  autopilot = NULL;
109  inauto = false;
110 
111  //Initial Joystick Mode
112  //NOTE: Perhaps it should be handled by FlyByJoystick, but it was cumbersome to do that
113  //since it handled mainly keystrokes - Any ideas?
114  static string initialJoyMode = vs_config->getVariable( "joystick", "initial_mode", "normal" );
115  joy_mode = 0;
116  if (initialJoyMode == "inertialxy")
118 
119  else if (initialJoyMode == "inertialxz")
121 
122  else if (initialJoyMode == "roll")
124 
125  else if (initialJoyMode == "bank")
127 }
128 
129 #define FBWABS( m ) (m >= 0 ? m : -m)
130 
131 void FlyByKeyboard::Execute( bool resetangvelocity )
132 {
133 #define SSCK (starshipcontrolkeys[whichplayer])
134  if (Network != NULL && !SSCK.startcomm && SSCK.commchanged && whichplayer == 0) {
135  printf( "Stopping a NETCOMM\n" );
137  SSCK.commchanged = false;
138  }
139  if (Network != NULL && SSCK.startcomm && SSCK.commchanged && whichplayer == 0) {
140  printf( "Starting a NETCOMM\n" );
142  SSCK.commchanged = false;
143  }
144  if (Network != NULL && SSCK.freq_increase) {
145  SSCK.freq_increase = false;
147  }
148  if (Network != NULL && SSCK.freq_decrease) {
149  SSCK.freq_decrease = false;
151  }
152  if (Network != NULL && SSCK.switchwebcam) {
153  SSCK.switchwebcam = false;
155  }
156  if (Network != NULL && SSCK.switchsecured) {
157  SSCK.switchsecured = false;
159  }
160  if (SSCK.setunvel) {
161  SSCK.setunvel = false;
162  Unit *t = parent->Target();
163  int neu = FactionUtil::GetNeutralFaction();
164  int upg = FactionUtil::GetUpgradeFaction();
165  static bool allowanyreference = XMLSupport::parse_bool( vs_config->getVariable( "AI", "AllowAnySpeedReference", "false" ) );
166  static bool onlyupgraderef =
167  XMLSupport::parse_bool( vs_config->getVariable( "AI", "OnlyUpgradeSpeedReference", "false" ) );
168  if (t) {
169  if ( (t->getRelation( parent ) >= 0
170  && !onlyupgraderef) || t->faction == neu || t->faction == upg || allowanyreference )
172  }
173  }
174  if (SSCK.setnulvel) {
175  SSCK.setnulvel = false;
176  parent->VelocityReference( NULL );
177  }
178  if (SSCK.switch_combat_mode) {
179  SSCK.switch_combat_mode = false;
181  }
182  if (SSCK.ASAP) {
183  SSCK.ASAP = false;
184  if (FlyByKeyboard::inauto) {
185  this->eraseType( FACING|MOVEMENT );
186  FlyByKeyboard::inauto = false;
191  }
192  } else {
193  // Use AutoDocker if docking clearance on target, otherwise use AutoPilot
194  static bool autodock =
195  XMLSupport::parse_bool( vs_config->getVariable( "test", "autodocker", "false" ) );
196  Order *autoNavigator = NULL;
197  if (autodock)
198  {
199  Unit *station = parent->Target();
200  if (Orders::AutoDocking::CanDock(parent, station))
201  {
202  autoNavigator = new Orders::AutoDocking(station);
203  }
204  }
205  if (autoNavigator == NULL)
206  {
207  autoNavigator = new Orders::AutoLongHaul();
208  autoNavigator->SetParent( parent );
209  }
210  Order::EnqueueOrderFirst(autoNavigator);
211  FlyByKeyboard::inauto = true;
213  }
214  }
215  bool enteredautopilot = false;
216  if (SSCK.realauto) {
218  if (cp)
219  cp->Autopilot( parent->Target() );
220  enteredautopilot = true;
221  SSCK.realauto = false;
222  }
223  if (autopilot)
224  autopilot->Execute();
225  if (resetangvelocity)
226  desired_ang_velocity = Vector( 0, 0, 0 );
227  static bool initial_inertial_mode = XMLSupport::parse_bool( vs_config->getVariable( "flight", "inertial::initial", "false" ) );
228  if (SSCK.dirty) {
229  //go with what's last there: no frames since last physics frame
230  if (SSCK.uppress <= 0 && SSCK.downpress <= 0) {
231  KeyboardUp( 0 );
232  } else {
233  if (SSCK.uppress > 0)
234  KeyboardUp( 1 );
235  if (SSCK.downpress > 0)
236  KeyboardUp( -1 );
237  }
238  if (SSCK.leftpress <= 0 && SSCK.rightpress <= 0) {
239  KeyboardUp( 0 );
240  } else {
241  if (SSCK.rightpress > 0)
242  KeyboardRight( 1 );
243  if (SSCK.leftpress > 0)
244  KeyboardRight( -1 );
245  }
246  if (SSCK.rollrightpress <= 0 && SSCK.rollleftpress <= 0) {
247  KeyboardRollRight( 0 );
248  } else {
249  if (SSCK.rollrightpress > 0)
250  KeyboardRollRight( 1 );
251  if (SSCK.rollleftpress > 0)
252  KeyboardRollRight( -1 );
253  }
254  if (SSCK.ABpress >= 1)
255  Afterburn( 1 );
256  else
257  Afterburn( 0 );
258  if (SSCK.joyinertialxypress > 0)
260  if (SSCK.joyinertialxzpress > 0)
262  if (SSCK.joyrollpress > 0)
264  if (SSCK.joybankpress > 0)
266  if (SSCK.inertialflightpress > 0)
267  InertialFlight( !initial_inertial_mode );
268  if (SSCK.accelpress > 0)
269  Accel( 1 );
270  if (SSCK.decelpress > 0)
271  Accel( -1 );
272  } else {
273  if (SSCK.uppress == 0 && SSCK.downpress == 0) {
274  KeyboardUp( 0 );
275  } else {
276  if (SSCK.uppress != 0 && SSCK.downpress == 0) {
277  KeyboardUp( ( (float) FBWABS( SSCK.uppress ) )/(FBWABS( SSCK.uppress )+SSCK.uprelease) );
278  } else {
279  if (SSCK.downpress != 0 && SSCK.uppress == 0) {
280  KeyboardUp( -( (float) FBWABS( SSCK.downpress ) )/(FBWABS( SSCK.downpress )+SSCK.downrelease) );
281  } else {
282  KeyboardUp( ( (float) FBWABS( SSCK.uppress )
283  -(float) FBWABS( SSCK.downpress ) )
284  /(FBWABS( SSCK.downpress )+SSCK.downrelease+FBWABS( SSCK.uppress )+SSCK.uprelease) );
285  }
286  }
287  }
288  if (SSCK.rightpress == 0 && SSCK.leftpress == 0) {
289  KeyboardRight( 0 );
290  } else {
291  if (SSCK.rightpress != 0 && SSCK.leftpress == 0) {
292  KeyboardRight( ( (float) FBWABS( SSCK.rightpress ) )/(FBWABS( SSCK.rightpress )+SSCK.rightrelease) );
293  } else {
294  if (SSCK.leftpress != 0 && SSCK.rightpress == 0) {
295  KeyboardRight( -( (float) FBWABS( SSCK.leftpress ) )/(FBWABS( SSCK.leftpress )+SSCK.leftrelease) );
296  } else {
297  KeyboardRight( ( (float) FBWABS( SSCK.rightpress )
298  -(float) FBWABS( SSCK.leftpress ) )
299  /(FBWABS( SSCK.leftpress )+SSCK.leftrelease+FBWABS( SSCK.rightpress )+SSCK.rightrelease) );
300  }
301  }
302  }
303  if (SSCK.rollrightpress == 0 && SSCK.rollleftpress == 0) {
304  KeyboardRollRight( 0 );
305  } else {
306  if (SSCK.rollrightpress != 0 && SSCK.rollleftpress == 0) {
307  KeyboardRollRight( ( (float) FBWABS( SSCK.rollrightpress ) )
308  /(FBWABS( SSCK.rollrightpress )+SSCK.rollrightrelease) );
309  } else {
310  if (SSCK.rollleftpress != 0 && SSCK.rollrightpress == 0) {
311  KeyboardRollRight( -( (float) FBWABS( SSCK.rollleftpress ) )
312  /(FBWABS( SSCK.rollleftpress )+SSCK.rollleftrelease) );
313  } else {
314  KeyboardRollRight( ( (float) FBWABS( SSCK.rollrightpress )
315  -(float) FBWABS( SSCK.rollleftpress ) )
316  /(FBWABS( SSCK.rollleftpress )+SSCK.rollleftrelease+FBWABS( SSCK.rollrightpress )
317  +SSCK.rollrightrelease) );
318  }
319  }
320  }
321  if (SSCK.accelpress != 0)
322  Accel( ( (float) FBWABS( SSCK.accelpress ) )/(FBWABS( SSCK.accelpress )+SSCK.accelrelease) );
323  if (SSCK.decelpress != 0)
324  Accel( -( (float) FBWABS( SSCK.decelpress ) )/(FBWABS( SSCK.decelpress )+SSCK.decelrelease) );
325  if (SSCK.ABpress || SSCK.ABrelease)
326  Afterburn( (SSCK.ABpress >= 1) ? 1 : 0 );
327  if (SSCK.joyinertialxypress || SSCK.joyinertialxyrelease) {
328  if (SSCK.joyinertialxypress > 0)
330 
331  else
333  }
334  if (SSCK.joyinertialxzpress || SSCK.joyinertialxzrelease) {
335  if (SSCK.joyinertialxzpress > 0)
337 
338  else
340  }
341  if (SSCK.joyrollpress || SSCK.joyrollrelease) {
342  if (SSCK.joyrollpress > 0)
344 
345  else
346  joy_mode &= ~joyModeRoll;
347  }
348  if (SSCK.joybankpress || SSCK.joybankrelease) {
349  if (SSCK.joybankpress > 0)
351 
352  else
353  joy_mode &= ~joyModeBank;
354  }
355  if (SSCK.inertialflightpress || SSCK.inertialflightrelease) {
356  if (SSCK.inertialflightpress > 0)
357  InertialFlight( !initial_inertial_mode );
358 
359  else
360  InertialFlight( initial_inertial_mode );
361  }
362  }
363  if (SSCK.stoppress) {
364  Stop( 0 );
365  SSCK.stoppress = false;
366  }
367  if (SSCK.startpress || enteredautopilot) {
368  Stop( 1 );
369  SSCK.startpress = false;
370  }
371  if (SSCK.sheltonpress > 0)
372  SheltonSlide( true );
373  else
374  SheltonSlide( false );
375  if (SSCK.switchinertialflight) {
377  SSCK.switchinertialflight = false;
378  }
379  if (SSCK.switchjoyinertialxy) {
381  SSCK.switchjoyinertialxy = false;
382  }
383  if (SSCK.switchjoyinertialxz) {
385  SSCK.switchjoyinertialxz = false;
386  }
387  if (SSCK.switchjoyroll) {
389  SSCK.switchjoyroll = false;
390  }
391  if (SSCK.switchjoybank) {
393  SSCK.switchjoybank = false;
394  }
395  if (SSCK.switchmode)
397  if (SSCK.vertical)
398  FlyByWire::DirectThrustUp( SSCK.vertical );
399  if (SSCK.horizontal)
400  FlyByWire::DirectThrustRight( SSCK.horizontal );
401  if (SSCK.axial)
403  if (SSCK.autopilot && !autopilot) {
404  autopilot = new Orders::FaceTarget( false, 1 );
405  autopilot->SetParent( parent );
406  SSCK.autopilot = false;
407  }
408  if (SSCK.autopilot || SSCK.terminateauto) {
409  if (autopilot) {
410  autopilot->Destroy();
411  autopilot = NULL;
412  }
413  SSCK.autopilot = false;
414  SSCK.terminateauto = false;
415  }
416  if (SSCK.matchspeed) {
417  SSCK.matchspeed = false;
418  Unit *targ = parent->Target();
419  if (targ)
420  MatchSpeed( targ->GetVelocity() );
421  }
422  static unsigned int counter = 0;
423  counter++;
424  if (SSCK.jumpkey) {
425  static float jump_key_delay = XMLSupport::parse_float( vs_config->getVariable( "general", "jump_key_delay", ".125" ) );
426  if ( (counter-last_jumped) > static_cast<unsigned>(jump_key_delay/SIMULATION_ATOM) || last_jumped == 0) {
427  last_jumped = counter;
429  if (parent->GetJumpStatus().drive >= 0) {
430  static soundContainer foobar;
431  if (foobar.sound == -2) {
432  static string str = vs_config->getVariable( "cockpitaudio", "jump_engaged", "jump" );
433  foobar.loadsound( str );
434  }
435  foobar.playsound();
436  }
437  }
438  SSCK.jumpkey = false;
439  } else {
441  }
442  SSCK.dirty = true;
443 #undef SSCK
444  if ( queryType( FACING|MOVEMENT ) ) {
445  Order::Execute();
446  if (queryType( FACING|MOVEMENT ) == NULL)
447  FlyByKeyboard::inauto = false;
448  done = false;
449  } else {
451  }
452 }
453 
454 //Changing the frequency doesn't kill a communication anymore until the player stopped its current one
455 //and starts a new one in that other frequency
456 
458 {
459  if (Network != NULL)
460  if (g().dirty) g().UnDirty();
461  switch (k)
462  {
463  case DOWN:
464  g().freq_decrease = true;
465  break;
466  case UP:
467  case PRESS:
468  case RELEASE:
469  case RESET:
470  break;
471  }
472 }
473 
475 {
476  if (Network != NULL)
477  if (g().dirty) g().UnDirty();
478  switch (k)
479  {
480  case DOWN:
481  g().freq_increase = true;
482  break;
483  case UP:
484  case PRESS:
485  case RELEASE:
486  case RESET:
487  break;
488  }
489 }
490 
492 {
493  if (Network != NULL)
494  if (g().dirty) g().UnDirty();
495  switch (k)
496  {
497  case DOWN:
498  case UP:
499  break;
500  case PRESS:
501  printf( "Pressed NETCOMM key !!!\n" );
502  if (g().startcomm == true)
503  g().startcomm = false;
504  else
505  g().startcomm = true;
506  g().commchanged = true;
507  break;
508  case RELEASE:
509  case RESET:
510  break;
511  }
512 }
513 
515 {
516  if (Network != NULL)
517  if (g().dirty) g().UnDirty();
518  switch (k)
519  {
520  case DOWN:
521  case UP:
522  break;
523  case PRESS:
524  printf( "Pressed SWITCHWEBCAM key !!!\n" );
525  g().switchwebcam = true;
526  break;
527  case RELEASE:
528  case RESET:
529  break;
530  }
531 }
532 
534 {
535  if (Network != NULL)
536  if (g().dirty) g().UnDirty();
537  switch (k)
538  {
539  case DOWN:
540  case UP:
541  break;
542  case PRESS:
543  printf( "Pressed SWITCHSECURED key !!!\n" );
544  g().switchsecured = true;
545  break;
546  case RELEASE:
547  case RESET:
548  break;
549  }
550 }
551 
553 {
554  if (g().dirty) g().UnDirty();
555  switch (k)
556  {
557  case UP:
558  break;
559  case DOWN:
560  g().setunvel = true;
561  break;
562  default:
563  break;
564  }
565 }
567 {
568  if (g().dirty) g().UnDirty();
569  switch (k)
570  {
571  case UP:
572  break;
573  case DOWN:
574  g().setnulvel = true;
575  break;
576  default:
577  break;
578  }
579 }
580 
582 {
583  if (g().dirty) g().UnDirty();
584  switch (k)
585  {
586  case UP:
587  g().sheltonrelease = FBWABS( g().sheltonrelease )+1;
588  break;
589  case DOWN:
590  g().sheltonpress = FBWABS( g().sheltonpress )+1;
591  break;
592  default:
593  break;
594  }
595 }
596 
598 {
599  if (g().dirty) g().UnDirty();
600  switch (k)
601  {
602  case PRESS:
603  g().switchinertialflight = true;
604  break;
605  default:
606  break;
607  }
608 }
609 
611 {
612  if (g().dirty) g().UnDirty();
613  switch (k)
614  {
615  case UP:
616  g().inertialflightrelease = FBWABS( g().inertialflightrelease )+1;
617  break;
618  case DOWN:
619  g().inertialflightpress = FBWABS( g().inertialflightpress )+1;
620  break;
621  default:
622  break;
623  }
624 }
625 
627 {
628  if (g().dirty) g().UnDirty();
629  switch (k)
630  {
631  case PRESS:
632  g().switchjoyinertialxy = true;
633  break;
634  default:
635  break;
636  }
637 }
638 
640 {
641  if (g().dirty) g().UnDirty();
642  switch (k)
643  {
644  case PRESS:
645  g().switchjoyinertialxz = true;
646  break;
647  default:
648  break;
649  }
650 }
651 
653 {
654  if (g().dirty) g().UnDirty();
655  switch (k)
656  {
657  case PRESS:
658  g().switchjoyroll = true;
659  break;
660  default:
661  break;
662  }
663 }
664 
666 {
667  if (g().dirty) g().UnDirty();
668  switch (k)
669  {
670  case PRESS:
671  g().switchjoybank = true;
672  break;
673  default:
674  break;
675  }
676 }
677 
679 {
680  if (g().dirty) g().UnDirty();
681  switch (k)
682  {
683  case UP:
684  g().joyinertialxyrelease = FBWABS( g().joyinertialxyrelease )+1;
685  break;
686  case DOWN:
687  g().joyinertialxypress = FBWABS( g().joyinertialxypress )+1;
688  break;
689  default:
690  break;
691  }
692 }
693 
695 {
696  if (g().dirty) g().UnDirty();
697  switch (k)
698  {
699  case UP:
700  g().joyinertialxzrelease = FBWABS( g().joyinertialxzrelease )+1;
701  break;
702  case DOWN:
703  g().joyinertialxzpress = FBWABS( g().joyinertialxzpress )+1;
704  break;
705  default:
706  break;
707  }
708 }
709 
711 {
712  if (g().dirty) g().UnDirty();
713  switch (k)
714  {
715  case UP:
716  g().joyrollrelease = FBWABS( g().joyrollrelease )+1;
717  break;
718  case DOWN:
719  g().joyrollpress = FBWABS( g().joyrollpress )+1;
720  break;
721  default:
722  break;
723  }
724 }
725 
727 {
728  if (g().dirty) g().UnDirty();
729  switch (k)
730  {
731  case UP:
732  g().joybankrelease = FBWABS( g().joybankrelease )+1;
733  break;
734  case DOWN:
735  g().joybankpress = FBWABS( g().joybankpress )+1;
736  break;
737  default:
738  break;
739  }
740 }
741 
743 {
744  switch (k)
745  {
746  case PRESS:
748  break;
749  case UP:
750  case RELEASE:
751  g().jumpkey = false;
752  break;
753  default:
754  break;
755  }
756 }
758 {
759  if (g().dirty) g().UnDirty();
760  switch (k)
761  {
762  case UP:
763  g().uprelease++;
764  break;
765  case DOWN:
766  g().uppress = FBWABS( g().uppress )+1;
767  break;
768  case PRESS:
769  g().uppress = FBWABS( g().uppress );
771  break;
772  case RELEASE:
773  g().uppress = -FBWABS( g().uppress );
774  break;
775  default:
776  break;
777  }
778 }
780 {
781  if (g().dirty) g().UnDirty();
782  switch (k)
783  {
784  case DOWN:
785  g().horizontal -= 1;
786  break;
787  case UP:
788  case PRESS:
789  case RELEASE:
790  case RESET:
791  break;
792  }
793 }
795 {
796  if (g().dirty) g().UnDirty();
797  switch (k)
798  {
799  case DOWN:
800  g().horizontal += 1;
801  break;
802  case UP:
803  case PRESS:
804  case RELEASE:
805  case RESET:
806  break;
807  }
808 }
810 {
811  if (g().dirty) g().UnDirty();
812  switch (k)
813  {
814  case DOWN:
815  g().vertical += 1;
816  break;
817  case UP:
818  case PRESS:
819  case RELEASE:
820  case RESET:
821  break;
822  }
823 }
825 {
826  if (g().dirty) g().UnDirty();
827  switch (k)
828  {
829  case DOWN:
830  g().vertical -= 1;
831  break;
832  case UP:
833  case PRESS:
834  case RELEASE:
835  case RESET:
836  break;
837  }
838 }
840 {
841  if (g().dirty) g().UnDirty();
842  switch (k)
843  {
844  case DOWN:
845  g().axial += 1;
846  break;
847  case UP:
848  case PRESS:
849  case RELEASE:
850  case RESET:
851  break;
852  }
853 }
855 {
856  if (g().dirty) g().UnDirty();
857  switch (k)
858  {
859  case DOWN:
860  g().axial -= 1;
861  break;
862  case UP:
863  case PRESS:
864  case RELEASE:
865  case RESET:
866  break;
867  }
868 }
869 
871 {
872  if (g().dirty) g().UnDirty();
873  switch (k)
874  {
875  case UP:
876  g().downrelease++;
877  break;
878  case DOWN:
879  g().downpress = FBWABS( g().downpress )+1;
880  break;
881  case PRESS:
882  g().downpress = FBWABS( g().downpress );
884  break;
885  case RELEASE:
886  g().downpress = -FBWABS( g().downpress );
887  break;
888  default:
889  break;
890  }
891 }
892 
894 {
895  if (g().dirty) g().UnDirty();
896  switch (k)
897  {
898  case UP:
899  g().leftrelease++;
900  break;
901  case DOWN:
902  g().leftpress = FBWABS( g().leftpress )+1;
903  break;
904  case PRESS:
905  g().leftpress = FBWABS( g().leftpress );
907  break;
908  case RELEASE:
909  g().leftpress = -FBWABS( g().leftpress );
910  break;
911  default:
912  break;
913  }
914 }
916 {
917  if (g().dirty) g().UnDirty();
918  switch (k)
919  {
920  case PRESS:
921  g().switchmode = true;
922  break;
923  default:
924  break;
925  }
926 }
928 {
929  if (g().dirty) g().UnDirty();
930  switch (k)
931  {
932  case UP:
933  g().rightrelease++;
934  break;
935  case DOWN:
936  g().rightpress = FBWABS( g().rightpress )+1;
937  break;
938  case PRESS:
939  g().rightpress = FBWABS( g().rightpress );
941  break;
942  case RELEASE:
943  g().rightpress = -FBWABS( g().rightpress );
944  break;
945  default:
946  break;
947  }
948 }
950 {
951  if (g().dirty) g().UnDirty();
952  switch (k)
953  {
954  case UP:
955  g().ABrelease++;
956  break;
957  case DOWN:
958  g().ABpress = FBWABS( g().ABpress )+1;
959  break;
960  case PRESS:
961  g().ABpress = FBWABS( g().ABpress );
962  break;
963  case RELEASE:
964  g().ABpress = -FBWABS( g().ABpress );
965  break;
966  default:
967  break;
968  }
969 }
970 
972 {
973  if (g().dirty) g().UnDirty();
974  if (k == PRESS)
975  g().realauto = true;
976 }
977 
979 {
980  if (g().dirty) g().UnDirty();
981  if (k == PRESS)
982  g().ASAP = true;
983 }
984 
986 {
987  if (g().dirty) g().UnDirty();
988  if (k == PRESS)
989  g().switch_combat_mode = true;
990 }
992 {
993  if (g().dirty) g().UnDirty();
994  if (k == PRESS)
995  g().autopilot = true;
996 }
997 
999 {
1000  if (g().dirty) g().UnDirty();
1001  if (k == PRESS)
1002  g().stoppress = true;
1003 }
1005 {
1006  if (g().dirty) g().UnDirty();
1007  switch (k)
1008  {
1009  case UP:
1010  g().accelrelease++;
1011  break;
1012  case DOWN:
1013  g().accelpress = FBWABS( g().accelpress )+1;
1014  break;
1015  case PRESS:
1016  g().accelpress = FBWABS( g().accelpress );
1017  break;
1018  case RELEASE:
1019  g().accelpress = -FBWABS( g().accelpress );
1020  break;
1021  default:
1022  break;
1023  }
1024 }
1026 {
1027  if (g().dirty) g().UnDirty();
1028  switch (k)
1029  {
1030  case UP:
1031  g().decelrelease++;
1032  break;
1033  case DOWN:
1034  g().decelpress = FBWABS( g().decelpress )+1;
1035  break;
1036  case PRESS:
1037  g().decelpress = FBWABS( g().decelpress );
1038  break;
1039  case RELEASE:
1040  g().decelpress = -FBWABS( g().decelpress );
1041  break;
1042  default:
1043  break;
1044  }
1045 }
1046 
1048 {
1049  if (g().dirty) g().UnDirty();
1050  if (k == PRESS)
1051  g().startpress = true;
1052 }
1053 
1055 {
1056  if (g().dirty) g().UnDirty();
1057  switch (k)
1058  {
1059  case UP:
1060  g().rollrightrelease++;
1061  break;
1062  case DOWN:
1063  g().rollrightpress = FBWABS( g().rollrightpress )+1;
1064  break;
1065  case PRESS:
1066  g().rollrightpress = FBWABS( g().rollrightpress );
1067  break;
1068  case RELEASE:
1069  g().rollrightpress = -FBWABS( g().rollrightpress );
1070  break;
1071  default:
1072  break;
1073  }
1074 }
1076 {
1077  if (k == PRESS) {
1078  if (g().dirty) g().UnDirty();
1079  g().matchspeed = true;
1080  }
1081 }
1083 {
1084  if (g().dirty) g().UnDirty();
1085  switch (k)
1086  {
1087  case UP:
1088  g().rollleftrelease++;
1089  break;
1090  case DOWN:
1091  g().rollleftpress = FBWABS( g().rollleftpress )+1;
1092  break;
1093  case PRESS:
1094  g().rollleftpress = FBWABS( g().rollleftpress );
1095  break;
1096  case RELEASE:
1097  g().rollleftpress = -FBWABS( g().rollleftpress );
1098  break;
1099  default:
1100  break;
1101  }
1102 }
1103