XNA show xbox onscreen keyboard in PC
Asked Answered
D

5

5

I need to show, and input some text in xbox-like onscreen keyboard. Sadly, when I call Guide.BeginShowKeyboardInput, there is only some funny textbox shown, and i must fill it via keyboard. I know, that on PC iv very normal to use keyboard, but in my case i MUST enter text via gamepad, using xbox on screen keyboard.

Is there any way to achieve this? To call xbox onscreen keyboard on PC?

Daguerreotype answered 29/1, 2013 at 19:4 Comment(0)
S
4

If you need one for like a touchscreen monitor you could do

 using System.Diagnostics;
 using System.IO;

then use this function

  Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");

but if you need it to work with like an xbox controller you will probably need to build your own

Shepp answered 1/2, 2013 at 17:38 Comment(0)
T
2

No. It was a design decision (documented here) to give the end user control of the keyboard being invoked. Therefore, the end user has to touch a text box (or the like) to invoke the virtual on-screen keyboard.

Check this text form this link

Blockquote User-driven invocation The invocation model of the touch keyboard is designed to put the user in control of the keyboard. Users indicate to the system that they want to input text by tapping on an input control instead of having an application make that decision on their behalf. This reduces to zero the scenarios where the keyboard is invoked unexpectedly, which can be a painful source of UI churn because the keyboard can consume up to 50% of the screen and mar the application's user experience. To enable user-driven invocation, we track the coordinates of the last touch event and compare them to the location of the bounding rectangle of the element that currently has focus. If the point is contained within the bounding rectangle, the touch keyboard is invoked.

Blockquote This means that applications cannot programmatically invoke the touch keyboard via manipulation of focus. Big culprits here in the past have been webpages—many of them set focus by default into an input field but have many other experiences available on their page for the user to enjoy. A good example of this is msn.com. The website has a lot of content for consumption, but happens to have a Bing search bar on the top of its page that takes focus by default. If the keyboard were automatically invoked, all of the articles located below that search bar would be occluded by default, thus ruining the website's experience on tablets. There are certain scenarios where it doesn't feel great to have to tap to get the keyboard, such as when a user has started a new email message or has opened the Search pane. However, we feel that requiring the user to tap the input field is an acceptable compromise.

Targett answered 3/2, 2013 at 13:30 Comment(1)
answer not related. I'm asking about Xbox onscreen keyboard, to enter text via gamepad, not touch keyboard. But thanks for you time :)Daguerreotype
A
1

Check out: http://classes.soe.ucsc.edu/cmps020/Winter08/lectures/controller-keyboard-input.pdf
You might find your answer in here, It has all information about the input of a gamepad and such.

Archduchess answered 1/2, 2013 at 12:8 Comment(4)
unfortunately, in this document i cannot find nothing that I need. I read it before i ask this question ;). But thanks anyway :)Daguerreotype
hmm thats unfortunate, ill look around a bit more ^^Archduchess
Try this one out. xboxforums.create.msdn.com/forums/p/38725/353171.aspx In the second post you can find a step by step plan to create a virtual keyboard.Archduchess
Sadly, I need to use default xbox onscreen keyboard, and i must not use any alternatives. I know how to handle input from gamepad ;). Thx anyway...Daguerreotype
P
1

There is a good guide on how to do this here:

static public string GetKeyboardInput() 
{ 
    if (HandleInput.currentState.IsButtonDown(Buttons.B)) 
    { 
        useKeyboardResult = false; 
    } 

    if (KeyboardResult == null && !Guide.IsVisible) 
    { 
         string title = "Name"; 
         string description = "Pick a name for this game"; 
         string defaultText = "Your name here"; 

         pauseType = PauseType.pauseAll; 
         KeyboardResult = Guide.BeginShowKeyboardInput(HandleInput.playerIndex, title, 
                                                       description, defaultText, null, null); 

         useKeyboardResult = true; 
         pauseType = PauseType.pauseAll; 

     } 
     else if (KeyboardResult != null && KeyboardResult.IsCompleted) 
     { 
          pauseType = PauseType.none; 
          KeyboardInputRquested = false; 

          string input = Guide.EndShowKeyboardInput(KeyboardResult); 
          KeyboardResult = null; 

          if (useKeyboardResult) 
          { 
               return input; 
          } 
     } 

     return null; 
} 

And your Update method should contain something like this:

if (KeyboardInputRequested) 
{ 
    string result = GetKeyboardInput(); 
} 

if (result != null) 
{ 
    //use result here 
} 
Pronator answered 4/2, 2013 at 12:15 Comment(1)
As I say in question: this code will show onscreen keyboard, but only on xbox (and widows phone, i assume). On PC it will show only textbox to grab text from old, standard, hardware pc keyboard.Daguerreotype
T
0

It is unlikely that the on-screen keyboard was packaged in the XNA DLLs for PC, but if you really want to find out, you could research a free .NET decompiling program (such as ILSpy) and look through it.

Also, you can't use the chatpad either. I would recommend either making your own on-screen keyboard that is usable by a controller, or maybe, if you can, using the MonoGame framework (an open-source version of XNA), and modifying it to have an on-screen keyboard on Windows. You could also make a separate program that acts as a virtual keyboard controlled by the controller.

Travel answered 5/7, 2013 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.