The curse of Event2 continues

This is Event2 of my crude Jetpack prop. Jetpack compiles.

    bool Event2(enum BUTTON button, EVENT event, uint32_t) override {
        return Event(button, event);
    }

This is Event2 of my not so crude Morse Code prop. It didn’t compile while exactly the same as the Jetpack.
But after an hour or two of waisting time trying different stuff, this works (compiles):

    bool Event2(enum BUTTON button, EVENT event, uint32_t) override {
        return Event(button, event);
        return false;
    }

It had to have return false;

Both Event2 are “empty” of functions, so why does one compile without return false; (it also compiles with it),
and the other must have return false; or it does not compile ? I would love to know so I do not waste time next trying to figure it out.

In my tries, I also made a “blank” prop. One that that has the minimum base code (but does nothing) so I can add more stuff to my multi_prop and check if I didn’t miss updating one part or another from the switches and get another Event2 Error. So I am wondering what is the minimum code a prop must have ? This is what I got:
blank_prop.h (676 Bytes)

This one, also has to have return false; in Event2 or it does not compile.

If I can get away with less, please let me know.

Thanks

Ayayay, this is going to fail spectacularly.
PropBase::Event calls Event2, and your Event2 calls Event → infinite recursive loop, stack blows up, proffieboard freezes.

The second return never happens and has no effect, and the compiler is likely to give you a warning about that.

Where did “mode” go?

PropBase implements most of the functions with some sort of default, so you don’t need a lot of stuff to make a prop that does nothing. Generally, you do not need to override Event(), not should you, in most props, only Event2() is overriden.

I don’t know much but I know Ayayay is no good ! So what should it be for an Event2 that does nothing so it doesn’t “blow up” ?

But it didn’t give me a warning, so again what should it be ? And I don’t understand what this means “The second return NEVER HAPPENS and has no effect” (I am not “shouting”, just trying to emphasize what really flies miles above my head.

What “mode” ? (I am not trying to make fun, I just have no clue of what/where mode should be.

So what would a place holder prop (that does nothing, except help test If I made my modifications in multi_prop.h correctly - I am basically only looking for a prop that would react “well” or compile with “#define PROP_TYPE Blank”) look like ? If I try a blank prop without some Event2 reference in the code, I get a compile error, which I would really like to avoid.

You do understand that computers execute one thing at a time from top to bottom, right?

Return means that it stops executing the function, and returns to the previous function. Imagine having a book, and on page 183 it says “STOP READING HERE”. If you were a computer, you would actually stop reading, and whatever it says on the next page doesn’t matter.

Sorry, I guess it’s called “modifiers”, not “mode”:

1 Like

Yes that I do understand. Is this better:

    // Event handling for button presses (do nothing)
    bool Event(enum BUTTON button, EVENT event) override {
        return false;  // No action
    }

    // Optional Event2 function, if needed (currently does nothing)
    bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override {
        return false;  // No action
    }

The code above came from ChatGPT. It does compile. Should I remove the 2 override

I asked ChatGPT because I tried this:

but that didn’t compile.

Ok, I’m going to stop here.
I help people because I think they will learn how to do it eventually.
However, I’m not interested in teaching ChatGPT how to code.

1 Like