Opened 11 years ago

Last modified 4 years ago

#2041 closed enhancement

SDL2 Support — at Version 4

Reported by: historic_bruno Owned by:
Priority: Release Blocker Milestone: Alpha 17
Component: Core engine Keywords: patch
Cc: againsttcpa84@…, Josh Patch:

Description (last modified by fabio)

This ticket is for working on SDL2 support (first stable release on 2013-08-13). Doc for 1.2 -> 2.0 migration here.

Known problems:

  • Text input has changed in SDL2 to better support CJK, see TextInput tutorial and this forum topic. Basically Unicode characters may take multiple key presses to generate and we're now expected to use the text input API. In particular, SDL_Keysym.unicode is used by all text input in the game, but that was deprecated and has now been removed in the latest RC.
  • Using SDL on Windows conflicts with our hardware cursor implementation. This can be fixed by using SDL2's color cursors on all platforms, provided it works, #935 has a patch for that.
  • WMI shutdown crashes, moving it before SDL shutdown fixes that.
  • Atlas is broken on Linux, OpenGL functions fail in the engine thread (note the GL context is created by wxWidgets in the GUI thread)

Change History (4)

comment:1 by ben, 11 years ago

In 13572:

Fixes a build error with SDL2, refs #2041

in reply to:  description comment:2 by historic_bruno, 11 years ago

Replying to historic_bruno:

  • Text input has changed in SDL2 to better support CJK, see TextInput tutorial and this forum topic. Basically Unicode characters may take multiple key presses to generate and we're now expected to use the text input API. In particular, SDL_Keysym.unicode is used by all text input in the game, but that was deprecated and has now been removed in the latest RC.

Looked into this a bit more, and it's not as significant a change as I was expecting. Text input events will typically contain only single characters in UTF-8 encoding, roughly the same as the old SDL_Keysym.unicode, so it needs a conversion from UTF-8 to wide chars, but also a loop in case of multiple characters per event (or we can assert that there is only one).

I added some text input event handling to CConsole and CInput, and got basic input working (with the nice bonus of supporting Alt codes in Windows, allowing entry of special Unicode characters not available on the keyboard). Now there is an issue with backquote (`) and tilde (~) opening the console when an input box has focus, this is probably due to the old keydown event being handled in addition to the new text input event. And it remains to be tested on Linux and OS X.

comment:3 by fabio, 11 years ago

Description: modified (diff)

comment:4 by fabio, 11 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.