The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL IME support question
Alexey Petruchik
Guest

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

 if( wParam == VK_PROCESSKEY ) return 0;


condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in     SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.



Regards, Alexey
 
SDL IME support question
Sik


Joined: 26 Nov 2011
Posts: 905
SDL_TEXTEDITING indicates composition is in progress (and provides the
current text so far), SDL_TEXTINPUT indicates composition has just
finished (and provides the resulting text). Maybe you can do something
with these two?

Note that you can get SDL_TEXTINPUT alone if it's a system without
composition, e.g. letters get entered directly.

2015-03-28 14:15 GMT-03:00, Alexey Petruchik:
Quote:
I'm porting to SDL2 windows game that has IME support. Game logic implies
that no keys are processed during IME composition. This is accomplished by

if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate
this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags
in SDL_KeyboardEvent structure that can be used to filter keys during
IME composition. I don't see any composition-started/composition-ended
events so i can maintain my own boolean flag. Any ideas how should I
accomplish my goal? Should I prepare a patch that adds such functionality?
Any opinions are welcome.


Regards, Alexey

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL IME support question
Ryan C. Gordon
Guest

Does the SDL_TEXTEDITING event fire in any useful way here?

--ryan.



Quote:
On Mar 28, 2015, at 1:15 PM, Alexey Petruchik wrote:

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.


Regards, Alexey

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL IME support question
Alexey Petruchik
Guest

SDL_TEXEDITING seems to be not enough for me. Here is an example (I use Japanese IME) I press Ctrl+Caps to start IME than I write "waruso" and hit enter. Here is a dump of sdl events:

SDL_KEYDOWN: 224 1073742048
SDL_KEYDOWN: 57 1073741881
SDL_KEYUP: 224 1073742048
SDL_KEYUP: 57 1073741881
SDL_KEYDOWN: 26 119
SDL_TEXTEDITING: "ï½—"
SDL_KEYUP: 26 119
SDL_KEYDOWN: 4 97
SDL_TEXTEDITING: "わ"
SDL_KEYUP: 4 97
SDL_KEYDOWN: 21 114
SDL_TEXTEDITING: "わr"
SDL_KEYUP: 21 114
SDL_KEYDOWN: 24 117
SDL_TEXTEDITING: "わる"
SDL_KEYUP: 24 117
SDL_KEYDOWN: 22 115
SDL_TEXTEDITING: "わるs"
SDL_KEYUP: 22 115
SDL_KEYDOWN: 18 111
SDL_TEXTEDITING: "わるそ"
SDL_KEYUP: 18 111
SDL_KEYDOWN: 40 13
SDL_TEXTINPUT: "わるそ"
SDL_TEXTEDITING: ""
SDL_KEYUP: 40 13



As you see when SDL_KEYDOWN for "w" letter comes I'm already in IME mode (Ctrl+Caps pressed) but SDL_TEXEDITING event hadn't yet come so I can't filter this keydown. Same comes for SDL_KEYUP for Enter after i received textediting with empty string which seems to mean that IME composition is completed.


On 28 March 2015 at 22:10, Ryan C. Gordon wrote:
Quote:

Does the SDL_TEXTEDITING event fire in any useful way here?

--ryan.



Quote:
On Mar 28, 2015, at 1:15 PM, Alexey Petruchik wrote:

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

  if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in     SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.


Regards, Alexey



Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL IME support question
Alexey Petruchik
Guest

Here is more detailed log. I've marked keydown events that have wParam equal to VK_PROCESSKEY



SDL_KEYDOWN: 224 1073742048
SDL_KEYDOWN: 57 1073741881 - VK_PROCESSKEY
SDL_KEYUP: 224 1073742048
SDL_KEYUP: 57 1073741881
SDL_KEYDOWN: 26 119 - VK_PROCESSKEY
WM_IME_STARTCOMPOSITION
SDL_TEXTEDITING: "ï½—"
SDL_KEYUP: 26 119
SDL_KEYDOWN: 4 97 - VK_PROCESSKEY
SDL_TEXTEDITING: "わ"
SDL_KEYUP: 4 97
SDL_KEYDOWN: 21 114 - VK_PROCESSKEY
SDL_TEXTEDITING: "わr"
SDL_KEYUP: 21 114
SDL_KEYDOWN: 24 117 - VK_PROCESSKEY
SDL_TEXTEDITING: "わる"
SDL_KEYUP: 24 117
SDL_KEYDOWN: 22 115 - VK_PROCESSKEY
SDL_TEXTEDITING: "わるs"
SDL_KEYUP: 22 115
SDL_KEYDOWN: 18 111 - VK_PROCESSKEY
SDL_TEXTEDITING: "わるそ"
SDL_KEYUP: 18 111
SDL_KEYDOWN: 40 13 - VK_PROCESSKEY
SDL_TEXTINPUT: "わるそ"
WM_IME_ENDCOMPOSITION
SDL_TEXTEDITING: ""
SDL_KEYUP: 40 13



On 30 March 2015 at 00:21, Alexey Petruchik wrote:
Quote:
SDL_TEXEDITING seems to be not enough for me. Here is an example (I use Japanese IME) I press Ctrl+Caps to start IME than I write "waruso" and hit enter. Here is a dump of sdl events:

SDL_KEYDOWN: 224 1073742048
SDL_KEYDOWN: 57 1073741881
SDL_KEYUP: 224 1073742048
SDL_KEYUP: 57 1073741881
SDL_KEYDOWN: 26 119
SDL_TEXTEDITING: "ï½—"
SDL_KEYUP: 26 119
SDL_KEYDOWN: 4 97
SDL_TEXTEDITING: "わ"
SDL_KEYUP: 4 97
SDL_KEYDOWN: 21 114
SDL_TEXTEDITING: "わr"
SDL_KEYUP: 21 114
SDL_KEYDOWN: 24 117
SDL_TEXTEDITING: "わる"
SDL_KEYUP: 24 117
SDL_KEYDOWN: 22 115
SDL_TEXTEDITING: "わるs"
SDL_KEYUP: 22 115
SDL_KEYDOWN: 18 111
SDL_TEXTEDITING: "わるそ"
SDL_KEYUP: 18 111
SDL_KEYDOWN: 40 13
SDL_TEXTINPUT: "わるそ"
SDL_TEXTEDITING: ""
SDL_KEYUP: 40 13



As you see when SDL_KEYDOWN for "w" letter comes I'm already in IME mode (Ctrl+Caps pressed) but SDL_TEXEDITING event hadn't yet come so I can't filter this keydown. Same comes for SDL_KEYUP for Enter after i received textediting with empty string which seems to mean that IME composition is completed.


On 28 March 2015 at 22:10, Ryan C. Gordon wrote:
Quote:

Does the SDL_TEXTEDITING event fire in any useful way here?

--ryan.



Quote:
On Mar 28, 2015, at 1:15 PM, Alexey Petruchik wrote:

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

  if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in     SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.


Regards, Alexey



Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







SDL IME support question
eric.w


Joined: 12 Feb 2014
Posts: 38
Hi,Not sure if this helps, but to implement the text fields in Quakespasm (the console, chat prompt, etc.),  what we did is:

- when the user focuses a text field, we call SDL_StartTextInput() and set a flag in our code that indicates we're in text editing mode
- when in text editing mode, we ignore all SDL_KEYDOWN/SDL_KEYUP events, except keys that manipulate the cursor, like backspace, delete, and the arrow keys
- any text that comes in via SDL_TEXTINPUT is pasted into the text field.



After experimenting a bit, I think this is the "right" design for doing a text field in a game with SDL2.
Trying to match key and text input/text editing events on a per-character basis is fragile and bound to fail, in my experience.





On Sun, Mar 29, 2015 at 4:13 PM, Alexey Petruchik wrote:
Quote:
Here is more detailed log. I've marked keydown events that have wParam equal to VK_PROCESSKEY



SDL_KEYDOWN: 224 1073742048
SDL_KEYDOWN: 57 1073741881 - VK_PROCESSKEY
SDL_KEYUP: 224 1073742048
SDL_KEYUP: 57 1073741881
SDL_KEYDOWN: 26 119 - VK_PROCESSKEY
WM_IME_STARTCOMPOSITION
SDL_TEXTEDITING: "ï½—"
SDL_KEYUP: 26 119
SDL_KEYDOWN: 4 97 - VK_PROCESSKEY
SDL_TEXTEDITING: "わ"
SDL_KEYUP: 4 97
SDL_KEYDOWN: 21 114 - VK_PROCESSKEY
SDL_TEXTEDITING: "わr"
SDL_KEYUP: 21 114
SDL_KEYDOWN: 24 117 - VK_PROCESSKEY
SDL_TEXTEDITING: "わる"
SDL_KEYUP: 24 117
SDL_KEYDOWN: 22 115 - VK_PROCESSKEY
SDL_TEXTEDITING: "わるs"
SDL_KEYUP: 22 115
SDL_KEYDOWN: 18 111 - VK_PROCESSKEY
SDL_TEXTEDITING: "わるそ"
SDL_KEYUP: 18 111
SDL_KEYDOWN: 40 13 - VK_PROCESSKEY
SDL_TEXTINPUT: "わるそ"
WM_IME_ENDCOMPOSITION
SDL_TEXTEDITING: ""
SDL_KEYUP: 40 13



On 30 March 2015 at 00:21, Alexey Petruchik wrote:
Quote:
SDL_TEXEDITING seems to be not enough for me. Here is an example (I use Japanese IME) I press Ctrl+Caps to start IME than I write "waruso" and hit enter. Here is a dump of sdl events:

SDL_KEYDOWN: 224 1073742048
SDL_KEYDOWN: 57 1073741881
SDL_KEYUP: 224 1073742048
SDL_KEYUP: 57 1073741881
SDL_KEYDOWN: 26 119
SDL_TEXTEDITING: "ï½—"
SDL_KEYUP: 26 119
SDL_KEYDOWN: 4 97
SDL_TEXTEDITING: "わ"
SDL_KEYUP: 4 97
SDL_KEYDOWN: 21 114
SDL_TEXTEDITING: "わr"
SDL_KEYUP: 21 114
SDL_KEYDOWN: 24 117
SDL_TEXTEDITING: "わる"
SDL_KEYUP: 24 117
SDL_KEYDOWN: 22 115
SDL_TEXTEDITING: "わるs"
SDL_KEYUP: 22 115
SDL_KEYDOWN: 18 111
SDL_TEXTEDITING: "わるそ"
SDL_KEYUP: 18 111
SDL_KEYDOWN: 40 13
SDL_TEXTINPUT: "わるそ"
SDL_TEXTEDITING: ""
SDL_KEYUP: 40 13



As you see when SDL_KEYDOWN for "w" letter comes I'm already in IME mode (Ctrl+Caps pressed) but SDL_TEXEDITING event hadn't yet come so I can't filter this keydown. Same comes for SDL_KEYUP for Enter after i received textediting with empty string which seems to mean that IME composition is completed.


On 28 March 2015 at 22:10, Ryan C. Gordon wrote:
Quote:

Does the SDL_TEXTEDITING event fire in any useful way here?

--ryan.



Quote:
On Mar 28, 2015, at 1:15 PM, Alexey Petruchik wrote:

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

  if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in     SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.


Regards, Alexey



Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org













_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org