diff --git a/CHANGELOG.md b/CHANGELOG.md index f73ac2a..d12704e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ All notable changes to Keyboard Splitter, explained in plain language. +## [0.3.8] - 2026-09-06 + +### Fixed +- Fixed a bug where you could not select the **Football (eFootball / PES)** + preset: choosing it looked like it snapped straight back to the FIFA one. + The Mapping editor identified a preset by the physical keys alone, and the + two football presets deliberately use the same keys - so any football + layout was reported as the FIFA preset and the picker jumped back. It now + compares what each key *does* (the full key → controller-button table), + so every preset is recognized on its own. +- Fixed a bug where the eFootball/PES preset pressed the wrong buttons for + the game: shoot, pass, cross and through ball were assigned to buttons + Konami does not use for them, so e.g. "shoot" crossed the ball instead. + The layout was researched against the games' control charts and corrected + to the Konami **Standard** scheme that PES 2017 through eFootball ship + with: A low pass, X shoot, B lofted pass/cross, Y through ball, dash on + RB, specials on RT. The EA FC / FIFA preset now also documents its own + in-game **Classic** scheme (A pass, B shoot, X cross/lob, Y through ball, + sprint on RT) instead of mixing the two games' conventions. + +### Changed +- The two football presets' descriptions say which in-game scheme each + matches and what every key does, including how to get the *other* feel: + eFootball's in-game "Alternate" layout is the EA FC preset, and EA's + "Alternate" is the eFootball/PES one. PES 2017 players: the eFootball/PES + preset is the exact layout PES 2017 ships with. + ## [0.3.7] - 2026-09-06 ### Fixed diff --git a/README.md b/README.md index bc9de69..87bcbb4 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Cutting a release is therefore just: # bump "version" in src-tauri/tauri.conf.json (and keep package.json and # src-tauri/Cargo.toml in sync), add a CHANGELOG.md entry in plain language, # then: -git add -A && git commit -m "chore(release): bump to 0.3.7" && git push +git add -A && git commit -m "chore(release): bump to 0.3.8" && git push ``` The workflow skips runs whose version was already released, so unrelated @@ -145,6 +145,17 @@ assign them → start engine) so you always know what's left. (e.g. `W` → `Left Stick ↑`, `Space` → `A`). The preset picker highlights which preset a player is currently using and flags custom layouts that match none of the built-in ones. + + **Football presets follow each game's real Xbox defaults** (checked against the games' + own control charts): the *EA FC / FIFA* preset matches EA's in-game **Classic** scheme + (A pass, B shoot, X cross/lob, Y through ball, RT sprint), and the *eFootball / PES* + preset matches Konami's **Standard** scheme that PES 2017 through eFootball ship with + (A low pass, X shoot, B lofted pass/cross, Y through ball, RB dash). Both deliberately + use the same keyboard keys - only the controller button each key presses differs. If you + switch a game to its *other* scheme in its own options, apply the matching preset: + eFootball's "Alternate" layout is the EA FC preset, and EA's "Alternate" is the + eFootball/PES one. + 6. Open your game. Each player controls the game with their own keyboard. 7. Close the window to keep it running in the tray; **Quit** from the tray unplugs the controllers cleanly. diff --git a/package.json b/package.json index 1dafdec..55c77df 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "keyboardsplitternext", "private": true, - "version": "0.3.7", + "version": "0.3.8", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5437dab..dbb60ac 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -66,7 +66,7 @@ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "app" -version = "0.3.7" +version = "0.3.8" dependencies = [ "log", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 591615e..5f32c26 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "0.3.7" +version = "0.3.8" description = "Modern Keyboard Splitter - multiple keyboards as independent virtual Xbox controllers" authors = ["e4crypt3d"] license = "" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 79b6aec..8d15f4f 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -160,11 +160,11 @@ pub async fn list_presets( } #[tauri::command(rename_all = "camelCase")] -pub async fn list_preset_keys( +pub async fn list_preset_bindings( engine: State<'_, EngineHandle>, preset_id: String, -) -> Result, String> { - ask(&engine, |reply| EngineMsg::ListPresetKeys { preset_id, reply }).await +) -> Result, String> { + ask(&engine, |reply| EngineMsg::ListPresetBindings { preset_id, reply }).await } #[tauri::command(rename_all = "camelCase")] diff --git a/src-tauri/src/engine.rs b/src-tauri/src/engine.rs index d90276f..7541103 100644 --- a/src-tauri/src/engine.rs +++ b/src-tauri/src/engine.rs @@ -53,8 +53,10 @@ pub enum EngineMsg { ApplyPreset { player: usize, preset_id: String, reply: Reply }, /// List built-in presets (id/name/description). ListPresets(Reply>), - /// Canonical key names bound by one built-in preset. - ListPresetKeys { preset_id: String, reply: Reply> }, + /// The full key -> target table of one built-in preset (the preset picker + /// compares these tables to tell presets apart, even when two layouts use + /// the same physical keys). + ListPresetBindings { preset_id: String, reply: Reply> }, /// A key was pressed/released on one physical keyboard. #[cfg_attr(not(target_os = "windows"), allow(dead_code))] KeyEvent { device: String, key: String, down: bool }, @@ -695,10 +697,10 @@ fn handle_message(app: &AppHandle, core: &mut Core, msg: EngineMsg) -> bool { EngineMsg::ListPresets(reply) => { let _ = reply.send(Ok(presets::list())); } - EngineMsg::ListPresetKeys { preset_id, reply } => { - let keys = presets::keys(&preset_id) + EngineMsg::ListPresetBindings { preset_id, reply } => { + let bindings = presets::bindings(&preset_id) .ok_or_else(|| format!("Unknown preset '{preset_id}'")); - let _ = reply.send(keys); + let _ = reply.send(bindings); } EngineMsg::KeyEvent { device, key, down } => { handle_key_event(app, core, &device, &key, down); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 01fdffa..69105c2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -331,7 +331,7 @@ pub fn run() { commands::list_profiles, commands::apply_preset, commands::list_presets, - commands::list_preset_keys, + commands::list_preset_bindings, ]) .build(tauri::generate_context!()) .expect("error while building tauri application"); diff --git a/src-tauri/src/mapping/mod.rs b/src-tauri/src/mapping/mod.rs index 8c913a8..eb6e6ff 100644 --- a/src-tauri/src/mapping/mod.rs +++ b/src-tauri/src/mapping/mod.rs @@ -68,4 +68,28 @@ mod tests { let r = report_for(&map, &held(&["F9", "W"])); assert_eq!(r.left_y, i16::MAX); } + + #[test] + fn two_players_with_the_same_preset_stay_independent() { + // The "each keyboard is its own controller" flow: every player keeps + // its own held-key set and its own report, so two players can run the + // very same preset on two keyboards. Pressing the same keys on both + // must drive two identical-but-separate reports, and a press on one + // player's keyboard must never leak into the other player's report. + let map = crate::presets::bindings("football-pes").unwrap(); + + // Both players hold the same keys on their own keyboards: move + pass. + let p1 = report_for(&map, &held(&["W", "Space"])); + let p2 = report_for(&map, &held(&["W", "Space"])); + assert_eq!(p1, p2, "identical inputs on two keyboards = identical reports"); + assert_eq!(p1.buttons, crate::controller::BIT_A); + + // Player 2 now also taps shoot (E). Only p2's report changes. + let p2_shot = report_for(&map, &held(&["W", "Space", "E"])); + let p1_unchanged = report_for(&map, &held(&["W", "Space"])); + assert_eq!(p1_unchanged, p1, "player 1's pad must not react to player 2's keys"); + // On the eFootball/PES (Konami Standard) preset, shoot = Xbox X. + assert_eq!(p2_shot.buttons, crate::controller::BIT_A | crate::controller::BIT_X); + assert_ne!(p2_shot, p1_unchanged); + } } diff --git a/src-tauri/src/presets.rs b/src-tauri/src/presets.rs index 9983d01..2df64aa 100644 --- a/src-tauri/src/presets.rs +++ b/src-tauri/src/presets.rs @@ -6,8 +6,10 @@ //! one-keyboard splitters, where players had to use different zones). //! //! Controller-side layouts follow the games' documented Xbox defaults: -//! - EA Sports FC / FIFA: A pass · X through ball · B cross · Y shoot -//! - eFootball / PES: A low pass · X through ball · B shoot · Y lofted pass +//! - EA Sports FC / FIFA: A pass · B shoot · X cross/lob · Y through (in-game "Classic") +//! - eFootball / PES: A low pass · X shoot · B lofted/cross · Y through, dash on RB +//! (Konami "Standard" - also the out-of-the-box PES 2017 layout; +//! eFootball's "Alternate" scheme is the EA-style one above) //! - Mortal Kombat 1/11: X/Y/A/B = FP/BP/FK/BK · LB throw · RT block //! - Tekken 7/8: X/Y/A/B = LP/RP/LK/RK (combos are key chords) //! - Street Fighter 6: X/Y/RB = LP/MP/HP · A/B/RT = LK/MK/HK @@ -85,22 +87,24 @@ const GENERAL_KEYS: &[(&str, Target)] = &[ ("L", dpad(DpadDirection::Right)), ]; -/// Football: EA Sports FC / FIFA. Movement on the left stick, passing / -/// shooting cluster on the left hand. Classic layout A pass · X through · -/// B cross · Y shoot; newer FC titles default shoot to Y - swap E/R if needed. +/// Football: EA Sports FC / FIFA, in-game "Classic" scheme (the default). +/// Movement on the left stick, passing/shooting cluster on the left hand: +/// A pass · B shoot · X cross/lob · Y through ball. Dash/sprint is the right +/// trigger (C). EA's in-game "Alternate" scheme (sprint on RB, shoot on X) +/// matches the eFootball/PES Standard preset instead. const FOOTBALL_FC_KEYS: &[(&str, Target)] = &[ ("W", stick(StickSide::Left, StickDirection::Up)), ("A", stick(StickSide::Left, StickDirection::Left)), ("S", stick(StickSide::Left, StickDirection::Down)), ("D", stick(StickSide::Left, StickDirection::Right)), - ("Space", b(GamepadButton::A)), // pass + ("Space", b(GamepadButton::A)), // pass / header ("E", b(GamepadButton::B)), // shoot - ("Q", b(GamepadButton::X)), // through ball - ("R", b(GamepadButton::Y)), // cross / lob + ("Q", b(GamepadButton::X)), // cross / lob pass + ("R", b(GamepadButton::Y)), // through ball ("Tab", b(GamepadButton::LB)), // change player - ("F", b(GamepadButton::RB)), // sprint - ("LCtrl", trig(TriggerSide::Left)), // precision dribble / special - ("C", trig(TriggerSide::Right)), // alternate sprint / dash + ("F", b(GamepadButton::RB)), // teammate press / call for support (hold) + ("LCtrl", trig(TriggerSide::Left)), // shield / jockey (hold) + ("C", trig(TriggerSide::Right)), // sprint / dash (hold) ("Up", dpad(DpadDirection::Up)), ("Left", dpad(DpadDirection::Left)), ("Down", dpad(DpadDirection::Down)), @@ -108,21 +112,26 @@ const FOOTBALL_FC_KEYS: &[(&str, Target)] = &[ ("Enter", b(GamepadButton::Start)), // pause ]; -/// Football: eFootball / PES. A low pass · X through ball · B shoot · -/// Y lofted pass, RT dash. Same ergonomic cluster as the FC preset. +/// Football: eFootball / PES with the Konami "Standard" scheme that PES 2017, +/// PES 2021 and eFootball ship out of the box (verified against the games' +/// control charts/manuals): A low pass · X shoot · B lofted pass/cross · +/// Y through ball, dash on RB, specials on RT. Note the Xbox labels are +/// positional - the PlayStation ▢/○/△ faces sit on Xbox X/B/Y. eFootball's +/// in-game "Alternate" scheme is the EA-style one (shoot B, dash RT); use +/// the EA FC preset for that feel. const FOOTBALL_PES_KEYS: &[(&str, Target)] = &[ ("W", stick(StickSide::Left, StickDirection::Up)), ("A", stick(StickSide::Left, StickDirection::Left)), ("S", stick(StickSide::Left, StickDirection::Down)), ("D", stick(StickSide::Left, StickDirection::Right)), - ("Space", b(GamepadButton::A)), // low/short pass - ("E", b(GamepadButton::B)), // shoot - ("Q", b(GamepadButton::X)), // through ball - ("R", b(GamepadButton::Y)), // lofted pass / cross - ("Tab", b(GamepadButton::LB)), // change player / pressure - ("F", b(GamepadButton::RB)), // match-up / second press - ("C", trig(TriggerSide::Right)), // dash (sprint) - ("LCtrl", trig(TriggerSide::Left)), // dribbling modifier / manual + ("Space", b(GamepadButton::A)), // low/short pass (pressure when defending) + ("E", b(GamepadButton::X)), // shoot (Xbox X = PlayStation ▢ position) + ("Q", b(GamepadButton::B)), // lofted pass / cross + ("R", b(GamepadButton::Y)), // through ball + ("Tab", b(GamepadButton::LB)), // cursor change / change player + ("F", b(GamepadButton::RB)), // dash / sprint (hold) + ("C", trig(TriggerSide::Right)), // special controls / skill modifier (hold) + ("LCtrl", trig(TriggerSide::Left)), // manual controls (hold) ("Up", dpad(DpadDirection::Up)), ("Left", dpad(DpadDirection::Left)), ("Down", dpad(DpadDirection::Down)), @@ -273,13 +282,13 @@ static PRESETS: &[PresetDef] = &[ PresetDef { id: "football-fc", name: "Football (FIFA / EA FC)", - description: "Classic EA FC scheme: A pass, X through ball, B shoot, Y cross on Space/Q/E/R, sprint on F, player change on Tab. Newer FC titles default shoot to Y - swap E and R to taste.", + description: "EA FC defaults (in-game Classic scheme): pass Space, shoot E, cross Q, through R, sprint C (right trigger), teammate press F, change player Tab. Shooting feels wrong in PES? That game's default puts shoot on X - use the eFootball/PES preset instead.", keys: FOOTBALL_FC_KEYS, }, PresetDef { id: "football-pes", name: "Football (eFootball / PES)", - description: "eFootball scheme: A low pass, X through ball, B shoot, Y lofted pass; dash on C, pressure on F. Kick-off at full speed.", + description: "PES/eFootball out-of-the-box layout (Konami Standard, same scheme as PES 2017): pass Space, shoot E, cross Q, through R, dash F (RB), specials C (RT), change player Tab. If eFootball is set to its Alternate scheme the buttons are EA-style - apply the EA FC preset instead.", keys: FOOTBALL_PES_KEYS, }, PresetDef { @@ -347,11 +356,6 @@ pub fn bindings(id: &str) -> Option> { .map(|p| p.keys.iter().map(|(k, t)| Binding { key: k.to_string(), target: *t }).collect()) } -/// The canonical key names of a built-in preset, in display order. The UI -/// sorts them itself; used to detect which preset a player's bindings match. -pub fn keys(id: &str) -> Option> { - bindings(id).map(|b| b.into_iter().map(|x| x.key).collect()) -} /// Default layout for new players == the "general" preset. pub fn default_bindings() -> Vec { @@ -390,12 +394,85 @@ mod tests { } #[test] - fn keys_mirror_the_preset_definitions() { + fn bindings_mirror_the_preset_definitions() { for def in PRESETS { - let expected: Vec = def.keys.iter().map(|(k, _)| k.to_string()).collect(); - assert_eq!(super::keys(def.id).as_ref(), Some(&expected), "preset {}", def.id); + let expected: Vec = def + .keys + .iter() + .map(|(k, t)| Binding { key: k.to_string(), target: *t }) + .collect(); + assert_eq!( + super::bindings(def.id).as_ref(), + Some(&expected), + "preset {}", + def.id + ); } - assert_eq!(super::keys("nope"), None); + assert_eq!(super::bindings("nope"), None); + } + + #[test] + fn every_preset_has_a_distinct_key_target_table() { + // The preset picker identifies the preset a player is using by + // comparing (key → target) pairs, so two presets that bind the same + // keys to the same targets would be indistinguishable (this is what + // made the PES preset "snap back" to FIFA: they shared the same key + // list and the picker compared keys only). No two presets may share + // an identical table. + // Compare rows of "key|target" - Binding itself is not Hash (it is a + // serde DTO and stays that way), so fingerprint via Debug. + let mut seen: HashSet> = HashSet::new(); + for def in PRESETS { + let mut table: Vec = def + .keys + .iter() + .map(|(k, t)| format!("{k}|{t:?}")) + .collect(); + table.sort(); + assert!( + seen.insert(table), + "preset '{}' has the exact same key->target table as another preset - the picker could not tell them apart", + def.id + ); + } + } + + #[test] + fn football_presets_follow_each_games_xbox_defaults() { + // Researched from the games' control charts / manuals: + // - EA FC "Classic" (its default): A pass, B shoot, X cross/lob, + // Y through ball, sprint on RT. + // - eFootball/PES "Standard" (the Konami default, unchanged since + // PES 2017): A low pass, X shoot, B lofted pass/cross, Y through + // ball, dash on RB, specials on RT. Xbox labels are positional - + // the PS ▢/○/△ faces map to Xbox X/B/Y. + let at = |bs: &[Binding], key: &str| { + bs.iter() + .find(|b| b.key == key) + .map(|b| b.target) + .unwrap_or_else(|| panic!("key {key} not bound")) + }; + + let fc = bindings("football-fc").unwrap(); + assert_eq!(at(&fc, "E"), b(GamepadButton::B)); // shoot + assert_eq!(at(&fc, "Q"), b(GamepadButton::X)); // cross / lob + assert_eq!(at(&fc, "R"), b(GamepadButton::Y)); // through ball + assert_eq!(at(&fc, "C"), trig(TriggerSide::Right)); // sprint (RT) + + let pes = bindings("football-pes").unwrap(); + assert_eq!(at(&pes, "E"), b(GamepadButton::X)); // shoot (Konami Standard) + assert_eq!(at(&pes, "Q"), b(GamepadButton::B)); // lofted pass / cross + assert_eq!(at(&pes, "R"), b(GamepadButton::Y)); // through ball + assert_eq!(at(&pes, "F"), b(GamepadButton::RB)); // dash (RB) + assert_eq!(at(&pes, "C"), trig(TriggerSide::Right)); // specials (RT) + + // Both keep the same ergonomic key cluster so switching games is + // seamless; only the Xbox targets follow each game's scheme. + let keys_of = |bs: &[Binding]| -> HashSet { + bs.iter().map(|b| b.key.clone()).collect() + }; + assert_eq!(keys_of(&fc), keys_of(&pes)); + assert_ne!(bindings("football-fc").unwrap(), bindings("football-pes").unwrap()); } #[test] diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 760af4a..7347763 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../../../node_modules/@tauri-apps/cli/config.schema.json", "productName": "Keyboard Splitter", - "version": "0.3.7", + "version": "0.3.8", "identifier": "com.e4crypt3d.keyboardsplitter", "mainBinaryName": "Keyboard Splitter", "build": { diff --git a/src/api.ts b/src/api.ts index a8dcc23..cb7066c 100644 --- a/src/api.ts +++ b/src/api.ts @@ -42,9 +42,11 @@ export const resetDefault = (player: number) => /** Built-in game presets (FIFA, MK, Tekken, ...). */ export const listPresets = () => invoke('list_presets') -/** Canonical key names bound by one built-in preset (display order). */ -export const listPresetKeys = (presetId: string) => - invoke('list_preset_keys', { presetId }) +/** Full key -> target table of one built-in preset (the picker needs the + * targets, not just the keys, to tell presets with identical key layouts + * apart - e.g. the two football presets). */ +export const listPresetBindings = (presetId: string) => + invoke('list_preset_bindings', { presetId }) /** Replace one player's bindings with a built-in preset. */ export const applyPreset = (player: number, presetId: string) => invoke('apply_preset', { player, presetId }) diff --git a/src/components/Mapping.tsx b/src/components/Mapping.tsx index aa5f20b..d873c3e 100644 --- a/src/components/Mapping.tsx +++ b/src/components/Mapping.tsx @@ -3,6 +3,7 @@ import * as api from '../api' import { keyLabel, targetLabel, + type Binding, type GamepadButton, type PresetMeta, type Snapshot, @@ -38,28 +39,26 @@ export default function Mapping({ playerRef.current = player }) - // Sorted keys currently bound to this player. - const boundKeys = useMemo(() => { - return [...player.bindings].map((b) => b.key).sort() - }, [player.bindings]) + // Canonical (key → target) tables of every built-in preset, fetched from + // the backend once the preset list arrives. Comparing full tables - not + // bare key lists - is what lets the picker tell presets apart when two + // layouts use the same physical keys (the football presets do on purpose). + const [presetTables, setPresetTables] = useState>(() => new Map()) - // Canonical per-preset key lists, fetched from the backend once the preset - // list arrives. Only the ids are cached here, never the targets. - const [presetKeys, setPresetKeys] = useState>(() => new Map()) + // Fingerprint of THIS player's current bindings (key → target pairs). + const playerTable = useMemo(() => bindingFingerprint(player.bindings), [player.bindings]) // Which built-in preset (if any) currently matches this player's bindings. - // We compare the sorted key list against each preset so the picker shows - // the real current preset, not the last value selected in the dropdown. + // We compare the full key→target table against each preset so the picker + // shows the real current preset, not the last value selected in the dropdown. const appliedPreset = useMemo(() => { - if (!presets.length || !boundKeys.length) return null + if (!presets.length || !playerTable) return null for (const p of presets) { - const keys = presetKeys.get(p.id) - if (!keys) continue - if (keys.length !== boundKeys.length) continue - if (keys.join(',') === boundKeys.join(',')) return p + const table = presetTables.get(p.id) + if (table && table === playerTable) return p } return null - }, [presets, presetKeys, boundKeys]) + }, [presets, presetTables, playerTable]) // Built-in game presets (loaded once; the backend owns the definitions). useEffect(() => { @@ -67,18 +66,18 @@ export default function Mapping({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []) - // Fetch the per-preset binding-key lists so the preset picker can compare + // Fetch the per-preset key→target tables so the preset picker can compare // them against the current player's bindings. useEffect(() => { if (!presets.length) return let cancelled = false void Promise.all( presets.map((p) => - api.listPresetKeys(p.id).then((keys) => { + api.listPresetBindings(p.id).then((bindings) => { if (cancelled) return - setPresetKeys((prev) => { + setPresetTables((prev) => { const next = new Map(prev) - next.set(p.id, [...keys].sort()) + next.set(p.id, bindingFingerprint(bindings)) return next }) }), @@ -389,6 +388,16 @@ export default function Mapping({ // --------------------------------------------------------------------------- +/** Canonical (key → target) fingerprint of a binding table. The picker needs + * the targets, not just the keys: the EA FC and eFootball/PES presets share + * the same key cluster on purpose and only differ in what each key does. */ +function bindingFingerprint(bindings: Binding[]): string { + return bindings + .map((b) => `${b.key}|${JSON.stringify(b.target)}`) + .sort() + .join('\n') +} + const BUTTONS: GamepadButton[] = [ 'A', 'B', 'X', 'Y', 'LB', 'RB', 'BACK', 'START', 'LTHUMB', 'RTHUMB', ]