Get HID Device data only from my delphi application - delphi

I have 2 keyboards attached via usb. I want that my application to receive input only from one of them. I tried to use the TJvHidDeviceController i sucesefully get a handle to the device but i can't get any data.
Is it possible to prevent other applications to receive input from the second keyboard ?

Is it possible for your set-up to not load a device driver for the keyboard you want to listen to? If it is, you could try this method:
Use QueryDosDevice to list all devices on your computer. You can either search the vendor and device ID in the list if you know them, or build a list before and after you plug in the second keyboard and see which item(s) appear on the list.
Use CreateFile with the \\?\ prefix to connect to this device and read/write raw data from it.

Related

How reconnect programatically Classic Bluetooh on IOS with MFi and external-accessory framework

I am creating an IOS App to connect into a Bluetooth Device using Classic Bluetooth with Mpi using ExternalAccessory Framework.
Using showBluetoothAccessoryPicker method, I can display an alert with a list of devices that allows the user to select one Device to pair.
I can perform Steps 1 -5 of my use case as below. However I not able to perform step 6
Use case:
The User picks one Device to pair. On that case, I am using showBluetoothAccessoryPicker
The App stores, into a variable, the accessory that the user picked
Turn off the Device
The App shows an alert "Connection dropped"
Turn On the Device
The App needs to reconnect with the Device automatically without needs to select it into a list.
Is there any way or method to pair a device without display a list?
As my company is a member of the Apple MFi licensing program, I asked for Apple support and I received the answer below.
"
In response to your request below, there is presently no support for implementing the bluetooth reconnection process from the device side after an existing connection has been broken. This would be an API enhancement request which you can submit using the Apple Developer feedback assistant web page - https://feedbackassistant.apple.com.
"
"
One option would be for the accessory to handle the reconnection process itself as this is a supported bluetooth option. However, I understand if for power conservation reasons, this is not supported accessory option."
It means, there is no way, yet, to implement it from the App side. if you need that, you need to do it on the Device side.
We can submit feedback for the Apple, using the Apple Developer feedback assistant web page - https://feedbackassistant.apple.com to ask them to create it
you need to make some changes in your firmware to reinitiate the connection when it identifies the connection drop. Or else you can write a method and call on connection drop in your application which keeps looking for device in proximity (with accessory info saved in your app variable) and as and when it finds, it connects using that accessory instance.

iOS Previously Bonded BLE Devices

I've searched everywhere for the answer to this and have yet to find a definitive answer... Please help...
I have created an app that connects and bonds to a BLE device which requires a pin. The pin is pragmatically created and displayed to the user before the iOS bluetooth bonding dialog is triggered. So far, so good. If the user correctly enters the pin into the bonding dialog the phone and the BLE device are now bonded and everyone is happy.
Now the user closes the app and terminates the bluetooth connection.
When the app starts up again and the BLE device is discovered, is there any way to know that the bonding has already taken place? Basically, I don't want to re-display a pin to the user if the device has already bonded.
I'm currently saving the identifier of the BLE device and calling RetrievePeripheralsWithIdentifiers to see if the device has been connected before. This works but if the user goes to the bluetooth listing and selects "Forget this device", RetrievePeripheralsWithIdentifiers still returns ther peripheral. I've tried restarting the phone, uninstalling and reinstalling the app. Nothing seems to make iOS forget that at some point in the past, that identifier was connected...
Help!
iOS has no API whatsoever for pairing or bonding. iOS will only prompt a pairing dialog upon request from the other device or when it reads a characteristic that requires security. Your app won't even know that the pairing dialog is being shown, when pairing is complete, or when/if the current link is encrypted.
If the device is already bonded and the LTK that iOS has stored during a previous pairing process can be used (the slave also has it), then the link will automatically be encrypted and therefore no new pairing dialog will be shown.
The list about previously connected devices has nothing to do with bonded devices. It's just a list of previously known devices.
I think you are mixing up concepts a bit. Bonding essentially means "having the same Long Term Key".
So if you have two devices, and you want them to open up an encrypted connection, both devices simply check if they have a key associated with the corresponding device, and try to use this key to encrypt the messages.
This is why a device can't really check if the bond still exists. Each device can check if its own key still exists, but how would it know if the other device still has the key? As soon as one side has forgotten the key, the bond is lost.
I don't have much experience with iOS, but I assume their should be a function to get the stored Long Term Keys to check if there is an LTK associated with a Bluetooth address. Alternatively, it should be possible to
use external storage so that instead of the stack doing it for you, you can define a file where all keys are stored, and provide the stack with the key when needed. (At least, this works with other implementations.) In this case, you could directly look in the file to check if the devices have been bonded.
Note that entering the pin corresponds to the process of "pairing". The successful conduction of this procedure and the subsequent encryption of the connection does not prove that the devices are bonded. After disconnection, the pairing information is lost and the devices need to pair again - except if you have stored the key, which makes the pair a bond.
I faced a similar problem in my app, where if the user selected "Forget this device" from the settings then my app wouldn't know.
You can use retrieveConnectedPeripherals(withServices: [CBUUID]) to check if your device is connected to the OS. If yes then proceed with your other functions, else show PIN again(or whatever you want).
retrievePeripherals(withIdentifiers:) will return the device if it was connected to your OS previously.
I am doing this in my app. Hope this helps.

How to remote desktop to an iOS device, a.k.a. how do Mobile Device Farms work?

I have been trying to understand how Mobile Device Farms like DeviceConnect, AWS Device Farm, SauceLabs, etc. get to remote control iOS devices, but I can't find anything on the subject. They get to do it without jailbreaking, which baffles me even more.
I love these kind of projects, because at the moment it seems undoable, but I know that it is possible ('they' are doing it).
With remote control I mean: seeing the screen of the iOS device on your computer screen and able to touch and swipe with your mouse.
Can someone please point me in the right direction as to how these technically work?
If you're using an iPad (in particular) or an iPhone (if you think you'll be able to make our any detail on the smaller screen) then using remote access to view and control what's on your friend's Mac is a good option. And the best way to remote-access a Mac from an iPad is to use Google's free Chrome Remote Access service, which lets you remotely use Mac programs from an iOS device.
It's quite an involved process to set it up the first time, but easy if you want to do it again in future. You'll need the Google Chrome web browser for Mac, and a Google account.
Here is link for Chrome Remote access
https://chrome.google.com/webstore/detail/chrome-remote-desktop/gbchcmhmhahfdphkhkmpfmihenigjmpp?hl=en
Open Chrome and go to Chrome Remote Desktop on the Chrome Webstore. Click Add to Chrome, then Add App. Click Allow, then Continue.
I will give you one approach and small explanation .
You will need to create application with all possible permissions at first also implementation handlers functions .
For example :
Works with files
Real native Socket connections (not http protocol) + need to have some main server signalling (domain or static ip).
Handle remote touch trigger (main problem for real remote/iOS)
Background part experience
Your app need to be non-Market app (more likely).
You can make Application with all possible options that apple give us.
What can you do remote with your app : -control camera/ Mic read geo data , work with galleries , delete or create files . Socket will be communication line .
Also app must initially started and make (on user request) always allow all permissions .
Use camera :
Send with socket some command example ( openCamera ) . AFTER receive this string perform action for opening camera .
If you can fix programability triggering touch events you can make remoteIOS.
More data links :
Q/A send remote events
Q about touch events
Q/A about Permisions
Sorry for the first quick answer,
All of these: DeviceConnect, AWS Device Farm, SauceLabs use Appium in order to control devices.
The component that execute the command is the WebDriver.
Appium have different WebDriver implementation in order to execute operations to different device.
The iOS WebDriver can be found here: https://github.com/appium/appium-ios-driver.
The protocol in use is the JsonWireProtocol.
more details can be found here:
http://appium.io/,
http://www.seleniumhq.org/
Regards

Listen for iOS device power button presses

I am creating an app, which needs to do something when the user presses the power button 5 times.
I figured out that it's difficult to implement in iOS, but I think it's not impossible. How do I listen for power key events, even when the app is running in the background?
Can anyone help me to find solution?
you can tap a power key once and also you cannot detect the event from your application, this is not possible in iOS as far now, better try a different way to send alert with in your app, set some conditions with in your app and then send a alert based on those conditions if satisfied, I think this would be better,
Somehow ,If you try to override the existing functionality of the power key, apple will reject your app I think so,
You can't directly get the power button events. But there are notifications which you can count like UIApplicationProtectedDataWillBecomeUnavailable or UIApplicationWillResignActiveNotification. Or just register for all low level notifications with CFNotificationCenter and see if you find something fitting like com.apple.springboard.lockstate.
I don't think you can override system level actions like holding the power button, pressing the home button, overriding the mute sound switch within your own app. iOS system doesn't exactly behave like an normal computer OS, it's to much more limited.
Apple is not allowing you to use hardware components completely. They have added some restrictions. They provided the method in the app delegate i.e. applicationDidEnterBackground can catch the home button press .Also they has provided the the API's to access the camera,bluetooth etc .At least this much of API's I know which provided by apple publicly to access the hardware. You cannot access the other hardware elements in your application which not provided publicly by apple .If you are able to do this by any way then also your application will not approved by apple .

Capturing iPhone's key input?

I am trying to write a program for iPhone that pop up messages/information depending on the combination of keys a user press on the iPhone. For example, if a user type a certain key word, my program will display a message (my program will be running in the back ground upon user’s request). Can you please tell me if there is a way we can capture what keys user is pressing on his/her iPhone. Either on a text message or a web browser etc.. Any ideas would be greatly appreciated
This is not possible (thankfully) using public APIs. It might be possible (I don't know) using private APIs on jailbroken devices.

Resources