Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I bought a bluetooth keyboard to enter data quickly while using my app. I was wondering if anyone knew if it were possible to assign function keys to UIButtons. I did some Google'n but didn't come up with anything much. I guess that is a sign you can't do it but I thought I would ask at least.

Thanks.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
You want to trigger a UIButton with the function keys on your keyboard? is that your question? I don't thnk that's possible, but I have never integrated with Bluetooth, but I think it's a cool question :) would like to hear about it too.
 

KnightWRX

macrumors Pentium
Jan 28, 2009
15,046
4
Quebec, Canada
I would start by seeing if the keyboard is presented as an External Accessory using the framework available for communicating with such devices :

https://developer.apple.com/library...roduction.html#//apple_ref/doc/uid/TP40009502

The following article describes how to connect to an accessory by its protocol string, I would simply use the example code to list devices and their protocol strings to see if the keyboard is present :

https://developer.apple.com/library...cting.html#//apple_ref/doc/uid/TP40009499-SW1

Reference to the EAAccessory class :

http://developer.apple.com/library/...ce/EAAccessory_class/Reference/Reference.html

If you find the keyboard as a supported MFi accessory, you will be able to open a session to it (EASession) and tie it to the run loop to send messages to a delegate. That delegate can check input streams for "key functions", and you'll pretty much have to write your own handlers to map these to your button actions, I really doubt IB lets you just to what you want.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Thanks for the links. I started to read the apple doc and it sounds like each manufacture has it's own set of specifications "Communicating with an external accessory requires you to work closely with the accessory manufacturer to understand the services provided by that accessory".

So if I manage to struggle through learning process and get it to work with my bluetooth keyboard it may only work with mine and no others.

I'll keep looking into it and read further.

Thanks.
 

xStep

macrumors 68020
Jan 28, 2003
2,030
143
Less lost in L.A.
My recent experience with a bluetooth barcode scanner...

The scanner has two main modes. The first is HID (Human Interface Device) keyboard mode. For control via software the second mode is SPP (Serial Port Profile).

HID allows it to easily connect to devices such as an iPad which has the capability to connect to standard bluetooth keyboards. When you have selected a field in an iOS app and then scan, the scanned item is entered into the field as if you typed it.

SPP allows you to write software to communicate with the device. This is very dependent on the manufacturer to develop a SDK. In my case, the manufacturer has developed SDKs for iOS, Android, and Blackberry. I'm working with the iOS one which allows me to change feedback, get battery level and a few other things.

If you are the developer of the software you want to control, I'd think that you would need to use the SPP mode. If you are just a Joe user, I have my doubts that you could customize a HID keyboard to select a particular button. You'll need to see how the interaction between the keyboard, virtual or not, is handled with software. I don't recall seeing a close interaction that would allow knowledge of the app from the keyboard input. I'd like to be proven wrong of course.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I am the developer of the software. From your experience it sounds like you were working with a specific bar code scanner. It sounds more and more that I would need to write software for each bluetooth keyboard since each manufacture would create their own SDK.

There has to be some generic IOS Class that allows bluetooth keyboards to function with my iPad since I don't install anything to use it. But it sounds like if I want to extend the keyboard beyond the basics I would need the manufactures SDK. Since there are so many different bluetooth keyboards on the market that means it would be writing lots of code for different ones if the Manufacture has created SDK's

Thanks for the insight.
 

xStep

macrumors 68020
Jan 28, 2003
2,030
143
Less lost in L.A.
Apple has a restrictive Bluetooth implementation. As I understand things, to use the SPP service, you need to enroll in the Apple MFi licensing program. That would mean the keyboard manufacturer would do that and supply a SDK to developers. That is what the scanner company has done.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I read up on this. It seems a lot more complicated then it needs to be for me to invest the time. The user will just have to press buttons instead of having a function for a button or tabbing through textfields.

Thanks for the insight though!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.