Skip to content

Commit

Permalink
[macOS] A couple of small bugfixes (#456)
Browse files Browse the repository at this point in the history
* [macOS] A couple of small bugfixes

* Update some deprecated names
  • Loading branch information
fauxpark committed Mar 6, 2024
1 parent c25f094 commit db96e80
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
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

0 comments on commit db96e80

Please sign in to comment.