Download

Arrays of Bitmask Integers

Hi, I’d like to buffer my inputs as an array of bitmasks, so that I can take the maximum value once all the buttons are released. So for example giving my function an array [ X, Y, X + Y ] , I can return X+Y.

But there doesn’t seem to be a way to create an array of bitmasks. Is it possible some other way, or using C++?

Bytes and Integers are bitmasks. Do bitwise operations on them.

For Eg:
3735931646 DEC = 0xDEADCAFE = 11011110101011011100101011111110 b

Then you use bitwise nodes:

1 Like

Thanks. The workflow where you mark an enum as a bitmask was throwing me off. For some reason a 0 value bitmask int is 256 and I take it you can’t use them in arrays as they take up a lot of memory?

I decided to do basically as you said for now, but instead of bitwise operations on ints I used a byte and add/subtract powers of two.

Adding and subtracting powers of two kind of works, but it is so easy to add twice same power, and you can get strange errors in code. It is better to use bitwise OR.

Here are some pics that may give idea:

For this function you need to set masks in same order you made enums.
Better (less prone to bugs) is to give results with (switch on enum), that is more readable.
Function is set to be “pure”

And how to use masks with bitwise OR: