File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
OpenRA.Renderer.SdlCommon Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -82,12 +82,6 @@ public static bool HasModifier(this Modifiers k, Modifiers mod)
82
82
return ( k & mod ) == mod ;
83
83
}
84
84
85
- public static bool IsValidInput ( this KeyInput key )
86
- {
87
- return char . IsLetter ( key . UnicodeChar ) || char . IsDigit ( key . UnicodeChar ) ||
88
- char . IsSymbol ( key . UnicodeChar ) || char . IsSeparator ( key . UnicodeChar ) ||
89
- char . IsPunctuation ( key . UnicodeChar ) ;
90
- }
91
85
92
86
public static V GetOrAdd < K , V > ( this Dictionary < K , V > d , K k )
93
87
where V : new ( )
Original file line number Diff line number Diff line change @@ -151,8 +151,16 @@ public class SdlInput
151
151
{ Sdl . SDLK_UNDO , Keycode . UNDO } ,
152
152
} ;
153
153
154
+
154
155
MouseButton lastButtonBits = ( MouseButton ) 0 ;
155
156
157
+ static bool IsValidInput ( char c )
158
+ {
159
+ return char . IsLetter ( c ) || char . IsDigit ( c ) ||
160
+ char . IsSymbol ( c ) || char . IsSeparator ( c ) ||
161
+ char . IsPunctuation ( c ) ;
162
+ }
163
+
156
164
MouseButton MakeButton ( byte b )
157
165
{
158
166
return b == Sdl . SDL_BUTTON_LEFT ? MouseButton . Left
@@ -242,7 +250,14 @@ public void PumpInput(IInputHandler inputHandler)
242
250
// Drop unknown keys
243
251
Keycode keyCode ;
244
252
if ( ! KeyRemap . TryGetValue ( e . key . keysym . sym , out keyCode ) )
253
+ {
254
+ // Try parsing it as text
255
+ var c = ( char ) e . key . keysym . unicode ;
256
+ if ( IsValidInput ( c ) )
257
+ inputHandler . OnTextInput ( c . ToString ( ) ) ;
258
+
245
259
break ;
260
+ }
246
261
247
262
var type = e . type == Sdl . SDL_KEYDOWN ?
248
263
KeyInputEvent . Down : KeyInputEvent . Up ;
@@ -269,7 +284,7 @@ public void PumpInput(IInputHandler inputHandler)
269
284
else
270
285
inputHandler . OnKeyInput ( keyEvent ) ;
271
286
272
- if ( keyEvent . IsValidInput ( ) )
287
+ if ( IsValidInput ( keyEvent . UnicodeChar ) )
273
288
inputHandler . OnTextInput ( keyEvent . UnicodeChar . ToString ( ) ) ;
274
289
275
290
break ;
You can’t perform that action at this time.
0 commit comments