Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
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 NexxuSix on Thu Oct 08, 2020 3:03 pm

nineseventytwo,
I kinda figured that the interface might be the prohibiting factor. I am using the “old school” Camera Connection Kit connector. I see that there is a “USB only” interface for the iPad, and I think that is the solution. Perhaps there is a updated firmware in that interface that is will allow the Trinket M0 to properly connect to the iPad. I will get a new connector for the iPad, and try again. I will update this thread on my progress. Thank you again for the help.

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

Re: USB HID on iPad (iOS)

by NexxuSix on Thu Oct 08, 2020 10:41 pm

Update:
So, I did recompile the CircuitPython code tonight for the Trinket_M0. It compiles as 6.0.0-beta.2-21.g66c2567d-dirty. As a side note, upon discovering this, I also tried the stable version 5.3.1, and still had the same results on my iPad running iOS 14.0 (See below). I should mention that I also corrected the line before compiling, and put that as the last line in the Trinket M0 mpconfigboard.mk file:

Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER


Oh, and I even purchased a USB-A to Lightning Port adapter tonight, thinking that the different kind of port would make a difference, but it too did not.

So... what I did was figure out what the iPad would accept for input. Strangely, my Raspberry Pi Standard USB keyboard works just fine with the new Lightning Connector, and I was able to use the RPi keyboard as normal, even using the < and > arrows, to move through a string of text. However, if I try connecting the Trinket M0, I cannot get the cursor to move at all. If I take the Trinket M0 and connect it to a Win10 computer running Notepad, I can get the cursor to move left or right through a string of text as intended. So, at least I know the code is working in Windows 10 just fine.

My conclusion to all of this is, that it is not the USB cable, nor is it the Lightning adapters. Those work fine with a standard USB keyboard. It seems the problem is getting iOS 14 to recognize the Trinket M0 as a HID keyboard (this is what the Win10 Device Manager sees it as). Being that iOS does not have a Device Manager, its hard to troubleshoot exactly what iOS sees the Trinket M0 as.

At this point, I’m a bit lost as to what to try to do next, so if you have any suggestions, I will most certainly try to implement them. Thanks again for all of your suggestions an help so far. I hope to get this project working with all of the help.

Thank you,
-NexxuSix

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

Re: USB HID on iPad (iOS)

by nineseventytwo on Fri Oct 09, 2020 8:21 am

I also have been working making keyboards for a while now. Before CircuitPython, before iOS allowed externally connected keyboards I used Bluetooth and Arduino. It’s more expensive, but recently the prices are getting closer (wired/ble). The feather is an easy go to for this. It has battery management included.

Here’s a tutorial using CircuitPython for a ble keyboard:
https://learn.adafruit.com/ble-hid-keyboard-buttons-with-circuitpython/overview

If you’re in a rush ble might be the way to go until iOS 14 plays nice with trinkets.

Not the answer you wanted. But it’s an answer.

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

Re: USB HID on iPad (iOS)

by NexxuSix on Fri Oct 09, 2020 10:07 am

Thank you for a possible solution. That being said, why is it the Trinket M0 having problems connecting with iOS as an HID device?

I’m guessing at this point, and will say the problem is iOS itself, and whether or not it will accept the Trinket M0 as an HID device. I’m not an avid programmer, so again, guessing here, would it be possible to make the Trinket M0 a Class Compliant device, or perhaps somehow “spoof” iOS to make it think it has a genuine Microsoft keyboard?

What I think is a bit odd about iOS is, that it will accept a Raspberry Pi keyboard, or a Microsoft keyboard, or even an arcade interface made by Ultimarc (it emulates a keyboard, sending button presses as keyboard commands to MAME for example).

So... what gives with CircuitPython / Trinket M0 / <insert unknown factor here> when it comes to iOS and a physical interface? Can someone explain to me why “everything else” seems to work with my iPad, but the Trinket M0 is left unacknowledged by iOS?

Thank you,
-NexxuSix
Last edited by NexxuSix on Fri Oct 09, 2020 10:54 am, edited 1 time in total.

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

Re: USB HID on iPad (iOS)

by danhalbert on Fri Oct 09, 2020 10:34 am

I will test this later when I get some free time. It should work fine since you have removed the gamepad. The main issue has been that iOS will reject a composite HID device that has a gamepad. There is nothing special about the Trinket M0 in particular that would differ. It's possible that an iOS 14 change broke something.

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

Re: USB HID on iPad (iOS)

by nineseventytwo on Fri Oct 09, 2020 2:05 pm

I might also run into this issue when I go to update iOS. I decided to try to build CircuitPython 6.0 for the Trinket M0. I changed the line to only included the Keyboard option.

Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD

vs.
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER


Not sure if this would help. I have not way of testing it. Would you be able to?

firmware.uf2
(362.5 KiB) Downloaded 1 time

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

Re: USB HID on iPad (iOS)

by NexxuSix on Fri Oct 09, 2020 2:45 pm

BINGO!

This works! Thank you!

Ok, so I gotta ask: What did you do, that I haven't done, other than to modify the one line? If possible, could you post the Trinket M0 mpconfigboard.mk file? Also, I take it you compiled the Circuitpython from source, giving you the 6.0.0 beta version?

Thank you so much!
-NexxuSix

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

Re: USB HID on iPad (iOS)

by nineseventytwo on Fri Oct 09, 2020 2:55 pm

Awesome! I have one more request for you. Can you try this .uf2 file?

firmware.uf2
(363 KiB) Downloaded 1 time


This file include the mouse functionality. So, the line reads:
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE


If this works then, it will work for my needs also. Thanks.

The mpconfigboard.mk file reads as follows:
Code: Select all | TOGGLE FULL SIZE
USB_VID = 0x239A
USB_PID = 0x801F
USB_PRODUCT = "Trinket M0"
USB_MANUFACTURER = "Adafruit Industries LLC"

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
USB_HID_DEVICES=KEYBOARD,MOUSE


Again I just followed this tutorial:
https://learn.adafruit.com/building-circuitpython/build-circuitpython

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

Re: USB HID on iPad (iOS)

by NexxuSix on Fri Oct 09, 2020 4:05 pm

Yes, this version of the firmware works just as well. I tested it both in Windows 10 Notepad, and also using text string in iOS. I was able to move the cursor left or right. The mpconfigboard.mk file looks exactly like mine, so now I can confirm I was modifying the right file with the right contents. This helps =)

Awesome!

Thank you again for the help!
-NexxuSix

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

Re: USB HID on iPad (iOS)

by nineseventytwo on Fri Oct 09, 2020 5:03 pm

So now that it works, let's break it. This .uf2 has the line:
Code: Select all | TOGGLE FULL SIZE
USB_HID_DEVICES=KEYBOARD,MOUSE,CONSUMER


If this works with iOS, then the issue was with how you built it. It could be some step you missed, a Windows 10 issue, etc. I'm building on a Mac. I'm not an expert on the build process.

Thanks, for your help. I would have run into these issues when I go to update.
Attachments
firmware.uf2
(363 KiB) Downloaded 1 time

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

Re: USB HID on iPad (iOS)

by NexxuSix on Fri Oct 09, 2020 5:29 pm

Ok, this works as well. Hmmm....

When I built this, I built it on a Windows 10 platform running the Ubuntu app. After several attempts (I was missing gcc, etc...), I finally got a "good" compile. I turned on the V=1 option to watch the compilation just to make sure I wasn't missing anything, but didn't see any errors on the final compile. I just couldn't get it to work under iOS for some reason.

I think I will try again on the Windows 10 platform in the days coming and see if I can compile a working firmware file. I have the Trinket M0 hooked up to my iPad, and I'm fine tuning my app at the moment, but in all cases, now it works.

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

Re: USB HID on iPad (iOS)

by nineseventytwo on Fri Oct 09, 2020 6:04 pm

Awesome!

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

Please be positive and constructive with your questions and comments.