Git Product home page Git Product logo

Comments (11)

xanather avatar xanather commented on July 20, 2024

Seems like it is possible. Ill possibly add a PR soon.

from fna-mghistory.

xanather avatar xanather commented on July 20, 2024

So I managed to get everything working except for control keys such as Backspace, Tab and Space. I have no experience with either SDL or C/C++, how can you get control characters?

But for now I will temporarily check IsKeyDown for backspace/tab/space.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 20, 2024

If you've not seen it yet:

http://wiki.libsdl.org/moin.fcg/Tutorials/TextInput

As far as I know TextEditingEvents handle most of those things already. If not, hop into the SDL mailing list and ask about control keys, as I've not dealt with this myself.

from fna-mghistory.

xanather avatar xanather commented on July 20, 2024

Yep, that's what I'm currently using. The TEXTINPUT event, sadly it doesn't trigger control keys. I could not figure out how the TEXTEDITING event worked either. I have temporarily setup IsKeyDown(Delete), etc..., but this does not function like a real input, its just a key down.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 20, 2024

SDL TextInput/TextEditing event senders:
http://hg.libsdl.org/SDL/file/default/src/events/SDL_keyboard.c#l784

And since it sounds like you're only on Windows...

Win32 IME to SDL TextInput/TextEditing:

http://hg.libsdl.org/SDL/file/default/src/video/windows/SDL_windowskeyboard.c#l692

Win32 event to SDL TextInput/TextEditing:

http://hg.libsdl.org/SDL/file/default/src/video/windows/SDL_windowsevents.c#l488

It sort of looks like the OpenTK backend never actually had TextInput, it just took every keyboard event and made it a TextInput-looking event. If you want what OpenTK had, you're going to have to send every SDL_KEYDOWN keysym to OnTextInput, rather than actually using the SDL method, since that's what MonoGame was actually doing.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 20, 2024

9962d6a

So now you just need to send OnTextInput whatever it is you need from the KEYDOWN events.

from fna-mghistory.

xanather avatar xanather commented on July 20, 2024

"It sort of looks like the OpenTK backend never actually had TextInput, it just took every keyboard event and made it a TextInput-looking event. If you want what OpenTK had, you're going to have to send every SDL_KEYDOWN keysym to OnTextInput, rather than actually using the SDL method, since that's what MonoGame was actually doing."

But that won't allow for keyboard repeat, which can be important, does OpenTK handle that aswell? The TextInput event actually works very well and I probably want to stick to it for when I eventually want to make my game cross platform.

Anyway here is the culprit that I quickly realized when reading that code:

http://hg.libsdl.org/SDL/file/default/src/events/SDL_keyboard.c#l784
if ((unsigned char)*text < ' ' || *text == 127) {
792
return 0;

Controls characters are not visible but they are a character indeed, is it possible that SDL could provide them control keys somewhere else?

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 20, 2024

To my understanding, SendKeyboardText is supposed to send a completed text buffer from an IME, rather than constantly polled input from a textbox, so backspace wouldn't exist in this context. That's something the TextEditingEvent would handle anyway, wouldn't it? (At least, this is what the docs imply, never had to use it.)

Like I said, the MonoGame TextInput doesn't seem to be actual TextInput, it just seems to be keydown with repeating key support (SDL had this too, but was deprecated when TextInputEvent was added).

I would ask the SDL mailing list about this if you're stuck.

from fna-mghistory.

xanather avatar xanather commented on July 20, 2024

Will do

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 20, 2024

So this is all working then?

(Also, added the docs for GameWindow. I'm sort of assuming DirectX and SDL2 only, since I kindasorta want OpenTK to DIAF.)

from fna-mghistory.

xanather avatar xanather commented on July 20, 2024

Hahaha, yeah, it does work on OpenTK, but its your choice :). I'm going to message SDL developers and see if I can get control keys correctly without having to create snippets of code for each key. But for now this issue can be closed.

from fna-mghistory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.