Bjartr
Bjartr

Reputation: 502

Dealing with simultaneous button presses and changing shift states

I am currently working on a (Python2.5) application which handles input from a game controller. We've designated a button as a shift button to change the mapping (inputtype,value->function) of the other buttons on the fly. The mapping also depends on the mode our application is running in. We are running into lots of hairy edge cases (e.g. how to handle press shift, press button x, release shift, release button x) and I was wondering if there are any known good structures/architectures/patterns for dealing with this kind of input?

Upvotes: 0

Views: 383

Answers (1)

FabienAndre
FabienAndre

Reputation: 4604

Satemachines are a good pattern to handle complex inputs.

Here is a machine that handle the above sequence.

state machine picture

You can implement statemachines with switch or state pattern (see Python state-machine design )

Upvotes: 2

Related Questions