Comments (11)
Seems like it is possible. Ill possibly add a PR soon.
from fna-mghistory.
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.
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.
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.
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.
So now you just need to send OnTextInput whatever it is you need from the KEYDOWN events.
from fna-mghistory.
"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.
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.
Will do
from fna-mghistory.
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.
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)
- shader normalmap not work HOT 3
- Can't run on machine without audio device HOT 9
- [OpenGL] VMware/VBox Support? HOT 7
- [MojoShader] MOJOSHADER_glSetVertexAttribDivisor causes 'System.AccessViolationException' on some computers HOT 3
- [Keyboard] Proposal for Keyboard.GetLayoutEXT() HOT 1
- Microsoft.Xna.Framework.Input.GamePad.INTERNAL_AddInstance throws "An element with the same key already exists in the dictionary" HOT 2
- Triangle color is wrong with fairly simple shader + access violation exception HOT 7
- Unable to load a texture (.PNG) from stream HOT 9
- Initialization order mishap HOT 3
- GraphicsDeviceManager never set in Game HOT 1
- GL Object Disposal Wrappers are not thread-safe HOT 3
- DynamicSoundEffectInstance behavior incompatible with XNA4 HOT 8
- OpenGL 3.2+ Core Profile support HOT 4
- Starting game in full screen bug HOT 8
- Null reference when disposing sound effect after checking sound device exists HOT 5
- [QUESTIONS] learning, using FNA HOT 3
- More spec-compliant Touch Support HOT 34
- FNA Binary Release HOT 1
- RasterizerState.MultiSampleAntiAlias not implemented HOT 8
- Set Render Target to Another Window HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fna-mghistory.