diff --git a/macos/QMK Toolbox.xcodeproj/project.pbxproj b/macos/QMK Toolbox.xcodeproj/project.pbxproj index e6382e80cb..d105b48cc8 100644 --- a/macos/QMK Toolbox.xcodeproj/project.pbxproj +++ b/macos/QMK Toolbox.xcodeproj/project.pbxproj @@ -42,7 +42,7 @@ 3A62C86526A96AED001C655A /* reset_right.eep in Resources */ = {isa = PBXBuildFile; fileRef = 3A62C86326A96AED001C655A /* reset_right.eep */; }; 3A62C86626A96AED001C655A /* reset_left.eep in Resources */ = {isa = PBXBuildFile; fileRef = 3A62C86426A96AED001C655A /* reset_left.eep */; }; 3A708D982848A23300394E52 /* USBListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A708D972848A23300394E52 /* USBListener.swift */; }; - 3A708D9A284901F500394E52 /* HIDConsoleListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A708D99284901F500394E52 /* HIDConsoleListener.swift */; }; + 3A708D9A284901F500394E52 /* HIDListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A708D99284901F500394E52 /* HIDListener.swift */; }; 3A708D9C284916F700394E52 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A708D9B284916F700394E52 /* AppDelegate.swift */; }; 3A7492CC27DF96BF0073A5A0 /* hid_bootloader_cli in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3A7492CB27DF96BF0073A5A0 /* hid_bootloader_cli */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3A8DE01A284636780012063A /* HIDConsoleDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A8DE019284636780012063A /* HIDConsoleDevice.swift */; }; @@ -134,7 +134,7 @@ 3A62C86326A96AED001C655A /* reset_right.eep */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = reset_right.eep; path = ../../../common/reset_right.eep; sourceTree = ""; }; 3A62C86426A96AED001C655A /* reset_left.eep */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = reset_left.eep; path = ../../../common/reset_left.eep; sourceTree = ""; }; 3A708D972848A23300394E52 /* USBListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = USBListener.swift; sourceTree = ""; }; - 3A708D99284901F500394E52 /* HIDConsoleListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIDConsoleListener.swift; sourceTree = ""; }; + 3A708D99284901F500394E52 /* HIDListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIDListener.swift; sourceTree = ""; }; 3A708D9B284916F700394E52 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 3A7492CB27DF96BF0073A5A0 /* hid_bootloader_cli */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = hid_bootloader_cli; sourceTree = ""; }; 3A7770D822BD3B8200398C40 /* libftdi1.2.5.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libftdi1.2.5.0.dylib; sourceTree = ""; }; @@ -187,7 +187,7 @@ 092963FA1F5C8B2C004F2D3F /* QMK Toolbox */ = { isa = PBXGroup; children = ( - 3A3DDC4C26AE27F600A04A99 /* HIDConsole */, + 3A3DDC4C26AE27F600A04A99 /* HID */, 3AC739EB26E23A9800D8B258 /* KeyTester */, 3AC7BE4B27254FB800FED7DB /* USB */, 3A708D9B284916F700394E52 /* AppDelegate.swift */, @@ -214,14 +214,14 @@ name = "Supporting Files"; sourceTree = ""; }; - 3A3DDC4C26AE27F600A04A99 /* HIDConsole */ = { + 3A3DDC4C26AE27F600A04A99 /* HID */ = { isa = PBXGroup; children = ( 3A8DE019284636780012063A /* HIDConsoleDevice.swift */, - 3A708D99284901F500394E52 /* HIDConsoleListener.swift */, + 3A708D99284901F500394E52 /* HIDListener.swift */, 3A92873C292CF7A10015D961 /* HIDConsoleViewController.swift */, ); - path = HIDConsole; + path = HID; sourceTree = ""; }; 3A53FB5B268A33F10020BAB0 /* Resources */ = { @@ -375,7 +375,7 @@ buildActionMask = 2147483647; files = ( 3A8DE01A284636780012063A /* HIDConsoleDevice.swift in Sources */, - 3A708D9A284901F500394E52 /* HIDConsoleListener.swift in Sources */, + 3A708D9A284901F500394E52 /* HIDListener.swift in Sources */, 3A92873D292CF7A10015D961 /* HIDConsoleViewController.swift in Sources */, 3A37607A283E769300C19B3F /* KeyView.swift in Sources */, 3A32CF59284141D60016D7B7 /* APM32DFUDevice.swift in Sources */, diff --git a/macos/QMK Toolbox/HIDConsole/HIDConsoleDevice.swift b/macos/QMK Toolbox/HID/HIDConsoleDevice.swift similarity index 100% rename from macos/QMK Toolbox/HIDConsole/HIDConsoleDevice.swift rename to macos/QMK Toolbox/HID/HIDConsoleDevice.swift diff --git a/macos/QMK Toolbox/HIDConsole/HIDConsoleViewController.swift b/macos/QMK Toolbox/HID/HIDConsoleViewController.swift similarity index 74% rename from macos/QMK Toolbox/HIDConsole/HIDConsoleViewController.swift rename to macos/QMK Toolbox/HID/HIDConsoleViewController.swift index 80b4b32695..101dca4182 100644 --- a/macos/QMK Toolbox/HIDConsole/HIDConsoleViewController.swift +++ b/macos/QMK Toolbox/HID/HIDConsoleViewController.swift @@ -1,18 +1,18 @@ import Cocoa -class HIDConsoleViewController: NSViewController, HIDConsoleListenerDelegate { +class HIDConsoleViewController: NSViewController, HIDListenerDelegate { @IBOutlet var consoleListBox: NSComboBox! @IBOutlet var logTextView: LogTextView! override func viewDidLoad() { - consoleListener = HIDConsoleListener() - consoleListener.delegate = self - consoleListener.start() + hidListener = HIDListener() + hidListener.delegate = self + hidListener.start() } override func viewWillDisappear() { - consoleListener.stop() + hidListener.stop() } @IBAction @@ -22,16 +22,16 @@ class HIDConsoleViewController: NSViewController, HIDConsoleListenerDelegate { // MARK: HID Console Devices - var consoleListener: HIDConsoleListener! + var hidListener: HIDListener! var lastReportedDevice: HIDConsoleDevice? - func consoleDeviceDidConnect(_ device: HIDConsoleDevice) { + func hidDeviceDidConnect(_ device: HIDConsoleDevice) { lastReportedDevice = device updateConsoleList() logTextView.logHID("HID console connected: \(device)") } - func consoleDeviceDidDisconnect(_ device: HIDConsoleDevice) { + func hidDeviceDidDisconnect(_ device: HIDConsoleDevice) { lastReportedDevice = nil updateConsoleList() logTextView.logHID("HID console disconnected: \(device)") @@ -39,7 +39,7 @@ class HIDConsoleViewController: NSViewController, HIDConsoleListenerDelegate { func consoleDevice(_ device: HIDConsoleDevice, didReceiveReport report: String) { let selectedDevice = consoleListBox.indexOfSelectedItem - if selectedDevice == 0 || consoleListener.devices[selectedDevice - 1] == device { + if selectedDevice == 0 || hidListener.devices[selectedDevice - 1] == device { if lastReportedDevice != device { logTextView.logHID("\(device.manufacturer ?? "") \(device.product ?? "")") lastReportedDevice = device @@ -53,7 +53,7 @@ class HIDConsoleViewController: NSViewController, HIDConsoleListenerDelegate { consoleListBox.deselectItem(at: selectedItem) consoleListBox.removeAllItems() - consoleListener.devices.forEach { device in + hidListener.devices.forEach { device in consoleListBox.addItem(withObjectValue: device.description) } diff --git a/macos/QMK Toolbox/HIDConsole/HIDConsoleListener.swift b/macos/QMK Toolbox/HID/HIDListener.swift similarity index 79% rename from macos/QMK Toolbox/HIDConsole/HIDConsoleListener.swift rename to macos/QMK Toolbox/HID/HIDListener.swift index 9f26dd99ca..3c0c7ceb40 100644 --- a/macos/QMK Toolbox/HIDConsole/HIDConsoleListener.swift +++ b/macos/QMK Toolbox/HID/HIDListener.swift @@ -4,16 +4,16 @@ import IOKit.hid let CONSOLE_USAGE_PAGE: UInt16 = 0xFF31 let CONSOLE_USAGE: UInt16 = 0x0074 -protocol HIDConsoleListenerDelegate: AnyObject { - func consoleDeviceDidConnect(_ device: HIDConsoleDevice) +protocol HIDListenerDelegate: AnyObject { + func hidDeviceDidConnect(_ device: HIDConsoleDevice) - func consoleDeviceDidDisconnect(_ device: HIDConsoleDevice) + func hidDeviceDidDisconnect(_ device: HIDConsoleDevice) func consoleDevice(_ device: HIDConsoleDevice, didReceiveReport report: String) } -class HIDConsoleListener: HIDConsoleDeviceDelegate { - weak var delegate: HIDConsoleListenerDelegate? +class HIDListener: HIDConsoleDeviceDelegate { + weak var delegate: HIDListenerDelegate? private var hidManager: IOHIDManager @@ -30,12 +30,12 @@ class HIDConsoleListener: HIDConsoleDeviceDelegate { IOHIDManagerOpen(hidManager, IOOptionBits(kIOHIDOptionsTypeNone)) let matchingCallback: IOHIDDeviceCallback = { context, result, sender, device in - let listener: HIDConsoleListener = Unmanaged.fromOpaque(context!).takeUnretainedValue() + let listener: HIDListener = Unmanaged.fromOpaque(context!).takeUnretainedValue() listener.deviceConnected(device) } let removalCallback: IOHIDDeviceCallback = { context, result, sender, device in - let listener: HIDConsoleListener = Unmanaged.fromOpaque(context!).takeUnretainedValue() + let listener: HIDListener = Unmanaged.fromOpaque(context!).takeUnretainedValue() listener.deviceDisconnected(device) } @@ -52,7 +52,7 @@ class HIDConsoleListener: HIDConsoleDeviceDelegate { let consoleDevice = HIDConsoleDevice(device) consoleDevice.delegate = self devices.append(consoleDevice) - delegate?.consoleDeviceDidConnect(consoleDevice) + delegate?.hidDeviceDidConnect(consoleDevice) } func deviceDisconnected(_ device: IOHIDDevice) { @@ -60,7 +60,7 @@ class HIDConsoleListener: HIDConsoleDeviceDelegate { devices = devices.filter { !discardedItems.contains($0) } for d in discardedItems { - delegate?.consoleDeviceDidDisconnect(d) + delegate?.hidDeviceDidDisconnect(d) } } diff --git a/windows/QMK Toolbox/HidConsole/HidConsoleDevice.cs b/windows/QMK Toolbox/Hid/HidConsoleDevice.cs similarity index 99% rename from windows/QMK Toolbox/HidConsole/HidConsoleDevice.cs rename to windows/QMK Toolbox/Hid/HidConsoleDevice.cs index 9b2bf1d4ca..b1cc0d016f 100644 --- a/windows/QMK Toolbox/HidConsole/HidConsoleDevice.cs +++ b/windows/QMK Toolbox/Hid/HidConsoleDevice.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace QMK_Toolbox.HidConsole +namespace QMK_Toolbox.Hid { public class HidConsoleDevice { diff --git a/windows/QMK Toolbox/HidConsole/HidConsoleWindow.Designer.cs b/windows/QMK Toolbox/Hid/HidConsoleWindow.Designer.cs similarity index 99% rename from windows/QMK Toolbox/HidConsole/HidConsoleWindow.Designer.cs rename to windows/QMK Toolbox/Hid/HidConsoleWindow.Designer.cs index c734c1beb3..baa2b9da26 100644 --- a/windows/QMK Toolbox/HidConsole/HidConsoleWindow.Designer.cs +++ b/windows/QMK Toolbox/Hid/HidConsoleWindow.Designer.cs @@ -1,4 +1,4 @@ -namespace QMK_Toolbox.HidConsole +namespace QMK_Toolbox.Hid { partial class HidConsoleWindow { diff --git a/windows/QMK Toolbox/HidConsole/HidConsoleWindow.cs b/windows/QMK Toolbox/Hid/HidConsoleWindow.cs similarity index 78% rename from windows/QMK Toolbox/HidConsole/HidConsoleWindow.cs rename to windows/QMK Toolbox/Hid/HidConsoleWindow.cs index 0d83b98719..ff9c550175 100644 --- a/windows/QMK Toolbox/HidConsole/HidConsoleWindow.cs +++ b/windows/QMK Toolbox/Hid/HidConsoleWindow.cs @@ -2,7 +2,7 @@ using System.ComponentModel; using System.Windows.Forms; -namespace QMK_Toolbox.HidConsole +namespace QMK_Toolbox.Hid { public partial class HidConsoleWindow : Form { @@ -29,27 +29,27 @@ private void HidConsoleWindow_Load(object sender, EventArgs e) { CenterToParent(); - consoleListener.consoleDeviceConnected += ConsoleDeviceConnected; - consoleListener.consoleDeviceDisconnected += ConsoleDeviceDisconnected; - consoleListener.consoleReportReceived += ConsoleReportReceived; - consoleListener.Start(); + hidListener.hidDeviceConnected += HidDeviceConnected; + hidListener.hidDeviceDisconnected += HidDeviceDisconnected; + hidListener.consoleReportReceived += ConsoleReportReceived; + hidListener.Start(); } private void HidConsoleWindow_FormClosing(object sender, FormClosingEventArgs e) { - consoleListener.consoleDeviceConnected -= ConsoleDeviceConnected; - consoleListener.consoleDeviceDisconnected -= ConsoleDeviceDisconnected; - consoleListener.consoleReportReceived -= ConsoleReportReceived; - consoleListener.Dispose(); + hidListener.hidDeviceConnected -= HidDeviceConnected; + hidListener.hidDeviceDisconnected -= HidDeviceDisconnected; + hidListener.consoleReportReceived -= ConsoleReportReceived; + hidListener.Dispose(); } #endregion #region HID Console - private readonly HidConsoleListener consoleListener = new(); + private readonly HidListener hidListener = new(); private HidConsoleDevice lastReportedDevice; - private void ConsoleDeviceConnected(HidConsoleDevice device) + private void HidDeviceConnected(HidConsoleDevice device) { Invoke(new Action(() => { @@ -59,7 +59,7 @@ private void ConsoleDeviceConnected(HidConsoleDevice device) })); } - private void ConsoleDeviceDisconnected(HidConsoleDevice device) + private void HidDeviceDisconnected(HidConsoleDevice device) { Invoke(new Action(() => { @@ -74,7 +74,7 @@ private void ConsoleReportReceived(HidConsoleDevice device, string report) Invoke(new Action(() => { int selectedDevice = consoleList.SelectedIndex; - if (selectedDevice == 0 || consoleListener.Devices[selectedDevice - 1] == device) + if (selectedDevice == 0 || hidListener.Devices[selectedDevice - 1] == device) { if (lastReportedDevice != device) { @@ -91,7 +91,7 @@ private void UpdateConsoleList() var selected = consoleList.SelectedIndex != -1 ? consoleList.SelectedIndex : 0; consoleList.Items.Clear(); - foreach (var device in consoleListener.Devices) + foreach (var device in hidListener.Devices) { if (device != null) { diff --git a/windows/QMK Toolbox/HidConsole/HidConsoleWindow.resx b/windows/QMK Toolbox/Hid/HidConsoleWindow.resx similarity index 100% rename from windows/QMK Toolbox/HidConsole/HidConsoleWindow.resx rename to windows/QMK Toolbox/Hid/HidConsoleWindow.resx diff --git a/windows/QMK Toolbox/HidConsole/HidConsoleListener.cs b/windows/QMK Toolbox/Hid/HidListener.cs similarity index 88% rename from windows/QMK Toolbox/HidConsole/HidConsoleListener.cs rename to windows/QMK Toolbox/Hid/HidListener.cs index c00dadf442..2984523cd8 100644 --- a/windows/QMK Toolbox/HidConsole/HidConsoleListener.cs +++ b/windows/QMK Toolbox/Hid/HidListener.cs @@ -4,20 +4,20 @@ using System.Linq; using System.Management; -namespace QMK_Toolbox.HidConsole +namespace QMK_Toolbox.Hid { - public class HidConsoleListener : IDisposable + public class HidListener : IDisposable { private const ushort ConsoleUsagePage = 0xFF31; private const ushort ConsoleUsage = 0x0074; public List Devices { get; private set; } - public delegate void HidConsoleDeviceEventDelegate(HidConsoleDevice device); + public delegate void HidDeviceEventDelegate(HidConsoleDevice device); public delegate void HidConsoleReportReceivedDelegate(HidConsoleDevice device, string data); - public HidConsoleDeviceEventDelegate consoleDeviceConnected; - public HidConsoleDeviceEventDelegate consoleDeviceDisconnected; + public HidDeviceEventDelegate hidDeviceConnected; + public HidDeviceEventDelegate hidDeviceDisconnected; public HidConsoleReportReceivedDelegate consoleReportReceived; private void EnumerateHidDevices(bool connected) @@ -36,12 +36,12 @@ private void EnumerateHidDevices(bool connected) if (device != null && !listed) { - HidConsoleDevice consoleDevice = new(device) + HidConsoleDevice hidDevice = new(device) { consoleReportReceived = HidConsoleReportReceived }; - Devices.Add(consoleDevice); - consoleDeviceConnected?.Invoke(consoleDevice); + Devices.Add(hidDevice); + hidDeviceConnected?.Invoke(hidDevice); } } } @@ -59,7 +59,7 @@ private void EnumerateHidDevices(bool connected) } Devices.Remove(device); device.consoleReportReceived = null; - consoleDeviceDisconnected?.Invoke(device); + hidDeviceDisconnected?.Invoke(device); } } } diff --git a/windows/QMK Toolbox/MainWindow.cs b/windows/QMK Toolbox/MainWindow.cs index 0f91e9e716..cfce656636 100644 --- a/windows/QMK Toolbox/MainWindow.cs +++ b/windows/QMK Toolbox/MainWindow.cs @@ -1,5 +1,5 @@ using QMK_Toolbox.Helpers; -using QMK_Toolbox.HidConsole; +using QMK_Toolbox.Hid; using QMK_Toolbox.KeyTester; using QMK_Toolbox.Properties; using QMK_Toolbox.Usb;