@@ -179,8 +179,29 @@ struct Pad
179179};
180180typedef struct Pad Pad ;
181181
182- /// @brief A classic 4-button representation of the Pad.
183- struct DPad
182+ /// @brief 8-directional DPad-like representation of the Pad.
183+ ///
184+ /// @details Constructed with Pad.toDPad8. Useful for simple games and ports.
185+ /// The middle of the pad is a "dead zone" pressing which will not activate any direction.
186+ ///
187+ /// Implements all the same methods as DPad4.
188+ ///
189+ /// Invariant: it's not possible for opposite directions (left and right, or down and up)
190+ /// to be active at the same time. However, it's possible for heighboring directions
191+ /// (like up and right) to be active at the same time if the player presses a diagonal.
192+ ///
193+ /// For completeness, here is the full list of possible states:
194+ ///
195+ /// * right
196+ /// * right and up
197+ /// * up
198+ /// * left and up
199+ /// * left
200+ /// * left and down
201+ /// * down
202+ /// * right and down
203+ /// * none
204+ struct DPad8
184205{
185206 /// @brief If the left segment of the Pad is pressed.
186207 bool left ;
@@ -191,7 +212,17 @@ struct DPad
191212 /// @brief If the lower segment of the Pad is pressed.
192213 bool down ;
193214};
194- typedef struct DPad DPad ;
215+ typedef struct DPad8 DPad8 ;
216+
217+ enum DPad4
218+ {
219+ NONE = 0 ,
220+ LEFT = 1 ,
221+ RIGHT = 2 ,
222+ UP = 3 ,
223+ DOWN = 4 ,
224+ };
225+ typedef enum DPad4 DPad4 ;
195226
196227/// @brief State of the buttons. True is pressed, false is released.
197228struct Buttons
@@ -351,7 +382,8 @@ Angle degrees(float a);
351382AudioTime samples (int32_t s );
352383AudioTime seconds (int32_t s );
353384AudioTime miliseconds (int32_t s );
354- DPad pad_to_dpad (Pad pad );
385+ DPad8 pad_to_dpad8 (Pad pad );
386+ DPad4 pad_to_dpad4 (Pad pad );
355387
356388void clear_screen (Color c );
357389void set_color (Color c , RGB v );
0 commit comments