| Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 1 |  | 
|  | 2 | #pragma once | 
|  | 3 | #include "config.h" | 
|  | 4 |  | 
|  | 5 | #include "button_factory.hpp" | 
|  | 6 | #include "button_interface.hpp" | 
|  | 7 | #include "common.hpp" | 
|  | 8 | #include "gpio.hpp" | 
|  | 9 | #include "xyz/openbmc_project/Chassis/Buttons/Button/server.hpp" | 
|  | 10 | #include "xyz/openbmc_project/Chassis/Common/error.hpp" | 
|  | 11 |  | 
|  | 12 | #include <unistd.h> | 
|  | 13 |  | 
|  | 14 | #include <phosphor-logging/elog-errors.hpp> | 
|  | 15 | #include <phosphor-logging/lg2.hpp> | 
|  | 16 |  | 
|  | 17 | static constexpr std::string_view DEBUG_SELECTOR_BUTTON = | 
|  | 18 | "DEBUG_SELECTOR_BUTTON"; | 
|  | 19 |  | 
|  | 20 | class DebugHostSelector final : | 
|  | 21 | public sdbusplus::server::object_t< | 
|  | 22 | sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>, | 
|  | 23 | public ButtonIface | 
|  | 24 |  | 
|  | 25 | { | 
|  | 26 | public: | 
| Patrick Williams | e3b4e11 | 2022-11-26 09:41:58 -0600 | [diff] [blame] | 27 | DebugHostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event, | 
| Delphine CC Chiu | ccd7db0 | 2023-02-09 14:48:53 +0800 | [diff] [blame] | 28 | ButtonConfig& buttonCfg) : | 
| Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 29 | sdbusplus::server::object_t< | 
|  | 30 | sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>( | 
|  | 31 | bus, path, action::defer_emit), | 
|  | 32 | ButtonIface(bus, event, buttonCfg) | 
|  | 33 | { | 
|  | 34 | init(); | 
|  | 35 | emit_object_added(); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | ~DebugHostSelector() | 
|  | 39 | { | 
|  | 40 | deInit(); | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | void simPress() override; | 
|  | 44 | void simRelease() override; | 
|  | 45 | void simLongPress() override; | 
|  | 46 | void handleEvent(sd_event_source* es, int fd, uint32_t revents) override; | 
|  | 47 |  | 
|  | 48 | static constexpr std::string_view getFormFactorName() | 
|  | 49 | { | 
|  | 50 | return DEBUG_SELECTOR_BUTTON; | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | static const char* getDbusObjectPath() | 
|  | 54 | { | 
|  | 55 | return DBG_HS_DBUS_OBJECT_NAME; | 
|  | 56 | } | 
|  | 57 | }; |