Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions stick/src/ctlr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::collections::HashMap;
use std::fmt::Debug;
use std::future::Future;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
use std::task::{Context, Poll};

use crate::Event;
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Default for Info {

/// Controller remapping information
#[derive(Debug)]
pub struct Remap(HashMap<u64, Rc<Info>>);
pub struct Remap(HashMap<u64, Arc<Info>>);

impl Default for Remap {
fn default() -> Self {
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Remap {
);
}

self.0.insert(id, Rc::new(Info { name, maps, type_ }));
self.0.insert(id, Arc::new(Info { name, maps, type_ }));
}

Some(self)
Expand All @@ -270,7 +270,7 @@ impl Remap {
/// A gamepad, flightstick, or other controller.
pub struct Controller {
// Shared remapping.
remap: Rc<Info>,
remap: Arc<Info>,
//
raw: Box<dyn crate::raw::Controller>,
// Button states
Expand Down Expand Up @@ -557,8 +557,12 @@ impl Controller {
TrimDown(p) => self.button(Btn::TrimDown, TrimDown, p),
TrimLeft(p) => self.button(Btn::TrimLeft, TrimLeft, p),
TrimRight(p) => self.button(Btn::TrimRight, TrimRight, p),
ActionWheelX(v) => self.axis(ev, Axs::ActionWheelX, ActionWheelX, v),
ActionWheelY(v) => self.axis(ev, Axs::ActionWheelY, ActionWheelY, v),
ActionWheelX(v) => {
self.axis(ev, Axs::ActionWheelX, ActionWheelX, v)
}
ActionWheelY(v) => {
self.axis(ev, Axs::ActionWheelY, ActionWheelY, v)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions stick/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ impl Listener for FakeListener {
}

/// Controller Listener Implementation
pub(crate) trait Listener {
pub(crate) trait Listener: Send {
/// Poll for controllers.
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<crate::Controller>;
}

/// Controller Implementation
pub(crate) trait Controller {
pub(crate) trait Controller: Send {
/// The hardware identifier for this controller.
fn id(&self) -> u64 {
0
Expand Down
15 changes: 7 additions & 8 deletions stick/src/raw/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use crate::{Event, Remap};
use std::fmt::{self, Debug, Formatter};
use std::rc::Rc;
use std::sync::Arc;
use std::task::Waker;
use std::task::{Context, Poll};
Expand Down Expand Up @@ -159,7 +158,7 @@ impl XInputHandle {
/// * `xinput1_1.dll`
/// * `xinput9_1_0.dll`
pub(crate) fn load_default(
) -> Result<Rc<XInputHandle>, XInputLoadingFailure> {
) -> Result<Arc<XInputHandle>, XInputLoadingFailure> {
let xinput14 = "xinput1_4.dll";
let xinput13 = "xinput1_3.dll";
let xinput12 = "xinput1_2.dll";
Expand All @@ -170,7 +169,7 @@ impl XInputHandle {
[xinput14, xinput13, xinput12, xinput11, xinput91].iter()
{
if let Ok(handle) = XInputHandle::load(lib_name) {
return Ok(Rc::new(handle));
return Ok(Arc::new(handle));
}
}

Expand Down Expand Up @@ -633,15 +632,15 @@ fn register_wake_timeout(delay: u32, waker: &Waker) {
////////////////////////////////////////////////////////////////////////////////

pub(crate) struct Controller {
xinput: Rc<XInputHandle>,
xinput: Arc<XInputHandle>,
device_id: u8,
pending_events: Vec<Event>,
last_packet: DWORD,
}

impl Controller {
#[allow(unused)]
fn new(device_id: u8, xinput: Rc<XInputHandle>) -> Self {
fn new(device_id: u8, xinput: Arc<XInputHandle>) -> Self {
Self {
xinput,
device_id,
Expand Down Expand Up @@ -792,14 +791,14 @@ impl super::Controller for Controller {
}

pub(crate) struct Listener {
xinput: Rc<XInputHandle>,
xinput: Arc<XInputHandle>,
connected: u64,
to_check: u8,
remap: Remap,
}

impl Listener {
fn new(remap: Remap, xinput: Rc<XInputHandle>) -> Self {
fn new(remap: Remap, xinput: Arc<XInputHandle>) -> Self {
Self {
xinput,
connected: 0,
Expand Down Expand Up @@ -842,7 +841,7 @@ impl super::Listener for Listener {
}

struct Global {
xinput: Rc<XInputHandle>,
xinput: Arc<XInputHandle>,
}

impl super::Global for Global {
Expand Down