/ source / blood / src / controls.h
controls.h
  1  //-------------------------------------------------------------------------
  2  /*
  3  Copyright (C) 2010-2019 EDuke32 developers and contributors
  4  Copyright (C) 2019 Nuke.YKT
  5  
  6  This file is part of NBlood.
  7  
  8  NBlood is free software; you can redistribute it and/or
  9  modify it under the terms of the GNU General Public License version 2
 10  as published by the Free Software Foundation.
 11  
 12  This program is distributed in the hope that it will be useful,
 13  but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 15  
 16  See the GNU General Public License for more details.
 17  
 18  You should have received a copy of the GNU General Public License
 19  along with this program; if not, write to the Free Software
 20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 21  */
 22  //-------------------------------------------------------------------------
 23  #pragma once
 24  
 25  #pragma pack(push, 1)
 26  
 27  union BUTTONFLAGS
 28  {
 29      int8_t byte;
 30      struct
 31      {
 32          unsigned int jump : 1;
 33          unsigned int crouch : 1;
 34          unsigned int shoot : 1;
 35          unsigned int shoot2 : 1;
 36          unsigned int lookUp : 1;
 37          unsigned int lookDown : 1;
 38      };
 39  };
 40  
 41  union KEYFLAGS
 42  {
 43      int16_t word;
 44      struct
 45      {
 46          unsigned int action : 1;
 47          //unsigned int jab : 1; // unused
 48          unsigned int isTyping : 1; // new to notblood
 49          unsigned int prevItem : 1;
 50          unsigned int nextItem : 1;
 51          unsigned int useItem : 1;
 52          unsigned int prevWeapon : 1;
 53          unsigned int nextWeapon : 1;
 54          unsigned int holsterWeapon : 1;
 55          unsigned int lookCenter : 1;
 56          unsigned int lookLeft : 1;
 57          unsigned int lookRight : 1;
 58          unsigned int spin180 : 1;
 59          unsigned int pause : 1;
 60          unsigned int quit : 1;
 61          unsigned int restart : 1;
 62          unsigned int lastWeapon : 1; // new to notblood
 63      };
 64  };
 65  
 66  union USEFLAGS
 67  {
 68      uint8_t byte;
 69      struct
 70      {
 71          unsigned int useBeastVision : 1;
 72          unsigned int useCrystalBall : 1;
 73          unsigned int useJumpBoots : 1;
 74          unsigned int useMedKit : 1;
 75      };
 76  };
 77  
 78  union SYNCFLAGS
 79  {
 80      uint8_t byte;
 81      struct
 82      {
 83          unsigned int buttonChange : 1;
 84          unsigned int keyChange : 1;
 85          unsigned int useChange : 1;
 86          unsigned int weaponChange : 1;
 87          unsigned int mlookChange : 1;
 88          unsigned int run : 1;
 89      };
 90  };
 91  struct GINPUT
 92  {
 93      SYNCFLAGS syncFlags;
 94      int16_t forward;
 95      fix16_t q16turn;
 96      int16_t strafe;
 97      BUTTONFLAGS buttonFlags;
 98      KEYFLAGS keyFlags;
 99      USEFLAGS useFlags;
100      uint8_t newWeapon;
101      fix16_t q16mlook;
102  };
103  
104  #pragma pack(pop)
105  
106  extern GINPUT gInput, gNetInput;
107  extern bool bSilentAim;
108  extern int32_t gMouseAim; // Should be an int32 due to being passed to OSD
109  
110  extern fix16_t gViewLook, gViewAngle;
111  extern float gViewAngleAdjust;
112  extern float gViewLookAdjust;
113  extern int gViewLookRecenter;
114  extern int gCrouchToggleState;
115  
116  extern int gWeaponRadialMenuState;
117  extern int gWeaponRadialMenuChoice;
118  
119  int32_t ctrlCheckAllInput(void);
120  void ctrlClearAllInput(void);
121  void ctrlInit();
122  void ctrlGetInput();
123  void ctrlJoystickRumble(int nTime);