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