wagiminator / MCU-Templates

Templates for bare-metal firmware development for some entry-level microcontrollers
Other
58 stars 8 forks source link

Request: HID Touchscreen for CH552 #3

Closed nelsonjchen closed 3 months ago

nelsonjchen commented 8 months ago

I've been using and hacking on https://github.com/biemster/3keys_1knob, a derivative of some of your work on Macropads for some cheap AliExpress keyboards.

I see that there's an HID mouse example. That is very neat but it only allows relative movements. I'm interested in sending touchscreen commands. There can be certain UIs that aren't friendly to mouses but are to touchscreens.

I have not been able to hack biemster's 3keys_1knob to the point where the Linux multitouch module is happy. I have been hacking the files in there, but I can't say I know exactly what I'm doing. I got it to the point that Linux knows to load multitouch to it but it's still pretty unhappy and multitouch in dmesg says it "can't get feature 0" or whatever that means. Not sure how I'm messing up the report descriptor.

I see you've been making changes to the templates for CH552. I'm probably going to start from scratch with the updated bases and try again to see if I can make HID Touchscreen "work" at rest without the kernel complaining.

Anyway, a HID touchscreen example that's compatible with Linux multitouch and possibly Windows 8+ for more users would be very much appreciated!

nelsonjchen commented 8 months ago

Arduino prior art:

https://github.com/NicoHood/HID/pull/297/files

wagiminator commented 8 months ago

That sounds like an interesting project. Unfortunately, I've never worked with touchscreens before, so I can't help you straight away. The updated templates do not fix any errors or add any new features. They are just slightly optimized and save about 100 bytes of code.

nelsonjchen commented 8 months ago

Thanks for your response. I'll continue to keep hacking. If I got something going, I'll be sure to share.

wagiminator commented 8 months ago

I'm keeping my fingers crossed for you and I'm looking forward to the result!

nelsonjchen commented 8 months ago

I bought a touchscreen off Amazon to compare/steal/capture how it interacts as a touchscreen.

It has a CH554T that talks/makes a touchscreen. Can't find the source though. Hmm.

nelsonjchen commented 8 months ago

Possible source. https://github.com/Remychou/usb-touchsreen. Messy, is the license real, but possibly a good reference and it's likely transformative as we're trying to get it to be a cleaner/SDCC implementation here.

wagiminator commented 8 months ago

That looks promising.

nelsonjchen commented 8 months ago

Bah the GitHub reply displayed twice in GitHub mobile and I accidentally deleted it.

Anyway, quick summary is the hacking I've been doing seems to cause interrupt troubles. Will rebase to the template to try to sort it out.

Also, not sure if my compilation environment is making something that causes this as well.

nelsonjchen commented 6 months ago

Haven't had much success. Life has been busy but what time I've had with it hasn't been too great. I've decided to go and rebase atop the newest templates and do a hello world with a mouse jiggler on my setup to make sure I can even send reports if necessary.

I can get the LED on my development board to blink, that's great. However, any calls to mouse_move afterwards seem to cause the board to lock up or something. Extremely, extremely frustrating. I'm not sure if it's an issue with SDCC either.

nelsonjchen commented 5 months ago

It took me forever, especially with life stuff, but i have a small hardcoded hello world going now. 😁

https://github.com/nelsonjchen/ch552-touch-play

It touches on a loop.

I need to get my use case going first and foremost and then look to see how to extract it out to a nice PR to this repo someday.

nelsonjchen commented 5 months ago

https://github.com/wagiminator/MCU-Templates/assets/5363/e9416470-748a-424c-a64b-48dd8ea15d02

Hardcoded use case so far so good 😄

wagiminator commented 5 months ago

Great!!!

nelsonjchen commented 5 months ago

Works for my use case with the comma three. But not my girlfriend's Windows laptop after going to 2 fingers and above for some reason.

Will continue to polish and hopefully PR a working Windows compatible template implementation.

https://youtube.com/shorts/-VjC_3XHyv0?si=vSlsnMmhSsbk-Hsw

nelsonjchen commented 4 months ago

"Productized" repo out.

https://github.com/nelsonjchen/c3-touchkey-keyboard

wagiminator commented 4 months ago

Fantastic, this really turned out to be a cool project. Congratulations!!!

nelsonjchen commented 4 months ago

Thanks! You and @biemster were the real MVPs!

nelsonjchen commented 4 months ago

https://github.com/nelsonjchen/c3-faux-touch-keyboard/releases/tag/0.0.4 released with a refactor candidate/test for future upstreaming. Am traveling next week for the following two weeks.

Will probably go for MVP with the API for now for upstreaming when back