robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
129 stars 12 forks source link

modifier keys return values twice on press #101

Open jaseknighter opened 11 months ago

jaseknighter commented 11 months ago

some modifier keys on mac os (lsuper, lctrl, lalt) return values twice on press. on release, values only return one time as expected. this only happens with some modifier keys. shift and enter don't have this issue, for example.

here is sample output using this code screen.key = function (char, modifier, is_repeat,state) print("char,char.name,modifier[1]: ",char,char.name,modifier[1],state) end:

char,char.name,modifier[1]:     a   nil nil
char,char.name,modifier[1]:     a   nil nil
char,char.name,modifier[1]:     b   nil nil
char,char.name,modifier[1]:     b   nil nil
char,char.name,modifier[1]:     c   nil nil
char,char.name,modifier[1]:     c   nil nil
char,char.name,modifier[1]:     table: 0x7fb092b0b100   lalt    alt
char,char.name,modifier[1]:     table: 0x7fb092b0b100   lalt    alt
char,char.name,modifier[1]:     table: 0x7fb092b0b100   lalt    nil
char,char.name,modifier[1]:     table: 0x7fb092b0b160   lsuper  super
char,char.name,modifier[1]:     table: 0x7fb092b0b160   lsuper  super
char,char.name,modifier[1]:     table: 0x7fb092b0b160   lsuper  nil
robbielyman commented 11 months ago

hmm, i can reproduce this. i also think this is an SDL issue that would be tough for me to dodge in comparison with the ease of a workaround at the script level: if you manage the state of lalt yourself, for example, you can discard the double triggers. i'll leave this open for when we ditch SDL.

p3r7 commented 10 months ago

i can reproduce as well.

fwiw, the is_repeat flag is set to true to the 2nd call. the culprit keys are only the modifier keys and those are not supposed to repeat so using not is_repeat as an additional condition makes it easy to filter out those crappy calls.