JPZV / BluN64-ESP32

A project to emulate a N64 controller as a modern one with ESP32.
Other
26 stars 9 forks source link

When using on BluN64 Mode on android, the buttons are not recognized #4

Open victorkte opened 1 year ago

victorkte commented 1 year ago

I cannot use it on emulators because some buttons are detected as different inputs from the xbox layout

Z is detected as L2 + R2 C buttons won't work (they are detected as an analog stick on some games) Dpad won't work (they are detected as an analog stick on some games) START is detected as Z

the only buttons that work perfectly are the analog stick, A and B

is there a way to change the inputs? I tried connecting to the esp32 using blueretro.io page but couldn't find it

JPZV commented 1 year ago

The Dpad thing is strange as it should be mapped as Dpad (if you open "Gamepad settings" on windows, you can see it through the POV indicator).

I think the rest of them may become from mistake that I made way back when I made this project. If I try to fix them, I may broke some other things, like the compatibility with BlueRetro.

Right now I'm working on another project based on this with way more functionalities and customization than this, but it's private right now until I finish some legal things with one of my partners.

For now, which emulator are you trying to use?

victorkte commented 1 year ago

I'm trying to use it mainly on super mario 64 android port and on retroarch

but you can see what I'm talking about if you try it with gamepad tester app on google play store https://play.google.com/store/apps/details?id=ru.elron.gamepadtester

victorkte commented 1 year ago

it would be really nice if its possible to add rumble feedback too, You could install those small smartphone rumble motors that has reduced battery drainage

JPZV commented 1 year ago

I'm trying to use it mainly on super mario 64 android port and on retroarch

Sadly I don't have my controls here, but I think you can set RetroArch to ignore some control inputs and even remap them to another button. I know it's not the perfect solution but we'll need to wait until I can release the new project (It's called BluControl by the way. It use the same logic as this, but it'll work on any controller, not just on N64).

try it with gamepad tester app

I used that app to make the project, but, as I said, I made some mistakes when I did the mapping, like using Z for both L and R, but I'm afraid about changing them and breaking the compatibility with BlueRetro.

add rumble feedback too

I cannot give you some spoilers about BluControl *wink wink*

victorkte commented 1 year ago

Will blucontrol work like the blun64 where you can change it to switch online mode on the go?

Also it would be really nice if we could buy a custom pcb to avoid sacrificing original controllers

JPZV commented 1 year ago

Will blucontrol work like the blun64 where you can change it to switch online mode on the go?

Yeah, with OTA updates support and with many more functions.

buy a custom pcb

Yeah! It'll would be nice! We're actually talking with one controller manufacture to do it ;)

victorkte commented 1 year ago

Hey is it too hard to edit the buttons? If you send me the tools and give me a little help maybe I can edit it

After testing a lot I found out that the only problem is with the Z button being mapped to L2 and R2

Also I made a video about it https://youtu.be/luE_MkXuZAc

JPZV commented 1 year ago

It's not that hard. You only have to edit main.cpp#L12-L20 where it says BUTTONS_.

The thing is that you'll need to change the Device's name to something else, otherwise BlueRetro may use another key map for the buttons.

Then, you have to compile it using Visual Studio Code and the Esp-idf extension. Please note that you have to compile both the switch mode and the BlueRetro mode separately, and then flash them using a flash tool like ESP Flash Tool or flash_tool.py included with the extension

Right now I'm traveling so I cannot help you for now. But if you need more help just let me know and I'll try to help you by memory.

By the way, IIRC Mundo Yakara uses another pinout different from this project. I'm not sure, but the pinout is defined on n64-pad.h#L9-L39 so you may want to take a look ;)

Also, thanks for the video!!! I'm so glad that you shared my project with more people ๐Ÿ˜Š

victorkte commented 1 year ago

Oh actually thinking about it again having to flash the chip again means dessoldering everything

So I think I'll just wait for blucontrol to be ready ๐Ÿ˜…

JPZV commented 1 year ago

I uploaded a new update (2023.04.1) which have the mapping fixed.

The new mapping should be working now in every device, including BlueRetro and Android, but I cannot test it on BlueRetro as I don't have my N64 on hand.

The BluControl project is still on its way. I hope I could release it soon

victorkte commented 1 year ago

Thanks a lot!!!

the pin layout is different than the one from mundo yakara right?

I will test it out I have a N64 with blueretro

JPZV commented 1 year ago

The original pin layout is different than the Mundo Yakara used on his video.

Check your Z Button. If it's connected to the GPIO22, then you're using the Original Pinout. Otherwise, if it's connected to the GPIO33, then you're using the Mundo Yakara's layout

victorkte commented 1 year ago

do you know if i can solder some wires and flash it directly on the controller board? I followed the steps here, but had no success, it stays forever on on preparing installation

https://www.mundoyakara.com/2022/08/miniaturizar-esp32-reducir-tamano-para.html

JPZV commented 1 year ago

The best way to flash an ESP32 is using an USB to TTL. You can use the break board like Yakara did, but remember that it shouldn't have an ESP32 already attached.

In both cases, you need to connect RX to TX, TX to RX (yes, it's a cross connection), GND to GND, and optionally 3.3V to 3V3 (or you can power the ESP from the battery).

Then, before turning it on, you have to short circuit the GPIO0 to GND. You can use a tweezers, a jumper cable, soldering a wire, or anything you want. In case you are using a break board, you have to press and hold the Boot button (also named as "Flash") while connecting your board to your computer, and releasing it only when you see "erasing" after pressing "Install" on the web installer.

After installing it, you have to remove the wire between GPIO0 and GND, and power it as normal

victorkte commented 1 year ago

what about EN?

and what? why is it a cross connection, then Yakara's diagram is wrong because he says that it should be TX to TX and RX to RX

JPZV commented 1 year ago

Sorry, my mistake. When you're using the USB-TTL, you've to do a cross wiring. If you're using a break board, then it's directly (TX to TX and RX to RX)

About the EN pin, I forget about that. It must be pulled up to 3.3 using a 10K resistor (a 10ฮผF capacitor is also recommended between EN and GND)

victorkte commented 1 year ago

Ok I gave up trying to flash the chip on the controller board and I decided to flash a brand new chip and start it from 0

But when I choose yakara's pinout it never connects to the nintendo switch

The original connects with no problem but I want to use yakara's pinout because I already have the wires soldered

victorkte commented 1 year ago

here's what i get from the logs

esp-web-tools-logs.txt

victorkte commented 1 year ago

Well i think i got it working now I guess something went wrong with the installation

JPZV commented 1 year ago

You may had the L + R + Start button shorted to ground, because the control tried to start into OTA mode, which doesn't exist in BluN64 (both BluN64 and BluControl share the same SDK)

victorkte commented 1 year ago

Well it worked on the break board but after i dessoldered it and installed it on the controller the switch won't detect it

victorkte commented 1 year ago

Do you have discord or telegram to help me figure this out?

JPZV commented 1 year ago

Do you have a multimeter? If so, check the continuity between ground and the GPIOs 15, 23 and 32.

Any way, I think I found some flaws on the SDK so I will try to fix it in a moment an I'll let you know for the new update

victorkte commented 1 year ago

I have but I will try again later

I've been up all night soldering this ๐Ÿ˜‚

victorkte commented 1 year ago

Ok there is definetly something wrong

I bought a brand new esp32 with another breaker board and turns out that by itself it wont connect but when you touch the pins of the breaker board something shorts and then it connects

victorkte commented 1 year ago

Tested the points with a multimeter

there's only continuity on 23 and 15

victorkte commented 1 year ago

another thing I was wondering... is it really necessary to remove all components of the board?, if you could install the chip on top of the original nintendo IC and wire the cables it wouldn't work?

it could be the ultimate solution, heck you could even make a plug for the wire and leave everything untouched, the only challenge would be to fit the battery and charging module (maybe use a wireless charging coil?)

JPZV commented 1 year ago

I think it's linked with the TOUCH GPIOs. For now I rolled a new update which should stop the boot loop, please let me know if that fixes the problem

victorkte commented 1 year ago

Something is weird

I flashed the old yakara's build and now it behaves like the 04.1 build where i need to touch the pins on the break board to make the connection

The log is also different from the logs on my video

https://youtu.be/luE_MkXuZAc check 4:10

Now see these logs esp-web-tools-logs (2).txt

I also noticed that the newer chips I bought are slightly different than the chips I used before

20230416_030449

Maybe thats the reason?

victorkte commented 1 year ago

I haven't actually tested the latest build out from the break board

I will redo the soldering all over again and report back

It might just take a while =p

victorkte commented 1 year ago

Ok I soldered everything correctly but there are still some issues

The button combinations for home wont work (R+Start)

The button combination to switch between blueretro mode and switch mode also won't work (L+R+Start)

The Led that indicates the mode is always blue (It used to be red on switch mode and blue on blueretro mode)

Another problem is that left and right on the main stick are reversed and up and down wont work at all (I havent checked if I did some mistake with the soldering but it's good to take a look on the software side)

victorkte commented 1 year ago

@JPZV any updates?

JPZV commented 1 year ago

Sorry, being little busy over here. I'll try to test the .bin on a ESP32, but sadly I don't have any N64 Controller near me, so if I couldn't reproduce the issues then we have to think in another way to test this

victorkte commented 1 year ago

well at least I think it's possible to test the button combination with the pins and some wires

eduardocintas commented 1 year ago

https://github.com/JPZV/BluN64-ESP32/issues/4#issuecomment-1510096900

I don ยดt think so, the left one miss some pins but no one is GPIO. At first look them seems compatible at least for this project. Can you provide SOM name of each(System on Module ex "ESP-WROOM-32") the datasheet of each SOM should tell safe pin for inputs and pins that needs special considerations.

eduardocintas commented 1 year ago

Also I made a video about it https://youtu.be/luE_MkXuZAc

There is a really important finding on the video, acceleration from joystick. He is describing an exponential acceleration(most posible parabolic) while a linear acceleration on BluN64. that is difficult to find without much experience on original control, and should be easy to fix on software. i think u need to fill a separate issue about that, to keep track.

eduardocintas commented 1 year ago

Oh actually thinking about it again having to flash the chip again means desoldering everything

I have it on a dev board connected to fightstick, i will try to fix Android and windows next weekend. but i don't have Switch nor BlueRetro. So idk if can do enough testing testing.

U dont need to desolder everything, u have tx and rx free, solder 2 wires there or use crocodiles and use an external USB to TTL they are easy to get and cheap. U can also power the module from the programmer(almost sure u MUST to connect GND), when connecting Tx and Rx it normally connected crossed, Tx of esp32 to Rx from programer and Rx to Tx. But sometimes the are labeled already crossed if crossing does not work try straight, the are data only can't fry anything. Just take care to no connect 5v to 3.3v that can fry your module.

eduardocintas commented 1 year ago

what about EN?

EN is HI by default that is for normal boot, when u press boot button or connect pin to gnd u pull it down, an make esp32 to boot flash mode.

and what? why is it a cross connection, then Yakara's diagram is wrong because he says that it should be TX to TX and RX to RX

On original board u connect straight cause the module should be there. On USB to TTL most times is crossed. U can test both safely.

eduardocintas commented 1 year ago

Ok there is definetly something wrong

I bought a brand new esp32 with another breaker board and turns out that by itself it wont connect but when you touch the pins of the breaker board something shorts and then it connects

Ohhh, that makes sense, i have similar problems with my new board. I'm pretty sure it have regulator problems. But sometimes things works. I don thought about what i touch but we can be doing the work of capacitors stabilizing 3.3v. xD

eduardocintas commented 1 year ago

I got al working OK on Android, in windows still need to unpair and pair on each connection. Thinking again on android it not auto pair need to manually pair on each connection just isn't needed to unpair first.

Tomorrow i will try to ensure my code does not break compatibility with blueretro and make a PR so JP can review and decide if it worth to merge.

victorkte commented 1 year ago

I've been away from it for a while, I'm waiting for a better battery pack with 500mAH to arrive, when it does I'm going to mess with it again

Also, I tried making a custom PCB to get rid of any soldering issues this is my first try so I'm not sure if measurements are correct, but if they are I'll make a follow up video SPOILER_kicad_3d_viewer