Factorio-Access / FactorioAccess

An accessibility mod for the video game Factorio, making the game accessible to the blind and visually impaired.
Other
20 stars 9 forks source link

refactor input handling so that we no longer have overlapping prototypes #262

Open ahicks92 opened 1 week ago

ahicks92 commented 1 week ago

Capturing stuff discussed elsewhere and on Discord. We have a problem: when multiple inputs share the same keys, it's a combinatorial explosion to make it actually exclusive. We need to handle that. To do so:

In future, for new things, we almost certainly want the conditions in the handler, e.g.:

if a_condition then handle_the_thing() elseif ...

But the advantage to the above is that it is almost an entirely mechanical process that should solve the problem without introducing bugs or instabilities, while guaranteeing that only one input ever triggers.

Disadvantage: we break remapping individual actions. We break current configs. Advantage: we stop having multiple "multiple inputs fired" bugs a month. Also unlocks some UI stuff.

LevFendi commented 6 days ago

Agreed. The disadvantage seems tolerable. It is unlikely that someone is going to rebind this one sub-feature and not the others when they originally all have the same keybind. I am most hesitant about left bracket itself but for the others it should be fine.

ahicks92 commented 6 days ago

[ is our biggest problem. It's O(N^2) to figure out if it's right (each callback requires reasoning about all others and it's not a transitive relation). The bugs usually specifically show up there.

Here's an alternative if it really comes up. We can make a bunch of action-specific keybinds that do exactly one thing and leave them all unmapped by default. Then it can be their problem if they're going to try to fiddle around with remapping the whole thing for something as core as [. For now we don't bother but if we get a lot of requests we just come back and do that. What do we think?

For what it's worth my scanner experiments have lead to me seeing input go weird at low UPS so I am less confident in other approaches. I haven't tried to figure out what weird specifically means, nor do I care to. I've got enough other problems.