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

#include "py.Windows.Phone.UI.Input.h"

namespace py::cpp::Windows::Phone::UI::Input
{
    // ----- BackPressedEventArgs class --------------------

    static PyObject* _new_BackPressedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Phone::UI::Input::BackPressedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Phone::UI::Input::BackPressedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_BackPressedEventArgs(py::wrapper::Windows::Phone::UI::Input::BackPressedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* BackPressedEventArgs_get_Handled(py::wrapper::Windows::Phone::UI::Input::BackPressedEventArgs* 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.Phone.UI.Input.BackPressedEventArgs", L"Handled");
            }

            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.Handled());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int BackPressedEventArgs_put_Handled(py::wrapper::Windows::Phone::UI::Input::BackPressedEventArgs* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        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.Phone.UI.Input.BackPressedEventArgs", L"Handled");
            }

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

            auto param0 = py::convert_to<bool>(arg);

            self->obj.Handled(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_BackPressedEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Phone::UI::Input::BackPressedEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_BackPressedEventArgs(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::Phone::UI::Input::BackPressedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_BackPressedEventArgs[] = {
        { "_assign_array_", _assign_array_BackPressedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_BackPressedEventArgs), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_BackPressedEventArgs[] = {
        { "handled", reinterpret_cast<getter>(BackPressedEventArgs_get_Handled), reinterpret_cast<setter>(BackPressedEventArgs_put_Handled), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_BackPressedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_BackPressedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_BackPressedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_BackPressedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_BackPressedEventArgs) },
        { }
    };

    static PyType_Spec type_spec_BackPressedEventArgs = {
        "winrt._winrt_windows_phone_ui_input.BackPressedEventArgs",
        sizeof(py::wrapper::Windows::Phone::UI::Input::BackPressedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_BackPressedEventArgs};

    // ----- CameraEventArgs class --------------------

    static PyObject* _new_CameraEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Phone::UI::Input::CameraEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Phone::UI::Input::CameraEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_CameraEventArgs(py::wrapper::Windows::Phone::UI::Input::CameraEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* _assign_array_CameraEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Phone::UI::Input::CameraEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CameraEventArgs(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::Phone::UI::Input::CameraEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CameraEventArgs[] = {
        { "_assign_array_", _assign_array_CameraEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CameraEventArgs), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_CameraEventArgs[] = {
        { }
    };

    static PyType_Slot _type_slots_CameraEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CameraEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CameraEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CameraEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CameraEventArgs) },
        { }
    };

    static PyType_Spec type_spec_CameraEventArgs = {
        "winrt._winrt_windows_phone_ui_input.CameraEventArgs",
        sizeof(py::wrapper::Windows::Phone::UI::Input::CameraEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CameraEventArgs};

    // ----- HardwareButtons class --------------------

    static PyObject* _new_HardwareButtons(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Phone::UI::Input::HardwareButtons>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Phone::UI::Input::HardwareButtons>::type_name);
        return nullptr;
    }

    static PyObject* HardwareButtons_add_BackPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"BackPressed");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Phone::UI::Input::BackPressedEventArgs>>(arg);

            return py::convert(winrt::Windows::Phone::UI::Input::HardwareButtons::BackPressed(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_remove_BackPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"BackPressed");
            }

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

            auto param0 = py::convert_to<winrt::event_token>(arg);

            winrt::Windows::Phone::UI::Input::HardwareButtons::BackPressed(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_add_CameraHalfPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraHalfPressed");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Phone::UI::Input::CameraEventArgs>>(arg);

            return py::convert(winrt::Windows::Phone::UI::Input::HardwareButtons::CameraHalfPressed(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_remove_CameraHalfPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraHalfPressed");
            }

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

            auto param0 = py::convert_to<winrt::event_token>(arg);

            winrt::Windows::Phone::UI::Input::HardwareButtons::CameraHalfPressed(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_add_CameraPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraPressed");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Phone::UI::Input::CameraEventArgs>>(arg);

            return py::convert(winrt::Windows::Phone::UI::Input::HardwareButtons::CameraPressed(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_remove_CameraPressed(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraPressed");
            }

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

            auto param0 = py::convert_to<winrt::event_token>(arg);

            winrt::Windows::Phone::UI::Input::HardwareButtons::CameraPressed(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_add_CameraReleased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraReleased");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Phone::UI::Input::CameraEventArgs>>(arg);

            return py::convert(winrt::Windows::Phone::UI::Input::HardwareButtons::CameraReleased(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* HardwareButtons_remove_CameraReleased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.UI.Input.HardwareButtons", L"CameraReleased");
            }

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

            auto param0 = py::convert_to<winrt::event_token>(arg);

            winrt::Windows::Phone::UI::Input::HardwareButtons::CameraReleased(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_HardwareButtons[] = {
        { }
    };

    static PyGetSetDef _getset_HardwareButtons[] = {
        { }
    };

    static PyType_Slot _type_slots_HardwareButtons[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_HardwareButtons) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_HardwareButtons) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_HardwareButtons) },
        { }
    };

    static PyType_Spec type_spec_HardwareButtons = {
        "winrt._winrt_windows_phone_ui_input.HardwareButtons",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_HardwareButtons};

    static PyGetSetDef getset_HardwareButtons_Static[] = {
        { }
    };

    static PyMethodDef methods_HardwareButtons_Static[] = {
        { "add_back_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_add_BackPressed), METH_O, nullptr },
        { "remove_back_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_remove_BackPressed), METH_O, nullptr },
        { "add_camera_half_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_add_CameraHalfPressed), METH_O, nullptr },
        { "remove_camera_half_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_remove_CameraHalfPressed), METH_O, nullptr },
        { "add_camera_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_add_CameraPressed), METH_O, nullptr },
        { "remove_camera_pressed", reinterpret_cast<PyCFunction>(HardwareButtons_remove_CameraPressed), METH_O, nullptr },
        { "add_camera_released", reinterpret_cast<PyCFunction>(HardwareButtons_add_CameraReleased), METH_O, nullptr },
        { "remove_camera_released", reinterpret_cast<PyCFunction>(HardwareButtons_remove_CameraReleased), METH_O, nullptr },
        { }
    };

    static PyType_Slot type_slots_HardwareButtons_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_HardwareButtons_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_HardwareButtons_Static) },
        { }
    };

    static PyType_Spec type_spec_HardwareButtons_Static =
    {
        "winrt._winrt_windows_phone_ui_input.HardwareButtons_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_HardwareButtons_Static
    };

    // ----- Windows.Phone.UI.Input Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Phone.UI.Input");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_phone_ui_input",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Phone::UI::Input

PyMODINIT_FUNC PyInit__winrt_windows_phone_ui_input(void) noexcept
{
    using namespace py::cpp::Windows::Phone::UI::Input;

    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::pytype_handle BackPressedEventArgs_type{py::register_python_type(module.get(), &type_spec_BackPressedEventArgs, object_bases.get(), nullptr)};
    if (!BackPressedEventArgs_type)
    {
        return nullptr;
    }

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

    py::pyobj_handle type_HardwareButtons_Static{PyType_FromSpec(&type_spec_HardwareButtons_Static)};
    if (!type_HardwareButtons_Static)
    {
        return nullptr;
    }

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


    return module.detach();
}
