Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

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 
} 

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top