Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] A couple of small bugfixes #456

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions macos/QMK Toolbox/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>fm.qmk.hex</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>NSDocument</string>
<string></string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
Expand All @@ -29,14 +31,16 @@
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.macbinary-archive</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>NSDocument</string>
<string></string>
</dict>
</array>
<key>CFBundleExecutable</key>
Expand Down
6 changes: 5 additions & 1 deletion macos/QMK Toolbox/MainViewController.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Cocoa
import UniformTypeIdentifiers

class MainViewController: NSViewController, USBListenerDelegate {
@IBOutlet var filepathBox: NSComboBox!
Expand Down Expand Up @@ -273,7 +274,10 @@ class MainViewController: NSViewController, USBListenerDelegate {
openPanel.canChooseDirectories = false
openPanel.allowsMultipleSelection = false
openPanel.message = "Select firmware to load"
openPanel.allowedFileTypes = ["bin", "hex"]
openPanel.allowedContentTypes = [
UTType(filenameExtension: "bin")!,
UTType(filenameExtension: "hex")!
]
openPanel.beginSheetModal(for: window) { response in
guard response == .OK, let file = openPanel.url else { return }
self.setFilePath(file)
Expand Down
2 changes: 1 addition & 1 deletion macos/QMK Toolbox/USB/Bootloader/BootloaderDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class BootloaderDevice: USBDeviceProtocol, CustomStringConvertible {
let serialMatcher = IOServiceMatching(kIOSerialBSDServiceValue)
var serialIterator: io_iterator_t = 0

guard IOServiceGetMatchingServices(kIOMasterPortDefault, serialMatcher, &serialIterator) == KERN_SUCCESS else { return nil }
guard IOServiceGetMatchingServices(kIOMainPortDefault, serialMatcher, &serialIterator) == KERN_SUCCESS else { return nil }

repeat {
let port = IOIteratorNext(serialIterator)
Expand Down
2 changes: 1 addition & 1 deletion macos/QMK Toolbox/USB/Bootloader/LUFAMSDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LUFAMSDevice: BootloaderDevice {
massStorageMatcher[kIOMediaRemovableKey] = true

var massStorageIterator: io_iterator_t = 0
guard IOServiceGetMatchingServices(kIOMasterPortDefault, massStorageMatcher as CFDictionary, &massStorageIterator) == KERN_SUCCESS else { return nil }
guard IOServiceGetMatchingServices(kIOMainPortDefault, massStorageMatcher as CFDictionary, &massStorageIterator) == KERN_SUCCESS else { return nil }

repeat {
let media = IOIteratorNext(massStorageIterator)
Expand Down
2 changes: 1 addition & 1 deletion macos/QMK Toolbox/USB/USBListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class USBListener: BootloaderDeviceDelegate {
}

func start() {
notificationPort = IONotificationPortCreate(kIOMasterPortDefault)
notificationPort = IONotificationPortCreate(kIOMainPortDefault)
let runLoopSource = IONotificationPortGetRunLoopSource(notificationPort).takeUnretainedValue()
CFRunLoopAddSource(RunLoop.current.getCFRunLoop(), runLoopSource, .defaultMode)

Expand Down