JDPeckham

if i'm trying to get typed text into xna, what is the best way to do that

I thought maybe i could start with a Windows Form and override WndProc() to capture WM_CHAR, but how do i properly do that...

is there a #define that represents if i'm building for 360 or windows

can i create a form then associate my game object with it somehow if i'm building for windows




Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

Jim Perry

What do you mean by "get typed text into xna" Do you want the text rendered as it's typed Check the various font rendering projects, such as this one. If you're doing windowed projects (you can XNA render onto a form, there's projects out there that'll show you how) you might be able to use the Key... events of a form to capture the input. I haven't tried it so I'm not sure how well it'll work.






Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

JDPeckham

Jim Perry wrote:

What do you mean by "get typed text into xna" Do you want the text rendered as it's typed Check the various font rendering projects, such as this one. If you're doing windowed projects (you can XNA render onto a form, there's projects out there that'll show you how) you might be able to use the Key... events of a form to capture the input. I haven't tried it so I'm not sure how well it'll work.

I'm currently using Nuclex.Fonts to render text, which works exceptionally well. My problem is getting typed text, unicode specifically to support localization in the future. The problem with the xna libraries is theres no convenient way to do this. From what i've heard, any time you get keyboard entry into a game you need to capture the WM_CHAR messages directed to your window handle. Unfortunately, i see no way in the Xna framework to access the messages going to my xna game window.

so this is a question to the community: How do i get the WM_CHAR messages that are being thrown at my game window within the Xna framework

Do i need to start with a System.Windows.Forms.Form object and override WndProc(Message m) (And if so, how do i run this instance of the form side by side with an instance of the Xna.Framework.Game class, since the game class is consuming windows messages and it won't allow me to operate both on the same thread, which in turn creates another issue, if i try to run the game and form on seperate threads i would have to use a delegate on the game class as a proxy to send messages to my game thread.

I've seen one other post about this with the comment of "we're working on a solution", but does anyone have a work around I really want to be able to have a game console within my game where i can type text into it and execute shell commands, load scenes and other types of stuff interactively.

What i do NOT want to have to do is interpret all of the Key presses from Keyboard.GetState() into char values and handle the shift button to determine caps etc. It's a whole lot of mapping and it's so much easier just to get the WPARAM of the windows message since it is the actual character the user is typing into the window.

PLAIN ENGLISH: I want to get the WM_CHAR messages that are being sent to my XNA game window, what is the easiest way to do that






Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

Fluxtah

I dont think there is an easy way to do this, I have tried myself at one point when I went down the text input route and settled for mapping the keys enum instead, unless there is some other magical way but I doubt it, they have pretty much abstracted away anything to do with windows forms even though Game.Window does indirectly inherit from Form.

 





Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

JDPeckham

that would be unfortunate if there is no way to do this... do they have keyboards on 360's I suppose if they do then your mapping method would be the best way so i can support 360 keyboards, they doubtfully use windows messages.




Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

TwelveBaud

The XBOX 360 supports standard USB keyboards.



Re: XNA Framework Getting typed text into xna aka getting WM_CHAR in xna?

JDPeckham

but does xbox 360 use windows messaging to do character input or does it map keys to actions (clunky!)