randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
479 stars 56 forks source link

Configure 18 USB gamepad buttons #158

Open WebbedQuasar opened 3 years ago

WebbedQuasar commented 3 years ago

I got a XBOX360 controller and the directional pad buttons are on 15 (up), 16 (right), 17 (down) and 18 (left). BMC64 supports 15 configurable buttons. It would be great to expand that to 18 buttons so I can use the D-Pad too.

rhester72 commented 3 years ago

Please see this message in the BMC64 thread on lemon64:

https://www.lemon64.com/forum/viewtopic.php?p=937614#937614

rhester72 commented 3 years ago

There are two required fixes here.

The first changes the maximum number of supported input buttons in BMC64 from 16 to 20. 19 is actually the "correct" number (because although the Xbox 360 controller in particular omits buttons 1 and 2, the highest button number is what matters), but 20 is a safe high-water limit as anything more than needed will be ignored. That patch is called "MAX_USB_BUTTONS.diff".

The second is actually an upstream bug in Circle. The dedicated Xbox 360 driver has a hardcoded button count of 16, whereas the actual controller has 17 addressable buttons (including the Xbox button itself, button 0). This results in Circle reporting events for the highest-numbered button (18, dpad left), but being unable to assign them in BMC64 (because it thinks there's one less than actual). That patch is called "circle_patch_xbox360.diff" and in fact patches the already-existing Circle patch (to prevent conflicts with the git reset used by the clean_all.sh script). It has also already been reported upstream.

Both patches can be found in this ZIP file:

bmc64_xbox360_patch.zip

Precompiled kernels containing both this fix and the 8580 SID filter updates are in this ZIP file:

[removed, see entry further down]

Randy, if you're fine with the approach and the patch, feel free to integrate it as an old-school pull request and close out this issue.

CemTezcan commented 3 years ago

@rhester72 thanks for these updates. FYI, I couldn't be able to boot my pizero with these precompiled kernels. I just overwrote the files, not sure if I'm missing something. Just black screen.

rhester72 commented 3 years ago

@CemTezcan Thanks for the report. I don't have a Pi Zero to test with, unfortunately - those builds are coming from the same build system used to produce the official binaries, so I can't explain why this kernel set wouldn't work (I know they are compiling for the Zero because it is the only one using teensyresid).

Does the attached C64 kernel for the Pi Zero work?

kernel_C64_Zero_HEAD.zip

It was compiled directly from the existing github tree with no modifications at all, using the same OS, compiler, and environment the author (Randy Rossi) uses, and I've confirmed that the compile-time options and flags are correct for the Zero (and the resulting binaries are indeed ARMv6 with hardfloat as expected).

If this one also black-screens, does replacing only kernel.img from https://accentual.com/bmc64/downloads/bmc64-3.6.files.zip on the SD card restore normal operation? If so, I'm not sure how to troubleshoot further...perhaps Randy will be able to weigh in.

CemTezcan commented 3 years ago

@rhester72 just tested the new one. and yes, it also gives black screen. As you said, I took just the kernal.img from Randy's pack, and it worked OK.

randyrossi commented 3 years ago

Let me roll some changes into master branch and put up a 'master' build on the web site. It won't be a stable release but you'll get some fixes like this. I've been meaning to start a new release branch but never seem to find the time so give me a day or two and I will set this up....

On Wed, Jan 27, 2021 at 3:08 PM rhester72 notifications@github.com wrote:

There are two required fixes here.

The first changes the maximum number of supported input buttons in BMC64 from 16 to 20. 19 is actually the "correct" number (because although the Xbox 360 controller in particular omits buttons 1 and 2, the highest button number is what matters), but 20 is a safe high-water limit as anything more than needed will be ignored. That patch is called "MAX_USB_BUTTONS.diff".

The second is actually an upstream bug in Circle. The dedicated Xbox 360 driver has a hardcoded button count of 16, whereas the actual controller has 17 addressable buttons (including the Xbox button itself, button 0). This results in Circle reporting events for the highest-numbered button (18, dpad left), but being unable to assign them in BMC64 (because it thinks there's one less than actual). That patch is called "circle_patch_xbox360.diff" and in fact patches the already-existing Circle patch (to prevent conflicts with the git reset used by the clean_all.sh script). It has also already been reported upstream https://github.com/rsta2/circle/issues/201.

Both patches can be found in this ZIP file:

bmc64_xbox360_patch.zip https://github.com/randyrossi/bmc64/files/5882546/bmc64_xbox360_patch.zip

Precompiled kernels containing both this fix and the 8580 SID filter updates are in this ZIP file:

bmc64_xbox360_bin.zip https://github.com/randyrossi/bmc64/files/5882752/bmc64_xbox360_bin.zip

Randy, if you're fine with the approach and the patch, feel free to integrate it as an old-school pull request and close out this issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/158#issuecomment-768545520, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKBSA2UDYWS7VJUPLTLS4BXFTANCNFSM4WUHMKCQ .

-- Randy Rossi

randyrossi commented 3 years ago

FYI: I merged in the xbox button num change and ran a build. I added a section for master builds off the main bmc64 web site ( http://accentual.com/bmc64) so you can download it from there and try it out.

On Wed, Jan 27, 2021 at 4:34 PM Randy Rossi randy.rossi@gmail.com wrote:

Let me roll some changes into master branch and put up a 'master' build on the web site. It won't be a stable release but you'll get some fixes like this. I've been meaning to start a new release branch but never seem to find the time so give me a day or two and I will set this up....

On Wed, Jan 27, 2021 at 3:08 PM rhester72 notifications@github.com wrote:

There are two required fixes here.

The first changes the maximum number of supported input buttons in BMC64 from 16 to 20. 19 is actually the "correct" number (because although the Xbox 360 controller in particular omits buttons 1 and 2, the highest button number is what matters), but 20 is a safe high-water limit as anything more than needed will be ignored. That patch is called "MAX_USB_BUTTONS.diff".

The second is actually an upstream bug in Circle. The dedicated Xbox 360 driver has a hardcoded button count of 16, whereas the actual controller has 17 addressable buttons (including the Xbox button itself, button 0). This results in Circle reporting events for the highest-numbered button (18, dpad left), but being unable to assign them in BMC64 (because it thinks there's one less than actual). That patch is called "circle_patch_xbox360.diff" and in fact patches the already-existing Circle patch (to prevent conflicts with the git reset used by the clean_all.sh script). It has also already been reported upstream https://github.com/rsta2/circle/issues/201.

Both patches can be found in this ZIP file:

bmc64_xbox360_patch.zip https://github.com/randyrossi/bmc64/files/5882546/bmc64_xbox360_patch.zip

Precompiled kernels containing both this fix and the 8580 SID filter updates are in this ZIP file:

bmc64_xbox360_bin.zip https://github.com/randyrossi/bmc64/files/5882752/bmc64_xbox360_bin.zip

Randy, if you're fine with the approach and the patch, feel free to integrate it as an old-school pull request and close out this issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/158#issuecomment-768545520, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKBSA2UDYWS7VJUPLTLS4BXFTANCNFSM4WUHMKCQ .

-- Randy Rossi

  • "There are only two things that are hard about computer science; Naming things, Cache Invalidation, and Off-by-one errors."

-- Randy Rossi

rhester72 commented 3 years ago

@randyrossi - thank you! Any chance you can offer some insight as to why following BUILDING.md (and using gcc-arm-none-eabi-9-2019-q4-major, if that's a factor), bootable images can no longer be produced for the Pi Zero? (For that matter, understanding why the build process fails to build teensy-resid for the pi0 and it has to be built manually after clear_all.sh but before make_all.sh would be useful...I've looked MANY times and can't figure that one out).

randyrossi commented 3 years ago

The kernel that black screens has the 8580 fix in? I will patch those in and do a build myself here to see if I get the same problem.

rhester72 commented 3 years ago

@randyrossi ANY Pi Zero kernel built with gcc-arm-none-eabi-9-2019-q4-major black screens, even previous github HEAD. It's not specific to any of my changes. Have you changed something about the build environment since the last update to BUILDING.md?

@CemTezcan do ALL the kernels I've compiled fail on the Zero - i.e. does PET work, for example? How about VIC20? I'm wondering if the issue is specific to teensy-resid, because there's always an issue building out of the box that causes it to initially fail (but the second attempt works, and compiles with proper flags, so I'm shooting in the dark a bit here).

CemTezcan commented 3 years ago

@rhester72 I couldn't tested others but it also boots to blank screen with C128 emulation.

rhester72 commented 3 years ago

Acquired a Pi Zero and confirmed this is an issue with the version of the SDK used (see here).

This attached ZIP should work on all systems and includes paddle support as recently added, the 8580 filter fixes, and the Xbox 360 gamepad button fix.

bmc64_kernels_20210201+8580fix.zip

CemTezcan commented 3 years ago

@rhester72 Thanks so much for this update. Since @randyrossi is busy these days and it looks like a similar concept like this issue, is there any chance if you can make a master build solution according to the issue #126 ?

rhester72 commented 3 years ago

@randyrossi The Circle team expanded this concept to all defined USB gamepads, not just Xbox 360 (as my initial patch did). I've produced another diff-to-the-diff that removes the first limited-scope patch and adds the complete patch set from upstream as seen here:

circle_patch_gamepad_buttons.zip

Please apply it to bmc64 upstream. (I promise, I'll learn git someday, honest LOL)

All: Updated binaries (still with the 8580 filter fix which isn't in upstream yet on purpose due to lack of testing/feedback, CAN SOMEONE PLEASE PROVIDE ACTUAL FEEDBACK BASED ON REAL TEST CASES?) here:

bmc64_20210202_circle_gamepad_fix_bin.zip

WebbedQuasar commented 3 years ago

https://github.com/randyrossi/bmc64/issues/141

CAN SOMEONE PLEASE PROVIDE ACTUAL FEEDBACK BASED ON REAL TEST CASES?) here:

I am not a programmer, but as a user I can give the following feedback regarding my YT videos. Maybe it will be helpful:

All: fast resampling.

8580 without filter fix: There were sometimes regular and short sound dropouts (very quiet crackling) after loading snapshots between the jumps in this video. Open the video description and klick the 19 cars jump: https://youtu.be/vrI8xUT_od4

8580 without filter fix: Here is a video without snapshots with a very sophisticated sound track: https://youtu.be/N7SgsVVitgo Sounds fine.

8580 without filter fix: With snapshots between the levels: https://youtu.be/Bzq1DbSxTYI Sounds fine too.

8580 with filter fix: My only video where the fix was already integrated. Sounds great. Note, however, that many snapshots were used here, mostly by pausing the game (to avoid the typical short click after loading the snapshot), saving the game and after loading, ending the pause and continuing to play. Especially a little later in the video, a minimal beat out of the rhythm and sound dropouts can be noticed if you listen carefully, as it was not always possible for me to cut the sound and the image perfectly back into the video. So this is not a bug of BMC64: https://youtu.be/pT2auVpm4xw

rhester72 commented 3 years ago

@WebbedQuasar Thank you for this! One question...is the recording (particularly with the filter fix) done at 50Hz or 60Hz (more specifically, is BMC64 in PAL or NTSC at the time)? I've read (but cannot confirm) the 'bad' filter was much more obvious in PAL.

WebbedQuasar commented 3 years ago

@rhester72 BMC64 is in PAL / 50Hz at the time, like all of my videos.

randyrossi commented 3 years ago

Rolled into 3.7. Closing.