Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PACKAGE/BOARD] Add handle usb-hid gadget #55

Merged
merged 7 commits into from
Nov 28, 2023
Merged

Conversation

tiopex
Copy link
Member

@tiopex tiopex commented Nov 21, 2023

Turn your handheld into usb gamepad for PC

Usage:

  1. Connect handheld to PC via USB
  2. Run USB HID shortcut from Apps menu
  3. Now you should be able to control PC via handheld buttons
  4. Press RESET button to leave USB HID mode

mappings:
dpad mapped to arrows
b mapped to l_ctrl
a mapped to space
y mapped to l_shift
x mapped to x
select mapped to backspace
start mapped to enter
lpad1 mapped to l_alt
rpad1 mapped to tab
lpad2 mapped to pg_up
rpad2 mapped to pg_down
reset not mapped, used to quit

PS Works also with phone

@tiopex tiopex changed the title Add handle usb-hid gadget [PACKAGE/BOARD] Add handle usb-hid gadget Nov 22, 2023
@tiopex tiopex requested a review from Apaczer November 22, 2023 06:30
@tiopex tiopex force-pushed the pcgamepad branch 3 times, most recently from e6914fb to eb0fa2f Compare November 22, 2023 13:55
Copy link
Member

@Apaczer Apaczer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're making these devices worth your money ;p. I did a quick test on a Win machine and np!

The python world is unknown to me but I see it has potential! AFAIK smb wrote a neat frontend in py back in the days.

@tiopex tiopex force-pushed the pcgamepad branch 2 times, most recently from 0cf2e49 to 719a756 Compare November 23, 2023 12:03
@Apaczer
Copy link
Member

Apaczer commented Nov 23, 2023

last question: why not use tarball from boppreh/keyboard?

@tiopex tiopex force-pushed the pcgamepad branch 2 times, most recently from e31adfe to 96ccb05 Compare November 23, 2023 14:33
@tiopex
Copy link
Member Author

tiopex commented Nov 23, 2023

last question: why not use tarball from boppreh/keyboard?

done

@Apaczer
Copy link
Member

Apaczer commented Nov 23, 2023

How did you find hid codes for DV special keys, while everything else follows Usage ID numbering? My suggestion is to add hid.man.txt file with above "Usage:.." description and list with "HID codes for standard and special keys".

Marking as resolved, well played.

@Apaczer
Copy link
Member

Apaczer commented Nov 23, 2023

I have small issue on my Win machine, when before it registered device as CDC after connection but after HID gadget activation it now only register it by HID device and I can't connect handheld to old serial port.

@tiopex
Copy link
Member Author

tiopex commented Nov 24, 2023

I have small issue on my Win machine, when before it registered device as CDC after connection but after HID gadget activation it now only register it by HID device and I can't connect handheld to old serial port.

When the device is in HID mode serial connection won't work.

I checked, and after exiting from HID mode and switching back to CDC mode serial connection works correctly on my Win machine

@tiopex
Copy link
Member Author

tiopex commented Nov 24, 2023

How did you find hid codes for DV special keys, while everything else follows Usage ID numbering? My suggestion is to add hid.man.txt file with above "Usage:.." description and list with "HID codes for standard and special keys".

Marking as resolved, well played.

https://www.usb.org/sites/default/files/hid1_11.pdf

page 56 chapter 8.3 Report Format for Array Items

Maybe add another function translate_special_keys which will translate E0-E7 values from the usage table to bitmask values.
It will be more user-friendly

@Apaczer
Copy link
Member

Apaczer commented Nov 24, 2023

It will be more user-friendly

Great much easier to understand now.

Serial connection works correctly on my Win machine

It did not on my, even after rebooting or changing to stock SD. It always register as HID device after using gadget, I had to unregister driver from Windows and then it showed CDC again. This was on old 8.1 machine, I'll try latest Win tonight.

@tiopex
Copy link
Member Author

tiopex commented Nov 24, 2023

It did not on my, even after rebooting or changing to stock SD. It always register as HID device after using gadget, I had to unregister driver from Windows and then it showed CDC again. This was on old 8.1 machine, I'll try latest Win tonight.

this could be related that we always use the same product/vendor ID, and old Win cannot handle it

@Apaczer
Copy link
Member

Apaczer commented Nov 24, 2023

this could be related that we always use the same product/vendor ID, and old Win cannot handle it

Yes it works correct on Win 11, so I guess it's the best to leave it as it was (e507b56 - this somewhat works but I've to restart handheld to enable ms-gadget again).

@tiopex tiopex force-pushed the pcgamepad branch 3 times, most recently from a8970e2 to 8830c02 Compare November 27, 2023 11:09
rm _usb-hid.sh & use one script file to exec
@Apaczer
Copy link
Member

Apaczer commented Nov 28, 2023

When u connect USB OTG changing mode to peripheral it seems it doesn't revert to b_idle after disconnecting devices, so the USB-HID start even when devices are not connected. On the second usb-hid.sh run every seems to go back to normal.

@tiopex
Copy link
Member Author

tiopex commented Nov 28, 2023

When u connect USB OTG changing mode to peripheral it seems it doesn't revert to b_idle after disconnecting devices, so the USB-HID start even when devices are not connected. On the second usb-hid.sh run every seems to go back to normal.

in fact, it should not require device connected, but when it is in b_idle state, it hangs, so this check is a workaround to avoid such issue

@Apaczer Apaczer merged commit 10d3f8c into MiyooCFW:master Nov 28, 2023
@NoNamedCat
Copy link

MiyooCFW rubberDucky on the way?

@tiopex tiopex deleted the pcgamepad branch October 22, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants