@@ -148,10 +148,34 @@ pg_event_filter(void *_, SDL_Event *event)
148
148
_pg_repeat_timer = SDL_AddTimer (pg_key_repeat_delay , _pg_repeat_callback ,
149
149
NULL );
150
150
}
151
+ #ifdef WIN32
152
+ /* This does not seem to work on Mac 10.13. */
153
+ #pragma PG_WARN(PumpEvents is not thread-safe)
154
+ SDL_PumpEvents ();
155
+ if (SDL_PeepEvents (inputEvent , 1 , SDL_PEEKEVENT ,
156
+ SDL_TEXTINPUT , SDL_TEXTINPUT ) == 1 )
157
+ {
158
+ SDL_Event * ev = inputEvent ;
159
+ SDL_PumpEvents ();
160
+ if (_pg_last_unicode_char [0 ] == 0 ) {
161
+ if (SDL_PeepEvents (inputEvent , 2 , SDL_PEEKEVENT ,
162
+ SDL_TEXTINPUT , SDL_TEXTINPUT ) == 2 )
163
+ ev = & inputEvent [1 ];
164
+ }
151
165
166
+ /* Only copy size - 1. This will always leave the string
167
+ * terminated with a 0. */
168
+ strncpy (_pg_last_unicode_char , ev -> text .text ,
169
+ sizeof (_pg_last_unicode_char ) - 1 );
170
+ }
171
+ else {
172
+ _pg_last_unicode_char [0 ] = 0 ;
173
+ }
174
+ #else
152
175
_pg_last_unicode_char [0 ] = 0 ;
153
176
/* store the keydown event for later in the SDL_TEXTINPUT */
154
177
_pg_last_keydown_event = event ;
178
+ #endif /* WIN32 */
155
179
}
156
180
else if (type == SDL_TEXTINPUT ) {
157
181
if (_pg_last_keydown_event != NULL ) {
0 commit comments