I'm trying to understand if (and if so, how) it's possible to dedicate a HID (USB-card reader for NFC cards) to a specific application in macOS.
The card reader acts as a keyboard, sending the number of the card to whatever is open in macOS. I'm trying to get that USB-device locked to a specific application (e.g. firefox, chrome etc).
I really have no idea where to start looking for this. Hence I'm posting here for any help in the right direction.
Googling "Dedicate USB device to app" etc gave nothing useful.
macOS version 10.14.5 (18F132) (Mojave).
The way applications communicate to USB devices is IOKit framework. You could write it as service if you want to lock applications anywhere. And you need to know about launchd (Launch Daemon). It manages all your background service.
Related
Anyone has any experience with application deployment through Mac App Store with 3rd party drivers? I have an application that is used to manage external device through usb port. It requires some drivers to be installed within. Any ideas how to deploy such application with Mac App Store so I don't have to bother user with any confusing messages about drivers? Is there any way to deploy such driver? Is there any way to load drivers only in userspace (sandbox?)
It's a virtual com port driver.
As far as I'm aware, you can use the user space I/O Kit framework from Mac App Store apps. So if your device can be driven entirely via that, go ahead. USB devices are usually good candidates for user space drivers, but it heavily depends on how the device will be used. If only your app is going to be accessing the device, you stand a very good chance. If you're intending to make it available to multiple applications, e.g. by creating a /dev node, you'll need to drop to the kernel.
You can't ship kernel extensions (kexts) with apps via the Mac App Store.
I don't know what the status is regarding MAS apps which require a specific device and kext to work, without shipping the kext together with the app. If the kext is optional, I suspect they'll allow it.
I received a direct marketing USB stick on the mail the other day. As soon as I inserted it into my test-Mac - it opened Safari and wrote in the address of a website it wanted to visit. It had the exact same behaviour on my test PC.
Now, I was under the assumption that OSX didn't have an autorun feature. I'm running 10.10.3 and I can't even find the device under disk utility.
Any ideas on how they are doing this? The only thing I can think of is that it's piggybacking on a helper service, but I've never used any products from this company before.
How can I investigate the contents of the USB if I can't find it on my mac?
I can't even find the device under disk utility.
That is beacause it is not a disk device, but a USB HID "keyboard". The stick sends the key codes that will open the website automatically.
I have been searching through how to do gamepad and joystick support on Mac for some days and all resources that I found seems to suggest a pre-installed driver along with using Apple's HID API, which works.
The drawback about this approach is that each joystick and gamepad will require another kernel extension to be loaded, so it can be recognized by HID manager, or at least a code less Info.plist saying it conforms to the earlier installed driver. For instance, when I have an 360 Xbox driver KEXT in house, the Xbox controller from Microsoft will work, but not the Logitech one (I tried F710).
As Apple suggests the application that uses a gamepad or joystick should be able to do themselves at user space without introducing any KEXT stuff. Is there a way to do it?
The thing I had in mind was something like using IORegistry or IOUSB API to get the device when they get plugged in (USB Prober shows it at least). Then somehow get the description of the device, then use that description to register the device as a HID one. Then the whole HID manager can be used.
Am I on the right track? Or is there any other way to do this?
Since IOKit API actually provided keywords like kHIDUsage_GD_Joystick, and there's an ForceFeedback.h library, I suppose Apple designed their HID API with joystick and force feedback in mind. That's the slim hope I had that this might work.
Some reference documentation and open source project:
Colin Munro's 360 driver
HID API Documents
DDHID Project
After revisiting this, I found out the solution to be operating directly on the file descriptors of the device. libusb is an excellent library which greatly simplify your life on this and they have Mac supported.
xboxdrv link is a great example on how to operate on file socket using libusb.
In pseudo code, it should look like this:
enumerate device
detect kernel driver and detach it if possible
open device
file off a initial transfer
wait on the callback function to handle msg and error properly
start run loop or select on fd to call libusb_event_handle
Check libusb for more info link.
I want to create a fake flash drive programmatically under Mac OSX and Windows.
It should behave like a normal drive, that means it should appear in explorer/finder, should be unmountable,.. If someone puts some data in it, it should be handled in a backend software.
Is that possible?
I'm not aware of any existing cross-platform frameworks. For Windows, the documentation for writing device drivers is here: http://msdn.microsoft.com/en-us/library/ff557573. See also http://msdn.microsoft.com/en-us/windows/hardware/gg463062 but note that this is hard-core stuff.
I'm developing an application that runs on a machine that has several usb keyboards attached. Occasionally keyboards will added or removed. Each time a key is pressed, the application needs to find out which key was pressed, and which keyboard was used.
I have got a working version of the application which uses RawInput under windows. However windows can take a while to work out whats happened if you add or remove a hub or two full of keyboards, and I'm looking too see if the same can be achieved on a different OS more robustly.
Mac OS X/Cocoa would be the second choice if it is possible, but I am open to suggestions for any other platforms like linux if you can suggest a way to do it.
On Mac OS X, you can use the HID Manager to get direct visibility into which HID elements are being actuated on which devices.
That should work not just for keyboard but for all HID devices — mice, game pads, etc. — though of course you can restrict what your code pays attention to to only specific devices or devices of a specific class.
You'll need to be familiar with the concepts of USB device matching and USB Human Interface Device communication in general, but if you are then it should be fairly straightforward to get something up and running with the HID Manager on Mac OS X Leopard (10.5).