@@ -34,6 +34,13 @@ function sepiaFW_build_input_controls() {
3434 $ ( '#SepiaFW-hotkeys-define-back' ) . off ( ) . on ( 'click' , function ( ) {
3535 InputControls . defineHotkeyFunction ( backButton ) ;
3636 } ) ;
37+ //Ignore keys
38+ $ ( '#SepiaFW-hotkeys-ignore-key1' ) . off ( ) . on ( 'change' , function ( ) {
39+ if ( this . value ) {
40+ ignoreKeys = JSON . parse ( "[" + this . value + "]" ) ;
41+ settingsAppendDebug ( "New ignore keys: " + JSON . stringify ( ignoreKeys ) ) ;
42+ }
43+ } ) ;
3744 //Buttons for button mappings
3845 $ ( '#SepiaFW-buttons-define-mic' ) . off ( ) . on ( 'click' , function ( ) {
3946 InputControls . defineButtonFunction ( toggleMicrophone ) ;
@@ -68,8 +75,11 @@ function sepiaFW_build_input_controls() {
6875 } ) ;
6976 settingsAppendDebug ( "<b>Hotkey matrix:</b>" ) ;
7077 settingsAppendDebug ( convertActionMatrixToString ( hotkeyActionMatrix ) ) ;
78+ settingsAppendDebug ( "<b>Ignoring keys:</b>" ) ;
79+ settingsAppendDebug ( JSON . stringify ( ignoreKeys ) ) ;
7180 settingsAppendDebug ( "<b>Button matrix:</b>" ) ;
7281 settingsAppendDebug ( convertActionMatrixToString ( buttonActionMatrix ) ) ;
82+ settingsAppendDebug ( "<hr>" ) ;
7383 settingsAppendDebug ( "<b>Controller and key events:</b>" ) ;
7484
7585 SepiaFW . ui . scrollToTop ( 'sepiaFW-frame-page-1' ) ;
@@ -89,20 +99,32 @@ function sepiaFW_build_input_controls() {
8999 var keys = convertActionMatrixToString ( hotkeyActionMatrix ) ;
90100 SepiaFW . data . set ( "input-controls-buttons" , buttons ) ;
91101 SepiaFW . data . set ( "input-controls-hotkeys" , keys ) ;
102+ SepiaFW . data . set ( "input-controls-ignore" , JSON . stringify ( {
103+ "keys" : ignoreKeys ,
104+ "buttons" : ignoreButtons
105+ } ) ) ;
92106 SepiaFW . debug . log ( 'Stored hotkeys and button settings in client storage.' ) ;
93107 SepiaFW . ui . showPopup ( 'Stored hotkeys and button settings.' ) ;
94108 }
95109 InputControls . clearMappings = function ( ) {
96110 SepiaFW . data . set ( "input-controls-buttons" , "" ) ;
97111 SepiaFW . data . set ( "input-controls-hotkeys" , "" ) ;
112+ SepiaFW . data . set ( "input-controls-ignore" , "" ) ;
98113 SepiaFW . debug . log ( 'Cleared hotkeys and button settings from client storage.' ) ;
99114 SepiaFW . ui . showPopup ( 'Cleared hotkeys and button settings (please reload app).' ) ;
100115 }
101116 InputControls . importMappings = function ( ) {
102117 var buttonsMapString = SepiaFW . data . get ( "input-controls-buttons" ) ;
103118 var keysMapString = SepiaFW . data . get ( "input-controls-hotkeys" ) ;
119+ var ignoresString = SepiaFW . data . get ( "input-controls-ignore" ) ;
104120 if ( buttonsMapString ) buttonActionMatrix = importJsonToActionMatrix ( buttonsMapString ) ;
105121 if ( keysMapString ) hotkeyActionMatrix = importJsonToActionMatrix ( keysMapString ) ;
122+ if ( ignoresString ) {
123+ ignoresJson = JSON . parse ( ignoresString ) ;
124+ ignoreKeys = ignoresJson . keys ;
125+ $ ( '#SepiaFW-hotkeys-ignore-key1' ) . val ( JSON . stringify ( ignoreKeys ) . replace ( / \[ | \] / g, "" ) ) ;
126+ ignoreButtons = ignoresJson . buttons ;
127+ }
106128 SepiaFW . debug . log ( 'Imported hotkeys and button settings from client storage.' ) ;
107129 }
108130 function convertActionMatrixToString ( actionMatrix ) {
@@ -127,6 +149,7 @@ function sepiaFW_build_input_controls() {
127149 //--------------- Keyboard Shortcuts ----------------
128150
129151 var hotkeyActionMatrix = { } ; //{unicode-key} -> action
152+ var ignoreKeys = [ ] ; //for quirky controllers that always fire more than one event at the same time
130153
131154 InputControls . listenToGlobalHotkeys = function ( ) {
132155 if ( InputControls . useGamepads && InputControls . useHotkeysInAlwaysOn ) {
@@ -144,6 +167,10 @@ function sepiaFW_build_input_controls() {
144167 //Evaluate hotkey press
145168 function onHotkey ( event ) {
146169 var e = event || window . event ; // for IE to cover IEs window event-object
170+ //ignore?
171+ if ( ignoreKeys && ignoreKeys . length > 0 && $ . inArray ( e . which , ignoreKeys ) > - 1 ) {
172+ return ;
173+ }
147174 if ( InputControls . settingsAreOpen ) {
148175 settingsAppendDebug ( 'Key pressed with unicode: ' + e . which ) ;
149176 }
@@ -173,6 +200,7 @@ function sepiaFW_build_input_controls() {
173200 var controllers = { } ; //Object to hold all connected controllers {"1":..,"2":..}
174201 var buttonMatrix = { } ; //2D "object" with {controllerIndex}{buttonIndex} that holds current "pressed" state
175202 var buttonActionMatrix = { } ; //2D "object" with {controllerIndex}{buttonIndex} that holds action method (if any)
203+ var ignoreButtons = [ ] ; //for quirky controllers that always fire more than one event at the same time
176204 var isGamepadListening = false ;
177205
178206 //Used for state scan-loop
0 commit comments