开发者

Dealing with simultaneous button presses and changing shift states

开发者 https://www.devze.com 2023-01-12 17:19 出处:网络
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 ot

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?


Satemachines are a good pattern to handle complex inputs.

Here is a machine that handle the above sequence.

Dealing with simultaneous button presses and changing shift states

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

0

精彩评论

暂无评论...
验证码 换一张
取 消