openrr_plugin/gen/
proxy.rs

1// This file is @generated by openrr-internal-codegen.
2// It is not intended for manual editing.
3
4#![allow(unused_variables)]
5#![allow(clippy::useless_conversion, clippy::unit_arg)]
6
7use abi_stable::{rtry, std_types::{RBox, RDuration, ROk, RResult, RStr}};
8use super::*;
9pub(crate) type PluginTraitObject = RPluginTrait_TO<RBox<()>>;
10#[sabi_trait]
11pub(crate) trait RPluginTrait: Send + Sync + 'static {
12    fn new_gamepad(
13        &self,
14        args: RString,
15    ) -> RResult<ROption<crate::GamepadProxy>, RError>;
16    fn new_joint_trajectory_client(
17        &self,
18        args: RString,
19    ) -> RResult<ROption<crate::JointTrajectoryClientProxy>, RError>;
20    fn new_laser_scan2_d(
21        &self,
22        args: RString,
23    ) -> RResult<ROption<crate::LaserScan2DProxy>, RError>;
24    fn new_localization(
25        &self,
26        args: RString,
27    ) -> RResult<ROption<crate::LocalizationProxy>, RError>;
28    fn new_motor_drive_position(
29        &self,
30        args: RString,
31    ) -> RResult<ROption<crate::MotorDrivePositionProxy>, RError>;
32    fn new_motor_drive_velocity(
33        &self,
34        args: RString,
35    ) -> RResult<ROption<crate::MotorDriveVelocityProxy>, RError>;
36    fn new_motor_drive_effort(
37        &self,
38        args: RString,
39    ) -> RResult<ROption<crate::MotorDriveEffortProxy>, RError>;
40    fn new_move_base(
41        &self,
42        args: RString,
43    ) -> RResult<ROption<crate::MoveBaseProxy>, RError>;
44    fn new_navigation(
45        &self,
46        args: RString,
47    ) -> RResult<ROption<crate::NavigationProxy>, RError>;
48    fn new_speaker(
49        &self,
50        args: RString,
51    ) -> RResult<ROption<crate::SpeakerProxy>, RError>;
52    fn new_transform_resolver(
53        &self,
54        args: RString,
55    ) -> RResult<ROption<crate::TransformResolverProxy>, RError>;
56}
57impl<T> RPluginTrait for T
58where
59    T: crate::Plugin,
60{
61    fn new_gamepad(
62        &self,
63        args: RString,
64    ) -> RResult<ROption<crate::GamepadProxy>, RError> {
65        ROk(
66            rtry!(crate ::Plugin::new_gamepad(self, args.into()))
67                .map(crate::GamepadProxy::new)
68                .into(),
69        )
70    }
71    fn new_joint_trajectory_client(
72        &self,
73        args: RString,
74    ) -> RResult<ROption<crate::JointTrajectoryClientProxy>, RError> {
75        ROk(
76            rtry!(crate ::Plugin::new_joint_trajectory_client(self, args.into()))
77                .map(crate::JointTrajectoryClientProxy::new)
78                .into(),
79        )
80    }
81    fn new_laser_scan2_d(
82        &self,
83        args: RString,
84    ) -> RResult<ROption<crate::LaserScan2DProxy>, RError> {
85        ROk(
86            rtry!(crate ::Plugin::new_laser_scan2_d(self, args.into()))
87                .map(crate::LaserScan2DProxy::new)
88                .into(),
89        )
90    }
91    fn new_localization(
92        &self,
93        args: RString,
94    ) -> RResult<ROption<crate::LocalizationProxy>, RError> {
95        ROk(
96            rtry!(crate ::Plugin::new_localization(self, args.into()))
97                .map(crate::LocalizationProxy::new)
98                .into(),
99        )
100    }
101    fn new_motor_drive_position(
102        &self,
103        args: RString,
104    ) -> RResult<ROption<crate::MotorDrivePositionProxy>, RError> {
105        ROk(
106            rtry!(crate ::Plugin::new_motor_drive_position(self, args.into()))
107                .map(crate::MotorDrivePositionProxy::new)
108                .into(),
109        )
110    }
111    fn new_motor_drive_velocity(
112        &self,
113        args: RString,
114    ) -> RResult<ROption<crate::MotorDriveVelocityProxy>, RError> {
115        ROk(
116            rtry!(crate ::Plugin::new_motor_drive_velocity(self, args.into()))
117                .map(crate::MotorDriveVelocityProxy::new)
118                .into(),
119        )
120    }
121    fn new_motor_drive_effort(
122        &self,
123        args: RString,
124    ) -> RResult<ROption<crate::MotorDriveEffortProxy>, RError> {
125        ROk(
126            rtry!(crate ::Plugin::new_motor_drive_effort(self, args.into()))
127                .map(crate::MotorDriveEffortProxy::new)
128                .into(),
129        )
130    }
131    fn new_move_base(
132        &self,
133        args: RString,
134    ) -> RResult<ROption<crate::MoveBaseProxy>, RError> {
135        ROk(
136            rtry!(crate ::Plugin::new_move_base(self, args.into()))
137                .map(crate::MoveBaseProxy::new)
138                .into(),
139        )
140    }
141    fn new_navigation(
142        &self,
143        args: RString,
144    ) -> RResult<ROption<crate::NavigationProxy>, RError> {
145        ROk(
146            rtry!(crate ::Plugin::new_navigation(self, args.into()))
147                .map(crate::NavigationProxy::new)
148                .into(),
149        )
150    }
151    fn new_speaker(
152        &self,
153        args: RString,
154    ) -> RResult<ROption<crate::SpeakerProxy>, RError> {
155        ROk(
156            rtry!(crate ::Plugin::new_speaker(self, args.into()))
157                .map(crate::SpeakerProxy::new)
158                .into(),
159        )
160    }
161    fn new_transform_resolver(
162        &self,
163        args: RString,
164    ) -> RResult<ROption<crate::TransformResolverProxy>, RError> {
165        ROk(
166            rtry!(crate ::Plugin::new_transform_resolver(self, args.into()))
167                .map(crate::TransformResolverProxy::new)
168                .into(),
169        )
170    }
171}
172pub(crate) type GamepadTraitObject = RGamepadTrait_TO<RBox<()>>;
173#[abi_stable::sabi_trait]
174pub(crate) trait RGamepadTrait: Send + Sync + Clone + 'static {
175    fn next_event(&self) -> FfiFuture<RGamepadEvent>;
176    fn stop(&self);
177}
178impl<T> RGamepadTrait for Arc<T>
179where
180    T: ?Sized + arci::Gamepad + 'static,
181{
182    fn next_event(&self) -> FfiFuture<RGamepadEvent> {
183        let _guard = crate::TOKIO.enter();
184        let this = self.clone();
185        async move { arci::Gamepad::next_event(&*this).await.into() }.into_ffi()
186    }
187    fn stop(&self) {
188        let _guard = crate::TOKIO.enter();
189        arci::Gamepad::stop(&**self).into()
190    }
191}
192pub(crate) type JointTrajectoryClientTraitObject = RJointTrajectoryClientTrait_TO<
193    RBox<()>,
194>;
195#[abi_stable::sabi_trait]
196pub(crate) trait RJointTrajectoryClientTrait: Send + Sync + 'static {
197    fn joint_names(&self) -> RVec<RString>;
198    fn current_joint_positions(&self) -> RResult<RVec<f64>, RError>;
199    fn send_joint_positions(
200        &self,
201        positions: RVec<f64>,
202        duration: RDuration,
203    ) -> RResult<RWaitFuture, RError>;
204    fn send_joint_trajectory(
205        &self,
206        trajectory: RVec<RTrajectoryPoint>,
207    ) -> RResult<RWaitFuture, RError>;
208}
209impl<T> RJointTrajectoryClientTrait for T
210where
211    T: arci::JointTrajectoryClient + 'static,
212{
213    fn joint_names(&self) -> RVec<RString> {
214        let _guard = crate::TOKIO.enter();
215        arci::JointTrajectoryClient::joint_names(self)
216            .into_iter()
217            .map(Into::into)
218            .collect()
219    }
220    fn current_joint_positions(&self) -> RResult<RVec<f64>, RError> {
221        let _guard = crate::TOKIO.enter();
222        ROk(rtry!(arci::JointTrajectoryClient::current_joint_positions(self)).into())
223    }
224    fn send_joint_positions(
225        &self,
226        positions: RVec<f64>,
227        duration: RDuration,
228    ) -> RResult<RWaitFuture, RError> {
229        let _guard = crate::TOKIO.enter();
230        ROk(
231            rtry!(
232                arci::JointTrajectoryClient::send_joint_positions(self, positions.into(),
233                duration.into())
234            )
235                .into(),
236        )
237    }
238    fn send_joint_trajectory(
239        &self,
240        trajectory: RVec<RTrajectoryPoint>,
241    ) -> RResult<RWaitFuture, RError> {
242        let _guard = crate::TOKIO.enter();
243        ROk(
244            rtry!(
245                arci::JointTrajectoryClient::send_joint_trajectory(self, trajectory
246                .into_iter().map(Into::into).collect())
247            )
248                .into(),
249        )
250    }
251}
252pub(crate) type LaserScan2DTraitObject = RLaserScan2DTrait_TO<RBox<()>>;
253#[abi_stable::sabi_trait]
254pub(crate) trait RLaserScan2DTrait: Send + Sync + 'static {
255    fn current_scan(&self) -> RResult<RScan2D, RError>;
256}
257impl<T> RLaserScan2DTrait for T
258where
259    T: arci::LaserScan2D + 'static,
260{
261    fn current_scan(&self) -> RResult<RScan2D, RError> {
262        let _guard = crate::TOKIO.enter();
263        ROk(rtry!(arci::LaserScan2D::current_scan(self)).into())
264    }
265}
266pub(crate) type LocalizationTraitObject = RLocalizationTrait_TO<RBox<()>>;
267#[abi_stable::sabi_trait]
268pub(crate) trait RLocalizationTrait: Send + Sync + 'static {
269    fn current_pose(&self, frame_id: RStr<'_>) -> RResult<RIsometry2F64, RError>;
270}
271impl<T> RLocalizationTrait for T
272where
273    T: arci::Localization + 'static,
274{
275    fn current_pose(&self, frame_id: RStr<'_>) -> RResult<RIsometry2F64, RError> {
276        let _guard = crate::TOKIO.enter();
277        ROk(rtry!(arci::Localization::current_pose(self, frame_id.into())).into())
278    }
279}
280pub(crate) type MotorDrivePositionTraitObject = RMotorDrivePositionTrait_TO<RBox<()>>;
281#[abi_stable::sabi_trait]
282pub(crate) trait RMotorDrivePositionTrait: Send + Sync + 'static {
283    fn set_motor_position(&self, position: f64) -> RResult<(), RError>;
284    fn get_motor_position(&self) -> RResult<f64, RError>;
285}
286impl<T> RMotorDrivePositionTrait for T
287where
288    T: arci::MotorDrivePosition + 'static,
289{
290    fn set_motor_position(&self, position: f64) -> RResult<(), RError> {
291        let _guard = crate::TOKIO.enter();
292        ROk(
293            rtry!(arci::MotorDrivePosition::set_motor_position(self, position.into()))
294                .into(),
295        )
296    }
297    fn get_motor_position(&self) -> RResult<f64, RError> {
298        let _guard = crate::TOKIO.enter();
299        ROk(rtry!(arci::MotorDrivePosition::get_motor_position(self)).into())
300    }
301}
302pub(crate) type MotorDriveVelocityTraitObject = RMotorDriveVelocityTrait_TO<RBox<()>>;
303#[abi_stable::sabi_trait]
304pub(crate) trait RMotorDriveVelocityTrait: Send + Sync + 'static {
305    fn set_motor_velocity(&self, velocity: f64) -> RResult<(), RError>;
306    fn get_motor_velocity(&self) -> RResult<f64, RError>;
307}
308impl<T> RMotorDriveVelocityTrait for T
309where
310    T: arci::MotorDriveVelocity + 'static,
311{
312    fn set_motor_velocity(&self, velocity: f64) -> RResult<(), RError> {
313        let _guard = crate::TOKIO.enter();
314        ROk(
315            rtry!(arci::MotorDriveVelocity::set_motor_velocity(self, velocity.into()))
316                .into(),
317        )
318    }
319    fn get_motor_velocity(&self) -> RResult<f64, RError> {
320        let _guard = crate::TOKIO.enter();
321        ROk(rtry!(arci::MotorDriveVelocity::get_motor_velocity(self)).into())
322    }
323}
324pub(crate) type MotorDriveEffortTraitObject = RMotorDriveEffortTrait_TO<RBox<()>>;
325#[abi_stable::sabi_trait]
326pub(crate) trait RMotorDriveEffortTrait: Send + Sync + 'static {
327    fn set_motor_effort(&self, effort: f64) -> RResult<(), RError>;
328    fn get_motor_effort(&self) -> RResult<f64, RError>;
329}
330impl<T> RMotorDriveEffortTrait for T
331where
332    T: arci::MotorDriveEffort + 'static,
333{
334    fn set_motor_effort(&self, effort: f64) -> RResult<(), RError> {
335        let _guard = crate::TOKIO.enter();
336        ROk(rtry!(arci::MotorDriveEffort::set_motor_effort(self, effort.into())).into())
337    }
338    fn get_motor_effort(&self) -> RResult<f64, RError> {
339        let _guard = crate::TOKIO.enter();
340        ROk(rtry!(arci::MotorDriveEffort::get_motor_effort(self)).into())
341    }
342}
343pub(crate) type MoveBaseTraitObject = RMoveBaseTrait_TO<RBox<()>>;
344#[abi_stable::sabi_trait]
345pub(crate) trait RMoveBaseTrait: Send + Sync + 'static {
346    fn send_velocity(&self, velocity: RBaseVelocity) -> RResult<(), RError>;
347    fn current_velocity(&self) -> RResult<RBaseVelocity, RError>;
348}
349impl<T> RMoveBaseTrait for T
350where
351    T: arci::MoveBase + 'static,
352{
353    fn send_velocity(&self, velocity: RBaseVelocity) -> RResult<(), RError> {
354        let _guard = crate::TOKIO.enter();
355        ROk(rtry!(arci::MoveBase::send_velocity(self, & velocity.into())).into())
356    }
357    fn current_velocity(&self) -> RResult<RBaseVelocity, RError> {
358        let _guard = crate::TOKIO.enter();
359        ROk(rtry!(arci::MoveBase::current_velocity(self)).into())
360    }
361}
362pub(crate) type NavigationTraitObject = RNavigationTrait_TO<RBox<()>>;
363#[abi_stable::sabi_trait]
364pub(crate) trait RNavigationTrait: Send + Sync + 'static {
365    fn send_goal_pose(
366        &self,
367        goal: RIsometry2F64,
368        frame_id: RStr<'_>,
369        timeout: RDuration,
370    ) -> RResult<RWaitFuture, RError>;
371    fn cancel(&self) -> RResult<(), RError>;
372}
373impl<T> RNavigationTrait for T
374where
375    T: arci::Navigation + 'static,
376{
377    fn send_goal_pose(
378        &self,
379        goal: RIsometry2F64,
380        frame_id: RStr<'_>,
381        timeout: RDuration,
382    ) -> RResult<RWaitFuture, RError> {
383        let _guard = crate::TOKIO.enter();
384        ROk(
385            rtry!(
386                arci::Navigation::send_goal_pose(self, goal.into(), frame_id.into(),
387                timeout.into())
388            )
389                .into(),
390        )
391    }
392    fn cancel(&self) -> RResult<(), RError> {
393        let _guard = crate::TOKIO.enter();
394        ROk(rtry!(arci::Navigation::cancel(self)).into())
395    }
396}
397pub(crate) type SpeakerTraitObject = RSpeakerTrait_TO<RBox<()>>;
398#[abi_stable::sabi_trait]
399pub(crate) trait RSpeakerTrait: Send + Sync + 'static {
400    fn speak(&self, message: RStr<'_>) -> RResult<RWaitFuture, RError>;
401}
402impl<T> RSpeakerTrait for T
403where
404    T: arci::Speaker + 'static,
405{
406    fn speak(&self, message: RStr<'_>) -> RResult<RWaitFuture, RError> {
407        let _guard = crate::TOKIO.enter();
408        ROk(rtry!(arci::Speaker::speak(self, message.into())).into())
409    }
410}
411pub(crate) type TransformResolverTraitObject = RTransformResolverTrait_TO<RBox<()>>;
412#[abi_stable::sabi_trait]
413pub(crate) trait RTransformResolverTrait: Send + Sync + 'static {
414    fn resolve_transformation(
415        &self,
416        from: RStr<'_>,
417        to: RStr<'_>,
418        time: RSystemTime,
419    ) -> RResult<RIsometry3F64, RError>;
420}
421impl<T> RTransformResolverTrait for T
422where
423    T: arci::TransformResolver + 'static,
424{
425    fn resolve_transformation(
426        &self,
427        from: RStr<'_>,
428        to: RStr<'_>,
429        time: RSystemTime,
430    ) -> RResult<RIsometry3F64, RError> {
431        let _guard = crate::TOKIO.enter();
432        ROk(
433            rtry!(
434                arci::TransformResolver::resolve_transformation(self, from.into(), to
435                .into(), rtry!(time.try_into()))
436            )
437                .into(),
438        )
439    }
440}
441/// FFI-safe equivalent of [`arci::TrajectoryPoint`].
442#[derive(StableAbi)]
443#[repr(C)]
444pub(crate) struct RTrajectoryPoint {
445    positions: RVec<f64>,
446    velocities: ROption<RVec<f64>>,
447    time_from_start: RDuration,
448}
449impl From<arci::TrajectoryPoint> for RTrajectoryPoint {
450    fn from(v: arci::TrajectoryPoint) -> Self {
451        let arci::TrajectoryPoint { positions, velocities, time_from_start } = v;
452        Self {
453            positions: positions.into_iter().collect(),
454            velocities: velocities.map(|v| v.into_iter().collect()).into(),
455            time_from_start: time_from_start.into(),
456        }
457    }
458}
459impl From<RTrajectoryPoint> for arci::TrajectoryPoint {
460    fn from(v: RTrajectoryPoint) -> Self {
461        let RTrajectoryPoint { positions, velocities, time_from_start } = v;
462        Self {
463            positions: positions.into_iter().collect(),
464            velocities: velocities.into_option().map(|v| v.into_iter().collect()),
465            time_from_start: time_from_start.into(),
466        }
467    }
468}
469/// FFI-safe equivalent of [`arci::Scan2D`].
470#[derive(StableAbi)]
471#[repr(C)]
472pub(crate) struct RScan2D {
473    angle_min: f64,
474    angle_max: f64,
475    angle_increment: f64,
476    time_increment: f64,
477    scan_time: f64,
478    range_min: f64,
479    range_max: f64,
480    ranges: RVec<f64>,
481    intensities: RVec<f64>,
482}
483impl From<arci::Scan2D> for RScan2D {
484    fn from(v: arci::Scan2D) -> Self {
485        let arci::Scan2D {
486            angle_min,
487            angle_max,
488            angle_increment,
489            time_increment,
490            scan_time,
491            range_min,
492            range_max,
493            ranges,
494            intensities,
495        } = v;
496        Self {
497            angle_min,
498            angle_max,
499            angle_increment,
500            time_increment,
501            scan_time,
502            range_min,
503            range_max,
504            ranges: ranges.into_iter().collect(),
505            intensities: intensities.into_iter().collect(),
506        }
507    }
508}
509impl From<RScan2D> for arci::Scan2D {
510    fn from(v: RScan2D) -> Self {
511        let RScan2D {
512            angle_min,
513            angle_max,
514            angle_increment,
515            time_increment,
516            scan_time,
517            range_min,
518            range_max,
519            ranges,
520            intensities,
521        } = v;
522        Self {
523            angle_min,
524            angle_max,
525            angle_increment,
526            time_increment,
527            scan_time,
528            range_min,
529            range_max,
530            ranges: ranges.into_iter().collect(),
531            intensities: intensities.into_iter().collect(),
532        }
533    }
534}
535/// FFI-safe equivalent of [`arci::BaseVelocity`].
536#[derive(StableAbi)]
537#[repr(C)]
538pub(crate) struct RBaseVelocity {
539    x: f64,
540    y: f64,
541    theta: f64,
542}
543impl From<arci::BaseVelocity> for RBaseVelocity {
544    fn from(v: arci::BaseVelocity) -> Self {
545        let arci::BaseVelocity { x, y, theta } = v;
546        Self { x, y, theta }
547    }
548}
549impl From<RBaseVelocity> for arci::BaseVelocity {
550    fn from(v: RBaseVelocity) -> Self {
551        let RBaseVelocity { x, y, theta } = v;
552        Self { x, y, theta }
553    }
554}
555/// FFI-safe equivalent of [`arci::Button`].
556#[derive(StableAbi)]
557#[repr(C)]
558pub(crate) enum RButton {
559    South,
560    East,
561    North,
562    West,
563    LeftTrigger,
564    LeftTrigger2,
565    RightTrigger,
566    RightTrigger2,
567    Select,
568    Start,
569    Mode,
570    LeftThumb,
571    RightThumb,
572    DPadUp,
573    DPadDown,
574    DPadLeft,
575    DPadRight,
576    Unknown,
577}
578impl From<arci::gamepad::Button> for RButton {
579    fn from(v: arci::gamepad::Button) -> Self {
580        match v {
581            arci::gamepad::Button::South => Self::South,
582            arci::gamepad::Button::East => Self::East,
583            arci::gamepad::Button::North => Self::North,
584            arci::gamepad::Button::West => Self::West,
585            arci::gamepad::Button::LeftTrigger => Self::LeftTrigger,
586            arci::gamepad::Button::LeftTrigger2 => Self::LeftTrigger2,
587            arci::gamepad::Button::RightTrigger => Self::RightTrigger,
588            arci::gamepad::Button::RightTrigger2 => Self::RightTrigger2,
589            arci::gamepad::Button::Select => Self::Select,
590            arci::gamepad::Button::Start => Self::Start,
591            arci::gamepad::Button::Mode => Self::Mode,
592            arci::gamepad::Button::LeftThumb => Self::LeftThumb,
593            arci::gamepad::Button::RightThumb => Self::RightThumb,
594            arci::gamepad::Button::DPadUp => Self::DPadUp,
595            arci::gamepad::Button::DPadDown => Self::DPadDown,
596            arci::gamepad::Button::DPadLeft => Self::DPadLeft,
597            arci::gamepad::Button::DPadRight => Self::DPadRight,
598            arci::gamepad::Button::Unknown => Self::Unknown,
599        }
600    }
601}
602impl From<RButton> for arci::gamepad::Button {
603    fn from(v: RButton) -> Self {
604        match v {
605            RButton::South => Self::South,
606            RButton::East => Self::East,
607            RButton::North => Self::North,
608            RButton::West => Self::West,
609            RButton::LeftTrigger => Self::LeftTrigger,
610            RButton::LeftTrigger2 => Self::LeftTrigger2,
611            RButton::RightTrigger => Self::RightTrigger,
612            RButton::RightTrigger2 => Self::RightTrigger2,
613            RButton::Select => Self::Select,
614            RButton::Start => Self::Start,
615            RButton::Mode => Self::Mode,
616            RButton::LeftThumb => Self::LeftThumb,
617            RButton::RightThumb => Self::RightThumb,
618            RButton::DPadUp => Self::DPadUp,
619            RButton::DPadDown => Self::DPadDown,
620            RButton::DPadLeft => Self::DPadLeft,
621            RButton::DPadRight => Self::DPadRight,
622            RButton::Unknown => Self::Unknown,
623        }
624    }
625}
626/// FFI-safe equivalent of [`arci::Axis`].
627#[derive(StableAbi)]
628#[repr(C)]
629pub(crate) enum RAxis {
630    LeftStickX,
631    LeftStickY,
632    LeftTrigger,
633    RightStickX,
634    RightStickY,
635    RightTrigger,
636    DPadX,
637    DPadY,
638    Unknown,
639}
640impl From<arci::gamepad::Axis> for RAxis {
641    fn from(v: arci::gamepad::Axis) -> Self {
642        match v {
643            arci::gamepad::Axis::LeftStickX => Self::LeftStickX,
644            arci::gamepad::Axis::LeftStickY => Self::LeftStickY,
645            arci::gamepad::Axis::LeftTrigger => Self::LeftTrigger,
646            arci::gamepad::Axis::RightStickX => Self::RightStickX,
647            arci::gamepad::Axis::RightStickY => Self::RightStickY,
648            arci::gamepad::Axis::RightTrigger => Self::RightTrigger,
649            arci::gamepad::Axis::DPadX => Self::DPadX,
650            arci::gamepad::Axis::DPadY => Self::DPadY,
651            arci::gamepad::Axis::Unknown => Self::Unknown,
652        }
653    }
654}
655impl From<RAxis> for arci::gamepad::Axis {
656    fn from(v: RAxis) -> Self {
657        match v {
658            RAxis::LeftStickX => Self::LeftStickX,
659            RAxis::LeftStickY => Self::LeftStickY,
660            RAxis::LeftTrigger => Self::LeftTrigger,
661            RAxis::RightStickX => Self::RightStickX,
662            RAxis::RightStickY => Self::RightStickY,
663            RAxis::RightTrigger => Self::RightTrigger,
664            RAxis::DPadX => Self::DPadX,
665            RAxis::DPadY => Self::DPadY,
666            RAxis::Unknown => Self::Unknown,
667        }
668    }
669}
670/// FFI-safe equivalent of [`arci::GamepadEvent`].
671#[derive(StableAbi)]
672#[repr(C)]
673pub(crate) enum RGamepadEvent {
674    ButtonPressed(RButton),
675    ButtonReleased(RButton),
676    AxisChanged(RAxis, f64),
677    Connected,
678    Disconnected,
679    Unknown,
680}
681impl From<arci::gamepad::GamepadEvent> for RGamepadEvent {
682    fn from(v: arci::gamepad::GamepadEvent) -> Self {
683        match v {
684            arci::gamepad::GamepadEvent::ButtonPressed(field0) => {
685                Self::ButtonPressed(field0.into())
686            }
687            arci::gamepad::GamepadEvent::ButtonReleased(field0) => {
688                Self::ButtonReleased(field0.into())
689            }
690            arci::gamepad::GamepadEvent::AxisChanged(field0, field1) => {
691                Self::AxisChanged(field0.into(), field1)
692            }
693            arci::gamepad::GamepadEvent::Connected => Self::Connected,
694            arci::gamepad::GamepadEvent::Disconnected => Self::Disconnected,
695            arci::gamepad::GamepadEvent::Unknown => Self::Unknown,
696        }
697    }
698}
699impl From<RGamepadEvent> for arci::gamepad::GamepadEvent {
700    fn from(v: RGamepadEvent) -> Self {
701        match v {
702            RGamepadEvent::ButtonPressed(field0) => Self::ButtonPressed(field0.into()),
703            RGamepadEvent::ButtonReleased(field0) => Self::ButtonReleased(field0.into()),
704            RGamepadEvent::AxisChanged(field0, field1) => {
705                Self::AxisChanged(field0.into(), field1)
706            }
707            RGamepadEvent::Connected => Self::Connected,
708            RGamepadEvent::Disconnected => Self::Disconnected,
709            RGamepadEvent::Unknown => Self::Unknown,
710        }
711    }
712}