Skip to main content

bevy_input/
touch.rs

1//! The touch input functionality.
2
3#[cfg(feature = "bevy_reflect")]
4use bevy_ecs::prelude::ReflectMessage;
5use bevy_ecs::{
6    entity::Entity,
7    message::{Message, MessageReader},
8    resource::Resource,
9    system::ResMut,
10};
11use bevy_math::Vec2;
12use bevy_platform::collections::HashMap;
13#[cfg(feature = "bevy_reflect")]
14use bevy_reflect::Reflect;
15
16#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
17use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
18
19/// A touch input event.
20///
21/// ## Logic
22///
23/// Every time the user touches the screen, a new [`TouchPhase::Started`] event with an unique
24/// identifier for the finger is generated. When the finger is lifted, the [`TouchPhase::Ended`]
25/// event is generated with the same finger id.
26///
27/// After a [`TouchPhase::Started`] event has been emitted, there may be zero or more [`TouchPhase::Moved`]
28/// events when the finger is moved or the touch pressure changes.
29///
30/// The finger id may be reused by the system after an [`TouchPhase::Ended`] event. The user
31/// should assume that a new [`TouchPhase::Started`] event received with the same id has nothing
32/// to do with the old finger and is a new finger.
33///
34/// A [`TouchPhase::Canceled`] event is emitted when the system has canceled tracking this
35/// touch, such as when the window loses focus, or on iOS if the user moves the
36/// device against their face.
37///
38/// ## Note
39///
40/// This event is the translated version of the `WindowEvent::Touch` from the `winit` crate.
41/// It is available to the end user and can be used for game logic.
42#[derive(impl bevy_ecs::message::Message for TouchInput where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Message, #[automatically_derived]impl ::core::fmt::Debug for TouchInput {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "TouchInput",
            "phase", &self.phase, "position", &self.position, "window",
            &self.window, "force", &self.force, "id", &&self.id)
    }
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for TouchInput {
}
#[automatically_derived]impl ::core::clone::Clone for TouchInput {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<TouchPhase>;
        let _: ::core::clone::AssertParamIsClone<Vec2>;
        let _: ::core::clone::AssertParamIsClone<Entity>;
        let _: ::core::clone::AssertParamIsClone<Option<ForceTouch>>;
        let _: ::core::clone::AssertParamIsClone<u64>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for TouchInput { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    TouchInput {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TouchInput {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.id == other.id && self.phase == other.phase &&
                    self.position == other.position &&
                self.window == other.window && self.force == other.force
    }
}PartialEq)]
43#[cfg_attr(
44    feature = "bevy_reflect",
45    derive(const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for TouchInput where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectMessage, Self,
                    _>(());
                registration.register_type_data_with::<ReflectSerialize, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDeserialize,
                    Self, _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <TouchPhase as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <Vec2 as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <Entity as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <Option<ForceTouch> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <u64 as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for TouchInput where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[bevy_reflect::NamedField::new::<TouchPhase>("phase"),
                                                bevy_reflect::NamedField::new::<Vec2>("position"),
                                                bevy_reflect::NamedField::new::<Entity>("window"),
                                                bevy_reflect::NamedField::new::<Option<ForceTouch>>("force"),
                                                bevy_reflect::NamedField::new::<u64>("id")]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for TouchInput where  {
            fn type_path() -> &'static str { "bevy_input::touch::TouchInput" }
            fn short_type_path() -> &'static str { "TouchInput" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("TouchInput")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch")
            }
        }
        impl bevy_reflect::Reflect for TouchInput where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        impl bevy_reflect::structs::Struct for TouchInput where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name {
                    "phase" => ::core::option::Option::Some(&self.phase),
                    "position" => ::core::option::Option::Some(&self.position),
                    "window" => ::core::option::Option::Some(&self.window),
                    "force" => ::core::option::Option::Some(&self.force),
                    "id" => ::core::option::Option::Some(&self.id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name {
                    "phase" => ::core::option::Option::Some(&mut self.phase),
                    "position" =>
                        ::core::option::Option::Some(&mut self.position),
                    "window" => ::core::option::Option::Some(&mut self.window),
                    "force" => ::core::option::Option::Some(&mut self.force),
                    "id" => ::core::option::Option::Some(&mut self.id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.phase),
                    1usize => ::core::option::Option::Some(&self.position),
                    2usize => ::core::option::Option::Some(&self.window),
                    3usize => ::core::option::Option::Some(&self.force),
                    4usize => ::core::option::Option::Some(&self.id),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.phase),
                    1usize => ::core::option::Option::Some(&mut self.position),
                    2usize => ::core::option::Option::Some(&mut self.window),
                    3usize => ::core::option::Option::Some(&mut self.force),
                    4usize => ::core::option::Option::Some(&mut self.id),
                    _ => ::core::option::Option::None,
                }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index {
                    0usize => ::core::option::Option::Some("phase"),
                    1usize => ::core::option::Option::Some("position"),
                    2usize => ::core::option::Option::Some("window"),
                    3usize => ::core::option::Option::Some("force"),
                    4usize => ::core::option::Option::Some("id"),
                    _ => ::core::option::Option::None,
                }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name {
                    "phase" => ::core::option::Option::Some(0usize),
                    "position" => ::core::option::Option::Some(1usize),
                    "window" => ::core::option::Option::Some(2usize),
                    "force" => ::core::option::Option::Some(3usize),
                    "id" => ::core::option::Option::Some(4usize),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_len(&self) -> usize { 5usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                ->
                    ::core::result::Result<bevy_reflect::structs::DynamicStruct,
                    bevy_reflect::ReflectCloneError> {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed("phase",
                    bevy_reflect::PartialReflect::to_dynamic(&self.phase)?);
                dynamic.insert_boxed("position",
                    bevy_reflect::PartialReflect::to_dynamic(&self.position)?);
                dynamic.insert_boxed("window",
                    bevy_reflect::PartialReflect::to_dynamic(&self.window)?);
                dynamic.insert_boxed("force",
                    bevy_reflect::PartialReflect::to_dynamic(&self.force)?);
                dynamic.insert_boxed("id",
                    bevy_reflect::PartialReflect::to_dynamic(&self.id)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl bevy_reflect::PartialReflect for TouchInput where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for TouchInput where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let __this =
                        Self {
                            phase: <TouchPhase as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "phase")?)?,
                            position: <Vec2 as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "position")?)?,
                            window: <Entity as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "window")?)?,
                            force: <Option<ForceTouch> as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "force")?)?,
                            id: <u64 as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "id")?)?,
                        };
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect),
46    reflect(Debug, PartialEq, Clone, Message)
47)]
48#[cfg_attr(feature = "serialize", derive(#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl _serde::Serialize for TouchInput {
            fn serialize<__S>(&self, __serializer: __S)
                -> _serde::__private229::Result<__S::Ok, __S::Error> where
                __S: _serde::Serializer {
                let mut __serde_state =
                    _serde::Serializer::serialize_struct(__serializer,
                            "TouchInput", false as usize + 1 + 1 + 1 + 1 + 1)?;
                _serde::ser::SerializeStruct::serialize_field(&mut __serde_state,
                        "phase", &self.phase)?;
                _serde::ser::SerializeStruct::serialize_field(&mut __serde_state,
                        "position", &self.position)?;
                _serde::ser::SerializeStruct::serialize_field(&mut __serde_state,
                        "window", &self.window)?;
                _serde::ser::SerializeStruct::serialize_field(&mut __serde_state,
                        "force", &self.force)?;
                _serde::ser::SerializeStruct::serialize_field(&mut __serde_state,
                        "id", &self.id)?;
                _serde::ser::SerializeStruct::end(__serde_state)
            }
        }
    };serde::Serialize, #[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl<'de> _serde::Deserialize<'de> for TouchInput {
            fn deserialize<__D>(__deserializer: __D)
                -> _serde::__private229::Result<Self, __D::Error> where
                __D: _serde::Deserializer<'de> {
                #[allow(non_camel_case_types)]
                #[doc(hidden)]
                enum __Field {
                    __field0,
                    __field1,
                    __field2,
                    __field3,
                    __field4,
                    __ignore,
                }
                #[doc(hidden)]
                struct __FieldVisitor;
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
                    type Value = __Field;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "field identifier")
                    }
                    fn visit_u64<__E>(self, __value: u64)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            0u64 => _serde::__private229::Ok(__Field::__field0),
                            1u64 => _serde::__private229::Ok(__Field::__field1),
                            2u64 => _serde::__private229::Ok(__Field::__field2),
                            3u64 => _serde::__private229::Ok(__Field::__field3),
                            4u64 => _serde::__private229::Ok(__Field::__field4),
                            _ => _serde::__private229::Ok(__Field::__ignore),
                        }
                    }
                    fn visit_str<__E>(self, __value: &str)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            "phase" => _serde::__private229::Ok(__Field::__field0),
                            "position" => _serde::__private229::Ok(__Field::__field1),
                            "window" => _serde::__private229::Ok(__Field::__field2),
                            "force" => _serde::__private229::Ok(__Field::__field3),
                            "id" => _serde::__private229::Ok(__Field::__field4),
                            _ => { _serde::__private229::Ok(__Field::__ignore) }
                        }
                    }
                    fn visit_bytes<__E>(self, __value: &[u8])
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            b"phase" => _serde::__private229::Ok(__Field::__field0),
                            b"position" => _serde::__private229::Ok(__Field::__field1),
                            b"window" => _serde::__private229::Ok(__Field::__field2),
                            b"force" => _serde::__private229::Ok(__Field::__field3),
                            b"id" => _serde::__private229::Ok(__Field::__field4),
                            _ => { _serde::__private229::Ok(__Field::__ignore) }
                        }
                    }
                }
                #[automatically_derived]
                impl<'de> _serde::Deserialize<'de> for __Field {
                    #[inline]
                    fn deserialize<__D>(__deserializer: __D)
                        -> _serde::__private229::Result<Self, __D::Error> where
                        __D: _serde::Deserializer<'de> {
                        _serde::Deserializer::deserialize_identifier(__deserializer,
                            __FieldVisitor)
                    }
                }
                #[doc(hidden)]
                struct __Visitor<'de> {
                    marker: _serde::__private229::PhantomData<TouchInput>,
                    lifetime: _serde::__private229::PhantomData<&'de ()>,
                }
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
                    type Value = TouchInput;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "struct TouchInput")
                    }
                    #[inline]
                    fn visit_seq<__A>(self, mut __seq: __A)
                        -> _serde::__private229::Result<Self::Value, __A::Error>
                        where __A: _serde::de::SeqAccess<'de> {
                        let __field0 =
                            match _serde::de::SeqAccess::next_element::<TouchPhase>(&mut __seq)?
                                {
                                _serde::__private229::Some(__value) => __value,
                                _serde::__private229::None =>
                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(0usize,
                                                &"struct TouchInput with 5 elements")),
                            };
                        let __field1 =
                            match _serde::de::SeqAccess::next_element::<Vec2>(&mut __seq)?
                                {
                                _serde::__private229::Some(__value) => __value,
                                _serde::__private229::None =>
                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(1usize,
                                                &"struct TouchInput with 5 elements")),
                            };
                        let __field2 =
                            match _serde::de::SeqAccess::next_element::<Entity>(&mut __seq)?
                                {
                                _serde::__private229::Some(__value) => __value,
                                _serde::__private229::None =>
                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(2usize,
                                                &"struct TouchInput with 5 elements")),
                            };
                        let __field3 =
                            match _serde::de::SeqAccess::next_element::<Option<ForceTouch>>(&mut __seq)?
                                {
                                _serde::__private229::Some(__value) => __value,
                                _serde::__private229::None =>
                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(3usize,
                                                &"struct TouchInput with 5 elements")),
                            };
                        let __field4 =
                            match _serde::de::SeqAccess::next_element::<u64>(&mut __seq)?
                                {
                                _serde::__private229::Some(__value) => __value,
                                _serde::__private229::None =>
                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(4usize,
                                                &"struct TouchInput with 5 elements")),
                            };
                        _serde::__private229::Ok(TouchInput {
                                phase: __field0,
                                position: __field1,
                                window: __field2,
                                force: __field3,
                                id: __field4,
                            })
                    }
                    #[inline]
                    fn visit_map<__A>(self, mut __map: __A)
                        -> _serde::__private229::Result<Self::Value, __A::Error>
                        where __A: _serde::de::MapAccess<'de> {
                        let mut __field0: _serde::__private229::Option<TouchPhase> =
                            _serde::__private229::None;
                        let mut __field1: _serde::__private229::Option<Vec2> =
                            _serde::__private229::None;
                        let mut __field2: _serde::__private229::Option<Entity> =
                            _serde::__private229::None;
                        let mut __field3:
                                _serde::__private229::Option<Option<ForceTouch>> =
                            _serde::__private229::None;
                        let mut __field4: _serde::__private229::Option<u64> =
                            _serde::__private229::None;
                        while let _serde::__private229::Some(__key) =
                                _serde::de::MapAccess::next_key::<__Field>(&mut __map)? {
                            match __key {
                                __Field::__field0 => {
                                    if _serde::__private229::Option::is_some(&__field0) {
                                        return _serde::__private229::Err(<__A::Error as
                                                        _serde::de::Error>::duplicate_field("phase"));
                                    }
                                    __field0 =
                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<TouchPhase>(&mut __map)?);
                                }
                                __Field::__field1 => {
                                    if _serde::__private229::Option::is_some(&__field1) {
                                        return _serde::__private229::Err(<__A::Error as
                                                        _serde::de::Error>::duplicate_field("position"));
                                    }
                                    __field1 =
                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<Vec2>(&mut __map)?);
                                }
                                __Field::__field2 => {
                                    if _serde::__private229::Option::is_some(&__field2) {
                                        return _serde::__private229::Err(<__A::Error as
                                                        _serde::de::Error>::duplicate_field("window"));
                                    }
                                    __field2 =
                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<Entity>(&mut __map)?);
                                }
                                __Field::__field3 => {
                                    if _serde::__private229::Option::is_some(&__field3) {
                                        return _serde::__private229::Err(<__A::Error as
                                                        _serde::de::Error>::duplicate_field("force"));
                                    }
                                    __field3 =
                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<Option<ForceTouch>>(&mut __map)?);
                                }
                                __Field::__field4 => {
                                    if _serde::__private229::Option::is_some(&__field4) {
                                        return _serde::__private229::Err(<__A::Error as
                                                        _serde::de::Error>::duplicate_field("id"));
                                    }
                                    __field4 =
                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<u64>(&mut __map)?);
                                }
                                _ => {
                                    let _ =
                                        _serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)?;
                                }
                            }
                        }
                        let __field0 =
                            match __field0 {
                                _serde::__private229::Some(__field0) => __field0,
                                _serde::__private229::None =>
                                    _serde::__private229::de::missing_field("phase")?,
                            };
                        let __field1 =
                            match __field1 {
                                _serde::__private229::Some(__field1) => __field1,
                                _serde::__private229::None =>
                                    _serde::__private229::de::missing_field("position")?,
                            };
                        let __field2 =
                            match __field2 {
                                _serde::__private229::Some(__field2) => __field2,
                                _serde::__private229::None =>
                                    _serde::__private229::de::missing_field("window")?,
                            };
                        let __field3 =
                            match __field3 {
                                _serde::__private229::Some(__field3) => __field3,
                                _serde::__private229::None =>
                                    _serde::__private229::de::missing_field("force")?,
                            };
                        let __field4 =
                            match __field4 {
                                _serde::__private229::Some(__field4) => __field4,
                                _serde::__private229::None =>
                                    _serde::__private229::de::missing_field("id")?,
                            };
                        _serde::__private229::Ok(TouchInput {
                                phase: __field0,
                                position: __field1,
                                window: __field2,
                                force: __field3,
                                id: __field4,
                            })
                    }
                }
                #[doc(hidden)]
                const FIELDS: &'static [&'static str] =
                    &["phase", "position", "window", "force", "id"];
                _serde::Deserializer::deserialize_struct(__deserializer,
                    "TouchInput", FIELDS,
                    __Visitor {
                        marker: _serde::__private229::PhantomData::<TouchInput>,
                        lifetime: _serde::__private229::PhantomData,
                    })
            }
        }
    };serde::Deserialize))]
49#[cfg_attr(
50    all(feature = "serialize", feature = "bevy_reflect"),
51    reflect(Serialize, Deserialize)
52)]
53pub struct TouchInput {
54    /// The phase of the touch input.
55    pub phase: TouchPhase,
56    /// The position of the finger on the touchscreen.
57    pub position: Vec2,
58    /// The window entity registering the touch.
59    pub window: Entity,
60    /// Describes how hard the screen was pressed.
61    ///
62    /// May be [`None`] if the platform does not support pressure sensitivity.
63    /// This feature is only available on **iOS** 9.0+ and **Windows** 8+.
64    pub force: Option<ForceTouch>,
65    /// The unique identifier of the finger.
66    pub id: u64,
67}
68
69/// A force description of a [`Touch`] input.
70#[derive(#[automatically_derived]impl ::core::fmt::Debug for ForceTouch {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Calibrated {
                force: __self_0,
                max_possible_force: __self_1,
                altitude_angle: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "Calibrated", "force", __self_0, "max_possible_force",
                    __self_1, "altitude_angle", &__self_2),
            Self::Normalized(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Normalized", &__self_0),
        }
    }
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ForceTouch {
}
#[automatically_derived]impl ::core::clone::Clone for ForceTouch {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<f64>;
        let _: ::core::clone::AssertParamIsClone<Option<f64>>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for ForceTouch { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ForceTouch {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ForceTouch {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Calibrated {
                    force: __self_0,
                    max_possible_force: __self_1,
                    altitude_angle: __self_2 }, Self::Calibrated {
                    force: __arg1_0,
                    max_possible_force: __arg1_1,
                    altitude_angle: __arg1_2 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1 &&
                        __self_2 == __arg1_2,
                (Self::Normalized(__self_0), Self::Normalized(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq)]
71#[cfg_attr(
72    feature = "bevy_reflect",
73    derive(const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for ForceTouch where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectSerialize, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDeserialize,
                    Self, _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <f64 as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <Option<f64> as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for ForceTouch where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Enum(bevy_reflect::enums::EnumInfo::new::<Self>(&[bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("Calibrated",
                                                        &[bevy_reflect::NamedField::new::<f64>("force"),
                                                                    bevy_reflect::NamedField::new::<f64>("max_possible_force"),
                                                                    bevy_reflect::NamedField::new::<Option<f64>>("altitude_angle")])),
                                                bevy_reflect::enums::VariantInfo::Tuple(bevy_reflect::enums::TupleVariantInfo::new("Normalized",
                                                        &[bevy_reflect::UnnamedField::new::<f64>(0usize)]))]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for ForceTouch where  {
            fn type_path() -> &'static str { "bevy_input::touch::ForceTouch" }
            fn short_type_path() -> &'static str { "ForceTouch" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("ForceTouch")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch")
            }
        }
        impl bevy_reflect::Reflect for ForceTouch where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        impl bevy_reflect::enums::Enum for ForceTouch where  {
            fn field(&self, __name_param: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self {
                    ForceTouch::Calibrated { force: __value, .. } if
                        __name_param == "force" =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { max_possible_force: __value, .. }
                        if __name_param == "max_possible_force" =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { altitude_angle: __value, .. } if
                        __name_param == "altitude_angle" =>
                        ::core::option::Option::Some(__value),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at(&self, __index_param: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self {
                    ForceTouch::Calibrated { force: __value, .. } if
                        __index_param == 0usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { max_possible_force: __value, .. }
                        if __index_param == 1usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { altitude_angle: __value, .. } if
                        __index_param == 2usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Normalized { 0: __value, .. } if
                        __index_param == 0usize =>
                        ::core::option::Option::Some(__value),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, __name_param: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self {
                    ForceTouch::Calibrated { force: __value, .. } if
                        __name_param == "force" =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { max_possible_force: __value, .. }
                        if __name_param == "max_possible_force" =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { altitude_angle: __value, .. } if
                        __name_param == "altitude_angle" =>
                        ::core::option::Option::Some(__value),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at_mut(&mut self, __index_param: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self {
                    ForceTouch::Calibrated { force: __value, .. } if
                        __index_param == 0usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { max_possible_force: __value, .. }
                        if __index_param == 1usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Calibrated { altitude_angle: __value, .. } if
                        __index_param == 2usize =>
                        ::core::option::Option::Some(__value),
                    ForceTouch::Normalized { 0: __value, .. } if
                        __index_param == 0usize =>
                        ::core::option::Option::Some(__value),
                    _ => ::core::option::Option::None,
                }
            }
            fn index_of(&self, __name_param: &str)
                -> ::core::option::Option<usize> {
                match self {
                    ForceTouch::Calibrated { .. } if __name_param == "force" =>
                        ::core::option::Option::Some(0usize),
                    ForceTouch::Calibrated { .. } if
                        __name_param == "max_possible_force" =>
                        ::core::option::Option::Some(1usize),
                    ForceTouch::Calibrated { .. } if
                        __name_param == "altitude_angle" =>
                        ::core::option::Option::Some(2usize),
                    _ => ::core::option::Option::None,
                }
            }
            fn name_at(&self, __index_param: usize)
                -> ::core::option::Option<&str> {
                match self {
                    ForceTouch::Calibrated { .. } if __index_param == 0usize =>
                        ::core::option::Option::Some("force"),
                    ForceTouch::Calibrated { .. } if __index_param == 1usize =>
                        ::core::option::Option::Some("max_possible_force"),
                    ForceTouch::Calibrated { .. } if __index_param == 2usize =>
                        ::core::option::Option::Some("altitude_angle"),
                    _ => ::core::option::Option::None,
                }
            }
            fn iter_fields(&self) -> bevy_reflect::enums::VariantFieldIter {
                bevy_reflect::enums::VariantFieldIter::new(self)
            }
            #[inline]
            fn field_len(&self) -> usize {
                match self {
                    ForceTouch::Calibrated { .. } => 3usize,
                    ForceTouch::Normalized { .. } => 1usize,
                    _ => 0,
                }
            }
            #[inline]
            fn variant_name(&self) -> &str {
                match self {
                    ForceTouch::Calibrated { .. } => "Calibrated",
                    ForceTouch::Normalized { .. } => "Normalized",
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            #[inline]
            fn variant_index(&self) -> usize {
                match self {
                    ForceTouch::Calibrated { .. } => 0usize,
                    ForceTouch::Normalized { .. } => 1usize,
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            #[inline]
            fn variant_type(&self) -> bevy_reflect::enums::VariantType {
                match self {
                    ForceTouch::Calibrated { .. } =>
                        bevy_reflect::enums::VariantType::Struct,
                    ForceTouch::Normalized { .. } =>
                        bevy_reflect::enums::VariantType::Tuple,
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            fn to_dynamic_enum(&self)
                ->
                    ::core::result::Result<bevy_reflect::enums::DynamicEnum,
                    bevy_reflect::ReflectCloneError> {
                bevy_reflect::enums::DynamicEnum::try_from_ref::<Self>(self)
            }
        }
        impl bevy_reflect::PartialReflect for ForceTouch where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self,
                __value_param: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Enum(__value_param) =
                        bevy_reflect::PartialReflect::reflect_ref(__value_param) {
                    if bevy_reflect::enums::Enum::variant_name(self) ==
                            bevy_reflect::enums::Enum::variant_name(__value_param) {
                        match bevy_reflect::enums::Enum::variant_type(__value_param)
                            {
                            bevy_reflect::enums::VariantType::Struct => {
                                for field in
                                    bevy_reflect::enums::Enum::iter_fields(__value_param) {
                                    let name = field.name().unwrap();
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_mut(self, name) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            bevy_reflect::enums::VariantType::Tuple => {
                                for (index, field) in
                                    ::core::iter::Iterator::enumerate(bevy_reflect::enums::Enum::iter_fields(__value_param))
                                    {
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_at_mut(self, index) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            _ => {}
                        }
                    } else {
                        match bevy_reflect::enums::Enum::variant_name(__value_param)
                            {
                            "Calibrated" => {
                                *self =
                                    ForceTouch::Calibrated {
                                        force: {
                                            let __force = __value_param.field("force");
                                            let __force =
                                                __force.ok_or(bevy_reflect::ApplyError::MissingEnumField {
                                                            variant_name: ::core::convert::Into::into("Calibrated"),
                                                            field_name: ::core::convert::Into::into("force"),
                                                        })?;
                                            <f64 as
                                                            bevy_reflect::FromReflect>::from_reflect(__force).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
                                                        from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__force)),
                                                        to_type: ::core::convert::Into::into(<f64 as
                                                                    bevy_reflect::TypePath>::type_path()),
                                                    })?
                                        },
                                        max_possible_force: {
                                            let __max_possible_force =
                                                __value_param.field("max_possible_force");
                                            let __max_possible_force =
                                                __max_possible_force.ok_or(bevy_reflect::ApplyError::MissingEnumField {
                                                            variant_name: ::core::convert::Into::into("Calibrated"),
                                                            field_name: ::core::convert::Into::into("max_possible_force"),
                                                        })?;
                                            <f64 as
                                                            bevy_reflect::FromReflect>::from_reflect(__max_possible_force).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
                                                        from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__max_possible_force)),
                                                        to_type: ::core::convert::Into::into(<f64 as
                                                                    bevy_reflect::TypePath>::type_path()),
                                                    })?
                                        },
                                        altitude_angle: {
                                            let __altitude_angle =
                                                __value_param.field("altitude_angle");
                                            let __altitude_angle =
                                                __altitude_angle.ok_or(bevy_reflect::ApplyError::MissingEnumField {
                                                            variant_name: ::core::convert::Into::into("Calibrated"),
                                                            field_name: ::core::convert::Into::into("altitude_angle"),
                                                        })?;
                                            <Option<f64> as
                                                            bevy_reflect::FromReflect>::from_reflect(__altitude_angle).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
                                                        from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__altitude_angle)),
                                                        to_type: ::core::convert::Into::into(<Option<f64> as
                                                                    bevy_reflect::TypePath>::type_path()),
                                                    })?
                                        },
                                    }
                            }
                            "Normalized" => {
                                *self =
                                    ForceTouch::Normalized {
                                        0: {
                                            let __0 = __value_param.field_at(0usize);
                                            let __0 =
                                                __0.ok_or(bevy_reflect::ApplyError::MissingEnumField {
                                                            variant_name: ::core::convert::Into::into("Normalized"),
                                                            field_name: ::core::convert::Into::into(".0"),
                                                        })?;
                                            <f64 as
                                                            bevy_reflect::FromReflect>::from_reflect(__0).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
                                                        from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__0)),
                                                        to_type: ::core::convert::Into::into(<f64 as
                                                                    bevy_reflect::TypePath>::type_path()),
                                                    })?
                                        },
                                    }
                            }
                            name => {
                                return ::core::result::Result::Err(bevy_reflect::ApplyError::UnknownVariant {
                                            enum_name: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(self)),
                                            variant_name: ::core::convert::Into::into(name),
                                        });
                            }
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(__value_param),
                                to_kind: bevy_reflect::ReflectKind::Enum,
                            });
                }
                ::core::result::Result::Ok(())
            }
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Enum
            }
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Enum(self)
            }
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Enum(self)
            }
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Enum(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_hash(&self) -> ::core::option::Option<u64> {
                (bevy_reflect::enums::enum_hash)(self)
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::enums::enum_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for ForceTouch where  {
            fn from_reflect(__param0: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Enum(__param0) =
                        bevy_reflect::PartialReflect::reflect_ref(__param0) {
                    match bevy_reflect::enums::Enum::variant_name(__param0) {
                        "Calibrated" =>
                            ::core::option::Option::Some(ForceTouch::Calibrated {
                                    force: {
                                        let __force = __param0.field("force");
                                        let __force = __force?;
                                        <f64 as bevy_reflect::FromReflect>::from_reflect(__force)?
                                    },
                                    max_possible_force: {
                                        let __max_possible_force =
                                            __param0.field("max_possible_force");
                                        let __max_possible_force = __max_possible_force?;
                                        <f64 as
                                                    bevy_reflect::FromReflect>::from_reflect(__max_possible_force)?
                                    },
                                    altitude_angle: {
                                        let __altitude_angle = __param0.field("altitude_angle");
                                        let __altitude_angle = __altitude_angle?;
                                        <Option<f64> as
                                                    bevy_reflect::FromReflect>::from_reflect(__altitude_angle)?
                                    },
                                }),
                        "Normalized" =>
                            ::core::option::Option::Some(ForceTouch::Normalized {
                                    0: {
                                        let __0 = __param0.field_at(0usize);
                                        let __0 = __0?;
                                        <f64 as bevy_reflect::FromReflect>::from_reflect(__0)?
                                    },
                                }),
                        name => ::core::option::Option::None,
                    }
                } else { ::core::option::Option::None }
            }
        }
    };Reflect),
74    reflect(Debug, PartialEq, Clone)
75)]
76#[cfg_attr(feature = "serialize", derive(#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl _serde::Serialize for ForceTouch {
            fn serialize<__S>(&self, __serializer: __S)
                -> _serde::__private229::Result<__S::Ok, __S::Error> where
                __S: _serde::Serializer {
                match *self {
                    ForceTouch::Calibrated {
                        ref force, ref max_possible_force, ref altitude_angle } => {
                        let mut __serde_state =
                            _serde::Serializer::serialize_struct_variant(__serializer,
                                    "ForceTouch", 0u32, "Calibrated", 0 + 1 + 1 + 1)?;
                        _serde::ser::SerializeStructVariant::serialize_field(&mut __serde_state,
                                "force", force)?;
                        _serde::ser::SerializeStructVariant::serialize_field(&mut __serde_state,
                                "max_possible_force", max_possible_force)?;
                        _serde::ser::SerializeStructVariant::serialize_field(&mut __serde_state,
                                "altitude_angle", altitude_angle)?;
                        _serde::ser::SerializeStructVariant::end(__serde_state)
                    }
                    ForceTouch::Normalized(ref __field0) =>
                        _serde::Serializer::serialize_newtype_variant(__serializer,
                            "ForceTouch", 1u32, "Normalized", __field0),
                }
            }
        }
    };serde::Serialize, #[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl<'de> _serde::Deserialize<'de> for ForceTouch {
            fn deserialize<__D>(__deserializer: __D)
                -> _serde::__private229::Result<Self, __D::Error> where
                __D: _serde::Deserializer<'de> {
                #[allow(non_camel_case_types)]
                #[doc(hidden)]
                enum __Field { __field0, __field1, }
                #[doc(hidden)]
                struct __FieldVisitor;
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
                    type Value = __Field;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "variant identifier")
                    }
                    fn visit_u64<__E>(self, __value: u64)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            0u64 => _serde::__private229::Ok(__Field::__field0),
                            1u64 => _serde::__private229::Ok(__Field::__field1),
                            _ =>
                                _serde::__private229::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
                                        &"variant index 0 <= i < 2")),
                        }
                    }
                    fn visit_str<__E>(self, __value: &str)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            "Calibrated" => _serde::__private229::Ok(__Field::__field0),
                            "Normalized" => _serde::__private229::Ok(__Field::__field1),
                            _ => {
                                _serde::__private229::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                    fn visit_bytes<__E>(self, __value: &[u8])
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            b"Calibrated" =>
                                _serde::__private229::Ok(__Field::__field0),
                            b"Normalized" =>
                                _serde::__private229::Ok(__Field::__field1),
                            _ => {
                                let __value =
                                    &_serde::__private229::from_utf8_lossy(__value);
                                _serde::__private229::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                }
                #[automatically_derived]
                impl<'de> _serde::Deserialize<'de> for __Field {
                    #[inline]
                    fn deserialize<__D>(__deserializer: __D)
                        -> _serde::__private229::Result<Self, __D::Error> where
                        __D: _serde::Deserializer<'de> {
                        _serde::Deserializer::deserialize_identifier(__deserializer,
                            __FieldVisitor)
                    }
                }
                #[doc(hidden)]
                struct __Visitor<'de> {
                    marker: _serde::__private229::PhantomData<ForceTouch>,
                    lifetime: _serde::__private229::PhantomData<&'de ()>,
                }
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
                    type Value = ForceTouch;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "enum ForceTouch")
                    }
                    fn visit_enum<__A>(self, __data: __A)
                        -> _serde::__private229::Result<Self::Value, __A::Error>
                        where __A: _serde::de::EnumAccess<'de> {
                        match _serde::de::EnumAccess::variant(__data) {
                            _serde::__private229::Ok((__Field::__field0, __variant)) =>
                                {
                                #[allow(non_camel_case_types)]
                                #[doc(hidden)]
                                enum __Field { __field0, __field1, __field2, __ignore, }
                                #[doc(hidden)]
                                struct __FieldVisitor;
                                #[automatically_derived]
                                impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
                                    type Value = __Field;
                                    fn expecting(&self,
                                        __formatter: &mut _serde::__private229::Formatter)
                                        -> _serde::__private229::fmt::Result {
                                        _serde::__private229::Formatter::write_str(__formatter,
                                            "field identifier")
                                    }
                                    fn visit_u64<__E>(self, __value: u64)
                                        -> _serde::__private229::Result<Self::Value, __E> where
                                        __E: _serde::de::Error {
                                        match __value {
                                            0u64 => _serde::__private229::Ok(__Field::__field0),
                                            1u64 => _serde::__private229::Ok(__Field::__field1),
                                            2u64 => _serde::__private229::Ok(__Field::__field2),
                                            _ => _serde::__private229::Ok(__Field::__ignore),
                                        }
                                    }
                                    fn visit_str<__E>(self, __value: &str)
                                        -> _serde::__private229::Result<Self::Value, __E> where
                                        __E: _serde::de::Error {
                                        match __value {
                                            "force" => _serde::__private229::Ok(__Field::__field0),
                                            "max_possible_force" =>
                                                _serde::__private229::Ok(__Field::__field1),
                                            "altitude_angle" =>
                                                _serde::__private229::Ok(__Field::__field2),
                                            _ => { _serde::__private229::Ok(__Field::__ignore) }
                                        }
                                    }
                                    fn visit_bytes<__E>(self, __value: &[u8])
                                        -> _serde::__private229::Result<Self::Value, __E> where
                                        __E: _serde::de::Error {
                                        match __value {
                                            b"force" => _serde::__private229::Ok(__Field::__field0),
                                            b"max_possible_force" =>
                                                _serde::__private229::Ok(__Field::__field1),
                                            b"altitude_angle" =>
                                                _serde::__private229::Ok(__Field::__field2),
                                            _ => { _serde::__private229::Ok(__Field::__ignore) }
                                        }
                                    }
                                }
                                #[automatically_derived]
                                impl<'de> _serde::Deserialize<'de> for __Field {
                                    #[inline]
                                    fn deserialize<__D>(__deserializer: __D)
                                        -> _serde::__private229::Result<Self, __D::Error> where
                                        __D: _serde::Deserializer<'de> {
                                        _serde::Deserializer::deserialize_identifier(__deserializer,
                                            __FieldVisitor)
                                    }
                                }
                                #[doc(hidden)]
                                struct __Visitor<'de> {
                                    marker: _serde::__private229::PhantomData<ForceTouch>,
                                    lifetime: _serde::__private229::PhantomData<&'de ()>,
                                }
                                #[automatically_derived]
                                impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
                                    type Value = ForceTouch;
                                    fn expecting(&self,
                                        __formatter: &mut _serde::__private229::Formatter)
                                        -> _serde::__private229::fmt::Result {
                                        _serde::__private229::Formatter::write_str(__formatter,
                                            "struct variant ForceTouch::Calibrated")
                                    }
                                    #[inline]
                                    fn visit_seq<__A>(self, mut __seq: __A)
                                        -> _serde::__private229::Result<Self::Value, __A::Error>
                                        where __A: _serde::de::SeqAccess<'de> {
                                        let __field0 =
                                            match _serde::de::SeqAccess::next_element::<f64>(&mut __seq)?
                                                {
                                                _serde::__private229::Some(__value) => __value,
                                                _serde::__private229::None =>
                                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(0usize,
                                                                &"struct variant ForceTouch::Calibrated with 3 elements")),
                                            };
                                        let __field1 =
                                            match _serde::de::SeqAccess::next_element::<f64>(&mut __seq)?
                                                {
                                                _serde::__private229::Some(__value) => __value,
                                                _serde::__private229::None =>
                                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(1usize,
                                                                &"struct variant ForceTouch::Calibrated with 3 elements")),
                                            };
                                        let __field2 =
                                            match _serde::de::SeqAccess::next_element::<Option<f64>>(&mut __seq)?
                                                {
                                                _serde::__private229::Some(__value) => __value,
                                                _serde::__private229::None =>
                                                    return _serde::__private229::Err(_serde::de::Error::invalid_length(2usize,
                                                                &"struct variant ForceTouch::Calibrated with 3 elements")),
                                            };
                                        _serde::__private229::Ok(ForceTouch::Calibrated {
                                                force: __field0,
                                                max_possible_force: __field1,
                                                altitude_angle: __field2,
                                            })
                                    }
                                    #[inline]
                                    fn visit_map<__A>(self, mut __map: __A)
                                        -> _serde::__private229::Result<Self::Value, __A::Error>
                                        where __A: _serde::de::MapAccess<'de> {
                                        let mut __field0: _serde::__private229::Option<f64> =
                                            _serde::__private229::None;
                                        let mut __field1: _serde::__private229::Option<f64> =
                                            _serde::__private229::None;
                                        let mut __field2:
                                                _serde::__private229::Option<Option<f64>> =
                                            _serde::__private229::None;
                                        while let _serde::__private229::Some(__key) =
                                                _serde::de::MapAccess::next_key::<__Field>(&mut __map)? {
                                            match __key {
                                                __Field::__field0 => {
                                                    if _serde::__private229::Option::is_some(&__field0) {
                                                        return _serde::__private229::Err(<__A::Error as
                                                                        _serde::de::Error>::duplicate_field("force"));
                                                    }
                                                    __field0 =
                                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<f64>(&mut __map)?);
                                                }
                                                __Field::__field1 => {
                                                    if _serde::__private229::Option::is_some(&__field1) {
                                                        return _serde::__private229::Err(<__A::Error as
                                                                        _serde::de::Error>::duplicate_field("max_possible_force"));
                                                    }
                                                    __field1 =
                                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<f64>(&mut __map)?);
                                                }
                                                __Field::__field2 => {
                                                    if _serde::__private229::Option::is_some(&__field2) {
                                                        return _serde::__private229::Err(<__A::Error as
                                                                        _serde::de::Error>::duplicate_field("altitude_angle"));
                                                    }
                                                    __field2 =
                                                        _serde::__private229::Some(_serde::de::MapAccess::next_value::<Option<f64>>(&mut __map)?);
                                                }
                                                _ => {
                                                    let _ =
                                                        _serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)?;
                                                }
                                            }
                                        }
                                        let __field0 =
                                            match __field0 {
                                                _serde::__private229::Some(__field0) => __field0,
                                                _serde::__private229::None =>
                                                    _serde::__private229::de::missing_field("force")?,
                                            };
                                        let __field1 =
                                            match __field1 {
                                                _serde::__private229::Some(__field1) => __field1,
                                                _serde::__private229::None =>
                                                    _serde::__private229::de::missing_field("max_possible_force")?,
                                            };
                                        let __field2 =
                                            match __field2 {
                                                _serde::__private229::Some(__field2) => __field2,
                                                _serde::__private229::None =>
                                                    _serde::__private229::de::missing_field("altitude_angle")?,
                                            };
                                        _serde::__private229::Ok(ForceTouch::Calibrated {
                                                force: __field0,
                                                max_possible_force: __field1,
                                                altitude_angle: __field2,
                                            })
                                    }
                                }
                                #[doc(hidden)]
                                const FIELDS: &'static [&'static str] =
                                    &["force", "max_possible_force", "altitude_angle"];
                                _serde::de::VariantAccess::struct_variant(__variant, FIELDS,
                                    __Visitor {
                                        marker: _serde::__private229::PhantomData::<ForceTouch>,
                                        lifetime: _serde::__private229::PhantomData,
                                    })
                            }
                            _serde::__private229::Ok((__Field::__field1, __variant)) =>
                                _serde::__private229::Result::map(_serde::de::VariantAccess::newtype_variant::<f64>(__variant),
                                    ForceTouch::Normalized),
                            _serde::__private229::Err(__err) =>
                                _serde::__private229::Err(__err),
                        }
                    }
                }
                #[doc(hidden)]
                const VARIANTS: &'static [&'static str] =
                    &["Calibrated", "Normalized"];
                _serde::Deserializer::deserialize_enum(__deserializer,
                    "ForceTouch", VARIANTS,
                    __Visitor {
                        marker: _serde::__private229::PhantomData::<ForceTouch>,
                        lifetime: _serde::__private229::PhantomData,
                    })
            }
        }
    };serde::Deserialize))]
77#[cfg_attr(
78    all(feature = "serialize", feature = "bevy_reflect"),
79    reflect(Serialize, Deserialize)
80)]
81pub enum ForceTouch {
82    /// On iOS, the force is calibrated so that the same number corresponds to
83    /// roughly the same amount of pressure on the screen regardless of the
84    /// device.
85    Calibrated {
86        /// The force of the touch, where a value of 1.0 represents the force of
87        /// an average touch (predetermined by the system, not user-specific).
88        ///
89        /// The force reported by Apple Pencil is measured along the axis of the
90        /// pencil. If you want a force perpendicular to the device, you need to
91        /// calculate this value using the `altitude_angle` value.
92        force: f64,
93        /// The maximum possible force for a touch.
94        ///
95        /// The value of this field is sufficiently high to provide a wide
96        /// dynamic range for values of the `force` field.
97        max_possible_force: f64,
98        /// The altitude (in radians) of the stylus.
99        ///
100        /// A value of 0 radians indicates that the stylus is parallel to the
101        /// surface. The value of this property is Pi/2 when the stylus is
102        /// perpendicular to the surface.
103        altitude_angle: Option<f64>,
104    },
105    /// If the platform reports the force as normalized, we have no way of
106    /// knowing how much pressure 1.0 corresponds to – we know it's the maximum
107    /// amount of force, but as to how much force, you might either have to
108    /// press really hard, or not hard at all, depending on the device.
109    Normalized(f64),
110}
111
112/// A phase of a [`TouchInput`].
113///
114/// ## Usage
115///
116/// It is used to describe the phase of the touch input that is currently active.
117/// This includes a phase that indicates that a touch input has started or ended,
118/// or that a finger has moved. There is also a canceled phase that indicates that
119/// the system canceled the tracking of the finger.
120#[derive(#[automatically_derived]impl ::core::fmt::Debug for TouchPhase {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TouchPhase::Started => "Started",
                TouchPhase::Moved => "Moved",
                TouchPhase::Ended => "Ended",
                TouchPhase::Canceled => "Canceled",
            })
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for TouchPhase {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    TouchPhase {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TouchPhase {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for TouchPhase { }Eq, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for TouchPhase {
}
#[automatically_derived]impl ::core::clone::Clone for TouchPhase {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for TouchPhase { }Copy)]
121#[cfg_attr(
122    feature = "bevy_reflect",
123    derive(const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for TouchPhase where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectSerialize, Self,
                    _>(());
                registration.register_type_data_with::<ReflectDeserialize,
                    Self, _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {}
        }
        impl bevy_reflect::Typed for TouchPhase where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Enum(bevy_reflect::enums::EnumInfo::new::<Self>(&[bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Started")),
                                                bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Moved")),
                                                bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Ended")),
                                                bevy_reflect::enums::VariantInfo::Unit(bevy_reflect::enums::UnitVariantInfo::new("Canceled"))]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for TouchPhase where  {
            fn type_path() -> &'static str { "bevy_input::touch::TouchPhase" }
            fn short_type_path() -> &'static str { "TouchPhase" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("TouchPhase")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_input::touch")
            }
        }
        impl bevy_reflect::Reflect for TouchPhase where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        impl bevy_reflect::enums::Enum for TouchPhase where  {
            fn field(&self, __name_param: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_at(&self, __index_param: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_mut(&mut self, __name_param: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn field_at_mut(&mut self, __index_param: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match self { _ => ::core::option::Option::None, }
            }
            fn index_of(&self, __name_param: &str)
                -> ::core::option::Option<usize> {
                match self { _ => ::core::option::Option::None, }
            }
            fn name_at(&self, __index_param: usize)
                -> ::core::option::Option<&str> {
                match self { _ => ::core::option::Option::None, }
            }
            fn iter_fields(&self) -> bevy_reflect::enums::VariantFieldIter {
                bevy_reflect::enums::VariantFieldIter::new(self)
            }
            #[inline]
            fn field_len(&self) -> usize {
                match self {
                    TouchPhase::Started { .. } => 0usize,
                    TouchPhase::Moved { .. } => 0usize,
                    TouchPhase::Ended { .. } => 0usize,
                    TouchPhase::Canceled { .. } => 0usize,
                    _ => 0,
                }
            }
            #[inline]
            fn variant_name(&self) -> &str {
                match self {
                    TouchPhase::Started { .. } => "Started",
                    TouchPhase::Moved { .. } => "Moved",
                    TouchPhase::Ended { .. } => "Ended",
                    TouchPhase::Canceled { .. } => "Canceled",
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            #[inline]
            fn variant_index(&self) -> usize {
                match self {
                    TouchPhase::Started { .. } => 0usize,
                    TouchPhase::Moved { .. } => 1usize,
                    TouchPhase::Ended { .. } => 2usize,
                    TouchPhase::Canceled { .. } => 3usize,
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            #[inline]
            fn variant_type(&self) -> bevy_reflect::enums::VariantType {
                match self {
                    TouchPhase::Started { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    TouchPhase::Moved { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    TouchPhase::Ended { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    TouchPhase::Canceled { .. } =>
                        bevy_reflect::enums::VariantType::Unit,
                    _ => ::core::panicking::unreachable_default_msg(),
                }
            }
            fn to_dynamic_enum(&self)
                ->
                    ::core::result::Result<bevy_reflect::enums::DynamicEnum,
                    bevy_reflect::ReflectCloneError> {
                bevy_reflect::enums::DynamicEnum::try_from_ref::<Self>(self)
            }
        }
        impl bevy_reflect::PartialReflect for TouchPhase where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self,
                __value_param: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Enum(__value_param) =
                        bevy_reflect::PartialReflect::reflect_ref(__value_param) {
                    if bevy_reflect::enums::Enum::variant_name(self) ==
                            bevy_reflect::enums::Enum::variant_name(__value_param) {
                        match bevy_reflect::enums::Enum::variant_type(__value_param)
                            {
                            bevy_reflect::enums::VariantType::Struct => {
                                for field in
                                    bevy_reflect::enums::Enum::iter_fields(__value_param) {
                                    let name = field.name().unwrap();
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_mut(self, name) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            bevy_reflect::enums::VariantType::Tuple => {
                                for (index, field) in
                                    ::core::iter::Iterator::enumerate(bevy_reflect::enums::Enum::iter_fields(__value_param))
                                    {
                                    if let ::core::option::Option::Some(v) =
                                            bevy_reflect::enums::Enum::field_at_mut(self, index) {
                                        bevy_reflect::PartialReflect::try_apply(v, field.value())?;
                                    }
                                }
                            }
                            _ => {}
                        }
                    } else {
                        match bevy_reflect::enums::Enum::variant_name(__value_param)
                            {
                            "Started" => { *self = TouchPhase::Started {} }
                            "Moved" => { *self = TouchPhase::Moved {} }
                            "Ended" => { *self = TouchPhase::Ended {} }
                            "Canceled" => { *self = TouchPhase::Canceled {} }
                            name => {
                                return ::core::result::Result::Err(bevy_reflect::ApplyError::UnknownVariant {
                                            enum_name: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(self)),
                                            variant_name: ::core::convert::Into::into(name),
                                        });
                            }
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(__value_param),
                                to_kind: bevy_reflect::ReflectKind::Enum,
                            });
                }
                ::core::result::Result::Ok(())
            }
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Enum
            }
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Enum(self)
            }
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Enum(self)
            }
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Enum(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_hash(&self) -> ::core::option::Option<u64> {
                use ::core::hash::{Hash, Hasher};
                let mut hasher = bevy_reflect::utility::reflect_hasher();
                Hash::hash(&::core::any::Any::type_id(self), &mut hasher);
                Hash::hash(self, &mut hasher);
                ::core::option::Option::Some(Hasher::finish(&hasher))
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                let value =
                    <dyn bevy_reflect::PartialReflect>::try_downcast_ref::<Self>(value);
                if let ::core::option::Option::Some(value) = value {
                    ::core::option::Option::Some(::core::cmp::PartialEq::eq(self,
                            value))
                } else { ::core::option::Option::Some(false) }
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::enums::enum_partial_cmp)(self, value)
            }
            fn debug(&self, f: &mut ::core::fmt::Formatter<'_>)
                -> ::core::fmt::Result {
                ::core::fmt::Debug::fmt(self, f)
            }
            #[inline]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(::core::clone::Clone::clone(self)))
            }
        }
        impl bevy_reflect::FromReflect for TouchPhase where  {
            fn from_reflect(__param0: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Enum(__param0) =
                        bevy_reflect::PartialReflect::reflect_ref(__param0) {
                    match bevy_reflect::enums::Enum::variant_name(__param0) {
                        "Started" =>
                            ::core::option::Option::Some(TouchPhase::Started {}),
                        "Moved" =>
                            ::core::option::Option::Some(TouchPhase::Moved {}),
                        "Ended" =>
                            ::core::option::Option::Some(TouchPhase::Ended {}),
                        "Canceled" =>
                            ::core::option::Option::Some(TouchPhase::Canceled {}),
                        name => ::core::option::Option::None,
                    }
                } else { ::core::option::Option::None }
            }
        }
    };Reflect),
124    reflect(Debug, Hash, PartialEq, Clone)
125)]
126#[cfg_attr(feature = "serialize", derive(#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl _serde::Serialize for TouchPhase {
            fn serialize<__S>(&self, __serializer: __S)
                -> _serde::__private229::Result<__S::Ok, __S::Error> where
                __S: _serde::Serializer {
                match *self {
                    TouchPhase::Started =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "TouchPhase", 0u32, "Started"),
                    TouchPhase::Moved =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "TouchPhase", 1u32, "Moved"),
                    TouchPhase::Ended =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "TouchPhase", 2u32, "Ended"),
                    TouchPhase::Canceled =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "TouchPhase", 3u32, "Canceled"),
                }
            }
        }
    };serde::Serialize, #[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl<'de> _serde::Deserialize<'de> for TouchPhase {
            fn deserialize<__D>(__deserializer: __D)
                -> _serde::__private229::Result<Self, __D::Error> where
                __D: _serde::Deserializer<'de> {
                #[allow(non_camel_case_types)]
                #[doc(hidden)]
                enum __Field { __field0, __field1, __field2, __field3, }
                #[doc(hidden)]
                struct __FieldVisitor;
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
                    type Value = __Field;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "variant identifier")
                    }
                    fn visit_u64<__E>(self, __value: u64)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            0u64 => _serde::__private229::Ok(__Field::__field0),
                            1u64 => _serde::__private229::Ok(__Field::__field1),
                            2u64 => _serde::__private229::Ok(__Field::__field2),
                            3u64 => _serde::__private229::Ok(__Field::__field3),
                            _ =>
                                _serde::__private229::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
                                        &"variant index 0 <= i < 4")),
                        }
                    }
                    fn visit_str<__E>(self, __value: &str)
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            "Started" => _serde::__private229::Ok(__Field::__field0),
                            "Moved" => _serde::__private229::Ok(__Field::__field1),
                            "Ended" => _serde::__private229::Ok(__Field::__field2),
                            "Canceled" => _serde::__private229::Ok(__Field::__field3),
                            _ => {
                                _serde::__private229::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                    fn visit_bytes<__E>(self, __value: &[u8])
                        -> _serde::__private229::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            b"Started" => _serde::__private229::Ok(__Field::__field0),
                            b"Moved" => _serde::__private229::Ok(__Field::__field1),
                            b"Ended" => _serde::__private229::Ok(__Field::__field2),
                            b"Canceled" => _serde::__private229::Ok(__Field::__field3),
                            _ => {
                                let __value =
                                    &_serde::__private229::from_utf8_lossy(__value);
                                _serde::__private229::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                }
                #[automatically_derived]
                impl<'de> _serde::Deserialize<'de> for __Field {
                    #[inline]
                    fn deserialize<__D>(__deserializer: __D)
                        -> _serde::__private229::Result<Self, __D::Error> where
                        __D: _serde::Deserializer<'de> {
                        _serde::Deserializer::deserialize_identifier(__deserializer,
                            __FieldVisitor)
                    }
                }
                #[doc(hidden)]
                struct __Visitor<'de> {
                    marker: _serde::__private229::PhantomData<TouchPhase>,
                    lifetime: _serde::__private229::PhantomData<&'de ()>,
                }
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
                    type Value = TouchPhase;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private229::Formatter)
                        -> _serde::__private229::fmt::Result {
                        _serde::__private229::Formatter::write_str(__formatter,
                            "enum TouchPhase")
                    }
                    fn visit_enum<__A>(self, __data: __A)
                        -> _serde::__private229::Result<Self::Value, __A::Error>
                        where __A: _serde::de::EnumAccess<'de> {
                        match _serde::de::EnumAccess::variant(__data) {
                            _serde::__private229::Ok((__Field::__field0, __variant)) =>
                                {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private229::Ok(TouchPhase::Started)
                            }
                            _serde::__private229::Ok((__Field::__field1, __variant)) =>
                                {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private229::Ok(TouchPhase::Moved)
                            }
                            _serde::__private229::Ok((__Field::__field2, __variant)) =>
                                {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private229::Ok(TouchPhase::Ended)
                            }
                            _serde::__private229::Ok((__Field::__field3, __variant)) =>
                                {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private229::Ok(TouchPhase::Canceled)
                            }
                            _serde::__private229::Err(__err) =>
                                _serde::__private229::Err(__err),
                        }
                    }
                }
                #[doc(hidden)]
                const VARIANTS: &'static [&'static str] =
                    &["Started", "Moved", "Ended", "Canceled"];
                _serde::Deserializer::deserialize_enum(__deserializer,
                    "TouchPhase", VARIANTS,
                    __Visitor {
                        marker: _serde::__private229::PhantomData::<TouchPhase>,
                        lifetime: _serde::__private229::PhantomData,
                    })
            }
        }
    };serde::Deserialize))]
127#[cfg_attr(
128    all(feature = "serialize", feature = "bevy_reflect"),
129    reflect(Serialize, Deserialize)
130)]
131pub enum TouchPhase {
132    /// A finger started to touch the touchscreen.
133    Started,
134    /// A finger moved over the touchscreen.
135    Moved,
136    /// A finger stopped touching the touchscreen.
137    Ended,
138    /// The system canceled the tracking of the finger.
139    ///
140    /// This occurs when the window loses focus, or on iOS if the user moves the
141    /// device against their face.
142    Canceled,
143}
144
145/// A touch input.
146///
147/// ## Usage
148///
149/// It is used to store the position and force of a touch input and also the `id` of the finger.
150/// The data of the touch input comes from the [`TouchInput`] event and is being stored
151/// inside of the [`Touches`] `bevy` resource.
152#[derive(#[automatically_derived]impl ::core::fmt::Debug for Touch {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["id", "start_position", "start_force", "previous_position",
                        "previous_force", "position", "force"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.id, &self.start_position, &self.start_force,
                        &self.previous_position, &self.previous_force,
                        &self.position, &&self.force];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Touch", names,
            values)
    }
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Touch {
}
#[automatically_derived]impl ::core::clone::Clone for Touch {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u64>;
        let _: ::core::clone::AssertParamIsClone<Vec2>;
        let _: ::core::clone::AssertParamIsClone<Option<ForceTouch>>;
        let _: ::core::clone::AssertParamIsClone<Option<ForceTouch>>;
        let _: ::core::clone::AssertParamIsClone<Option<ForceTouch>>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Touch { }Copy)]
153pub struct Touch {
154    /// The id of the touch input.
155    id: u64,
156    /// The starting position of the touch input.
157    start_position: Vec2,
158    /// The starting force of the touch input.
159    start_force: Option<ForceTouch>,
160    /// The previous position of the touch input.
161    previous_position: Vec2,
162    /// The previous force of the touch input.
163    previous_force: Option<ForceTouch>,
164    /// The current position of the touch input.
165    position: Vec2,
166    /// The current force of the touch input.
167    force: Option<ForceTouch>,
168}
169
170impl Touch {
171    /// The delta of the current `position` and the `previous_position`.
172    pub fn delta(&self) -> Vec2 {
173        self.position - self.previous_position
174    }
175
176    /// The distance of the `start_position` and the current `position`.
177    pub fn distance(&self) -> Vec2 {
178        self.position - self.start_position
179    }
180
181    /// Returns the `id` of the touch.
182    #[inline]
183    pub fn id(&self) -> u64 {
184        self.id
185    }
186
187    /// Returns the `start_position` of the touch.
188    #[inline]
189    pub fn start_position(&self) -> Vec2 {
190        self.start_position
191    }
192
193    /// Returns the `start_force` of the touch.
194    #[inline]
195    pub fn start_force(&self) -> Option<ForceTouch> {
196        self.start_force
197    }
198
199    /// Returns the `previous_position` of the touch.
200    #[inline]
201    pub fn previous_position(&self) -> Vec2 {
202        self.previous_position
203    }
204
205    /// Returns the `previous_force` of the touch.
206    #[inline]
207    pub fn previous_force(&self) -> Option<ForceTouch> {
208        self.previous_force
209    }
210
211    /// Returns the current `position` of the touch.
212    #[inline]
213    pub fn position(&self) -> Vec2 {
214        self.position
215    }
216
217    /// Returns the current `force` of the touch.
218    #[inline]
219    pub fn force(&self) -> Option<ForceTouch> {
220        self.force
221    }
222}
223
224impl From<&TouchInput> for Touch {
225    fn from(input: &TouchInput) -> Touch {
226        Touch {
227            id: input.id,
228            start_position: input.position,
229            start_force: input.force,
230            previous_position: input.position,
231            previous_force: input.force,
232            position: input.position,
233            force: input.force,
234        }
235    }
236}
237
238/// A collection of [`Touch`]es.
239///
240/// ## Usage
241///
242/// It is used to create a `bevy` resource that stores the data of the touches on a touchscreen
243/// and can be accessed inside of a system.
244///
245/// ## Updating
246///
247/// The resource is updated inside of the [`touch_screen_input_system`].
248#[derive(#[automatically_derived]impl ::core::fmt::Debug for Touches {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "Touches",
            "pressed", &self.pressed, "just_pressed", &self.just_pressed,
            "just_released", &self.just_released, "just_canceled",
            &&self.just_canceled)
    }
}Debug, #[automatically_derived]impl ::core::clone::Clone for Touches {
    #[inline]
    fn clone(&self) -> Self {
        Touches {
            pressed: ::core::clone::Clone::clone(&self.pressed),
            just_pressed: ::core::clone::Clone::clone(&self.just_pressed),
            just_released: ::core::clone::Clone::clone(&self.just_released),
            just_canceled: ::core::clone::Clone::clone(&self.just_canceled),
        }
    }
}Clone, #[automatically_derived]impl ::core::default::Default for Touches {
    #[inline]
    fn default() -> Self {
        Touches {
            pressed: ::core::default::Default::default(),
            just_pressed: ::core::default::Default::default(),
            just_released: ::core::default::Default::default(),
            just_canceled: ::core::default::Default::default(),
        }
    }
}Default, impl bevy_ecs::component::Component for Touches where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    const STORAGE_TYPE: bevy_ecs::component::StorageType =
        bevy_ecs::component::StorageType::SparseSet;
    type Mutability = bevy_ecs::component::Mutable;
    fn register_required_components(_requiree:
            bevy_ecs::component::ComponentId,
        required_components:
            &mut bevy_ecs::component::RequiredComponentsRegistrator) {
        let resource_component_id =
            if let ::core::option::Option::Some(id) =
                    required_components.components_registrator().component_id::<Touches>()
                {
                id
            } else {
                required_components.components_registrator().register_component::<Touches>()
            };
        required_components.register_required::<bevy_ecs::resource::IsResource>(move
                ||
                bevy_ecs::resource::IsResource::new(resource_component_id));
    }
    fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
        use bevy_ecs::component::{
            DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
        };
        (&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
    }
    fn relationship_accessor()
        ->
            ::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
        ::core::option::Option::None
    }
}
impl bevy_ecs::resource::Resource for Touches where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Resource)]
249pub struct Touches {
250    /// A collection of every [`Touch`] that is currently being pressed.
251    pressed: HashMap<u64, Touch>,
252    /// A collection of every [`Touch`] that just got pressed.
253    just_pressed: HashMap<u64, Touch>,
254    /// A collection of every [`Touch`] that just got released.
255    just_released: HashMap<u64, Touch>,
256    /// A collection of every [`Touch`] that just got canceled.
257    just_canceled: HashMap<u64, Touch>,
258}
259
260impl Touches {
261    /// An iterator visiting every pressed [`Touch`] input in arbitrary order.
262    pub fn iter(&self) -> impl Iterator<Item = &Touch> + '_ {
263        self.pressed.values()
264    }
265
266    /// Returns the [`Touch`] input corresponding to the `id` if it is being pressed.
267    pub fn get_pressed(&self, id: u64) -> Option<&Touch> {
268        self.pressed.get(&id)
269    }
270
271    /// Checks if any touch input was just pressed.
272    pub fn any_just_pressed(&self) -> bool {
273        !self.just_pressed.is_empty()
274    }
275
276    /// Register a release for a given touch input.
277    pub fn release(&mut self, id: u64) {
278        if let Some(touch) = self.pressed.remove(&id) {
279            self.just_released.insert(id, touch);
280        }
281    }
282
283    /// Registers a release for all currently pressed touch inputs.
284    pub fn release_all(&mut self) {
285        self.just_released.extend(self.pressed.drain());
286    }
287
288    /// Returns `true` if the input corresponding to the `id` has just been pressed.
289    pub fn just_pressed(&self, id: u64) -> bool {
290        self.just_pressed.contains_key(&id)
291    }
292
293    /// Clears the `just_pressed` state of the touch input and returns `true` if the touch input has just been pressed.
294    ///
295    /// Future calls to [`Touches::just_pressed`] for the given touch input will return false until a new press event occurs.
296    pub fn clear_just_pressed(&mut self, id: u64) -> bool {
297        self.just_pressed.remove(&id).is_some()
298    }
299
300    /// An iterator visiting every just pressed [`Touch`] input in arbitrary order.
301    pub fn iter_just_pressed(&self) -> impl Iterator<Item = &Touch> {
302        self.just_pressed.values()
303    }
304
305    /// Returns the [`Touch`] input corresponding to the `id` if it has just been released.
306    pub fn get_released(&self, id: u64) -> Option<&Touch> {
307        self.just_released.get(&id)
308    }
309
310    /// Checks if any touch input was just released.
311    pub fn any_just_released(&self) -> bool {
312        !self.just_released.is_empty()
313    }
314
315    /// Returns `true` if the input corresponding to the `id` has just been released.
316    pub fn just_released(&self, id: u64) -> bool {
317        self.just_released.contains_key(&id)
318    }
319
320    /// Clears the `just_released` state of the touch input and returns `true` if the touch input has just been released.
321    ///
322    /// Future calls to [`Touches::just_released`] for the given touch input will return false until a new release event occurs.
323    pub fn clear_just_released(&mut self, id: u64) -> bool {
324        self.just_released.remove(&id).is_some()
325    }
326
327    /// An iterator visiting every just released [`Touch`] input in arbitrary order.
328    pub fn iter_just_released(&self) -> impl Iterator<Item = &Touch> {
329        self.just_released.values()
330    }
331
332    /// Checks if any touch input was just canceled.
333    pub fn any_just_canceled(&self) -> bool {
334        !self.just_canceled.is_empty()
335    }
336
337    /// Returns `true` if the input corresponding to the `id` has just been canceled.
338    pub fn just_canceled(&self, id: u64) -> bool {
339        self.just_canceled.contains_key(&id)
340    }
341
342    /// Clears the `just_canceled` state of the touch input and returns `true` if the touch input has just been canceled.
343    ///
344    /// Future calls to [`Touches::just_canceled`] for the given touch input will return false until a new cancel event occurs.
345    pub fn clear_just_canceled(&mut self, id: u64) -> bool {
346        self.just_canceled.remove(&id).is_some()
347    }
348
349    /// An iterator visiting every just canceled [`Touch`] input in arbitrary order.
350    pub fn iter_just_canceled(&self) -> impl Iterator<Item = &Touch> {
351        self.just_canceled.values()
352    }
353
354    /// Retrieves the position of the first currently pressed touch, if any
355    pub fn first_pressed_position(&self) -> Option<Vec2> {
356        // Looking for the position in `pressed`. If nothing is found, also look into `just_pressed`
357        // A touch can be in `just_pressed` but not in `pressed` if it ended in the same frame it started
358        self.pressed
359            .values()
360            .next()
361            .or_else(|| self.just_pressed.values().next())
362            .map(|t| t.position)
363    }
364
365    /// Clears `just_pressed`, `just_released`, and `just_canceled` data for every touch input.
366    ///
367    /// See also [`Touches::reset_all`] for a full reset.
368    pub fn clear(&mut self) {
369        self.just_pressed.clear();
370        self.just_released.clear();
371        self.just_canceled.clear();
372    }
373
374    /// Clears `pressed`, `just_pressed`, `just_released`, and `just_canceled` data for every touch input.
375    ///
376    /// See also [`Touches::clear`] for clearing only touches that have just been pressed, released or canceled.
377    pub fn reset_all(&mut self) {
378        self.pressed.clear();
379        self.just_pressed.clear();
380        self.just_released.clear();
381        self.just_canceled.clear();
382    }
383
384    /// Processes a [`TouchInput`] event by updating the `pressed`, `just_pressed`,
385    /// `just_released`, and `just_canceled` collections.
386    fn process_touch_event(&mut self, event: &TouchInput) {
387        match event.phase {
388            TouchPhase::Started => {
389                self.pressed.insert(event.id, event.into());
390                self.just_pressed.insert(event.id, event.into());
391            }
392            TouchPhase::Moved => {
393                if let Some(mut new_touch) = self.pressed.get(&event.id).cloned() {
394                    // NOTE: This does not update the previous_force / previous_position field;
395                    // they should be updated once per frame, not once per event
396                    // See https://github.com/bevyengine/bevy/issues/12442
397                    new_touch.position = event.position;
398                    new_touch.force = event.force;
399                    self.pressed.insert(event.id, new_touch);
400                }
401            }
402            TouchPhase::Ended => {
403                // if touch `just_released`, add related event to it
404                // the event position info is inside `pressed`, so use it unless not found
405                if let Some((_, v)) = self.pressed.remove_entry(&event.id) {
406                    self.just_released.insert(event.id, v);
407                } else {
408                    self.just_released.insert(event.id, event.into());
409                }
410            }
411            TouchPhase::Canceled => {
412                // if touch `just_canceled`, add related event to it
413                // the event position info is inside `pressed`, so use it unless not found
414                if let Some((_, v)) = self.pressed.remove_entry(&event.id) {
415                    self.just_canceled.insert(event.id, v);
416                } else {
417                    self.just_canceled.insert(event.id, event.into());
418                }
419            }
420        };
421    }
422}
423
424/// Updates the [`Touches`] resource with the latest [`TouchInput`] events.
425///
426/// This is not clearing the `pressed` collection, because it could incorrectly mark a touch input
427/// as not pressed even though it is pressed. This could happen if the touch input is not moving
428/// for a single frame and would therefore be marked as not pressed, because this function is
429/// called on every single frame no matter if there was an event or not.
430///
431/// ## Differences
432///
433/// The main difference between the [`TouchInput`] event and the [`Touches`] resource is that
434/// the latter has convenient functions like [`Touches::just_pressed`] and [`Touches::just_released`].
435pub fn touch_screen_input_system(
436    mut touch_state: ResMut<Touches>,
437    mut touch_input_reader: MessageReader<TouchInput>,
438) {
439    if !touch_state.just_pressed.is_empty() {
440        touch_state.just_pressed.clear();
441    }
442    if !touch_state.just_released.is_empty() {
443        touch_state.just_released.clear();
444    }
445    if !touch_state.just_canceled.is_empty() {
446        touch_state.just_canceled.clear();
447    }
448
449    if !touch_input_reader.is_empty() {
450        for touch in touch_state.pressed.values_mut() {
451            touch.previous_position = touch.position;
452            touch.previous_force = touch.force;
453        }
454
455        for event in touch_input_reader.read() {
456            touch_state.process_touch_event(event);
457        }
458    }
459}
460
461#[cfg(test)]
462mod test {
463    use super::Touches;
464    use bevy_ecs::{entity::Entity, world::World};
465
466    fn dummy_window_entity() -> Entity {
467        World::default().spawn_empty().id()
468    }
469
470    #[test]
471    fn touch_update() {
472        use crate::{touch::Touch, Touches};
473        use bevy_math::Vec2;
474
475        let mut touches = Touches::default();
476
477        let touch_event = Touch {
478            id: 4,
479            start_position: Vec2::ZERO,
480            start_force: None,
481            previous_position: Vec2::ZERO,
482            previous_force: None,
483            position: Vec2::ZERO,
484            force: None,
485        };
486
487        // Add a touch to `just_pressed`, 'just_released', and 'just canceled'
488
489        touches.just_pressed.insert(4, touch_event);
490        touches.just_released.insert(4, touch_event);
491        touches.just_canceled.insert(4, touch_event);
492
493        clear_all(&mut touches);
494
495        // Verify that all the `just_x` maps are cleared
496        assert!(touches.just_pressed.is_empty());
497        assert!(touches.just_released.is_empty());
498        assert!(touches.just_canceled.is_empty());
499    }
500
501    #[test]
502    fn touch_process() {
503        use crate::{touch::TouchPhase, TouchInput, Touches};
504        use bevy_math::Vec2;
505
506        let mut touches = Touches::default();
507
508        // Test adding a `TouchPhase::Started`
509
510        let touch_event = TouchInput {
511            phase: TouchPhase::Started,
512            position: Vec2::splat(4.0),
513            window: dummy_window_entity(),
514            force: None,
515            id: 4,
516        };
517
518        clear_all(&mut touches);
519        touches.process_touch_event(&touch_event);
520
521        assert!(touches.pressed.get(&touch_event.id).is_some());
522        assert!(touches.just_pressed.get(&touch_event.id).is_some());
523
524        // Test adding a `TouchPhase::Moved`
525
526        let moved_touch_event = TouchInput {
527            phase: TouchPhase::Moved,
528            position: Vec2::splat(5.0),
529            window: dummy_window_entity(),
530            force: None,
531            id: touch_event.id,
532        };
533
534        clear_all(&mut touches);
535        touches.process_touch_event(&moved_touch_event);
536
537        assert_eq!(
538            touches
539                .pressed
540                .get(&moved_touch_event.id)
541                .expect("Missing from pressed after move.")
542                .previous_position,
543            touch_event.position
544        );
545
546        // Test cancelling an event
547
548        let cancel_touch_event = TouchInput {
549            phase: TouchPhase::Canceled,
550            position: Vec2::ONE,
551            window: dummy_window_entity(),
552            force: None,
553            id: touch_event.id,
554        };
555
556        clear_all(&mut touches);
557        touches.process_touch_event(&cancel_touch_event);
558
559        assert!(touches.just_canceled.get(&touch_event.id).is_some());
560        assert!(touches.pressed.get(&touch_event.id).is_none());
561
562        // Test ending an event
563
564        let end_touch_event = TouchInput {
565            phase: TouchPhase::Ended,
566            position: Vec2::splat(4.0),
567            window: dummy_window_entity(),
568            force: None,
569            id: touch_event.id,
570        };
571
572        clear_all(&mut touches);
573        touches.process_touch_event(&touch_event);
574        touches.process_touch_event(&moved_touch_event);
575        touches.process_touch_event(&end_touch_event);
576
577        assert!(touches.just_released.get(&touch_event.id).is_some());
578        assert!(touches.pressed.get(&touch_event.id).is_none());
579        let touch = touches.just_released.get(&touch_event.id).unwrap();
580        // Make sure the position is updated from TouchPhase::Moved and TouchPhase::Ended
581        assert_ne!(touch.previous_position, touch.position);
582    }
583
584    // See https://github.com/bevyengine/bevy/issues/12442
585    #[test]
586    fn touch_process_multi_event() {
587        use crate::{touch::TouchPhase, TouchInput, Touches};
588        use bevy_math::Vec2;
589
590        let mut touches = Touches::default();
591
592        let started_touch_event = TouchInput {
593            phase: TouchPhase::Started,
594            position: Vec2::splat(4.0),
595            window: dummy_window_entity(),
596            force: None,
597            id: 4,
598        };
599
600        let moved_touch_event1 = TouchInput {
601            phase: TouchPhase::Moved,
602            position: Vec2::splat(5.0),
603            window: dummy_window_entity(),
604            force: None,
605            id: started_touch_event.id,
606        };
607
608        let moved_touch_event2 = TouchInput {
609            phase: TouchPhase::Moved,
610            position: Vec2::splat(6.0),
611            window: dummy_window_entity(),
612            force: None,
613            id: started_touch_event.id,
614        };
615
616        // tick 1: touch is started during frame
617        for touch in touches.pressed.values_mut() {
618            // update ONCE, at start of frame
619            touch.previous_position = touch.position;
620        }
621        touches.process_touch_event(&started_touch_event);
622        touches.process_touch_event(&moved_touch_event1);
623        touches.process_touch_event(&moved_touch_event2);
624
625        {
626            let touch = touches.get_pressed(started_touch_event.id).unwrap();
627            assert_eq!(touch.previous_position, started_touch_event.position);
628            assert_eq!(touch.position, moved_touch_event2.position);
629        }
630
631        // tick 2: touch was started before frame
632        for touch in touches.pressed.values_mut() {
633            touch.previous_position = touch.position;
634        }
635        touches.process_touch_event(&moved_touch_event1);
636        touches.process_touch_event(&moved_touch_event2);
637        touches.process_touch_event(&moved_touch_event1);
638
639        {
640            let touch = touches.get_pressed(started_touch_event.id).unwrap();
641            assert_eq!(touch.previous_position, moved_touch_event2.position);
642            assert_eq!(touch.position, moved_touch_event1.position);
643        }
644    }
645
646    #[test]
647    fn touch_pressed() {
648        use crate::{touch::TouchPhase, TouchInput, Touches};
649        use bevy_math::Vec2;
650
651        let mut touches = Touches::default();
652
653        let touch_event = TouchInput {
654            phase: TouchPhase::Started,
655            position: Vec2::splat(4.0),
656            window: dummy_window_entity(),
657            force: None,
658            id: 4,
659        };
660
661        // Register the touch and test that it was registered correctly
662        touches.process_touch_event(&touch_event);
663
664        assert!(touches.get_pressed(touch_event.id).is_some());
665        assert!(touches.just_pressed(touch_event.id));
666        assert_eq!(touches.iter().count(), 1);
667
668        touches.clear_just_pressed(touch_event.id);
669        assert!(!touches.just_pressed(touch_event.id));
670    }
671
672    #[test]
673    fn touch_released() {
674        use crate::{touch::TouchPhase, TouchInput, Touches};
675        use bevy_math::Vec2;
676
677        let mut touches = Touches::default();
678
679        let touch_event = TouchInput {
680            phase: TouchPhase::Ended,
681            position: Vec2::splat(4.0),
682            window: dummy_window_entity(),
683            force: None,
684            id: 4,
685        };
686
687        // Register the touch and test that it was registered correctly
688        touches.process_touch_event(&touch_event);
689
690        assert!(touches.get_released(touch_event.id).is_some());
691        assert!(touches.just_released(touch_event.id));
692        assert_eq!(touches.iter_just_released().count(), 1);
693
694        touches.clear_just_released(touch_event.id);
695        assert!(!touches.just_released(touch_event.id));
696    }
697
698    #[test]
699    fn touch_canceled() {
700        use crate::{touch::TouchPhase, TouchInput, Touches};
701        use bevy_math::Vec2;
702
703        let mut touches = Touches::default();
704
705        let touch_event = TouchInput {
706            phase: TouchPhase::Canceled,
707            position: Vec2::splat(4.0),
708            window: dummy_window_entity(),
709            force: None,
710            id: 4,
711        };
712
713        // Register the touch and test that it was registered correctly
714        touches.process_touch_event(&touch_event);
715
716        assert!(touches.just_canceled(touch_event.id));
717        assert_eq!(touches.iter_just_canceled().count(), 1);
718
719        touches.clear_just_canceled(touch_event.id);
720        assert!(!touches.just_canceled(touch_event.id));
721    }
722
723    #[test]
724    fn release_touch() {
725        use crate::{touch::TouchPhase, TouchInput, Touches};
726        use bevy_math::Vec2;
727
728        let mut touches = Touches::default();
729
730        let touch_event = TouchInput {
731            phase: TouchPhase::Started,
732            position: Vec2::splat(4.0),
733            window: dummy_window_entity(),
734            force: None,
735            id: 4,
736        };
737
738        // Register the touch and test that it was registered correctly
739        touches.process_touch_event(&touch_event);
740
741        assert!(touches.get_pressed(touch_event.id).is_some());
742
743        touches.release(touch_event.id);
744        assert!(touches.get_pressed(touch_event.id).is_none());
745        assert!(touches.just_released(touch_event.id));
746    }
747
748    #[test]
749    fn release_all_touches() {
750        use crate::{touch::TouchPhase, TouchInput, Touches};
751        use bevy_math::Vec2;
752
753        let mut touches = Touches::default();
754
755        let touch_pressed_event = TouchInput {
756            phase: TouchPhase::Started,
757            position: Vec2::splat(4.0),
758            window: dummy_window_entity(),
759            force: None,
760            id: 4,
761        };
762
763        let touch_moved_event = TouchInput {
764            phase: TouchPhase::Moved,
765            position: Vec2::splat(4.0),
766            window: dummy_window_entity(),
767            force: None,
768            id: 4,
769        };
770
771        touches.process_touch_event(&touch_pressed_event);
772        touches.process_touch_event(&touch_moved_event);
773
774        assert!(touches.get_pressed(touch_pressed_event.id).is_some());
775        assert!(touches.get_pressed(touch_moved_event.id).is_some());
776
777        touches.release_all();
778
779        assert!(touches.get_pressed(touch_pressed_event.id).is_none());
780        assert!(touches.just_released(touch_pressed_event.id));
781        assert!(touches.get_pressed(touch_moved_event.id).is_none());
782        assert!(touches.just_released(touch_moved_event.id));
783    }
784
785    #[test]
786    fn clear_touches() {
787        use crate::{touch::TouchPhase, TouchInput, Touches};
788        use bevy_math::Vec2;
789
790        let mut touches = Touches::default();
791
792        let touch_press_event = TouchInput {
793            phase: TouchPhase::Started,
794            position: Vec2::splat(4.0),
795            window: dummy_window_entity(),
796            force: None,
797            id: 4,
798        };
799
800        let touch_canceled_event = TouchInput {
801            phase: TouchPhase::Canceled,
802            position: Vec2::splat(4.0),
803            window: dummy_window_entity(),
804            force: None,
805            id: 5,
806        };
807
808        let touch_released_event = TouchInput {
809            phase: TouchPhase::Ended,
810            position: Vec2::splat(4.0),
811            window: dummy_window_entity(),
812            force: None,
813            id: 6,
814        };
815
816        // Register the touches and test that it was registered correctly
817        touches.process_touch_event(&touch_press_event);
818        touches.process_touch_event(&touch_canceled_event);
819        touches.process_touch_event(&touch_released_event);
820
821        assert!(touches.get_pressed(touch_press_event.id).is_some());
822        assert!(touches.just_pressed(touch_press_event.id));
823        assert!(touches.just_canceled(touch_canceled_event.id));
824        assert!(touches.just_released(touch_released_event.id));
825
826        touches.clear();
827
828        assert!(touches.get_pressed(touch_press_event.id).is_some());
829        assert!(!touches.just_pressed(touch_press_event.id));
830        assert!(!touches.just_canceled(touch_canceled_event.id));
831        assert!(!touches.just_released(touch_released_event.id));
832    }
833
834    #[test]
835    fn reset_all_touches() {
836        use crate::{touch::TouchPhase, TouchInput, Touches};
837        use bevy_math::Vec2;
838
839        let mut touches = Touches::default();
840
841        let touch_press_event = TouchInput {
842            phase: TouchPhase::Started,
843            position: Vec2::splat(4.0),
844            window: dummy_window_entity(),
845            force: None,
846            id: 4,
847        };
848
849        let touch_canceled_event = TouchInput {
850            phase: TouchPhase::Canceled,
851            position: Vec2::splat(4.0),
852            window: dummy_window_entity(),
853            force: None,
854            id: 5,
855        };
856
857        let touch_released_event = TouchInput {
858            phase: TouchPhase::Ended,
859            position: Vec2::splat(4.0),
860            window: dummy_window_entity(),
861            force: None,
862            id: 6,
863        };
864
865        // Register the touches and test that it was registered correctly
866        touches.process_touch_event(&touch_press_event);
867        touches.process_touch_event(&touch_canceled_event);
868        touches.process_touch_event(&touch_released_event);
869
870        assert!(touches.get_pressed(touch_press_event.id).is_some());
871        assert!(touches.just_pressed(touch_press_event.id));
872        assert!(touches.just_canceled(touch_canceled_event.id));
873        assert!(touches.just_released(touch_released_event.id));
874
875        touches.reset_all();
876
877        assert!(touches.get_pressed(touch_press_event.id).is_none());
878        assert!(!touches.just_pressed(touch_press_event.id));
879        assert!(!touches.just_canceled(touch_canceled_event.id));
880        assert!(!touches.just_released(touch_released_event.id));
881    }
882
883    fn clear_all(touch_state: &mut Touches) {
884        touch_state.just_pressed.clear();
885        touch_state.just_released.clear();
886        touch_state.just_canceled.clear();
887    }
888}