// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_Devices_Gpio_Provider_H #define WINRT_Windows_Devices_Gpio_Provider_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.Devices.Gpio.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Foundation.Collections.2.h" #include "winrt/impl/Windows.Devices.Gpio.Provider.2.h" namespace winrt::impl { template auto consume_Windows_Devices_Gpio_Provider_IGpioControllerProvider::PinCount() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_PinCount(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_PinCount(&value)); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioControllerProvider::OpenPinProvider(int32_t pin, winrt::Windows::Devices::Gpio::Provider::ProviderGpioSharingMode const& sharingMode) const { void* gpioPinProvider{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->OpenPinProvider(pin, static_cast(sharingMode), &gpioPinProvider)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->OpenPinProvider(pin, static_cast(sharingMode), &gpioPinProvider)); } return winrt::Windows::Devices::Gpio::Provider::IGpioPinProvider{ gpioPinProvider, take_ownership_from_abi }; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::ValueChanged(winrt::Windows::Foundation::TypedEventHandler const& handler) const { winrt::event_token token{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->add_ValueChanged(*(void**)(&handler), put_abi(token))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->add_ValueChanged(*(void**)(&handler), put_abi(token))); } return token; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::ValueChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler const& handler) const { return impl::make_event_revoker(this, ValueChanged(handler)); } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::ValueChanged(winrt::event_token const& token) const noexcept { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; _winrt_abi_type->remove_ValueChanged(impl::bind_in(token)); } else { auto const _winrt_abi_type = *(abi_t**)this; _winrt_abi_type->remove_ValueChanged(impl::bind_in(token)); } } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::DebounceTimeout() const { winrt::Windows::Foundation::TimeSpan value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_DebounceTimeout(put_abi(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_DebounceTimeout(put_abi(value))); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::DebounceTimeout(winrt::Windows::Foundation::TimeSpan const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_DebounceTimeout(impl::bind_in(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_DebounceTimeout(impl::bind_in(value))); } } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::PinNumber() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_PinNumber(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_PinNumber(&value)); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::SharingMode() const { winrt::Windows::Devices::Gpio::Provider::ProviderGpioSharingMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::IsDriveModeSupported(winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinDriveMode const& driveMode) const { bool supported{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->IsDriveModeSupported(static_cast(driveMode), &supported)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->IsDriveModeSupported(static_cast(driveMode), &supported)); } return supported; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::GetDriveMode() const { winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinDriveMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetDriveMode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetDriveMode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::SetDriveMode(winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinDriveMode const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->SetDriveMode(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->SetDriveMode(static_cast(value))); } } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::Write(winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinValue const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Write(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Write(static_cast(value))); } } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProvider::Read() const { winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinValue value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Read(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Read(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProviderValueChangedEventArgs::Edge() const { winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinEdge value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_Edge(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_Edge(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Gpio_Provider_IGpioPinProviderValueChangedEventArgsFactory::Create(winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinEdge const& edge) const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Create(static_cast(edge), &value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Create(static_cast(edge), &value)); } return winrt::Windows::Devices::Gpio::Provider::GpioPinProviderValueChangedEventArgs{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Gpio_Provider_IGpioProvider::GetControllers() const { void* result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetControllers(&result)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetControllers(&result)); } return winrt::Windows::Foundation::Collections::IVectorView{ result, take_ownership_from_abi }; } template struct produce : produce_base { int32_t __stdcall get_PinCount(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().PinCount()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall OpenPinProvider(int32_t pin, int32_t sharingMode, void** gpioPinProvider) noexcept final try { clear_abi(gpioPinProvider); typename D::abi_guard guard(this->shim()); *gpioPinProvider = detach_from(this->shim().OpenPinProvider(pin, *reinterpret_cast(&sharingMode))); return 0; } catch (...) { return to_hresult(); } }; template struct produce : produce_base { int32_t __stdcall add_ValueChanged(void* handler, winrt::event_token* token) noexcept final try { zero_abi(token); typename D::abi_guard guard(this->shim()); *token = detach_from(this->shim().ValueChanged(*reinterpret_cast const*>(&handler))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall remove_ValueChanged(winrt::event_token token) noexcept final { typename D::abi_guard guard(this->shim()); this->shim().ValueChanged(*reinterpret_cast(&token)); return 0; } int32_t __stdcall get_DebounceTimeout(int64_t* value) noexcept final try { zero_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().DebounceTimeout()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_DebounceTimeout(int64_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().DebounceTimeout(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_PinNumber(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().PinNumber()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_SharingMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().SharingMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall IsDriveModeSupported(int32_t driveMode, bool* supported) noexcept final try { typename D::abi_guard guard(this->shim()); *supported = detach_from(this->shim().IsDriveModeSupported(*reinterpret_cast(&driveMode))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall GetDriveMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().GetDriveMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall SetDriveMode(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SetDriveMode(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Write(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Write(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Read(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Read()); return 0; } catch (...) { return to_hresult(); } }; #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_Edge(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Edge()); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall Create(int32_t edge, void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Create(*reinterpret_cast(&edge))); return 0; } catch (...) { return to_hresult(); } }; #endif template struct produce : produce_base { int32_t __stdcall GetControllers(void** result) noexcept final try { clear_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from>(this->shim().GetControllers()); return 0; } catch (...) { return to_hresult(); } }; } WINRT_EXPORT namespace winrt::Windows::Devices::Gpio::Provider { inline GpioPinProviderValueChangedEventArgs::GpioPinProviderValueChangedEventArgs(winrt::Windows::Devices::Gpio::Provider::ProviderGpioPinEdge const& edge) : GpioPinProviderValueChangedEventArgs(impl::call_factory([&](IGpioPinProviderValueChangedEventArgsFactory const& f) { return f.Create(edge); })) { } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif