| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file controls.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 13th July 2009: Created controls.h from parts of OpenJazz.h |
| 11 | * |
| 12 | * @par Licence: |
| 13 | * Copyright (c) 2005-2012 AJ Thomson |
| 14 | * Copyright (c) 2015-2026 Carsten Teibes |
| 15 | * |
| 16 | * OpenJazz is distributed under the terms of |
| 17 | * the GNU General Public License, version 2.0 |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef OJ_CONTROLS_H |
| 22 | #define OJ_CONTROLS_Hcxx . . $ `src/io/controls.h:22:9`! |
| 23 | |
| 24 | #include "loop.h"cxx . . $ `<file>/src/loop.h`/ |
| 25 | #include "OpenJazz.h"cxx . . $ `<file>/src/OpenJazz.h`/ |
| 26 | |
| 27 | // Constants |
| 28 | |
| 29 | // Indexes for the keys / buttons / axes player controls arrays |
| 30 | #define C_UPcxx . . $ `src/io/controls.h:30:9`! 0 |
| 31 | #define C_DOWNcxx . . $ `src/io/controls.h:31:9`! 1 |
| 32 | #define C_LEFTcxx . . $ `src/io/controls.h:32:9`! 2 |
| 33 | #define C_RIGHTcxx . . $ `src/io/controls.h:33:9`! 3 |
| 34 | #define C_JUMPcxx . . $ `src/io/controls.h:34:9`! 4 |
| 35 | #define C_SWIMcxx . . $ `src/io/controls.h:35:9`! 5 |
| 36 | #define C_FIREcxx . . $ `src/io/controls.h:36:9`! 6 |
| 37 | #define C_CHANGEcxx . . $ `src/io/controls.h:37:9`! 7 /* Change weapon */ |
| 38 | #define C_ENTERcxx . . $ `src/io/controls.h:38:9`! 8 |
| 39 | #define C_ESCAPEcxx . . $ `src/io/controls.h:39:9`! 9 |
| 40 | #define C_BLASTERcxx . . $ `src/io/controls.h:40:9`! 10 |
| 41 | #define C_TOASTERcxx . . $ `src/io/controls.h:41:9`! 11 |
| 42 | #define C_MISSILEcxx . . $ `src/io/controls.h:42:9`! 12 |
| 43 | #define C_BOUNCERcxx . . $ `src/io/controls.h:43:9`! 13 |
| 44 | #define C_TNTcxx . . $ `src/io/controls.h:44:9`! 14 |
| 45 | #define C_STATScxx . . $ `src/io/controls.h:45:9`! 15 |
| 46 | #define C_PAUSEcxx . . $ `src/io/controls.h:46:9`! 16 |
| 47 | #define C_YEScxx . . $ `src/io/controls.h:47:9`! 17 |
| 48 | #define C_NOcxx . . $ `src/io/controls.h:48:9`! 18 |
| 49 | // Size of those arrays |
| 50 | #define CONTROLScxx . . $ `src/io/controls.h:50:9`! 19 |
| 51 | |
| 52 | // Time interval |
| 53 | #define T_KEYcxx . . $ `src/io/controls.h:53:9`! 200 |
| 54 | |
| 55 | |
| 56 | // Class |
| 57 | |
| 58 | union SDL_Eventcxx . . $ SDL_Event#; |
| 59 | |
| 60 | /// Keeps track of all control input |
| 61 | class Controlscxx . . $ Controls# { |
| 62 | |
| 63 | private: |
| 64 | typedef structcxx . . $ Controls#$anonymous_type_0# { |
| 65 | |
| 66 | int keycxx . . $ Controls#$anonymous_type_0#key.; ///< Keyboard key |
| 67 | bool pressedcxx . . $ Controls#$anonymous_type_0#pressed.; ///< Whether or not the key is pressed |
| 68 | |
| 69 | } Keyscxx . . $ Controls#Keys#; |
| 70 | |
| 71 | typedef structcxx . . $ Controls#$anonymous_type_1# { |
| 72 | |
| 73 | int buttoncxx . . $ Controls#$anonymous_type_1#button.; ///< Joystick button |
| 74 | bool pressedcxx . . $ Controls#$anonymous_type_1#pressed.; ///< Whether or not the button is pressed |
| 75 | |
| 76 | } Buttonscxx . . $ Controls#Buttons#; |
| 77 | |
| 78 | typedef structcxx . . $ Controls#$anonymous_type_2# { |
| 79 | |
| 80 | int axiscxx . . $ Controls#$anonymous_type_2#axis.; ///< Joystick axis |
| 81 | bool directioncxx . . $ Controls#$anonymous_type_2#direction.; ///< Axis direction |
| 82 | bool pressedcxx . . $ Controls#$anonymous_type_2#pressed.; ///< Whether or not the axis is pressed in the given direction |
| 83 | |
| 84 | } Axescxx . . $ Controls#Axes#; |
| 85 | |
| 86 | typedef structcxx . . $ Controls#$anonymous_type_3# { |
| 87 | |
| 88 | int hatcxx . . $ Controls#$anonymous_type_3#hat.; ///< Joystick hat |
| 89 | int directioncxx . . $ Controls#$anonymous_type_3#direction.; ///< Hat direction |
| 90 | bool pressedcxx . . $ Controls#$anonymous_type_3#pressed.; ///< Whether or not the hat is pressed in the given direction |
| 91 | |
| 92 | } Hatscxx . . $ Controls#Hats#; |
| 93 | |
| 94 | typedef structcxx . . $ Controls#$anonymous_type_4# { |
| 95 | |
| 96 | unsigned int timecxx . . $ Controls#$anonymous_type_4#time.; ///< The time from which the control will respond to being pressed |
| 97 | bool statecxx . . $ Controls#$anonymous_type_4#state.; ///< Whether or not the control is being used |
| 98 | |
| 99 | } ControlStatecxx . . $ Controls#ControlState#; |
| 100 | |
| 101 | Keyscxx . . $ Controls#Keys# keyscxx . . $ Controls#keys.[CONTROLScxx . . $ `src/io/controls.h:50:9`!]; |
| 102 | Buttonscxx . . $ Controls#Buttons# buttonscxx . . $ Controls#buttons.[CONTROLScxx . . $ `src/io/controls.h:50:9`!]; |
| 103 | Axescxx . . $ Controls#Axes# axescxx . . $ Controls#axes.[CONTROLScxx . . $ `src/io/controls.h:50:9`!]; |
| 104 | Hatscxx . . $ Controls#Hats# hatscxx . . $ Controls#hats.[CONTROLScxx . . $ `src/io/controls.h:50:9`!]; |
| 105 | ControlStatecxx . . $ Controls#ControlState# controlstatescxx . . $ Controls#controlstates.[CONTROLScxx . . $ `src/io/controls.h:50:9`!]; |
| 106 | |
| 107 | int cursorXcxx . . $ Controls#cursorX.; ///< X-coordinate of the cursor |
| 108 | int cursorYcxx . . $ Controls#cursorY.; ///< Y-coordinate of the cursor |
| 109 | bool cursorPressedcxx . . $ Controls#cursorPressed.; ///< Whether or not the cursor is being pressed |
| 110 | bool cursorReleasedcxx . . $ Controls#cursorReleased.; ///< Whether or not the cursor has been released |
| 111 | int wheelUpcxx . . $ Controls#wheelUp.; ///< How many times the wheel has been scrolled upwards |
| 112 | int wheelDowncxx . . $ Controls#wheelDown.; ///< How many times the wheel has been scrolled downwards |
| 113 | |
| 114 | void setCursorcxx . . $ Controls#setCursor(6908015b96d379c0). (int x, int y, bool pressed); |
| 115 | |
| 116 | public: |
| 117 | Controlscxx . . $ Controls#Controls(49f6e7a06ebc5aa8). (); |
| 118 | |
| 119 | void initcxx . . $ Controls#init(49f6e7a06ebc5aa8).(); |
| 120 | void deinitcxx . . $ Controls#deinit(49f6e7a06ebc5aa8).(); |
| 121 | |
| 122 | void setKeycxx . . $ Controls#setKey(3e454b8ccf442868). (int control, int key); |
| 123 | void setButtoncxx . . $ Controls#setButton(3e454b8ccf442868). (int control, int button); |
| 124 | void setAxiscxx . . $ Controls#setAxis(6908015b96d379c0). (int control, int axis, bool direction); |
| 125 | void setHatcxx . . $ Controls#setHat(b1146eedae1e1d0b). (int control, int hat, int direction); |
| 126 | int getKeycxx . . $ Controls#getKey(7864480464b09eea). (int control); |
| 127 | int getButtoncxx . . $ Controls#getButton(7864480464b09eea). (int control); |
| 128 | int getAxiscxx . . $ Controls#getAxis(7864480464b09eea). (int control); |
| 129 | int getAxisDirectioncxx . . $ Controls#getAxisDirection(7864480464b09eea). (int control); |
| 130 | int getHatcxx . . $ Controls#getHat(7864480464b09eea). (int control); |
| 131 | int getHatDirectioncxx . . $ Controls#getHatDirection(7864480464b09eea). (int control); |
| 132 | |
| 133 | int updatecxx . . $ Controls#update(db42b6765f9e21b0). (SDL_Eventcxx . . $ SDL_Event# *event, LoopTypecxx . . $ LoopType# type); |
| 134 | void loopcxx . . $ Controls#loop(49f6e7a06ebc5aa8). (); |
| 135 | |
| 136 | bool getStatecxx . . $ Controls#getState(83c267b20bac841a). (int control); |
| 137 | bool releasecxx . . $ Controls#release(83c267b20bac841a). (int control); |
| 138 | bool getCursorcxx . . $ Controls#getCursor(8a990ad1ed500b42). (int& x, int& y); |
| 139 | bool wasCursorReleasedcxx . . $ Controls#wasCursorReleased(c9857a73d68e59ba). (); |
| 140 | |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | // Variable |
| 145 | |
| 146 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Controlscxx . . $ Controls# controlscxx . . $ controls.; |
| 147 | |
| 148 | #endif |