0

USB HID on iPad (iOS)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: USB HID on iPad (iOS)

by kmevans on Sun Aug 30, 2020 11:51 pm

Dan - thanks a lot. I will try doing a build. I already have a build environment setup, so it should be easy. I'll try tomorrow morning.

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by kmevans on Mon Aug 31, 2020 1:19 am

Ok - I couldn't resist a quick build and testing. It looks like this fixes it. I'll try to control iOS minecraft tomorrow and that should be a pretty good test + verifying that the MSC still mounts.

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by hathach on Mon Aug 31, 2020 4:07 am

Right, iOS won't accept generic gamepad either with usb or ble. Apple reall restrict what csn connect to their ios. However, I think ps4 controller can connect and work well with iOS. Maybe it is worth to take a look at how ps4 controller present itself.

https://support.playstation.com/s/artic ... uage=en_US

hathach
 
Posts: 1137
Joined: Tue Apr 23, 2013 1:02 am

Re: USB HID on iPad (iOS)

by kmevans on Mon Aug 31, 2020 2:02 pm

As far as I can tell this is fine, and I was able to use the mouse and keyboard. I got a little sidetracked because it wasn't working in iOS Minecraft, but apparently this is an issue with the app itself. There are forum threads about it. I verified that a USB mouse/keyboard and Apples own BLE keyboard don't work for iOS Minecraft either.

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by nineseventytwo on Sun Sep 13, 2020 8:32 pm

I've read thru this entire post and would like to use CircuitPython running on an ItsyBitsy M4 Express as a keyboard and mouse. I've used CircuitPython version 3 susessfully in the past to do this but I'm revisiting this project and updated to CircuitPython 6. I'm running into the same problem with it not functioning on IOS as a keyboard. I can follow that I would need to change a line to not include GAMEPAD. Can you point me in the right direction on how to do this? I'm basically inexperienced.

nineseventytwo
 
Posts: 31
Joined: Tue Aug 02, 2016 4:20 pm

Re: USB HID on iPad (iOS)

by kmevans on Sun Sep 13, 2020 8:54 pm

Start here and see if this is too much for you to do: https://learn.adafruit.com/building-circuitpython
If not then you can edit mpconfigboard.mk as described above. The one I edited was in ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk. You can look at a copy here https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk

If it's too complicated then perhaps someone else could build it for you.

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by nineseventytwo on Sun Sep 13, 2020 9:12 pm

Thanks for the quick reply. I'm half way through the how to build CircuitPython tutorial. Thanks for the link. So the file I'm changing should look like this then?
Code: Select all | TOGGLE FULL SIZE
USB_VID = 0x239A
USB_PID = 0x802C
USB_PRODUCT = "ItsyBitsy M4 Express"
USB_MANUFACTURER = "Adafruit Industries LLC"

CHIP_VARIANT = SAMD51G19A
CHIP_FAMILY = samd51

QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = GD25Q16C
LONGINT_IMPL = MPZ

# No I2S on SAMD51G
CIRCUITPY_AUDIOBUSIO = 0

CIRCUITPY_BITBANG_APA102 = 1
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER

nineseventytwo
 
Posts: 31
Joined: Tue Aug 02, 2016 4:20 pm

Re: USB HID on iPad (iOS)

by kmevans on Sun Sep 13, 2020 9:24 pm

That looks correct to me.

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by nineseventytwo on Sun Sep 13, 2020 9:39 pm

Thank you so much! I was able to build firmware, and it actually worked.

nineseventytwo
 
Posts: 31
Joined: Tue Aug 02, 2016 4:20 pm

Re: USB HID on iPad (iOS)

by kmevans on Sun Sep 13, 2020 9:42 pm

Great!

kmevans
 
Posts: 44
Joined: Mon Feb 06, 2017 4:32 pm

Re: USB HID on iPad (iOS)

by NexxuSix on Wed Oct 07, 2020 10:16 pm

Hello all,
This has been a very helpful thread. I am trying to do the same for the Trinket M0. My application is taking two of its inputs "0" and "2" and by toggling a physical switch to ground, I give the equivalent of ascii "<", and the other switch will toggle ascii ">". It also blinks the red LED on the board for a visual indicator. I can verify that this works fine in Notepad as I am able to move the cursor left or right in a string of letters. But, if I plug the Trinket M0 into an iOS device, I don't get any response at all.

I added this line:

USB_HID_DEVICES=KEYBOARD, MOUSE, CONSUMER

to the Trinket M0 mpconfigboard.mk file.

Everything compiles, and I get no errors. Everything seems to work as intended, but I cannot get the Trinket M0 to act as an keyboard for the iOS device. I did also confirm that despite adding the modified line to the file, Windows 10 Device Manager still shows the Trinket as a HID Gamepad Device, as well as a keyboard, and a couple of other HID devices. I also verified the ascii with a linux program called showkey, and it shows that my program on the Trinket M0 produces the exact ascii number sequences as a standard USB keyboard, so I know the ascii code is correct.

So, how do I disable the Gamepad HID from the Trinket M0 build?

Here is my modified code:
Code: Select all | TOGGLE FULL SIZE
USB_VID = 0x239A
USB_PID = 0x801F
USB_PRODUCT = "Trinket M0"
USB_MANUFACTURER = "Adafruit Industries LLC"
USB_HID_DEVICES=KEYBOARD, MOUSE, CONSUMER

CHIP_VARIANT = SAMD21E18A
CHIP_FAMILY = samd21

INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

SUPEROPT_GC = 0

CFLAGS_BOARD = --param max-inline-insns-auto=15
ifeq ($(TRANSLATION), zh_Latn_pinyin)
RELEASE_NEEDS_CLEAN_BUILD = 1
CFLAGS_INLINE_LIMIT = 35
endif
ifeq ($(TRANSLATION), de_DE)
RELEASE_NEEDS_CLEAN_BUILD = 1
CFLAGS_INLINE_LIMIT = 35
SUPEROPT_VM = 0
endif

NexxuSix
 
Posts: 8
Joined: Wed Oct 07, 2020 9:50 pm

Re: USB HID on iPad (iOS)

by nineseventytwo on Thu Oct 08, 2020 6:13 am

I was able to get a Trinket M0 to act as a keyboard on iOS iPhone. I can check it with an iPad later today.

The steps I followed are in this guide:
https://learn.adafruit.com/building-circuitpython

I setup am environment, and I changed the mpconfigboard.mk for the Trinket. Then I built CircuitPython for the Trinket M0. See my posted code from earlier. The code posted is for a ItsyBitsyM4, but the idea of adding the last line is the same.
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER


So, at that point I had a new firmware.uf2 file ready to boot and drag to my Trinket. Then I loaded my CircuitPython keyboard code, which looks like the code from this tutorial:
https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse

and It worked with iOS.

I did not add
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER
to my CircuitPython code file.

Hopefully following these steps helps you.

nineseventytwo
 
Posts: 31
Joined: Tue Aug 02, 2016 4:20 pm

Re: USB HID on iPad (iOS)

by NexxuSix on Thu Oct 08, 2020 10:14 am

Hello nineseventytwo,
Thank you for the reply! I removed the USB_HID_DEVICES line from the Trinket M0 mpconfigboard.mk file, and recompiled the code. I loaded the sketch for the keyboard to the Trinket M0, and was able to reproduce the results in Windows 10 Notepad (as a side note, before I modified the sketch, I used this tutorial to verify that everything was working with the new firmware before proceeding to make an app for iOS).

But, when I connected the Trinket M0 to my iPad, I don’t see any activity. It works fine in Notepad for Win10, so it makes me think perhaps I am not doing something correct in iOS???

For my iOS setup, I take the Trinket M0, and using the same USB cable that works for Win10, I transfer that USB cable to a Camera Connection Kit adapter that is connected to the iPad. I then test the setup on several apps within iOS: Notes, Koder, iEditor Pro, even the search bar for Safari, yield no results from key presses from the Trinket M0. This is a bit confusing at the moment...

How are you connecting your Trinket M0 to your iOS device? Are you using iOS 14, and what are your setting or apps that you are using to produce your results? Sorry for so many questions, but I think it has to be my setup in iOS, or perhaps my choice of app to test the Trinket M0.

Thank you in advance for your help...
-NexxuSix

NexxuSix
 
Posts: 8
Joined: Wed Oct 07, 2020 9:50 pm

Re: USB HID on iPad (iOS)

by danhalbert on Thu Oct 08, 2020 10:45 am

@NexxuSix: Remove the spaces after the commas in
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD, MOUSE, CONSUMER

and try again. The spaces are being considered as part of the HID device names.

danhalbert
 
Posts: 2289
Joined: Tue Aug 08, 2017 12:37 pm

Re: USB HID on iPad (iOS)

by nineseventytwo on Thu Oct 08, 2020 1:44 pm

I use the Apple branded camera connection cable.
[url]Apple Lightning to USB Camera Adapter https://www.amazon.com/dp/B014VGHG0U/re ... FFbFBBSCEX[/url]
I’ve tried others with limited success.

I can use any app and it works as expected. I don’t have access to latest Apple iPad but it works with iOS version 13.7.

Test the camera adapter with a usb keyboard to rule out a bad adapter.

nineseventytwo
 
Posts: 31
Joined: Tue Aug 02, 2016 4:20 pm

Please be positive and constructive with your questions and comments.