// WARNING: Please don't edit this file. It was generated by Python/WinRT v2.3.0

#include "py.Windows.Devices.Custom.h"

namespace py::cpp::Windows::Devices::Custom
{
    // ----- CustomDevice class --------------------

    static PyObject* _new_CustomDevice(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Custom::CustomDevice>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Custom::CustomDevice>::type_name);
        return nullptr;
    }

    static void _dealloc_CustomDevice(py::wrapper::Windows::Devices::Custom::CustomDevice* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CustomDevice_FromIdAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 3)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Custom.CustomDevice", L"FromIdAsync", 3);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(3);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Devices::Custom::DeviceAccessMode>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Devices::Custom::DeviceSharingMode>(args, 2);

                return py::convert(winrt::Windows::Devices::Custom::CustomDevice::FromIdAsync(param0, param1, param2));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CustomDevice_GetDeviceSelector(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Custom.CustomDevice", L"GetDeviceSelector", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::guid>(args, 0);

                return py::convert(winrt::Windows::Devices::Custom::CustomDevice::GetDeviceSelector(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CustomDevice_SendIOControlAsync(py::wrapper::Windows::Devices::Custom::CustomDevice* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 3)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Custom.CustomDevice", L"SendIOControlAsync", 3);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(3);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Custom::IIOControlCode>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Storage::Streams::IBuffer>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Storage::Streams::IBuffer>(args, 2);

                return py::convert(self->obj.SendIOControlAsync(param0, param1, param2));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CustomDevice_TrySendIOControlAsync(py::wrapper::Windows::Devices::Custom::CustomDevice* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 3)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Custom.CustomDevice", L"TrySendIOControlAsync", 3);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(3);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Custom::IIOControlCode>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Storage::Streams::IBuffer>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Storage::Streams::IBuffer>(args, 2);

                return py::convert(self->obj.TrySendIOControlAsync(param0, param1, param2));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CustomDevice_get_InputStream(py::wrapper::Windows::Devices::Custom::CustomDevice* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.CustomDevice", L"InputStream");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.InputStream());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CustomDevice_get_OutputStream(py::wrapper::Windows::Devices::Custom::CustomDevice* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.CustomDevice", L"OutputStream");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.OutputStream());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CustomDevice(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Custom::CustomDevice>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CustomDevice(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Custom::CustomDevice>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CustomDevice[] = {
        { "send_i_o_control_async", reinterpret_cast<PyCFunction>(CustomDevice_SendIOControlAsync), METH_VARARGS, nullptr },
        { "try_send_i_o_control_async", reinterpret_cast<PyCFunction>(CustomDevice_TrySendIOControlAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_CustomDevice, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CustomDevice), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_CustomDevice[] = {
        { "input_stream", reinterpret_cast<getter>(CustomDevice_get_InputStream), nullptr, nullptr, nullptr },
        { "output_stream", reinterpret_cast<getter>(CustomDevice_get_OutputStream), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_CustomDevice[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CustomDevice) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CustomDevice) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CustomDevice) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CustomDevice) },
        { }
    };

    static PyType_Spec type_spec_CustomDevice = {
        "winrt._winrt_windows_devices_custom.CustomDevice",
        sizeof(py::wrapper::Windows::Devices::Custom::CustomDevice),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CustomDevice};

    static PyGetSetDef getset_CustomDevice_Static[] = {
        { }
    };

    static PyMethodDef methods_CustomDevice_Static[] = {
        { "from_id_async", reinterpret_cast<PyCFunction>(CustomDevice_FromIdAsync), METH_VARARGS, nullptr },
        { "get_device_selector", reinterpret_cast<PyCFunction>(CustomDevice_GetDeviceSelector), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_CustomDevice_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_CustomDevice_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_CustomDevice_Static) },
        { }
    };

    static PyType_Spec type_spec_CustomDevice_Static =
    {
        "winrt._winrt_windows_devices_custom.CustomDevice_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_CustomDevice_Static
    };

    // ----- IOControlCode class --------------------

    static PyObject* _new_IOControlCode(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 4)
        {
            try
            {
                auto param0 = py::convert_to<uint16_t>(args, 0);
                auto param1 = py::convert_to<uint16_t>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Devices::Custom::IOControlAccessMode>(args, 2);
                auto param3 = py::convert_to<winrt::Windows::Devices::Custom::IOControlBufferingMethod>(args, 3);

                winrt::Windows::Devices::Custom::IOControlCode instance{param0, param1, param2, param3};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_IOControlCode(py::wrapper::Windows::Devices::Custom::IOControlCode* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* IOControlCode_get_AccessMode(py::wrapper::Windows::Devices::Custom::IOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IOControlCode", L"AccessMode");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.AccessMode());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IOControlCode_get_BufferingMethod(py::wrapper::Windows::Devices::Custom::IOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IOControlCode", L"BufferingMethod");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.BufferingMethod());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IOControlCode_get_ControlCode(py::wrapper::Windows::Devices::Custom::IOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IOControlCode", L"ControlCode");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.ControlCode());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IOControlCode_get_DeviceType(py::wrapper::Windows::Devices::Custom::IOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IOControlCode", L"DeviceType");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.DeviceType());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IOControlCode_get_Function(py::wrapper::Windows::Devices::Custom::IOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IOControlCode", L"Function");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Function());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_IOControlCode(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Custom::IOControlCode>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_IOControlCode(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Custom::IOControlCode>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_IOControlCode[] = {
        { "_assign_array_", _assign_array_IOControlCode, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IOControlCode), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IOControlCode[] = {
        { "access_mode", reinterpret_cast<getter>(IOControlCode_get_AccessMode), nullptr, nullptr, nullptr },
        { "buffering_method", reinterpret_cast<getter>(IOControlCode_get_BufferingMethod), nullptr, nullptr, nullptr },
        { "control_code", reinterpret_cast<getter>(IOControlCode_get_ControlCode), nullptr, nullptr, nullptr },
        { "device_type", reinterpret_cast<getter>(IOControlCode_get_DeviceType), nullptr, nullptr, nullptr },
        { "function", reinterpret_cast<getter>(IOControlCode_get_Function), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_IOControlCode[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_IOControlCode) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IOControlCode) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IOControlCode) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IOControlCode) },
        { }
    };

    static PyType_Spec type_spec_IOControlCode = {
        "winrt._winrt_windows_devices_custom.IOControlCode",
        sizeof(py::wrapper::Windows::Devices::Custom::IOControlCode),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IOControlCode};

    // ----- KnownDeviceTypes class --------------------

    static PyObject* _new_KnownDeviceTypes(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Custom::KnownDeviceTypes>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Custom::KnownDeviceTypes>::type_name);
        return nullptr;
    }

    static PyObject* KnownDeviceTypes_get_Unknown(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.KnownDeviceTypes", L"Unknown");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(winrt::Windows::Devices::Custom::KnownDeviceTypes::Unknown());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_KnownDeviceTypes[] = {
        { }
    };

    static PyGetSetDef _getset_KnownDeviceTypes[] = {
        { }
    };

    static PyType_Slot _type_slots_KnownDeviceTypes[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_KnownDeviceTypes) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_KnownDeviceTypes) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_KnownDeviceTypes) },
        { }
    };

    static PyType_Spec type_spec_KnownDeviceTypes = {
        "winrt._winrt_windows_devices_custom.KnownDeviceTypes",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_KnownDeviceTypes};

    static PyGetSetDef getset_KnownDeviceTypes_Static[] = {
        { "unknown", reinterpret_cast<getter>(KnownDeviceTypes_get_Unknown), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_KnownDeviceTypes_Static[] = {
        { }
    };

    static PyType_Slot type_slots_KnownDeviceTypes_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_KnownDeviceTypes_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_KnownDeviceTypes_Static) },
        { }
    };

    static PyType_Spec type_spec_KnownDeviceTypes_Static =
    {
        "winrt._winrt_windows_devices_custom.KnownDeviceTypes_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_KnownDeviceTypes_Static
    };

    // ----- IIOControlCode interface --------------------

    static PyObject* _new_IIOControlCode(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Custom::IIOControlCode>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Custom::IIOControlCode>::type_name);
        return nullptr;
    }

    static void _dealloc_IIOControlCode(py::wrapper::Windows::Devices::Custom::IIOControlCode* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* IIOControlCode_get_AccessMode(py::wrapper::Windows::Devices::Custom::IIOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IIOControlCode", L"AccessMode");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.AccessMode());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IIOControlCode_get_BufferingMethod(py::wrapper::Windows::Devices::Custom::IIOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IIOControlCode", L"BufferingMethod");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.BufferingMethod());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IIOControlCode_get_ControlCode(py::wrapper::Windows::Devices::Custom::IIOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IIOControlCode", L"ControlCode");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.ControlCode());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IIOControlCode_get_DeviceType(py::wrapper::Windows::Devices::Custom::IIOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IIOControlCode", L"DeviceType");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.DeviceType());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IIOControlCode_get_Function(py::wrapper::Windows::Devices::Custom::IIOControlCode* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Custom.IIOControlCode", L"Function");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Function());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_IIOControlCode(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Custom::IIOControlCode>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_IIOControlCode(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Custom::IIOControlCode>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_IIOControlCode[] = {
        { "_assign_array_", _assign_array_IIOControlCode, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IIOControlCode), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IIOControlCode[] = {
        { "access_mode", reinterpret_cast<getter>(IIOControlCode_get_AccessMode), nullptr, nullptr, nullptr },
        { "buffering_method", reinterpret_cast<getter>(IIOControlCode_get_BufferingMethod), nullptr, nullptr, nullptr },
        { "control_code", reinterpret_cast<getter>(IIOControlCode_get_ControlCode), nullptr, nullptr, nullptr },
        { "device_type", reinterpret_cast<getter>(IIOControlCode_get_DeviceType), nullptr, nullptr, nullptr },
        { "function", reinterpret_cast<getter>(IIOControlCode_get_Function), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_IIOControlCode[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_IIOControlCode) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IIOControlCode) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IIOControlCode) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IIOControlCode) },
        { }
    };

    static PyType_Spec type_spec_IIOControlCode = {
        "winrt._winrt_windows_devices_custom.IIOControlCode",
        sizeof(py::wrapper::Windows::Devices::Custom::IIOControlCode),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IIOControlCode};

    // ----- Windows.Devices.Custom Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Devices.Custom");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_devices_custom",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Devices::Custom

PyMODINIT_FUNC PyInit__winrt_windows_devices_custom(void) noexcept
{
    using namespace py::cpp::Windows::Devices::Custom;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_CustomDevice_Static{PyType_FromSpec(&type_spec_CustomDevice_Static)};
    if (!type_CustomDevice_Static)
    {
        return nullptr;
    }

    py::pytype_handle CustomDevice_type{py::register_python_type(module.get(), &type_spec_CustomDevice, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_CustomDevice_Static.get()))};
    if (!CustomDevice_type)
    {
        return nullptr;
    }

    py::pytype_handle IOControlCode_type{py::register_python_type(module.get(), &type_spec_IOControlCode, object_bases.get(), nullptr)};
    if (!IOControlCode_type)
    {
        return nullptr;
    }

    py::pyobj_handle type_KnownDeviceTypes_Static{PyType_FromSpec(&type_spec_KnownDeviceTypes_Static)};
    if (!type_KnownDeviceTypes_Static)
    {
        return nullptr;
    }

    py::pytype_handle KnownDeviceTypes_type{py::register_python_type(module.get(), &type_spec_KnownDeviceTypes, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_KnownDeviceTypes_Static.get()))};
    if (!KnownDeviceTypes_type)
    {
        return nullptr;
    }

    py::pytype_handle IIOControlCode_type{py::register_python_type(module.get(), &type_spec_IIOControlCode, object_bases.get(), nullptr)};
    if (!IIOControlCode_type)
    {
        return nullptr;
    }


    return module.detach();
}
