How can I get windows to remember my device after installing it so I don't get the new device message upon every connection? - windows

I have a piece of hardware that we created that connects to my PC via USB. We also wrote the drivers for it. EVERY time I plug this device in, the new device message comes up, even though the drivers are installed. I can cancel the dialog and it works fine, but it looks like crap and I'll be selling this product and want it to function like other USB products and only throw this dialog up once.
How do I make this happen?

Do you have all of the USB device descriptor fields populated in your device? Specifically, I am asking about the serial number field.
http://blogs.msdn.com/oldnewthing/archive/2004/11/10/255047.aspx

Related

How to get connection status on a BLE device in Windows

I have a Bluetooth low-energy device paired to my Windows 10 machine, when an application try to use it, Windows automatically connects the paired device. I want to be able to read if the device is connected or just paired to Windows. Searching around Window's Device Manager (accessible from Control Panel), I saw that the device had the property "Is connected" under the details tab, it's value (true/false) was changing accordingly to the actual device status.
I tried to read to access this property using the SetupDiGetDeviceProperty function with the DEVPKEY_DeviceContainer_IsConnected predefined key but for some reason I get ERROR_NOT_FOUND.
Any ideas?

How can you tell if your device has been whitelisted?

I got the email back from Google and they said they have, but having trouble getting it to show up under devices using some of the example code they provide, but now wondering if maybe I gave them the wrong serial or something and it really hasn't been white-listed.
You can always email them with the developer ID (Should be in the email), app ID, and your serial # to have them check. One thing I learned, though (when experiencing the same thing), was that I forgot to configure my chromecast with the "send this serial # to Google when communicating about updates" flag. If that isn't checked, then your Chromecast can't be notified that it is allowed to communicate with your app id. Also note that the Chromecast Android app had a bug (don't know if today's update fixed it) where setting that flag wouldn't stick, so I had to do it through the desktop app and then reboot the Chromecast and wait a few hours for the next time it pinged Google.
Make sure you have the "Send this Chromecast's serial number when checking for updates" setting enabled using one of the ChromeCast setup apps for your OS or Android. And reboot your ChromeCast device after enabling that setting.
You should be able to open Chrome and enter http://[ip.to.chrome.cast]:9222 in the browser address field. If your cromecast device is whitelisted the page will open.

USB device opens Applications, then types in text field

I got a letter in the mail that contained a small USB device. Here is what it loks like: http://imgur.com/a/VEtNK
When I plug it into my computer it seems to hover over the programs in my Dock and then opens one. It then types a link into a text field that is available. I originally had Skype in the dock and it defaulted to that one, strange. I removed Skype from the dock and now it opens to System Preferences.
Here's a video of what happens as I plug it in: https://www.dropbox.com/s/yuw6ggvo77rkvwh/Test1MysteryDevice.mov
Also, it does not appear like a memory stick does on my computer. I can't seem to locate it when it's plugged in. It would be cool if I could find it somehow. It would be even cooler if I could program it to do something I wanted.
Thanks, and if anyone can help out that's awesome or if you could point me to a forum/anywhere that might be able to help out, that'd be great!
Probably it self-identifies as a HID (Human Interface Device), specifically a keyboard. As soon as it is accepted as a keyboard by the OS it can send any sequence of keystrokes, and the OS will assume that it is input from a human user.
Scripting such behavior is easy using Applescript.
However automatically running a program from a USB stick when it is inserted is supposed to be impossible on OS X, as auto-run is a security risk.
Of course at the very least a custom USB device could be made to act like a mouse and keyboard, so even without autorun it's a risk to plug strange devices into your computer.
To get more info on the device you can go to System Profiler and look for the device on the USB bus.
If it is a custom device pretending to be a keyboard then it's probably hardwired to do what it does, and you probably won't be able to reprogram it; you'd need to find a manufacturer that will sell you customized devices.

Programmatically "unplug and replug" a USB device to load new driver in OS X?

I'm working on an installer in OS X that installs an IOKit driver for a USB device, and I'm trying to get it to not require a restart at the end. The installer installs the driver correctly and rebuilds the kext cache, and after it runs, if I unplug and replug the USB device, it correctly loads the new driver and everything works fine.
However, I don't want to require the user to physically unplug the device in order for the new driver to load. There's got to be a way to get OS X to load the new driver programmatically - in effect simulate the device being unplugged and plugged back in again, or something similar. How would I go about doing this? So far, hours of Googling has turned up nothing, so any help will be greatly appreciated!
IOUSBDeviceInterface187::USBDeviceReEnumerate() will do what you want. The only hitch is that to find all of the devices of interest and call this on them manually with IOServiceGetMatchingServices().
/*!
#function USBDeviceReEnumerate
#abstract Tells the IOUSBFamily to reenumerate the device.
#discussion This function will send a terminate message to all clients of the IOUSBDevice (such as
IOUSBInterfaces and their drivers, as well as the current User Client), emulating an unplug
of the device. The IOUSBFamily will then enumerate the device as if it had just
been plugged in. This call should be used by clients wishing to take advantage
of the Device Firmware Update Class specification. The device must be open to use this function.
#availability This function is only available with IOUSBDeviceInterface187 and above.
#param self Pointer to the IOUSBDeviceInterface.
#param options A UInt32 reserved for future use. Ignored in current implementation. Set to zero.
#result Returns kIOReturnSuccess if successful, kIOReturnNoDevice if there is no connection to an IOService,
or kIOReturnNotOpen if the device is not open for exclusive access.
*/
IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options);
Look in IOKit/usb/IOUSBLib.h
Take a look at diskutil, and especially the mount and unmount options. Those will softwarematically eject and mount devices. You can use diskutil list to get a list of all the currently mounted devices. If you need more info on diskutil, just look at the man page.

How do I tell OS X to ignore the input from one of two connected USB mice?

I have two USB mice connected to my Mac, one of which I'm using as a scanner. I need access to the Generic X and Y data but I don't want that data to move the cursor. How, under either carbon or cocoa environments, do I tell the system to ignore the mouse as a pointing device?
Edit: after some digging I've found that I can turn off mouse position updating with the CGAssociateMouseAndMouseCursorPosition() function, but this does not allow me to specify a single mouse. Can anyone explain the OS X relationship between HID mouse devices and the cursor? There has to be a binding between the hardware and software on a device by device basis but I can't find it.
I would look into writing a basic user-space driver for the mouse.
This will allow you direct access to the mouse as a USB device. You can also take control of the device from the system for your exclusive use.
There is some documentation here:
Working With USB Device Interfaces
To get you started, the set up steps to connect to a USB device go like this (I think, my IOKit is rusty)
include < IOKit/IOKitLib.h > and < IOKit/usb/IOUSBLib.h >
find the device you are interested in using IOServiceMatching(). This lets you pick find the correct USB device based on its properties, including things like vendor ID, &c. (See the IORegistryExplorer tool screen shot below)
get a USB plugin instance (let's call it plugin) with IOCreatePlugInInterfaceForService()
use plugin from step 2 get a device interface (let's call it device) using (**plugin)->QueryInterface()
device represents a connection handle to your USB device--open it first using either (**device).USBDeviceOpen or (**device).USBDeviceOpenSeize(). from there you should be able to send/receive data.
Sounds like a lot I know.. and there might be an easier way, but this is what comes to my mind. There may be some benefits to having this level of control of the device, not sure. good luck.

Resources