diff --git a/BetterJoyForCemu/3rdPartyControllers.Designer.cs b/BetterJoyForCemu/3rdPartyControllers.Designer.cs index 11e087e..461c80b 100644 --- a/BetterJoyForCemu/3rdPartyControllers.Designer.cs +++ b/BetterJoyForCemu/3rdPartyControllers.Designer.cs @@ -1,212 +1,206 @@ namespace BetterJoyForCemu { - partial class _3rdPartyControllers { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class _3rdPartyControllers { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_3rdPartyControllers)); - this.list_allControllers = new System.Windows.Forms.ListBox(); - this.list_customControllers = new System.Windows.Forms.ListBox(); - this.btn_add = new System.Windows.Forms.Button(); - this.btn_remove = new System.Windows.Forms.Button(); - this.group_props = new System.Windows.Forms.GroupBox(); - this.chk_isLeft = new System.Windows.Forms.CheckBox(); - this.chk_isPro = new System.Windows.Forms.CheckBox(); - this.btn_applyAndClose = new System.Windows.Forms.Button(); - this.btn_apply = new System.Windows.Forms.Button(); - this.lbl_all = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.tip_device = new System.Windows.Forms.ToolTip(this.components); - this.btn_refresh = new System.Windows.Forms.Button(); - this.group_props.SuspendLayout(); - this.SuspendLayout(); - // - // list_allControllers - // - this.list_allControllers.FormattingEnabled = true; - this.list_allControllers.Location = new System.Drawing.Point(12, 27); - this.list_allControllers.Name = "list_allControllers"; - this.list_allControllers.Size = new System.Drawing.Size(103, 225); - this.list_allControllers.TabIndex = 0; - this.list_allControllers.SelectedValueChanged += new System.EventHandler(this.list_allControllers_SelectedValueChanged); - this.list_allControllers.MouseDown += new System.Windows.Forms.MouseEventHandler(this.list_allControllers_MouseDown); - // - // list_customControllers - // - this.list_customControllers.FormattingEnabled = true; - this.list_customControllers.Location = new System.Drawing.Point(169, 27); - this.list_customControllers.Name = "list_customControllers"; - this.list_customControllers.Size = new System.Drawing.Size(103, 108); - this.list_customControllers.TabIndex = 1; - this.list_customControllers.SelectedValueChanged += new System.EventHandler(this.list_customControllers_SelectedValueChanged); - this.list_customControllers.MouseDown += new System.Windows.Forms.MouseEventHandler(this.list_customControllers_MouseDown); - // - // btn_add - // - this.btn_add.Location = new System.Drawing.Point(121, 27); - this.btn_add.Name = "btn_add"; - this.btn_add.Size = new System.Drawing.Size(42, 23); - this.btn_add.TabIndex = 2; - this.btn_add.Text = "->"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // btn_remove - // - this.btn_remove.Location = new System.Drawing.Point(121, 112); - this.btn_remove.Name = "btn_remove"; - this.btn_remove.Size = new System.Drawing.Size(42, 23); - this.btn_remove.TabIndex = 3; - this.btn_remove.Text = "<-"; - this.btn_remove.UseVisualStyleBackColor = true; - this.btn_remove.Click += new System.EventHandler(this.btn_remove_Click); - // - // group_props - // - this.group_props.Controls.Add(this.chk_isLeft); - this.group_props.Controls.Add(this.chk_isPro); - this.group_props.Location = new System.Drawing.Point(122, 142); - this.group_props.Name = "group_props"; - this.group_props.Size = new System.Drawing.Size(150, 81); - this.group_props.TabIndex = 4; - this.group_props.TabStop = false; - this.group_props.Text = "Settings"; - // - // chk_isLeft - // - this.chk_isLeft.AutoSize = true; - this.chk_isLeft.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; - this.chk_isLeft.Location = new System.Drawing.Point(6, 42); - this.chk_isLeft.Name = "chk_isLeft"; - this.chk_isLeft.Size = new System.Drawing.Size(96, 17); - this.chk_isLeft.TabIndex = 1; - this.chk_isLeft.Text = "Left Joycon? "; - this.chk_isLeft.UseVisualStyleBackColor = true; - this.chk_isLeft.CheckedChanged += new System.EventHandler(this.chk_isLeft_CheckedChanged); - // - // chk_isPro - // - this.chk_isPro.AutoSize = true; - this.chk_isPro.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; - this.chk_isPro.Location = new System.Drawing.Point(6, 19); - this.chk_isPro.Name = "chk_isPro"; - this.chk_isPro.Size = new System.Drawing.Size(95, 17); - this.chk_isPro.TabIndex = 0; - this.chk_isPro.Text = "Pro Controller?"; - this.chk_isPro.UseVisualStyleBackColor = true; - this.chk_isPro.CheckedChanged += new System.EventHandler(this.chk_isPro_CheckedChanged); - // - // btn_applyAndClose - // - this.btn_applyAndClose.Location = new System.Drawing.Point(203, 229); - this.btn_applyAndClose.Name = "btn_applyAndClose"; - this.btn_applyAndClose.Size = new System.Drawing.Size(69, 23); - this.btn_applyAndClose.TabIndex = 5; - this.btn_applyAndClose.Text = "Close"; - this.btn_applyAndClose.UseVisualStyleBackColor = true; - this.btn_applyAndClose.Click += new System.EventHandler(this.btn_applyAndClose_Click); - // - // btn_apply - // - this.btn_apply.Location = new System.Drawing.Point(121, 229); - this.btn_apply.Name = "btn_apply"; - this.btn_apply.Size = new System.Drawing.Size(69, 23); - this.btn_apply.TabIndex = 6; - this.btn_apply.Text = "Apply"; - this.btn_apply.UseVisualStyleBackColor = true; - this.btn_apply.Click += new System.EventHandler(this.btn_apply_Click); - // - // lbl_all - // - this.lbl_all.AutoSize = true; - this.lbl_all.Location = new System.Drawing.Point(12, 11); - this.lbl_all.Name = "lbl_all"; - this.lbl_all.Size = new System.Drawing.Size(60, 13); - this.lbl_all.TabIndex = 7; - this.lbl_all.Text = "All Devices"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(166, 11); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(91, 13); - this.label1.TabIndex = 8; - this.label1.Text = "Switch Controllers"; - // - // btn_refresh - // - this.btn_refresh.Location = new System.Drawing.Point(121, 56); - this.btn_refresh.Name = "btn_refresh"; - this.btn_refresh.Size = new System.Drawing.Size(42, 50); - this.btn_refresh.TabIndex = 9; - this.btn_refresh.Text = "Re-\r\nfresh"; - this.btn_refresh.UseVisualStyleBackColor = true; - this.btn_refresh.Click += new System.EventHandler(this.btn_refresh_Click); - // - // _3rdPartyControllers - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(284, 261); - this.Controls.Add(this.btn_refresh); - this.Controls.Add(this.label1); - this.Controls.Add(this.lbl_all); - this.Controls.Add(this.btn_apply); - this.Controls.Add(this.btn_applyAndClose); - this.Controls.Add(this.group_props); - this.Controls.Add(this.btn_remove); - this.Controls.Add(this.btn_add); - this.Controls.Add(this.list_customControllers); - this.Controls.Add(this.list_allControllers); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "_3rdPartyControllers"; - this.Text = "Add 3rd-Party Controllers"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._3rdPartyControllers_FormClosing); - this.group_props.ResumeLayout(false); - this.group_props.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_3rdPartyControllers)); + this.list_allControllers = new System.Windows.Forms.ListBox(); + this.list_customControllers = new System.Windows.Forms.ListBox(); + this.btn_add = new System.Windows.Forms.Button(); + this.btn_remove = new System.Windows.Forms.Button(); + this.group_props = new System.Windows.Forms.GroupBox(); + this.label2 = new System.Windows.Forms.Label(); + this.chooseType = new System.Windows.Forms.ComboBox(); + this.btn_applyAndClose = new System.Windows.Forms.Button(); + this.btn_apply = new System.Windows.Forms.Button(); + this.lbl_all = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.tip_device = new System.Windows.Forms.ToolTip(this.components); + this.btn_refresh = new System.Windows.Forms.Button(); + this.group_props.SuspendLayout(); + this.SuspendLayout(); + // + // list_allControllers + // + this.list_allControllers.FormattingEnabled = true; + this.list_allControllers.Location = new System.Drawing.Point(12, 27); + this.list_allControllers.Name = "list_allControllers"; + this.list_allControllers.Size = new System.Drawing.Size(103, 225); + this.list_allControllers.TabIndex = 0; + this.list_allControllers.SelectedValueChanged += new System.EventHandler(this.list_allControllers_SelectedValueChanged); + this.list_allControllers.MouseDown += new System.Windows.Forms.MouseEventHandler(this.list_allControllers_MouseDown); + // + // list_customControllers + // + this.list_customControllers.FormattingEnabled = true; + this.list_customControllers.Location = new System.Drawing.Point(169, 27); + this.list_customControllers.Name = "list_customControllers"; + this.list_customControllers.Size = new System.Drawing.Size(103, 108); + this.list_customControllers.TabIndex = 1; + this.list_customControllers.SelectedValueChanged += new System.EventHandler(this.list_customControllers_SelectedValueChanged); + this.list_customControllers.MouseDown += new System.Windows.Forms.MouseEventHandler(this.list_customControllers_MouseDown); + // + // btn_add + // + this.btn_add.Location = new System.Drawing.Point(121, 27); + this.btn_add.Name = "btn_add"; + this.btn_add.Size = new System.Drawing.Size(42, 23); + this.btn_add.TabIndex = 2; + this.btn_add.Text = "->"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // btn_remove + // + this.btn_remove.Location = new System.Drawing.Point(121, 112); + this.btn_remove.Name = "btn_remove"; + this.btn_remove.Size = new System.Drawing.Size(42, 23); + this.btn_remove.TabIndex = 3; + this.btn_remove.Text = "<-"; + this.btn_remove.UseVisualStyleBackColor = true; + this.btn_remove.Click += new System.EventHandler(this.btn_remove_Click); + // + // group_props + // + this.group_props.Controls.Add(this.label2); + this.group_props.Controls.Add(this.chooseType); + this.group_props.Location = new System.Drawing.Point(122, 142); + this.group_props.Name = "group_props"; + this.group_props.Size = new System.Drawing.Size(150, 81); + this.group_props.TabIndex = 4; + this.group_props.TabStop = false; + this.group_props.Text = "Settings"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(10, 22); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(31, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Type"; + // + // chooseType + // + this.chooseType.FormattingEnabled = true; + this.chooseType.Location = new System.Drawing.Point(47, 19); + this.chooseType.Name = "chooseType"; + this.chooseType.Size = new System.Drawing.Size(97, 21); + this.chooseType.TabIndex = 0; + this.chooseType.SelectedValueChanged += new System.EventHandler(this.chooseType_SelectedValueChanged); + // + // btn_applyAndClose + // + this.btn_applyAndClose.Location = new System.Drawing.Point(203, 229); + this.btn_applyAndClose.Name = "btn_applyAndClose"; + this.btn_applyAndClose.Size = new System.Drawing.Size(69, 23); + this.btn_applyAndClose.TabIndex = 5; + this.btn_applyAndClose.Text = "Close"; + this.btn_applyAndClose.UseVisualStyleBackColor = true; + this.btn_applyAndClose.Click += new System.EventHandler(this.btn_applyAndClose_Click); + // + // btn_apply + // + this.btn_apply.Location = new System.Drawing.Point(121, 229); + this.btn_apply.Name = "btn_apply"; + this.btn_apply.Size = new System.Drawing.Size(69, 23); + this.btn_apply.TabIndex = 6; + this.btn_apply.Text = "Apply"; + this.btn_apply.UseVisualStyleBackColor = true; + this.btn_apply.Click += new System.EventHandler(this.btn_apply_Click); + // + // lbl_all + // + this.lbl_all.AutoSize = true; + this.lbl_all.Location = new System.Drawing.Point(12, 11); + this.lbl_all.Name = "lbl_all"; + this.lbl_all.Size = new System.Drawing.Size(60, 13); + this.lbl_all.TabIndex = 7; + this.lbl_all.Text = "All Devices"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(166, 11); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(91, 13); + this.label1.TabIndex = 8; + this.label1.Text = "Switch Controllers"; + // + // btn_refresh + // + this.btn_refresh.Location = new System.Drawing.Point(121, 56); + this.btn_refresh.Name = "btn_refresh"; + this.btn_refresh.Size = new System.Drawing.Size(42, 50); + this.btn_refresh.TabIndex = 9; + this.btn_refresh.Text = "Re-\r\nfresh"; + this.btn_refresh.UseVisualStyleBackColor = true; + this.btn_refresh.Click += new System.EventHandler(this.btn_refresh_Click); + // + // _3rdPartyControllers + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 261); + this.Controls.Add(this.btn_refresh); + this.Controls.Add(this.label1); + this.Controls.Add(this.lbl_all); + this.Controls.Add(this.btn_apply); + this.Controls.Add(this.btn_applyAndClose); + this.Controls.Add(this.group_props); + this.Controls.Add(this.btn_remove); + this.Controls.Add(this.btn_add); + this.Controls.Add(this.list_customControllers); + this.Controls.Add(this.list_allControllers); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "_3rdPartyControllers"; + this.Text = "Add 3rd-Party Controllers"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._3rdPartyControllers_FormClosing); + this.group_props.ResumeLayout(false); + this.group_props.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); - } + } - #endregion + #endregion - private System.Windows.Forms.ListBox list_allControllers; - private System.Windows.Forms.ListBox list_customControllers; - private System.Windows.Forms.Button btn_add; - private System.Windows.Forms.Button btn_remove; - private System.Windows.Forms.GroupBox group_props; - private System.Windows.Forms.Button btn_applyAndClose; - private System.Windows.Forms.Button btn_apply; - private System.Windows.Forms.Label lbl_all; - private System.Windows.Forms.CheckBox chk_isPro; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.CheckBox chk_isLeft; - private System.Windows.Forms.ToolTip tip_device; - private System.Windows.Forms.Button btn_refresh; - } -} \ No newline at end of file + private System.Windows.Forms.ListBox list_allControllers; + private System.Windows.Forms.ListBox list_customControllers; + private System.Windows.Forms.Button btn_add; + private System.Windows.Forms.Button btn_remove; + private System.Windows.Forms.GroupBox group_props; + private System.Windows.Forms.Button btn_applyAndClose; + private System.Windows.Forms.Button btn_apply; + private System.Windows.Forms.Label lbl_all; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ToolTip tip_device; + private System.Windows.Forms.Button btn_refresh; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox chooseType; + } +} diff --git a/BetterJoyForCemu/3rdPartyControllers.cs b/BetterJoyForCemu/3rdPartyControllers.cs index 780ce80..626bd28 100644 --- a/BetterJoyForCemu/3rdPartyControllers.cs +++ b/BetterJoyForCemu/3rdPartyControllers.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -12,110 +13,179 @@ using System.Windows.Forms; using static BetterJoyForCemu.HIDapi; namespace BetterJoyForCemu { - public partial class _3rdPartyControllers : Form { - public _3rdPartyControllers() { - InitializeComponent(); - list_allControllers.DisplayMember = "Text"; - list_allControllers.ValueMember = "Value"; - list_customControllers.DisplayMember = "Text"; - list_customControllers.ValueMember = "Value"; + public partial class _3rdPartyControllers : Form { + public class SController { + public String name; + public ushort product_id; + public ushort vendor_id; + public byte type; // 1 is pro, 2 is left joy, 3 is right joy - RefreshControllerList(); + public SController(String name, ushort vendor_id, ushort product_id, byte type) { + this.product_id = product_id; this.vendor_id = vendor_id; this.type = type; + this.name = name; + } - group_props.Controls.Add(chk_isLeft); - group_props.Controls.Add(chk_isPro); - group_props.Enabled = false; - } + public override bool Equals(object obj) { + //Check for null and compare run-time types. + if ((obj == null) || !this.GetType().Equals(obj.GetType())) { + return false; + } else { + SController s = (SController)obj; + return (s.product_id == product_id) && (s.vendor_id == vendor_id); + } + } - private bool ContainsText(ListBox a, String manu) { - foreach (var v in a.Items) { - dynamic d = v as dynamic; - if (d.Text == null) - continue; - if (d.Text.Equals(manu)) - return true; - } - return false; - } + public override int GetHashCode() { + return Tuple.Create(product_id, vendor_id).GetHashCode(); + } - private void RefreshControllerList() { - list_allControllers.Items.Clear(); - IntPtr ptr = HIDapi.hid_enumerate(0x0, 0x0); - IntPtr top_ptr = ptr; + public override string ToString() { + return name; + } - hid_device_info enumerate; // Add device to list - while (ptr != IntPtr.Zero) { - enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); + public string Serialise() { + return String.Format("{0}|{1}|{2}|{3}", name, product_id, vendor_id, type); + } + } - if (!ContainsText(list_customControllers, enumerate.product_string) && !ContainsText(list_allControllers, enumerate.product_string)) - list_allControllers.Items.Add(new { Text = enumerate.product_string, Value = enumerate }); + const string PATH = "3rdPartyControllers"; - ptr = enumerate.next; - } - } + public _3rdPartyControllers() { + InitializeComponent(); + /*list_allControllers.DisplayMember = "Text"; + list_allControllers.ValueMember = "Value"; + list_customControllers.DisplayMember = "Text"; + list_customControllers.ValueMember = "Value";*/ + list_allControllers.HorizontalScrollbar = true; list_customControllers.HorizontalScrollbar = true; - private void btn_add_Click(object sender, EventArgs e) { - if (list_allControllers.SelectedItem != null) { - list_customControllers.Items.Add(list_allControllers.SelectedItem); - list_allControllers.Items.Remove(list_allControllers.SelectedItem); - list_allControllers.ClearSelected(); - } - } + chooseType.Items.AddRange(new String[] { "Pro Controller", "Left Joycon", "Right Joycon" }); - private void btn_remove_Click(object sender, EventArgs e) { - if (list_customControllers.SelectedItem != null) { - list_allControllers.Items.Add(list_customControllers.SelectedItem); - list_customControllers.Items.Remove(list_customControllers.SelectedItem); - list_customControllers.ClearSelected(); - } - } + chooseType.FormattingEnabled = true; + group_props.Controls.Add(chooseType); + group_props.Enabled = false; - private void chk_isPro_CheckedChanged(object sender, EventArgs e) { + if (File.Exists(PATH)) { + using (StreamReader file = new StreamReader(PATH)) { + string line = String.Empty; + while ((line = file.ReadLine()) != null && (line != String.Empty)) { + String[] split = line.Split('|'); + list_customControllers.Items.Add(new SController(split[0], ushort.Parse(split[1]), ushort.Parse(split[2]), byte.Parse(split[3]))); + } + } + } - } + CopyCustomControllers(); + RefreshControllerList(); + } - private void chk_isLeft_CheckedChanged(object sender, EventArgs e) { + public void CopyCustomControllers() { + Program.thirdPartyCons.Clear(); + foreach (SController v in list_customControllers.Items) { + Program.thirdPartyCons.Add(v); + } + } - } + private bool ContainsText(ListBox a, String manu) { + foreach (SController v in a.Items) { + if (v == null) + continue; + if (v.name.Equals(manu)) + return true; + } + return false; + } - private void btn_apply_Click(object sender, EventArgs e) { + private void RefreshControllerList() { + list_allControllers.Items.Clear(); + IntPtr ptr = HIDapi.hid_enumerate(0x0, 0x0); - } + hid_device_info enumerate; // Add device to list + while (ptr != IntPtr.Zero) { + enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); - private void btn_applyAndClose_Click(object sender, EventArgs e) { - btn_apply_Click(sender, e); - Close(); - } + if (!ContainsText(list_customControllers, enumerate.product_string) && !ContainsText(list_allControllers, enumerate.product_string)) { + list_allControllers.Items.Add(new SController(enumerate.product_string, enumerate.vendor_id, enumerate.product_id, 0)); + // 0 type is undefined + } - private void _3rdPartyControllers_FormClosing(object sender, FormClosingEventArgs e) { - btn_apply_Click(sender, e); - } + ptr = enumerate.next; + } + } - private void btn_refresh_Click(object sender, EventArgs e) { - RefreshControllerList(); - } + private void btn_add_Click(object sender, EventArgs e) { + if (list_allControllers.SelectedItem != null) { + list_customControllers.Items.Add(list_allControllers.SelectedItem); + list_allControllers.Items.Remove(list_allControllers.SelectedItem); - private void list_allControllers_SelectedValueChanged(object sender, EventArgs e) { - if (list_allControllers.SelectedItem != null) - tip_device.Show((list_allControllers.SelectedItem as dynamic).Text, list_allControllers); - } + list_allControllers.ClearSelected(); + } + } - private void list_customControllers_SelectedValueChanged(object sender, EventArgs e) { - if (list_customControllers.SelectedItem != null) { - tip_device.Show((list_customControllers.SelectedItem as dynamic).Text, list_customControllers); - group_props.Enabled = true; - } else - group_props.Enabled = false; - } + private void btn_remove_Click(object sender, EventArgs e) { + if (list_customControllers.SelectedItem != null) { + list_allControllers.Items.Add(list_customControllers.SelectedItem); + list_customControllers.Items.Remove(list_customControllers.SelectedItem); - private void list_customControllers_MouseDown(object sender, MouseEventArgs e) { - if (e.Y > list_customControllers.ItemHeight * list_customControllers.Items.Count) - list_customControllers.SelectedItems.Clear(); - } + list_customControllers.ClearSelected(); + } + } - private void list_allControllers_MouseDown(object sender, MouseEventArgs e) { - if (e.Y > list_allControllers.ItemHeight * list_allControllers.Items.Count) - list_allControllers.SelectedItems.Clear(); - } - } + private void btn_apply_Click(object sender, EventArgs e) { + String sc = ""; + foreach (SController v in list_customControllers.Items) { + sc += v.Serialise() + "\r\n"; + } + File.WriteAllText(PATH, sc); + CopyCustomControllers(); + } + + private void btn_applyAndClose_Click(object sender, EventArgs e) { + btn_apply_Click(sender, e); + Close(); + } + + private void _3rdPartyControllers_FormClosing(object sender, FormClosingEventArgs e) { + btn_apply_Click(sender, e); + } + + private void btn_refresh_Click(object sender, EventArgs e) { + RefreshControllerList(); + } + + private void list_allControllers_SelectedValueChanged(object sender, EventArgs e) { + if (list_allControllers.SelectedItem != null) + tip_device.Show((list_allControllers.SelectedItem as SController).name, list_allControllers); + } + + private void list_customControllers_SelectedValueChanged(object sender, EventArgs e) { + if (list_customControllers.SelectedItem != null) { + SController v = (list_customControllers.SelectedItem as SController); + tip_device.Show(v.name, list_customControllers); + + chooseType.SelectedIndex = v.type - 1; + + group_props.Enabled = true; + } else { + chooseType.SelectedIndex = -1; + group_props.Enabled = false; + } + } + + private void list_customControllers_MouseDown(object sender, MouseEventArgs e) { + if (e.Y > list_customControllers.ItemHeight * list_customControllers.Items.Count) + list_customControllers.SelectedItems.Clear(); + } + + private void list_allControllers_MouseDown(object sender, MouseEventArgs e) { + if (e.Y > list_allControllers.ItemHeight * list_allControllers.Items.Count) + list_allControllers.SelectedItems.Clear(); + } + + private void chooseType_SelectedValueChanged(object sender, EventArgs e) { + if (list_customControllers.SelectedItem != null) { + SController v = (list_customControllers.SelectedItem as SController); + v.type = (byte)(chooseType.SelectedIndex + 1); + } + } + } } diff --git a/BetterJoyForCemu/MainForm.Designer.cs b/BetterJoyForCemu/MainForm.Designer.cs index 17e7855..30b1359 100644 --- a/BetterJoyForCemu/MainForm.Designer.cs +++ b/BetterJoyForCemu/MainForm.Designer.cs @@ -26,7 +26,6 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.console = new System.Windows.Forms.TextBox(); - this.console_lbl = new System.Windows.Forms.Label(); this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -68,16 +67,6 @@ this.console.Size = new System.Drawing.Size(262, 100); this.console.TabIndex = 2; // - // console_lbl - // - this.console_lbl.AutoSize = true; - this.console_lbl.Location = new System.Drawing.Point(9, 116); - this.console_lbl.Name = "console_lbl"; - this.console_lbl.Size = new System.Drawing.Size(80, 13); - this.console_lbl.TabIndex = 1; - this.console_lbl.Text = "Console Output"; - this.console_lbl.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // // notifyIcon // this.notifyIcon.BalloonTipText = "Double click the tray icon to maximise"; @@ -265,7 +254,7 @@ // // btn_open3rdP // - this.btn_open3rdP.Location = new System.Drawing.Point(188, 112); + this.btn_open3rdP.Location = new System.Drawing.Point(93, 112); this.btn_open3rdP.Name = "btn_open3rdP"; this.btn_open3rdP.Size = new System.Drawing.Size(86, 20); this.btn_open3rdP.TabIndex = 7; @@ -337,7 +326,7 @@ // // btn_reassign_open // - this.btn_reassign_open.Location = new System.Drawing.Point(107, 112); + this.btn_reassign_open.Location = new System.Drawing.Point(12, 112); this.btn_reassign_open.Name = "btn_reassign_open"; this.btn_reassign_open.Size = new System.Drawing.Size(75, 20); this.btn_reassign_open.TabIndex = 13; @@ -362,7 +351,6 @@ this.Controls.Add(this.donationLink); this.Controls.Add(this.passiveScanBox); this.Controls.Add(this.version_lbl); - this.Controls.Add(this.console_lbl); this.Controls.Add(this.console); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -384,7 +372,6 @@ #endregion public System.Windows.Forms.TextBox console; - private System.Windows.Forms.Label console_lbl; private System.Windows.Forms.NotifyIcon notifyIcon; private System.Windows.Forms.Label version_lbl; private System.Windows.Forms.ContextMenuStrip contextMenu; diff --git a/BetterJoyForCemu/MainForm.cs b/BetterJoyForCemu/MainForm.cs index a8975ef..0bb4eac 100644 --- a/BetterJoyForCemu/MainForm.cs +++ b/BetterJoyForCemu/MainForm.cs @@ -14,423 +14,420 @@ using System.Windows.Forms; using System.Xml.Linq; namespace BetterJoyForCemu { - public partial class MainForm : Form { - public bool nonOriginal = Boolean.Parse(ConfigurationManager.AppSettings["NonOriginalController"]); - public List