Refactored everything.
This commit is contained in:
		
							
								
								
									
										50
									
								
								include/okapi/impl/device/button/adiButton.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								include/okapi/impl/device/button/adiButton.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| /* | ||||
|  * This Source Code Form is subject to the terms of the Mozilla Public | ||||
|  * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||
|  */ | ||||
| #pragma once | ||||
|  | ||||
| #include "api.h" | ||||
| #include "okapi/api/device/button/buttonBase.hpp" | ||||
|  | ||||
| namespace okapi { | ||||
| class ADIButton : public ButtonBase { | ||||
|   public: | ||||
|   /** | ||||
|    * A button in an ADI port. | ||||
|    * | ||||
|    * ```cpp | ||||
|    * auto btn = ADIButton('A', false); | ||||
|    * auto invertedBtn = ADIButton('A', true); | ||||
|    * ``` | ||||
|    * | ||||
|    * @param iport The ADI port number (``[1, 8]``, ``[a, h]``, ``[A, H]``). | ||||
|    * @param iinverted Whether the button is inverted (``true`` meaning default pressed and ``false`` | ||||
|    * meaning default not pressed). | ||||
|    */ | ||||
|   ADIButton(std::uint8_t iport, bool iinverted = false); | ||||
|  | ||||
|   /** | ||||
|    * A button in an ADI port. | ||||
|    * | ||||
|    * ```cpp | ||||
|    * auto btn = ADIButton({1, 'A'}, false); | ||||
|    * auto invertedBtn = ADIButton({1, 'A'}, true); | ||||
|    * ``` | ||||
|    * | ||||
|    * @param iports The ports the button is plugged in to in the order ``{smart port, button port}``. | ||||
|    * The smart port is the smart port number (``[1, 21]``). The button port is the ADI port number | ||||
|    * (``[1, 8]``, ``[a, h]``, ``[A, H]``). | ||||
|    * @param iinverted Whether the button is inverted (``true`` meaning default pressed and ``false`` | ||||
|    * meaning default not pressed). | ||||
|    */ | ||||
|   ADIButton(std::pair<std::uint8_t, std::uint8_t> iports, bool iinverted = false); | ||||
|  | ||||
|   protected: | ||||
|   std::uint8_t smartPort; | ||||
|   std::uint8_t port; | ||||
|  | ||||
|   virtual bool currentlyPressed() override; | ||||
| }; | ||||
| } // namespace okapi | ||||
							
								
								
									
										38
									
								
								include/okapi/impl/device/button/controllerButton.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								include/okapi/impl/device/button/controllerButton.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| /* | ||||
|  * This Source Code Form is subject to the terms of the Mozilla Public | ||||
|  * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||
|  */ | ||||
| #pragma once | ||||
|  | ||||
| #include "api.h" | ||||
| #include "okapi/api/device/button/buttonBase.hpp" | ||||
| #include "okapi/impl/device/controllerUtil.hpp" | ||||
|  | ||||
| namespace okapi { | ||||
| class ControllerButton : public ButtonBase { | ||||
|   public: | ||||
|   /** | ||||
|    * A button on a Controller. | ||||
|    * | ||||
|    * @param ibtn The button id. | ||||
|    * @param iinverted Whether the button is inverted (default pressed instead of default released). | ||||
|    */ | ||||
|   ControllerButton(ControllerDigital ibtn, bool iinverted = false); | ||||
|  | ||||
|   /** | ||||
|    * A button on a Controller. | ||||
|    * | ||||
|    * @param icontroller The Controller the button is on. | ||||
|    * @param ibtn The button id. | ||||
|    * @param iinverted Whether the button is inverted (default pressed instead of default released). | ||||
|    */ | ||||
|   ControllerButton(ControllerId icontroller, ControllerDigital ibtn, bool iinverted = false); | ||||
|  | ||||
|   protected: | ||||
|   pros::controller_id_e_t id; | ||||
|   pros::controller_digital_e_t btn; | ||||
|  | ||||
|   virtual bool currentlyPressed() override; | ||||
| }; | ||||
| } // namespace okapi | ||||
		Reference in New Issue
	
	Block a user
	 Jacob
					Jacob