controls.sii memory() function (1.35+)

sclurp
Posts: 13
Joined: 16 Aug 2018 07:17

controls.sii memory() function (1.35+)

#1 Post by sclurp » 15 Dec 2019 07:01

Sooooo since 1.35 there's been a memory() function available for use in controls.sii

https://modding.scssoft.com/wiki/Docume ... figuration
memory(2) 1.35+ Simple single-value memory. The memory starts at zero. If the first parameter evaluates to true, the second parameter is evaluated and its value is stored in the memory. Otherwise the second parameter is not evaluated and the memory is unchanged. The function returns the current value of the memory.
None of the default configuration seems to use it, so, if you are using it, what are you using it for? I'd love to see some examples.

I've been thinking about it all afternoon and it feels kinda... useless? Like, reading that documentation, the usage is like:

Code: Select all

previous_value = memory(condition, expression_to_save_as_new_value)
but if you look really closely, there does not seem to be any way to reference the previous_value from within expression_to_save_as_new_value. Every use I can think of for this function (on/off toggles, smoothing of joy axis inputs, etc) needs the previous value within the expression.

It's also kinda unclear whether "single value" is literally "you only have one memory slot", or if it's per-mix or something.

Hmm. I guess the expression could call it again with condition=false... something like:

Code: Select all

memory(1, memory(0, 0) * whatever_new_value)
Is that how this is supposed to be used?
gagar
Posts: 131
Joined: 07 Nov 2019 22:58

Re: controls.sii memory() function (1.35+)

#2 Post by gagar » 07 Dec 2024 21:29

Sorry for the posting to an old thread, but I'm currently struggling with using memory function. And this thread was the only one found by Google on that.

I was trying to set up blinker input config as I described here: viewtopic.php?p=1996111#p1996111. Even though it's a thread about Hori wheel, the approach should be applicable to any configuration of blinker controls.

Quoting my idea for reference:
is there a way to set up controls (using config files) to make left blinker button turn off right blinker (if it's turned on) and only on second click turn on right blinker (and vice versa, ofc)
First, I realized that it's probably "one per-mix" memory slot. You don't have an "address" parameter and having only one global memory slot would not make sense.

I tried to type the desired configs using memory function... and realized that it's not achievable with memory function: in "mix rblinker" you'd have to peek into lblinker's memory (to not trigger rblinker event if the lblinker is turned on which seems to be impossible.

So, my first question would be: what's the way to achieve the desired behavior?

Then, out of curiosity (well, I typed the config and then tried it out, finding out it doesn't work), I decided to proceed with logic for only one blinker, keeping the rblinker unassigned.

Here is an expression which I came up with:
config_lines[392]: "mix lblinker `(!memory(0.0, 0.0) & (joy.b40?0 & memory(1.0, 1.0))) | (memory(0.0, 0.0) & ((joy.b40?0 | joy.b41?0) & !memory(1.0, 0.0)))`"
memory(0.0, 0.0) is a pattern for reading from memory slot, as described by OP (well, given the docs it seems right)

How I expect it to work:
if memory(0.0, 0.0) is false (!memory(0.0, 0.0) is true), proceed to the second part of short-circuit AND:
config_lines[392]: "mix lblinker `(!memory(0.0, 0.0) & (joy.b40?0 & memory(1.0, 1.0))) | (memory(0.0, 0.0) & ((joy.b40?0 | joy.b41?0) & !memory(1.0, 0.0)))`"
which will activate if Button 40 is pressed and (with short-circuit AND) write 1.0 to the memory slot (short-circuit will ensure that that happens only when the button is pressed). The value returned from this part of expression (if the button is pressed is 1.0, returned from memory(1.0, 1.0) (a fresh value which was just written)

Now if the first part was evaluated to 0.0 (if 1.0 is in the memory slot or of button is not pressed), we go to the second check
config_lines[392]: "mix lblinker `(!memory(0.0, 0.0) & (joy.b40?0 & memory(1.0, 1.0))) | (memory(0.0, 0.0) & ((joy.b40?0 | joy.b41?0) & !memory(1.0, 0.0)))`"
The second part
config_lines[392]: "mix lblinker `(!memory(0.0, 0.0) & (joy.b40?0 & memory(1.0, 1.0))) | (memory(0.0, 0.0) & ((joy.b40?0 | joy.b41?0) & !memory(1.0, 0.0)))`"
is pretty much the same as for turned-off blinker whith the following differences:
- The expression which triggers the mix is OR-expression of two buttons now: joy.b40?0 | joy.b41?0
- we write 0.0 to memory now, which means memory(1.0, 0.0) will return 0.0 and we'd want 1.0 to be returned. Luckily, we can reverse it

Now that I did explanation to a rubber duck here (and even fixed a mistake while typing it), it still does not work as expected which leads me to crying for help here: what's wrong with my config?

Bonus question (was not able to find an answer anywhere: what is semantical.lblinker?0 notation widely present in the config?
servant007
Posts: 14
Joined: 18 Jan 2024 11:37

Re: controls.sii memory() function (1.35+)

#3 Post by servant007 » 14 Dec 2024 02:04

If you have a real car indicactor lever, There is an alternative blinker command with h-prefix for that.
It will autocancel when the lever is centered again.
User avatar
Komat
SCS Software
Posts: 1036
Joined: 26 Nov 2012 09:22

Re: controls.sii memory() function (1.35+)

#4 Post by Komat » 14 Dec 2024 15:08

Each use of the memory function has its own value storage. It is meant to preserve the value of the second parameter from the moment when the first parameter was last true so using it with constant values of the inputs is useless. A possible use would be to convert multiple momentary buttons into a single hold style input.

The semantical. notations reference separate internal mixes which are used to combine actions bound through the Steam Input API or semantical input devices from our input SDK.
gagar
Posts: 131
Joined: 07 Nov 2019 22:58

Re: controls.sii memory() function (1.35+)

#5 Post by gagar » 16 Dec 2024 01:09

Komat wrote: 14 Dec 2024 15:08 Each use of the memory function has its own value storage. It is meant to preserve the value of the second parameter from the moment when the first parameter was last true so using it with constant values of the inputs is useless. A possible use would be to convert multiple momentary buttons into a single hold style input.
Calling memory with 0.0 as the first parameter should read old value from the memory, as OP suggested (well, it seems so from the docs) and then I use short-circuit logic of AND and OR to perform writes conditionally (even though I write with 1.0 as a first parameter, I ensure the conditional nature of it with logic operators). My logic might be more verbose than it can be, but can you try following my logic and find a mistake there? Even though, it might be used "not as expected", I honestly believe (from the docs) that my logic should work.
servant007 wrote: 14 Dec 2024 02:04 If you have a real car indicactor lever, There is an alternative blinker command with h-prefix for that.
It will autocancel when the lever is centered again.
Yes, I know that and I don't have a real indicator lever. But still trying to understand memory function, even though it seems like there is no way it can be useful for my case.
Last edited by gagar on 16 Dec 2024 01:11, edited 1 time in total.
User avatar
Komat
SCS Software
Posts: 1036
Joined: 26 Nov 2012 09:22

Re: controls.sii memory() function (1.35+)

#6 Post by Komat » 16 Dec 2024 13:59

gagar wrote: 16 Dec 2024 01:09 Calling memory with 0.0 as the first parameter should read old value from the memory, as OP suggested (well, it seems so from the docs) and then I use short-circuit logic of AND and OR to perform writes conditionally (even though I write with 1.0 as a first parameter, I ensure the conditional nature of it with logic operators). My logic might be more verbose than it can be, but can you try following my logic and find a mistake there?
You are assuming that memory(0.0, 0.0) at one place in the expression share the memory storage with memory(1.0, 1.0) and memory(1.0, 0.0) at another places in the expression. That is not the case, each call of the function has its own memory storage. The memory function is basically a equivalent of what would be a gated D latch in a digital circuit just with data which can contain any numeric value.
gagar
Posts: 131
Joined: 07 Nov 2019 22:58

Re: controls.sii memory() function (1.35+)

#7 Post by gagar » 20 Dec 2024 00:11

That answers my question, I guess, thanks!
Komat wrote: 16 Dec 2024 13:59 The memory function is basically a equivalent of what would be a gated D latch in a digital circuit just with data which can contain any numeric value.
And what I am looking for in my question resembles a T latch. Seems like converting one to another is not possible with current memory implementation (i cannot have a "feedback wire")

This feedback wire seems to be not achievable with current memory implementation.
Komat wrote: 14 Dec 2024 15:08 The semantical. notations reference separate internal mixes which are used to combine actions bound through the Steam Input API or semantical input devices from our input SDK.
Is Hori's wheel "hardcoded" UI havigation defined through these semantical bindings?
servant007 wrote: 14 Dec 2024 02:04 If you have a real car indicactor lever, There is an alternative blinker command with h-prefix for that.
It will autocancel when the lever is centered again.
Real lever sounds really cool, but there is no way you can achieve real "auto turn-off" effect, so I guess we have what we have.
User avatar
Komat
SCS Software
Posts: 1036
Joined: 26 Nov 2012 09:22

Re: controls.sii memory() function (1.35+)

#8 Post by Komat » 20 Dec 2024 10:13

gagar wrote: 20 Dec 2024 00:11 And what I am looking for in my question resembles a T latch. Seems like converting one to another is not possible with current memory implementation (i cannot have a "feedback wire")
The only feedback which is currently supported is accessing the previous value of the mix itself. Also in general a mix re-evaluation is triggered by various things so direct use of the previous value is tricky. Some things can be done with use of edge reacting memory-based functions such as modifier or short_press however as result of various short circuit evaluations many ways of combining memory-based functions do not work.

For your use case you might try to use some controller remapping SW to generate a controller having input with the behavior you need.
Is Hori's wheel "hardcoded" UI havigation defined through these semantical bindings?
They are using a similar mechanism. The ui_joy bindings modified by input.ui_joy.* entries inside /def/default_input_setup.sii
User avatar
Serge SB
Posts: 43
Joined: 09 Nov 2013 07:19
Location: Russia, Moscow

Re: controls.sii memory() function (1.35+)

#9 Post by Serge SB » 24 Feb 2026 11:34

gagar, check this post to see how to use the memory function.

Return to “Help center - player to player”

Who is online

Users browsing this forum: CCBot [Bot]