Skip to content

About

Native Swift macOS menu bar utility that detects USB Ducky One keyboards and applies per-device PC-to-Mac HID key mapping.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Ducky Mac Mapper App Icon

Ducky Mac Mapper (DuckyKeyboardMod)

Native Swift macOS menu bar utility that automatically detects Ducky One keyboards on USB and applies a scoped PC → Mac HID key mapping — leaving Apple Magic Keyboards and built-in MacBook keyboards untouched.

Live Project Page · Download DMG

Ducky Mac Mapper Hero Graphic

Features

  • Real-time USB Detection (Zero Permissions Required): Watches macOS IOHIDEventService arrival/removal via IOKit IONotificationPort and recovers automatically after sleep/wake (NSWorkspace.didWakeNotification). Requires no Input Monitoring or Accessibility permissions.
  • Per-Device Scoped HID Mapping: Uses macOS's native UserKeyMapping (hidutil, Apple Technical Note TN2450) scoped to the detected Ducky keyboard's exact VendorID, ProductID, LocationID, and USB transport. Works in password prompts, Spotlight, Terminal, and all apps with zero latency.
  • Native Menu Bar Status Indicator:
    • ⌨ ⌘ (filled): Ducky One USB detected and Mac-mapped
    • ⌨ PC: Ducky One USB detected, mapping paused
    • ⌨: Waiting for Ducky One USB keyboard
  • Customizable PC → Mac Mapping Rules:
    • Swap Left Alt ↔ Left ⌘ Command (Win) (default: ON)
    • Swap Right Alt ↔ Right ⌘ Command (Win) (default: ON)
    • Map Print Screen / Scroll Lock / Pause → F13 / F14 / F15 (default: ON)
    • Remap Menu (App) key → Right ⌘ Command, Right ⌥ Option, or Unchanged (default: Right ⌘)
    • Optional Caps Lock → ⎋ Escape or ⌃ Left Control
    • Optional ISO § / ± ↔ ` / ~ swap
    • Optional Match any Ducky USB keyboard (expands matching beyond Ducky One series)
  • Clean Lifecycle: Optional Launch at Login (SMAppService.mainApp), a native About window with custom hero artwork and build info, bespoke macOS squircle app icon, auto-incrementing build numbers, and automatic restoration to default PC layout on app quit.

Build & Run

Build .app bundle (Release, auto-increments build number)

Every invocation of scripts/build-app.sh automatically increments Resources/build-number.txt and updates CFBundleVersion in Info.plist.

./scripts/build-app.sh
open build/DuckyKeyboardMod.app

Build .dmg Installer

# Build into build/DuckyKeyboardMod.dmg
./scripts/build-dmg.sh

# Build and copy directly to ~/Desktop/DuckyKeyboardMod.dmg
./scripts/build-dmg.sh --desktop

Install to /Applications and Launch

./scripts/install-app.sh

Run Unit Tests

DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test

Architecture

  • Sources/DuckyCore/ — Pure Swift core library:
    • HIDKeyCodes.swift: Apple HID Usage Page 0x07 key codes, mapping rules, and UserDefaults-persisted settings.
    • HIDKeyboardDevice.swift: NDJSON service parser, multi-interface physical keyboard deduplication (6KRO + NKRO), and DuckyDeviceMatcher (USB transport + Ducky One product names & known USB VID/PID fallbacks).
    • HIDUtilBackend.swift: Native /usr/bin/hidutil runner for listing keyboards and scoping UserKeyMapping per physical USB device.
    • USBDeviceWatcher.swift: IOKit IONotificationPort hot-plug watcher with debouncing and sleep/wake handling.
    • KeyboardMapperController.swift: @MainActor state machine coordinating detection, auto-mapping, verification, and cleanup.
  • Sources/DuckyKeyboardMod/ — Native SwiftUI + AppKit menu bar app (LSUIElement = true).
  • Tests/DuckyCoreTests/ — Swift Testing suite covering matching, NDJSON parsing, rule generation, controller lifecycle, and read-only live macOS HID enumeration.

About

Native Swift macOS menu bar utility that detects USB Ducky One keyboards and applies per-device PC-to-Mac HID key mapping.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages