iPhone/iPad Get State of Wireless keyboard - iphone

Is there any way in the iPhone SDK (not a jailbroken API, this needs to be AppStore-Compliant), to get the state of a connected wireless keyboard? e.g. which keys are pressed and which aren't? I have searched for this with google, but I am coming up short.
Any help would be greatly appreciated!

Not really. You can tell whether a keyboard is connected or not, but you won't get callbacks for corded shortcuts. There is clearly a way to do this, because Pages supports keyboard shortcuts (Cmd-Z, etc), but it's not in the public SDK.

Related

Using colour keys on keypad from Chrome on Google TV

I'm writing a Web app for Google TV and want to make use of the colour keys on the remote control for navigation.
I'm not getting any input from the keys in response to onkeypress or onkeydown events, does anyone know if it is possible to use these keys for input in Web apps? I have seen the keys used in apps on Google TV but I suspect these may be Android apps. I can get input from the keyboard keys and the D controller without any difficulty.
Thanks in advance,
Gordon.
The color key's are not currently supported within web applications. Chrome does not receive key events from the remote for the color keys.
These color keys are designed for universal remote functionalities on TV. Since there are no desktop equivalents to them, Chrome does not pass any keycode for them.
In general for available keys and keycodes, use the keycode tester here:
https://developers.google.com/tv/web/docs/implement_for_tv#keyboard

Can I make an app that toggles on and off the iPhone's bluetooth?

I have been looking around for an answer to this, but haven't been able to find anything. Can I toggle on/off my iPhone's bluetooth signal from an app. I hate the process of doing it through the settings app.
I don't have any desire to get this approved through the app store, I just want it for use on my phone (very similar to the Android functionality).
Yes! Jeff Broderick made a handy site that lets you add a shortcut icon to your home screen to do this sort of thing. http://brdrck.me/settings/
I use it for Airplane Mode and Wifi. Haven't tried the Bluetooth, but I'd imagine it works as well as the others.

Find focus in OS X

Is it possible to create an app for the mac (and iphone afterwards) that does something when it detects that the focus is on a certain object in the screen?
Meaning, the program runs in the background, and when it detects that the focus (or cursor) is on an edit box, it will run something.
Hopefully I made myself clear!
Thanks!
You can do this on the mac by using the Accessibility Framework.
Note that users will have to manually enable assistive devices and you will not be able to distribute your app on the Mac App Store due to Apple's soon-to-be-implemented sandboxing restriction.
On iOS, you can detect focus to certain but not all elements using specialized delegate methods such as textViewDidBeginEditing:. That said, as users use taps to navigate iOS apps most of the time, simple tap handling seems like a much better approach.
On the iPhone, you can only detect focus within your own app, there's no way to observe other apps from the background.
On the Mac, as 0x90 noted, the closest you'll get are the Accessibility APIs. The UIElementInspector sample code may help you to get started.

How can I override the iPhone's home and sleep hardware buttons?

Is it possible to override the hardware home and sleep buttons on the iPhone? I did a lot of research on this, but I was unable to find any definitive answers out there.
I'm not looking to design something malicious, but I was curious about the possibility of doing this for a personal project on my own iPhone.
It is not possible, the operating system intercepts those interrupts in the kernel and dispatches messages appropriately.
This is possible on a jailbroken device only. There are addons available that in fact "catch" hardware button events. I can't tell you how it works, though.
I suggest looking for "jailbreak" and "home button" with a search engine of your choice, for a start.
Since this is for personal use, jailbreaking may be acceptable.
However on a non-jailbroken device (and certainly for any app that should hit the appstore) there is no way to intercept the hardware button events.

Toggle iPhone tethering by code

I live in Canada, so am fortunate that I can tether. One issue is that to toggle tethering, you need to drill down four screens in Settings, which is just a big hassle.
A Google search returned nothing, so I was wondering if anyone here knew the code to turn on/off tethering?
I know there's a toggle for SBSettings, but I do not have a jailbroken phone, I just want to create an app I build onto my phone and have an icon for quickly toggling it.
Thanks
You cannot alter phone settings from within an application using any APIs allowed by the iPhone SDK. As you point out - there is an SBSettings toggle - which relies on a Private API (which you agree not to use when you get the iPhone SDK from Apple, incidentally).
There is a file located in the Preferences folder, along with the com.apple.SpringBoard.plist:
/var/mobile/Library/Preferences/com.apple.MobileInternetSharing.plist
In that file, you will want to set 1023 for key State to enable the Tethering feature. To disable the feature, you will want to set 1022 for key State.
This action is only possible on a jailbroken device