unbit / foohid

OSX IOKit driver for implementing virtual HID devices (joypads, keyboards, mices, ...) from userspace
MIT License
264 stars 35 forks source link

Swift interoperability #19

Open IgorMuzyka opened 6 years ago

IgorMuzyka commented 6 years ago

Yo hi. I'm in the process of developing my first mac app and I need to create a virtual HID keyboard so that I could send the events to the system but without intervening user input on the built-in keyboard. I have little to no experience with C++. And I've done my app in Swift 4.2. The question is: how do I use your library from Swift? I've managed to google some techniques with wrapping C++ code with Objective-C++ files and creating a bridging header. Even though I'm almost sure that this way would do this, but I'm kinda lost on how to do this quite right. Would like to hear your guidance on how to approach this. Or maybe you can provide a simple example and I'll learn from that and can cover the rest of calls/methods because I totally need this functionality. The only other option besides your library is also done in C++, this one Karabiner-Elements. To me, it seems that I have no other choice so I'll probably do this anyway, but with some help, I might be able to do this faster.

IgorMuzyka commented 6 years ago

Also, interested to hear your opinion on using such tool?

IgorMuzyka commented 6 years ago

@unbit

IgorMuzyka commented 6 years ago

Just realized there is a mouse.swift file in the repo. I feel stupid, probably shouldn't code til 6 in the morning and research solutions for my problems.

IgorMuzyka commented 6 years ago

Yo, I've kinda figured it out from mouse example. The only question I now have is how do I represent a composite report in Swift equivalently to union type in C? Is struct sufficient or is it not? @unbit