Arcade Shooter
GamePadState.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
23  enum class ButtonState
24  {
25  PRESSED,
26  RELEASED
27  };
28 
36  enum class Button
37  {
38  A,
39  B,
40  X,
41  Y,
42  START,
43  BACK,
44  LEFT_STICK,
46  RIGHT_STICK,
48  DPAD_UP,
49  DPAD_DOWN,
50  DPAD_LEFT,
51  DPAD_RIGHT
52  };
53 
61  struct GamePadDPad
62  {
67  };
68 
77  {
78  float Left;
79  float Right;
80  };
81 
90  {
93  };
94 
103  {
116  };
117 
126  {
127  bool IsConnected;
132  ALLEGRO_JOYSTICK *ID;
137  bool IsButtonDown(Button button) const
138  {
139  switch (button)
140  {
141  case Button::A: return (Buttons.A == ButtonState::PRESSED);
142  case Button::B: return (Buttons.B == ButtonState::PRESSED);
143  case Button::X: return (Buttons.X == ButtonState::PRESSED);
144  case Button::Y: return (Buttons.Y == ButtonState::PRESSED);
145 
146  case Button::START: return (Buttons.Start == ButtonState::PRESSED);
147  case Button::BACK: return (Buttons.Back == ButtonState::PRESSED);
148 
149  case Button::LEFT_STICK: return (Buttons.LeftStick == ButtonState::PRESSED);
150  case Button::LEFT_SHOULDER: return (Buttons.LeftShoulder == ButtonState::PRESSED);
151  case Button::RIGHT_STICK: return (Buttons.RightStick == ButtonState::PRESSED);
153  }
154 
155  return false;
156  }
157 
161  bool IsButtonUp(Button button) const { return !IsButtonDown(button); }
162  };
163 }
ButtonState A
Definition: GamePadState.h:104
ButtonState
Defines the possible states of a Button.
Definition: GamePadState.h:23
ButtonState Up
Definition: GamePadState.h:63
Identifies whether buttons on an Xbox Controller are pressed or released.
Definition: GamePadState.h:102
ButtonState B
Definition: GamePadState.h:105
ButtonState RightStick
Definition: GamePadState.h:114
ButtonState Back
Definition: GamePadState.h:110
ButtonState Left
Definition: GamePadState.h:65
Structure that defines the position of the left and right triggers on an Xbox Controller.
Definition: GamePadState.h:76
bool IsButtonDown(Button button) const
Determines if a button is pressed down.
Definition: GamePadState.h:137
ButtonState Right
Definition: GamePadState.h:66
GamePadDPad Dpad
The current state of the GamePad's Dpad.
Definition: GamePadState.h:131
ButtonState LeftShoulder
Definition: GamePadState.h:113
Identifies which directions on the directional pad of an Xbox Controller are being pressed...
Definition: GamePadState.h:61
Defines a vector with 2 components (x and y). This is additional information...
Definition: Vector2.h:18
GamePadButtons Buttons
The current state of the GamePad's Buttons.
Definition: GamePadState.h:128
bool IsButtonUp(Button button) const
Determines if a button is up.
Definition: GamePadState.h:161
Vector2 Right
Definition: GamePadState.h:92
GamePadThumbSticks Thumbsticks
The current state of the GamePad's Thumbsticks.
Definition: GamePadState.h:129
GamePadTriggers Triggers
The current state of the GamePad's Triggers.
Definition: GamePadState.h:130
ButtonState RightShoulder
Definition: GamePadState.h:115
Vector2 Left
Definition: GamePadState.h:91
bool IsConnected
True if the GamePad is connected, false otherwise.
Definition: GamePadState.h:127
float Left
Definition: GamePadState.h:78
ButtonState LeftStick
Definition: GamePadState.h:112
Represents specific information about the state of an Xbox Controller, including the current state of...
Definition: GamePadState.h:125
ButtonState X
Definition: GamePadState.h:106
float Right
Definition: GamePadState.h:79
ALLEGRO_JOYSTICK * ID
The underlaying allegro joystick id.
Definition: GamePadState.h:132
ButtonState Y
Definition: GamePadState.h:107
ButtonState Start
Definition: GamePadState.h:109
Button
Defines the buttons for an Xbox Controller.
Definition: GamePadState.h:36
Structure that represents the position of left and right sticks (thumbsticks) on an Xbox Controller...
Definition: GamePadState.h:89
ButtonState Down
Definition: GamePadState.h:64
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14