Skip to content

Commit

Permalink
adding all
Browse files Browse the repository at this point in the history
  • Loading branch information
Loc15 committed Feb 13, 2024
1 parent 09988e0 commit 1b07cd0
Show file tree
Hide file tree
Showing 3,886 changed files with 2,473,635 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "Pico-PIO-USB"]
path = Pico-PIO-USB
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
[submodule "tinyusb"]
path = tinyusb
url = https://github.com/hathach/tinyusb.git
1 change: 1 addition & 0 deletions Pico-PIO-USB
Submodule Pico-PIO-USB added at 0f747a
160 changes: 159 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,159 @@
# PicoGamepadConverter
# PICO-GAMEPAD-CONVERTER

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/O4O8TQSC8)

PicoGamepadCoverter is a project designed for RP2040 or Raspberry Pi Pico and variants, that enabling switch to different gamepad modes using a gamepad as input. Re-use old gamepads that dont't support USB conecctions or make compatibles with certain platafform.

---
## Features

- Read input from USB and Bluetooth controllers.
- Read inputs from no USB peripherals.
- Web interface to choose between modes.
- Different out modes (Dinput, Xinput, Switch, Bluetooth)
- Easy to use, no overcomplicated options.

---
## Getting Started

To get started with PicoGamepadConverter, follow the steps below:

### Prerequisites

- Raspberry Pi Pico microcontroller or onother RP2040 boards.
- OTG cable (micro-USB or USB-C it depents on your board)
- USB female connector (Recommended be the same type of OTG cable)
- USB cable (micro-USB or USB-C it depents on your board)
- Two push buttons (_Optional but RECOMMENDED!_)
- Breadboard (_Optional_)

### Installation

1. Download the build program and copy on the microcontroller.

```
git clone https://github.com/Loc15/PicoGamepadConverter.git
```

2. Make the conections.

![schematic](./docs/pico_pinout.png)
![conections1](./docs/bread_board1.jpg)
![conections2](./docs/bread_board2.jpg)

3. Go to configuration mode pressing the button on 18 GPIO on start. On web mode the led start to blink.

4. Choose the modes on the web server. Access http://192.168.3.1 in a web browser to begin configuration.

![web_mode](./docs/web_configurator.png)

5. Connect your gamepad, when it connected successfully the led on the board gonna turn on.

6. Enjoy!


### Additional information

- The led on board indicates that a gamepad has been mounted successfully, it works on all host modes except **Keyboard PS/2**

- The additional USB female connector PINS are **16** and **17 GPIO**.

- The conection for Keyboard PS/2 are on **19 GPIO** for **DATA PIN** and **20 GPIO** for **CLOCK PIN**.

![keyboard_schematic](./docs/keyboard_pinout.png)
![keyboard_connector](./docs/keyboard_connector.jpg)
![keyboard_pc](./docs/keyboard_pc.jpg)

- The conection for PS1 controllers are on **19 GPIO** for **COMMAND PIN**, **20 GPIO** for **CLOCK PIN**, **21 GPIO** for **ATTENTION PIN** and **22 GPIO** for **DATA PIN**

![ps1_schematic](./docs/ps1_pinout.png)
![ps1_connector](./docs/ps1_connector.jpg)
![ps1_pc](./docs/ps1_pc.jpg)

- Bluetooth modes only works on Pico W.

- On Bluetooth device mode, the host connection is on **native usb female connector on the microcontroller**.

- On Bluetooth host mode you must put the mac adress of your gamepad. You can get this adress connecting you gamepad to a PC or a mobile phone. This adress _should_ be put just once time, next time you just need choose the mode.

---
## Modes
Exist two parameter to choose on web interface, **host** and **device**. The first is the input and another one the output.

### HOST
#### USB MODES
- Xinput: Support Xbox controllers or Xinput compatibles controllers.
- Dinput: Support generic gamepads, PS4, PS3 and 8BITDO controllers.

#### Wireless MODES
- Bluetooth: Support generic gamepads, PS4 and 8BITDO controllers.

#### SPECIAL MODES
- Keyboard/PS2: Support keyboards with PS/2 connector.
- PS1/PS2: Support PS1 controllers (For now PS2 controller doesn't work well)

### DEVICE
#### USB MODES
- Xinput: Simulation of Xinput gamepad controllers (doesn't work on consoles, only on PC).
- Dinput: Simulation of a generic HID gamepad.
- Switch: Simulation of Switch Pro controller.

#### Wireless MODES
- Bluetooth: Simulation of a generic HID gamepad.

---
## Features

You can to set some additional configuration if you required:

![features](./docs/features.png)

- Block analogs.
- Swap Dpap and Left analog.
- Add deadzone to analogs.

---

## Testing
Controllers that was tested on diferent host modes.

| Tested Controllers | Modes (Host) |
| ------------------ | -------------- |
| Logitech F710 | Xinput, Dinput |
| 8BitDo Ultimate 2.4G | Xinput, Dinput, Bluetooth|
| 8BitDo Ultimate C 2.4G | **Doesn't work** |
| DualShock (PS1) | PS1/PS2 |
| DualShock 2 (PS2) | _Works weird_ |
| DualShock 3 (PS3) | Dinput |
| DualShock 4 (PS4) | Dinput, Bluetooth|
| Keyboard HP KB-0316 | Keyboard PS/2 |

---

### Troubleshooting

- 8bitdo controllers sometimes have problems to connect on USB or Bluetooth mode. On USB if it doesn't connect reboot the microcontroller without disconnect.

- On Bluetooth if doesn't connect on first, reboot and put your gamepad on pair mode.

---
## Acknowledgments

- [TinyUSB](https://github.com/hathach/tinyusb) USB stack.
- [Pico-PIO-USB](https://github.com/sekigon-gonnoc/Pico-PIO-USB/issues) USB host/device implementation using PIO.
- [GP2040-CE](https://github.com/OpenStickCommunity/GP2040-CE) for switch descriptor and inspiration in general. It's a great project.
- [Ryzee119](https://github.com/Ryzee119/tusb_xinput) for TinyUSB xinput host driver.
- [fluffymadness](https://github.com/fluffymadness/tinyusb-xinput) for xinput device example.
- [SelvinPL](https://github.com/selvinpl) for HID gamepad parser example.
- [lurk101](https://github.com/lurk101/pico-ps2kbd) for Keyboard PS/2 example.
- [dotcypress](https://github.com/dotcypress/ula) for the Logic Analyzer compatible with PulseView. Was very useful for PS1 controller part.
- [usedbytes](https://github.com/usedbytes/picow_ds4) for ps4 bluetooth example.


## License

This project is licensed under the [GNU Public License Version 3](LICENSE).

## Support

If you encounter any issues or have any questions regarding the PicoGamepadConverter project, please [open an issue](https://github.com/Loc15/PicoGamepadConverter/issues) on the GitHub repository.
Binary file added docs/bread_board1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/bread_board2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/features.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/keyboard_connector.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/keyboard_pc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/keyboard_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pico_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ps1_connector.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ps1_pc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ps1_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/usb_female.webp
Binary file not shown.
Binary file added docs/web_configurator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

set(PICO_BOARD pico_w)

set(target_name PicoGamepadConverter)

set(PICO_PIO_USB_DIR "${CMAKE_CURRENT_LIST_DIR}/../Pico-PIO-USB/")
set(PICO_BTSTACK_PATH "${CMAKE_CURRENT_LIST_DIR}/btstack")

#Until pico-sdk is updated
set(PICO_TINYUSB_PATH "${CMAKE_CURRENT_LIST_DIR}/../tinyusb")

# the second argument to add_subdirectory is needed here because this isn't
# a subdirectory, it's out of tree.

project(${target_name} C CXX ASM)

pico_sdk_init()

add_executable(${target_name})

target_sources(${target_name} PRIVATE
main.c
convert_data.c
utils.c
device_files/usb_descriptors.c
device_files/xinput/xinput_driver.c
device_files/switch/hid_driver.c
host_files/xinput_host.c
# can use 'tinyusb_pico_pio_usb' library later when pico-sdk is updated
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
#${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
#Use modify version to enable native and pio
hcd_pio_usb.c
)

add_subdirectory(${PICO_PIO_USB_DIR} pico_pio_usb)

add_subdirectory(host_files/ps2kbd-lib)
add_subdirectory(host_files/psx-lib)
add_subdirectory(host_files/parser-lib)
add_subdirectory(host_files/bluehost-lib)
add_subdirectory(device_files/rndis-lib)
add_subdirectory(device_files/bluehid-lib)
add_subdirectory(flash-lib)

pico_enable_stdio_uart(${target_name} 1)

# print memory usage, enable all warnings
target_link_options(${target_name} PRIVATE -Xlinker --print-memory-usage)
target_compile_options(${target_name} PRIVATE -Wall -Wextra)

# use tinyusb implementation
target_compile_definitions(${target_name} PRIVATE PIO_USB_USE_TINYUSB)

# what build use
add_compile_definitions(PICO_W=0)

# needed so tinyusb can find tusb_config.h
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_LIST_DIR} device_files/switch device_files/xinput host_files)

target_link_libraries(${target_name} PRIVATE pico_stdlib pico_pio_usb pico_cyw43_arch_none tinyusb_device tinyusb_host ps2kbd-lib psx-lib rndis-lib parser-lib
bluehost-lib flash-lib bluehid-lib)


pico_add_extra_outputs(${target_name})

39 changes: 39 additions & 0 deletions src/btstack/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**

Steps to reproduce the behavior:
1. Run example '...'
2. Connect to/from remove device '...'
3. Start action '...'

**Expected behavior**

A clear and concise description of what you expected to happen.

**HCI Packet Logs**
For all Bluetooth issues, please provide a full packet log that includes initial pairing. You need to zip the packet log as GitHub does not know how to handle .pklg files.

How to get packet log depends on the port:
- For desktop ports, full packet logging is enabled by default and the packet log is available as `/tmp/hci_dump.pklg` (Mac/Linux), or `hci_dump.pklg' (Windows).
- For embedded ports, you can enable #define ENABLE_LOG_INFO in btstack_config.h and uncomment the call to 'hci_dump_init(..)' in the main() function to enable logging over UART Console or Segger RTT. Please capture text output and process using `btstack/tool/create_packet_log.py`. The tool will generate the text file into a .pklg file which can be analysed with Wireshark or Apple's PacketLogger tool.
- For ESP32: BTstack's `port/esp32/integrate.py` script creates one project per example. To enable packet logging, you need to edit app_main in main/main.c of the example project.

**Environment: (please complete the following information):**
- Current BTstack branch: [e.g. develop]
- Bluetooth Controller [e.g. CSR 8510, TI CC2564C, ...]
- Remote device: [e.g. iPhone X with iOS 13.3]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions src/btstack/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
28 changes: 28 additions & 0 deletions src/btstack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*~
*.o
*.d
*.dSYM
*.aux
*.toc
*.out
*.pklg
*.fdb_latexmk
*.hex
*.a
*.dylib
*.bts
*.elf
*.map
.theos
.stamp
.bts
bluetooth_init_cc2560B_1.*_BT_Spec_4.1.c
bluetooth_init_cc2564B_1.*_BT_Spec_4.1.c
TIInit_11.8.32.c
initscripts_TIInit_6.7.16_bt_spec_4.1.c
*.jdebug
*.jdebug.user
cmake-build-*
build
build-asan
build-coverage
17 changes: 17 additions & 0 deletions src/btstack/3rd-party/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# List of Third-Party Libaries

This folder contains all third-party libraries used by BTstack. The following table lists their source, license type, and what it is used for.

Library | Version | License | Used | Notes
----------------------------------------------------------------------------------------------------------------|----------|---------------|------------------|----------
[Android SBC Codec](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/embdrv/sbc) | e8c3d75b | Apache 2.0 | HFP WBS, A2DP | optimized audio codec
[hxcmod-player](https://github.com/jfdelnero/HxCModPlayer) | 03d495c8 | Public Domain | A2DP Source Demo | mod music player
[Google LC3 Codec](https://github.com/google/liblc3.git) | 311ca4c0 | Apache 2.0 | LE Audio | audio codec
[lwIP](http://savannah.nongnu.org/projects/lwip/) | b3a93941 | BSD 3-Clause | PAN Demo | complete network stack
[md5](http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5) | 1.0 | Public Domain | PBAP | cryptographic hash function
[micro-ecc](https://github.com/kmackay/micro-ecc) | e4d264b5 | BSD 2-Clause | LE SC, Mesh | elliptic-curve library
[Rijndael Encryption Algorithm](http://www.efgh.com/software/rijndael.htm) | 20020903 | Public Domain | BTstack Crypto | optional AES128 software implementation
[segger-rtt](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) | V786a | BSD 3-Clause | HCI PacketLog | high-speed logging with SEGGER J-Link debug probes (development)
[tinydir](https://github.com/cxong/tinydir) | 677733da | BSD 2-Clause | GAP Bonding | get a directory listing on POSIX + Windwows systems
[Yxml](https://dev.yorhel.nl/yxml) | 10f968b0 | MIT | PBAP | minimal stream XML parser

17 changes: 17 additions & 0 deletions src/btstack/3rd-party/bluedroid/decoder/Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# sbc decoder
SBC_DECODER += \
alloc.c \
bitalloc.c \
bitalloc-sbc.c \
bitstream-decode.c \
decoder-oina.c \
decoder-private.c \
decoder-sbc.c \
dequant.c \
framing.c \
framing-sbc.c \
oi_codec_version.c \
synthesis-sbc.c \
synthesis-dct8.c \
synthesis-8-generated.c \

Loading

0 comments on commit 1b07cd0

Please sign in to comment.