File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,6 +122,17 @@ void OnDestroy()
122122 harmony ? . UnpatchAll ( ) ;
123123 }
124124
125+ private static void SetButtonKey ( string name , KeyCode keyCode )
126+ {
127+ var buttons = GetButtonsFromZInput ( ) ;
128+ buttons [ name ] . m_key = keyCode ;
129+ }
130+
131+ private static Dictionary < string , ZInput . ButtonDef > GetButtonsFromZInput ( )
132+ {
133+ return ( Dictionary < string , ZInput . ButtonDef > ) typeof ( ZInput ) . GetField ( "m_buttons" , BindingFlags . Instance | BindingFlags . NonPublic ) . GetValue ( ZInput . instance ) ;
134+ }
135+
125136 public static void ReplaceGamepadButton ( )
126137 {
127138 if ( ZInput . instance != null )
@@ -141,7 +152,8 @@ public static void ReplaceGamepadButton()
141152 replacedButtons . Add ( entry . Key ) ;
142153 replacedKey = keyCode ;
143154
144- ZInput . instance . Setbutton ( entry . Key , KeyCode . None ) ;
155+
156+ SetButtonKey ( entry . Key , KeyCode . None ) ;
145157 }
146158 }
147159 }
@@ -155,8 +167,7 @@ public static void RestoreGamepadButton()
155167 {
156168 foreach ( var button in replacedButtons )
157169 {
158- ZInput . instance . Setbutton ( button , replacedKey ) ;
159-
170+ SetButtonKey ( button , replacedKey ) ;
160171 }
161172 replacedButtons . Clear ( ) ;
162173 replacedKey = KeyCode . None ;
You can’t perform that action at this time.
0 commit comments