InputSettings.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // InputSettings.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. //
  23. // 03/31/97 JMI Started.
  24. //
  25. // 04/25/97 JMI Added execute input.
  26. //
  27. // 05/13/97 JMI Changed 'Run' to 'Walk'.
  28. // Also, added 'Suicide' and 'NextLevel'.
  29. //
  30. // 05/14/97 JMI Added pick up.
  31. //
  32. // 06/09/97 JMI Changed 'Walk' to 'Run'.
  33. //
  34. // 06/10/97 JMI Changed m_dDegreesPerSec to m_dMovingSlowDegreesPerSec and
  35. // added m_dMovingFastDegreesPerSec, m_dStillSlowDegreesPerSec,
  36. // m_dStillFastDegreesPerSec, and m_sTapRotationDegrees.
  37. //
  38. // 06/15/97 MJR Removed NextLevel.
  39. //
  40. // 07/03/97 JMI Moved InputInfo and ms_ainputinfo into CInputSettings.
  41. //
  42. // 07/06/97 JMI Changed m_au8PlayKeys[] from a U8 array to a short array,
  43. // m_asPlayKeys[].
  44. // Also, changed m_asPlayButtons to m_asPlayMouseButtons.
  45. //
  46. // 07/07/97 JMI Added m_dMouseSensitivityX and m_dMouseSensitivityY.
  47. //
  48. // 07/16/97 JMI Added Weapon10 enum.
  49. //
  50. // 07/25/97 JMI Removed PickUp enum.
  51. //
  52. // 08/04/97 JMI Added DefaultRotations().
  53. //
  54. // 08/10/97 JMI Added StrafeLeft and StrafeRight inputs.
  55. // Also, changed Jump to Revive.
  56. //
  57. // 08/12/97 JMI Removed StrafeLeft and StrafeRight inputs. Replaced with
  58. // Strafe2 which can get you the same thing if you combine
  59. // both strafes with an turn arrow key.
  60. // Also, added Run2 which is handy for similar reasons.
  61. //
  62. // 08/24/97 JMI Moved Execute and Suicide to before the weapons and changed
  63. // the weapon descriptions to reflect the actual weapons.
  64. //
  65. // 08/27/97 JMI Added pszSaveName to InputInfo.
  66. //
  67. // 08/27/97 JMI Added Fire2.
  68. //
  69. // 10/10/97 JMI Added m_sUseJoystick, JoyButtons, InputInfo.sJoyButtons.
  70. //
  71. ////////////////////////////////////////////////////////////////////////////////
  72. #ifndef INPUTSETTINGS_H
  73. #define INPUTSETTINGS_H
  74. #include "RSPiX.h"
  75. #ifdef PATHS_IN_INCLUDES
  76. #include "WishPiX/Prefs/prefs.h"
  77. #else
  78. #include "prefs.h"
  79. #endif
  80. #include "settings.h"
  81. #include "localize.h"
  82. // Game settings
  83. class CInputSettings : CSettings
  84. {
  85. ///////////////////////////////////////////////////////////////////////////
  86. // Typedefs, enums.
  87. ///////////////////////////////////////////////////////////////////////////
  88. public:
  89. typedef enum
  90. {
  91. Left,
  92. Right,
  93. Forward,
  94. Backward,
  95. Up,
  96. Down,
  97. MoveLeft,
  98. MoveRight,
  99. StrafeLeft,
  100. StrafeRight,
  101. Run,
  102. Run2,
  103. Strafe,
  104. Strafe2,
  105. Fire,
  106. Fire2,
  107. FireLeft,
  108. FireRight,
  109. FireUp,
  110. FireDown,
  111. Duck,
  112. Revive,
  113. Execute,
  114. Suicide,
  115. NextMap,
  116. NextWeapon,
  117. PrevWeapon,
  118. Weapon0,
  119. Weapon1,
  120. Weapon2,
  121. Weapon3,
  122. Weapon4,
  123. Weapon5,
  124. Weapon6,
  125. Weapon7,
  126. Weapon8,
  127. Weapon9,
  128. Weapon10,
  129. NumInputFunctions
  130. } InputFunction;
  131. typedef enum
  132. {
  133. None = 0,
  134. LeftButton = 1,
  135. RightButton = 2,
  136. MiddleButton = 4
  137. } MouseButtons;
  138. typedef enum
  139. {
  140. // None = 0,
  141. ButtonA = 1,
  142. ButtonB = 2,
  143. ButtonC = 4,
  144. ButtonD = 8
  145. } JoyButtons;
  146. // Game play input information.
  147. typedef struct
  148. {
  149. char* pszDescription; // Description of key.
  150. char* pszSaveName; // Name for INI.
  151. U8 u8DefaultKey; // Default rspScanKeys val (RSP_SK_*).
  152. short sDefMouseButtons; // Default rspGetMouse psButtons mask (MouseButtons).
  153. short sDefJoyButtons; // Default rspGetJoyState buttons mask (JoyButtons).
  154. } InputInfo;
  155. ///////////////////////////////////////////////////////////////////////////
  156. // Static members.
  157. ///////////////////////////////////////////////////////////////////////////
  158. public:
  159. // Function descriptions and default input settings.
  160. static InputInfo ms_ainputinfo[CInputSettings::NumInputFunctions];
  161. static InputInfo ms_ainputinfoOld[CInputSettings::NumInputFunctions];
  162. ///////////////////////////////////////////////////////////////////////////
  163. // Instantiable members.
  164. ///////////////////////////////////////////////////////////////////////////
  165. public:
  166. double m_dMovingSlowDegreesPerSec; // Degrees of rotation per second that the
  167. // user can achieve with the left and right
  168. // arrow keys when moving without the fast
  169. // key held down (for main dude input).
  170. double m_dMovingFastDegreesPerSec; // Degrees of rotation per second that the
  171. // user can achieve with the left and right
  172. // arrow keys when moving while holding the
  173. // 'fast' key (for main dude input).
  174. double m_dStillSlowDegreesPerSec; // Degrees of rotation per second that the
  175. // user can achieve with the left and right
  176. // arrow keys when moving without the fast
  177. // key held down (for main dude input).
  178. double m_dStillFastDegreesPerSec; // Degrees of rotation per second that the
  179. // user can achieve with the left and right
  180. // arrow keys when moving while holding the
  181. // 'fast' key (for main dude input).
  182. double m_sTapRotationDegrees; // Rotation when 'tapping' a rotate key.
  183. double m_dMouseSensitivityX; // Percentage of X mouse movement utilized.
  184. double m_dMouseSensitivityY; // Percentage of Y mouse movement utilized.
  185. // For example, if 0.50, mouse movement is
  186. // halved before interpretation by the
  187. // input logic.
  188. short m_sUseMouse; // Allow mouse input (for main dude).
  189. short m_sUseJoy; // Allow joystick input.
  190. U32 m_asPlayKeys[NumInputFunctions]; // Array of game play keys indexed
  191. // by an InputFunction value.
  192. U32 m_asPlayMouseButtons[NumInputFunctions]; // Array of game play mouse buttons
  193. // indexed by an InputFunction value.
  194. U32 m_asPlayJoyButtons[NumInputFunctions]; // Array of game play joystick buttons
  195. // indexed by an InputFunction value.
  196. short m_sJoyStartButton; // Default button to use as "Start"
  197. short m_sJoyMenuUpButton; // Default button to use as "Menu Up"
  198. short m_sJoyMenuDownButton; // Default button to use as "Menu Down"
  199. short m_sJoyMenuLeftButton; // Default button to use as "Menu Left"
  200. short m_sJoyMenuRightButton; // Default button to use as "Menu Right"
  201. short m_sJoyMenuUpAxis; // Default button to use as "Menu Up"
  202. short m_sJoyMenuDownAxis; // Default button to use as "Menu Down"
  203. short m_sJoyMenuLeftAxis; // Default button to use as "Menu Left"
  204. short m_sJoyMenuRightAxis; // Default button to use as "Menu Right"
  205. short m_sJoyMenuConfirmButton; // Default button to use as "Confirm"
  206. short m_sJoyMenuBackButton; // Default button to use as "Back"
  207. short m_sJoyMenuBackButton2; // Other default button to use as "Back"
  208. short m_sJoyMenuDeleteKeybindButton; // Default button to use for deleting keybinds
  209. public:
  210. // Set settings to default values
  211. CInputSettings(void);
  212. // Destructor
  213. ~CInputSettings();
  214. // Read settings that are stored in preference file
  215. short LoadPrefs(
  216. RPrefs* pPrefs);
  217. // Write settings that are stored in preference file
  218. short SavePrefs(
  219. RPrefs* pPrefs);
  220. // Load settings that are stored in game file
  221. short LoadGame(
  222. RFile* pFile);
  223. // Save settings that are stored in game file
  224. short SaveGame(
  225. RFile* pFile);
  226. // Temporarily set settings for demo mode (file is for saving current settings)
  227. short PreDemo(
  228. RFile* pFile);
  229. // Restore settings to what they were prior to demo mode
  230. short PostDemo(
  231. RFile* pFile);
  232. // Set rotation values to the defaults.
  233. void DefaultRotations(void);
  234. };
  235. #endif // INPUTSETTINGS_H
  236. ////////////////////////////////////////////////////////////////////////////////
  237. // EOF
  238. ////////////////////////////////////////////////////////////////////////////////