From 86bf85cb2220a7bffc70eeeed6a340142746545f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20A=2E=20S=C3=A6le?= Date: Thu, 26 May 2022 09:12:22 +0700 Subject: [PATCH 1/2] add more flydigi compatibility --- sdb/linux/0300B40411241101.toml | 33 ++++++++++++++++++++++++++++ sdb/linux/0300B40412241101.toml | 6 ++++++ sdb/linux/0500151940000100.toml | 38 +++++++++++++++++++++++++++++++++ stick/remap_linux.sdb | 18 +++++++++------- stick/src/ctlr.rs | 14 ++++++++++++ stick/src/event.rs | 37 +++++++++++++++++++++++++++++++- stick/src/raw/linux.rs | 22 +++++++++++++++++++ xtask/src/sdb.rs | 7 ++++++ 8 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 sdb/linux/0300B40411241101.toml create mode 100644 sdb/linux/0500151940000100.toml diff --git a/sdb/linux/0300B40411241101.toml b/sdb/linux/0300B40411241101.toml new file mode 100644 index 0000000..1d7930d --- /dev/null +++ b/sdb/linux/0300B40411241101.toml @@ -0,0 +1,33 @@ +name = "Flydigi Apex 2 (Wireless)" +type = "gamepad" + +[remap] +# Sticks +JoyZ = "CamX" +CamZ = "CamY" + +# Wheel +Brake = "ActionWheelX" +Gas = "ActionWheelY" + +# Dpad +PovUp = "Up" +PovDown = "Down" +PovLeft = "Left" +PovRight = "Right" + +# Face buttons flipped in function +ActionV = "ActionH" +ActionH = "ActionV" +PinkyRight = "ActionC" +11 = "ActionD" + +# Rear buttons +15 = "ActionL" # Left Nub, diagonally between and bumpers +14 = "ActionR" # Right Nub + +# Underside +13 = "PinkyLeft" # Left Grip +12 = "PinkyRight" # Right Grip +ActionD = "PaddleLeft" # Left Under +ActionC = "PaddleRight" # Right Under diff --git a/sdb/linux/0300B40412241101.toml b/sdb/linux/0300B40412241101.toml index 8c904ef..424a321 100644 --- a/sdb/linux/0300B40412241101.toml +++ b/sdb/linux/0300B40412241101.toml @@ -10,6 +10,12 @@ CamZ = "CamY" Brake = "ActionWheelX" Gas = "ActionWheelY" +# Dpad +PovUp = "Up" +PovDown = "Down" +PovLeft = "Left" +PovRight = "Right" + # Face buttons flipped in function ActionV = "ActionH" ActionH = "ActionV" diff --git a/sdb/linux/0500151940000100.toml b/sdb/linux/0500151940000100.toml new file mode 100644 index 0000000..dfc281c --- /dev/null +++ b/sdb/linux/0500151940000100.toml @@ -0,0 +1,38 @@ +name = "Flydigi Apex 2 (Bluetooth)" +type = "gamepad" + +[remap] +# Sticks +JoyZ = "CamX" +CamZ = "CamY" + +# Wheel +Brake = "ActionWheelX" +Gas = "ActionWheelY" + +# Dpad +PovUp = "Up" +PovDown = "Down" +PovLeft = "Left" +PovRight = "Right" + +# Face buttons flipped in function +ActionV = "ActionH" +ActionH = "ActionV" +MicPush = "ActionC" +Enter = "ActionD" + +# Rear buttons +Sleep = "ActionL" # Left Nub, diagonally between and bumpers +Lang2 = "ActionR" # Right Nub + +# Meta buttons +# Pair is already Pair +# Home is already Home +ThrottleButton = "Exit" + +# Underside +ChinaForward = "PinkyLeft" # Left Grip +Eject = "PinkyRight" # Right Grip +LandingGearSilence = "PaddleLeft" # Left Under +ChinaBackward = "PaddleRight" # Right Under diff --git a/stick/remap_linux.sdb b/stick/remap_linux.sdb index 243b4f8..44d6ca3 100644 --- a/stick/remap_linux.sdb +++ b/stick/remap_linux.sdb @@ -1,11 +1,13 @@ -03005E048E021001X360 Controller x8108;8209;8301;840A;850B;0203;0302;0506;320C;3303;3406;0605;3105;2323s0.992;2424s0.992;250F;2020s0.992;2121s0.992;220E;350D;1D11;1E12;1F13;1C10;3002 -03006F0E01050001PDP Wired Xbox 360 Gamepad x0506;0605;2323d0.075;2424d0.075;250F;2020d0.075;2121d0.075;220E;1D11;1E12;1F13;1C10;0E00;0F00 -03005E04D1020101Microsoft Xbox One Controller x8108;840A;850B;250F;220E;0801;1D11;1E12;1F13;1C10 -03006D0416C21101Logitech Dual Action PlayStation Gamepad p800E;810F;8208;8309;840A;850B;0205;0302;320C;3302;3406;3103;2324;2523s0.67;2223;080A;090B;350D;1D11;1E12;1F13;1C10;3005 -0300B50716031001Thrustmaster Flightstick f2020d0.125;2121d0.125;2227a127i-128 05005E04E0020309Microsoft Xbox Wireless Controller x0405;070D;050C;0C08;0D09;250F;5501;220E;0E0A;0F0B +0300B40411241101Flydigi Apex 2 (Wireless) g8B07;8C54;8D53;8E34;8F32;0452;0751;0506;0605;2E5E;2524;2D5F;2223;5404;1D11;1E12;1F13;1C10 03004C0568021081Shanwan PlayStation3 Gamepad p0203;0302;250F;220E;0E00;0F00 -0300790044181001GameCube Controller - Mayflash Adapter n810D;8A12;8309;8710;8813;8911;3200;3302;3406;3103;230Ed0.125;240Fd0.125;2523s0.67;2020s0.67;2121s0.67;2224s0.67;3500;1D11;1E12;1F13;1C10;3005 -03004F0404041101Thrustmaster Warthog Throttle f8145;8A40;8B41;8C3E;8D3F;8E48;8F4A;9038;9139;924B;9349;8244;944C;953C;963D;9942;9A43;833A;843B;8547;8646;8736;8837;894D;3219;332F;341A;3118;2528a16339;204Ea1024;214Fa1024;2229a16339;351B;2726;3050 +03006F0E01050001PDP Wired Xbox 360 Gamepad x0506;0605;2323d0.075;2424d0.075;250F;2020d0.075;2121d0.075;220E;1D11;1E12;1F13;1C10;0E00;0F00 +0300B50716031001Thrustmaster Flightstick f2020d0.125;2121d0.125;2227a127i-128 03002509E8030101Wii Remote - Mayflash Adapter n800C;810D;8208;8309;8401;3302;3405;3106;2324;240E;250F;2223;1D11;1E12;1F13;1C10;3003 -0300B40412241101Flydigi Apex 2 (Wired) g8B53;8C52;8D51;8E34;8F32;0506;0605;2E5E;2524;2D5F;2223 \ No newline at end of file +03004F0404041101Thrustmaster Warthog Throttle f8145;8A40;8B41;8C3E;8D3F;8E48;8F4A;9038;9139;924B;9349;8244;944C;953C;963D;9942;9A43;833A;843B;8547;8646;8736;8837;894D;3219;332F;341A;3118;2528a16339;204Ea1024;214Fa1024;2229a16339;351B;2726;3050 +03006D0416C21101Logitech Dual Action PlayStation Gamepad p800E;810F;8208;8309;840A;850B;0205;0302;320C;3302;3406;3103;2324;2523s0.67;2223;080A;090B;350D;1D11;1E12;1F13;1C10;3005 +0300B40412241101Flydigi Apex 2 (Wired) g8B53;8C52;8D51;8E34;8F32;0506;0605;2E5E;2524;2D5F;2223;1D11;1E12;1F13;1C10 +0300790044181001GameCube Controller - Mayflash Adapter n810D;8A12;8309;8710;8813;8911;3200;3302;3406;3103;230Ed0.125;240Fd0.125;2523s0.67;2020s0.67;2121s0.67;2224s0.67;3500;1D11;1E12;1F13;1C10;3005 +0500151940000100Flydigi Apex 2 (Bluetooth) g0506;0605;2E5E;2524;4652;4753;6254;6007;2D5F;2223;4A51;6534;2F04;1D11;1E12;1F13;1C10;6132;4D01 +03005E048E021001X360 Controller x8108;8209;8301;840A;850B;0203;0302;0506;320C;3303;3406;0605;3105;2323s0.992;2424s0.992;250F;2020s0.992;2121s0.992;220E;350D;1D11;1E12;1F13;1C10;3002 +03005E04D1020101Microsoft Xbox One Controller x8108;840A;850B;250F;220E;0801;1D11;1E12;1F13;1C10 \ No newline at end of file diff --git a/stick/src/ctlr.rs b/stick/src/ctlr.rs index a57f59a..e58f030 100644 --- a/stick/src/ctlr.rs +++ b/stick/src/ctlr.rs @@ -92,6 +92,13 @@ enum Btn { TrimDown = 69, TrimRight = 70, TrimLeft = 71, + Enter = 72, + Sleep = 73, + Eject = 74, + Pair = 75, + Lang1 = 76, + Lang2 = 77, + Home = 78, } #[repr(i8)] @@ -437,7 +444,10 @@ impl Controller { use Event::*; match event { Disconnect => Poll::Ready(Disconnect), + Enter(p) => self.button(Btn::Enter, Enter, p), Exit(p) => self.button(Btn::Exit, Exit, p), + Sleep(p) => self.button(Btn::Sleep, Sleep, p), + Eject(p) => self.button(Btn::Eject, Eject, p), MenuL(p) => self.button(Btn::MenuL, MenuL, p), MenuR(p) => self.button(Btn::MenuR, MenuR, p), ActionA(p) => self.button(Btn::ActionA, ActionA, p), @@ -559,6 +569,10 @@ impl Controller { 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), + Pair(p) => self.button(Btn::Pair, Pair, p), + Lang1(p) => self.button(Btn::Lang1, Lang1, p), + Lang2(p) => self.button(Btn::Lang2, Lang2, p), + Home(p) => self.button(Btn::Home, Home, p), } } } diff --git a/stick/src/event.rs b/stick/src/event.rs index 636e1f8..1701fb2 100644 --- a/stick/src/event.rs +++ b/stick/src/event.rs @@ -15,8 +15,22 @@ pub enum Event { /// Controller unplugged. Disconnect, - /// Exit / Main / Home / Mode + /// Enter / Carriage Return + Enter(bool), + /// Home Menu (if seperate exit button exists) + Home(bool), + /// Exit / Main / Home / Mode / Back (If seperate button from home) Exit(bool), + /// Sleep + Sleep(bool), + /// Language 1 + Lang1(bool), + /// Language 2 + Lang2(bool), + /// Pair + Pair(bool), + /// Eject + Eject(bool), /// A / 1 / 4 / Circle. Action A (Primary action). ActionA(bool), /// B / 2 / 3 / Cross. Action B (Secondary action). @@ -341,6 +355,13 @@ impl Event { 0x5D => Event::TrimRight(value != 0.0), 0x5E => Event::ActionWheelX(value), 0x5F => Event::ActionWheelY(value), + 0x60 => Event::Enter(value != 0.0), + 0x61 => Event::Sleep(value != 0.0), + 0x62 => Event::Eject(value != 0.0), + 0x63 => Event::Pair(value != 0.0), + 0x64 => Event::Lang1(value != 0.0), + 0x65 => Event::Lang2(value != 0.0), + 0x66 => Event::Home(value != 0.0), n => Event::Number((n & !0x80) as i8, value != 0.0), } } @@ -446,6 +467,13 @@ impl Event { TrimRight(p) => (0x5D, f64::from(u8::from(p))), ActionWheelX(v) => (0x5E, v), ActionWheelY(v) => (0x5F, v), + Enter(p) => (0x60, f64::from(u8::from(p))), + Sleep(p) => (0x61, f64::from(u8::from(p))), + Eject(p) => (0x62, f64::from(u8::from(p))), + Pair(p) => (0x63, f64::from(u8::from(p))), + Lang1(p) => (0x64, f64::from(u8::from(p))), + Lang2(p) => (0x65, f64::from(u8::from(p))), + Home(p) => (0x66, f64::from(u8::from(p))), } } } @@ -564,6 +592,13 @@ impl std::fmt::Display for Event { Pinky(p) => write!(f, "Pinky {}", pushed(p)), ActionWheelX(v) => write!(f, "ActionWheelX {}", v), ActionWheelY(v) => write!(f, "ActionWheelY {}", v), + Enter(p) => write!(f, "Enter {}", pushed(p)), + Sleep(p) => write!(f, "Sleep {}", pushed(p)), + Eject(p) => write!(f, "Eject {}", pushed(p)), + Pair(p) => write!(f, "Pair {}", pushed(p)), + Lang1(p) => write!(f, "Lang1 {}", pushed(p)), + Lang2(p) => write!(f, "Lang2 {}", pushed(p)), + Home(p) => write!(f, "Home {}", pushed(p)), } } } diff --git a/stick/src/raw/linux.rs b/stick/src/raw/linux.rs index ac36bf3..df236d3 100644 --- a/stick/src/raw/linux.rs +++ b/stick/src/raw/linux.rs @@ -29,11 +29,24 @@ fn linux_btn_to_stick_event( pushed: bool, ) { pending.push(match btn { + 0x01C /* KEY_ENTER */ => Event::Enter(pushed), + 0x08B /* KEY_MENU */ => Event::Context(pushed), + 0x096 /* KEY_SLEEP */ => Event::Sleep(pushed), + 0x09E /* KEY_BACK */ => Event::PaddleLeft(pushed), 0x09F /* KEY_FORWARD */ => Event::PaddleRight(pushed), + 0x0A1 /* KEY_EJECT */ => Event::Eject(pushed), + + 0x0D4 /* KEY_PAIR */ => Event::Pair(pushed), + + 0x0F1 /* KEY_LANG2 */ => Event::Lang2(pushed), + 0x0F2 /* KEY_LANG1 */ => Event::Lang1(pushed), + + 0x100 /* BTN_MIC_PUSH */ => Event::MicPush(pushed), + 0x120 /* BTN_TRIGGER */ => Event::Trigger(pushed), 0x121 /* BTN_THUMB */ => Event::ActionM(pushed), 0x122 /* BTN_THUMB2 */ => Event::Bumper(pushed), @@ -69,6 +82,15 @@ fn linux_btn_to_stick_event( 0x13F /* BTN_PINKYR */ => Event::PinkyRight(pushed), 0x140 /* BTN_PINKYL */ => Event::PinkyLeft(pushed), + 0x16A /* BTN_THROTTLE */ => Event::ThrottleButton(pushed), + + 0x16E /* BTN_HOME */ => Event::Home(pushed), + + 0x179 /* BTN_LANDING_GEAR_SILENCE */ => Event::LandingGearSilence(pushed), + + 0x192 /* BTN_CHINA_FORWARD */ => Event::ChinaForward(pushed), + 0x193 /* BTN_CHINA_BACKWARD */ => Event::ChinaBackward(pushed), + 0x220 /* BTN_DPAD_UP */ => Event::Up(pushed), 0x221 /* BTN_DPAD_DOWN */ => Event::Down(pushed), 0x222 /* BTN_DPAD_LEFT */ => Event::Left(pushed), diff --git a/xtask/src/sdb.rs b/xtask/src/sdb.rs index 68e3036..6fcd68b 100644 --- a/xtask/src/sdb.rs +++ b/xtask/src/sdb.rs @@ -126,6 +126,13 @@ fn name_to_hex(name: &str) -> &str { "TrimRight" => "5D", "ActionWheelX" => "5E", "ActionWheelY" => "5F", + "Enter" => "60", + "Sleep" => "61", + "Eject" => "62", + "Pair" => "63", + "Lang1" => "64", + "Lang2" => "65", + "Home" => "66", _unknown => panic!("Unknown: {}", _unknown), } } From d114f1a7127506800e30b4c99e21ff762b77fe32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20A=2E=20S=C3=A6le?= Date: Thu, 26 May 2022 11:57:12 +0700 Subject: [PATCH 2/2] rename Pair to Mode --- sdb/linux/0500151940000100.toml | 2 +- stick/src/ctlr.rs | 4 ++-- stick/src/event.rs | 10 +++++----- stick/src/raw/linux.rs | 2 +- xtask/src/sdb.rs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdb/linux/0500151940000100.toml b/sdb/linux/0500151940000100.toml index dfc281c..d92bd8f 100644 --- a/sdb/linux/0500151940000100.toml +++ b/sdb/linux/0500151940000100.toml @@ -27,7 +27,7 @@ Sleep = "ActionL" # Left Nub, diagonally between and bumpers Lang2 = "ActionR" # Right Nub # Meta buttons -# Pair is already Pair +# Mode is already Mode # Home is already Home ThrottleButton = "Exit" diff --git a/stick/src/ctlr.rs b/stick/src/ctlr.rs index e58f030..3d00f66 100644 --- a/stick/src/ctlr.rs +++ b/stick/src/ctlr.rs @@ -95,7 +95,7 @@ enum Btn { Enter = 72, Sleep = 73, Eject = 74, - Pair = 75, + Mode = 75, Lang1 = 76, Lang2 = 77, Home = 78, @@ -569,7 +569,7 @@ impl Controller { 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), - Pair(p) => self.button(Btn::Pair, Pair, p), + Mode(p) => self.button(Btn::Mode, Mode, p), Lang1(p) => self.button(Btn::Lang1, Lang1, p), Lang2(p) => self.button(Btn::Lang2, Lang2, p), Home(p) => self.button(Btn::Home, Home, p), diff --git a/stick/src/event.rs b/stick/src/event.rs index 1701fb2..2ab4475 100644 --- a/stick/src/event.rs +++ b/stick/src/event.rs @@ -27,8 +27,8 @@ pub enum Event { Lang1(bool), /// Language 2 Lang2(bool), - /// Pair - Pair(bool), + /// Mode + Mode(bool), /// Eject Eject(bool), /// A / 1 / 4 / Circle. Action A (Primary action). @@ -358,7 +358,7 @@ impl Event { 0x60 => Event::Enter(value != 0.0), 0x61 => Event::Sleep(value != 0.0), 0x62 => Event::Eject(value != 0.0), - 0x63 => Event::Pair(value != 0.0), + 0x63 => Event::Mode(value != 0.0), 0x64 => Event::Lang1(value != 0.0), 0x65 => Event::Lang2(value != 0.0), 0x66 => Event::Home(value != 0.0), @@ -470,7 +470,7 @@ impl Event { Enter(p) => (0x60, f64::from(u8::from(p))), Sleep(p) => (0x61, f64::from(u8::from(p))), Eject(p) => (0x62, f64::from(u8::from(p))), - Pair(p) => (0x63, f64::from(u8::from(p))), + Mode(p) => (0x63, f64::from(u8::from(p))), Lang1(p) => (0x64, f64::from(u8::from(p))), Lang2(p) => (0x65, f64::from(u8::from(p))), Home(p) => (0x66, f64::from(u8::from(p))), @@ -595,7 +595,7 @@ impl std::fmt::Display for Event { Enter(p) => write!(f, "Enter {}", pushed(p)), Sleep(p) => write!(f, "Sleep {}", pushed(p)), Eject(p) => write!(f, "Eject {}", pushed(p)), - Pair(p) => write!(f, "Pair {}", pushed(p)), + Mode(p) => write!(f, "Mode {}", pushed(p)), Lang1(p) => write!(f, "Lang1 {}", pushed(p)), Lang2(p) => write!(f, "Lang2 {}", pushed(p)), Home(p) => write!(f, "Home {}", pushed(p)), diff --git a/stick/src/raw/linux.rs b/stick/src/raw/linux.rs index df236d3..230b1ad 100644 --- a/stick/src/raw/linux.rs +++ b/stick/src/raw/linux.rs @@ -40,7 +40,7 @@ fn linux_btn_to_stick_event( 0x0A1 /* KEY_EJECT */ => Event::Eject(pushed), - 0x0D4 /* KEY_PAIR */ => Event::Pair(pushed), + 0x0D4 /* KEY_MODE */ => Event::Mode(pushed), 0x0F1 /* KEY_LANG2 */ => Event::Lang2(pushed), 0x0F2 /* KEY_LANG1 */ => Event::Lang1(pushed), diff --git a/xtask/src/sdb.rs b/xtask/src/sdb.rs index 6fcd68b..396b8e2 100644 --- a/xtask/src/sdb.rs +++ b/xtask/src/sdb.rs @@ -129,7 +129,7 @@ fn name_to_hex(name: &str) -> &str { "Enter" => "60", "Sleep" => "61", "Eject" => "62", - "Pair" => "63", + "Mode" => "63", "Lang1" => "64", "Lang2" => "65", "Home" => "66",