Skip to content

Commit

Permalink
buiklds but does it work?
Browse files Browse the repository at this point in the history
  • Loading branch information
kkevlar committed May 28, 2024
1 parent df72ab1 commit 169e1fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions mjoy_core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Config {
binding_names_file: String,
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Team {
name: String,
players: Vec<String>,
Expand Down Expand Up @@ -158,9 +158,9 @@ fn main() {
// mjoy_gui::gui::WidthHeight::new(1920, 1080),
// );

struct TopContext<'a> {
struct TopContext {
fbinfo: FeedbackInfo,
all_joys: outjoy::Outjoys<'a>,
all_joys: outjoy::Outjoys,
}

let mut top_context = RefCell::new(Some(TopContext {
Expand Down
26 changes: 13 additions & 13 deletions mjoy_core/src/outjoy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use gilrs;
use software_joystick::*;
use strum::IntoEnumIterator;

pub struct Outjoys<'a> {
pub outjoys: Vec<Outjoy<'a>>,
pub struct Outjoys {
pub outjoys: Vec<Outjoy>,
}

pub struct Outjoy<'a> {
team: &'a Team,
pub struct Outjoy {
team: Team,
joy: Joystick,
}

Expand All @@ -36,8 +36,8 @@ fn inaxis_to_outaxis(a: &crate::injoy::NamedAxis) -> software_joystick::Axis {
}
}

impl<'a> Outjoy<'a> {
pub fn new(team: &'a Team, index: u32) -> Self {
impl Outjoy {
pub fn new(team: Team, index: u32) -> Self {
let joy = Joystick::new(format!("Buster{}", index)).unwrap();
Self { team, joy }
}
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<'a> Outjoy<'a> {
}
}

fn update_axes<'b, 'c, 'd, 'e>(&'a self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
fn update_axes<'b, 'c, 'd, 'e>(&self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
use crate::injoy::NamedAxis;

let mut fb_team = None;
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<'a> Outjoy<'a> {
}
}

fn update_buttons<'b, 'c, 'd, 'e>(&'a self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
fn update_buttons<'b, 'c, 'd, 'e>(&self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
use crate::injoy::NamedButton;

let mut fb_team = None;
Expand Down Expand Up @@ -333,7 +333,7 @@ impl<'a> Outjoy<'a> {
}
}

pub fn update<'b, 'c, 'd, 'e>(&'a self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
pub fn update<'b, 'c, 'd, 'e>(&self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
self.update_axes(context);
self.update_buttons(context);
self.joy.synchronise().unwrap();
Expand All @@ -349,16 +349,16 @@ pub struct UpdateContext<'b, 'c, 'e> {
pub button_threshold: f32,
}

impl<'a> Outjoys<'a> {
pub fn new(tl: &'a TeamLock) -> Self {
impl Outjoys {
pub fn new(tl: &TeamLock) -> Self {
let mut outjoys = Vec::new();
for team in tl.teams.iter() {
outjoys.push(Outjoy::new(team, team.out_index));
outjoys.push(Outjoy::new(team.clone(), team.out_index));
}
Self { outjoys }
}

pub fn update<'b, 'c, 'd, 'e>(&'a self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
pub fn update<'b, 'c, 'd, 'e>(&self, context: &'d mut UpdateContext<'b, 'c, 'e>) {
for outjoy in self.outjoys.iter() {
outjoy.update(context);
}
Expand Down

0 comments on commit 169e1fb

Please sign in to comment.