Giter Club home page Giter Club logo

Comments (6)

LettucePie avatar LettucePie commented on June 18, 2024 2

Making some progress, I successfully distinguished against a freshly pressed down button vs on being used or held. It didn't fix the issue though which I thought confusing. It was like the inputs weren't being dropped between changing states, and that was exactly it. tic_api_reset in core.c seems to handle dropping inputs when a game crashes, or a screenstate changes entirely. Turns out, gamepads were not yet included lmao.

void tic_api_reset(tic_mem* memory)

I added the gamepad ram reset in the same structure that the keyboard is treated and it works! However I noticed this function shares space with the tick start and tick end, also it features some messages. So in the name of security I'm going to leave my fix to this function commented out until I finish working on the tic_api_btnd and btnu functions, then commit it last. That way redactions can be made a bit easier.

You can see some progress here : https://github.com/LettucePie/TIC-80-launcher/commits/btnd-btnu/

from tic-80.

Skeptim avatar Skeptim commented on June 18, 2024 1

@LettucePie Could you have a look at that?
Sorry to add work ^^'

from tic-80.

LettucePie avatar LettucePie commented on June 18, 2024 1

Hello! Thank you for the report.

I'll start looking into more precise ways to distinguish the button input. If there already are flags designed for pressed, released, and held then it will be painlessly easy to fix.

I am busy for the next couple of days however, so it may be a bit until I get to it.

from tic-80.

Skeptim avatar Skeptim commented on June 18, 2024 1

I tried this but it did not work, the issue is still there.
You can find documentation on how this API should work on the wiki: https://github.com/nesbox/TIC-80/wiki/btnp but I would have expected 6, -1, -1 to be the best option.

from tic-80.

LettucePie avatar LettucePie commented on June 18, 2024

Hello again, did a quick search into the button press command before going to work. It's located in the io.c file at 43 (

u32 tic_api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)
)

I then searched for different ways that function is being used since I don't yet understand what it's doing. I found a bunch of results where along with the input command is passed a Hold and Period value. (

if(tic_api_btnp(menu->tic, Up, Hold, Period)
)

I went to do a quick build, but unfortunately my system isn't ready for the newest build instructions and my internet is very very slow, so my quick morning investigation ends here. I have no way of testing it right now, but in theory you can edit my line of tic_api_btnp(tic, 6, -1, -1) into tic_api_btnp(tic, 6, 20, 3) in console.c (

if(tic->ram->input.keyboard.data == 0 && tic_api_btnp(tic, 6, -1, -1))
)

from tic-80.

LettucePie avatar LettucePie commented on June 18, 2024

I'm starting to have a slight idea of what is happening with tic_api_btnp. Inside that alien looking ternary thing, it is asking if the previous ticks game_pad data (referred to in the header file core.h) has the same button being held as the current game_pad data. That way it can check against the Hold and Period requirement.

So, the groundwork for checking if a button was freshly pressed or released is technically all there, it's just missing the functions to wrap it all together... Which has me cautious on how to proceed. There may be a solid reason these were passed up on. Currently you can emulate this functionality when programming a cart by using boolean flags to store the held status of a button, so it's probable it was seen as just unnecessary. I really don't know. The Occam's Razor approach would be to setup my own boolean flags in console.c the same way a user would when making their own cart, however that would be silly/messy lol.

For now I'm going to attempt to expand on the api in io.c... I'll try to stick with naming conventions:

  • tic_api_btnd = TIC API Button Down - Checks against previous game_pad data to see if provided button wasn't active, returns boolean
  • tic_api_btnu = TIC API Button Up - Checks against previous game_pad data to see if provided button was active, returns boolean

from tic-80.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.