private void lstPads_SelectedIndexChanged(object sender, EventArgs e) { if (lstPads.SelectedIndex == -1) { return; } mapping = Newtonsoft.Json.JsonConvert.DeserializeObject <GamepadMapping>(System.IO.File.ReadAllText(lstPads.SelectedItem.ToString())); }
public Form1() { InitializeComponent(); mapping = Newtonsoft.Json.JsonConvert.DeserializeObject <GamepadMapping>(System.IO.File.ReadAllText("./Gamepads/Speedlink.json")); kpMapping = Newtonsoft.Json.JsonConvert.DeserializeObject <KeypadMapping>(System.IO.File.ReadAllText("./Layouts/WingCommander4.json")); var pads = System.IO.Directory.EnumerateFiles(@".\Gamepads", "*.json"); var mappings = System.IO.Directory.EnumerateFiles(@".\Layouts", "*.json"); foreach (var k in mappings) { this.lstKeys.Items.Add(k); } foreach (var p in pads) { this.lstPads.Items.Add(p); } }