Keyboard support - Xbox 1 / UWP (Creators Collection)

Started by
3 comments, last by Steven Ford 5 years, 6 months ago

Hi all,

having gotten the game virtually ready for release (development used a Win32 wrapper as easier), I now need to create a UWP version of the app for release on the X1 (Creators Collection). My initial expectation would be to have the UWP version solely available for the Xbox 1 and to get the game released on Steam for the PC. Given that the MS store allows the game to be released on both X1 / PC, I'm thinking that if I can get the UWP version to function on the PC then I might as well do it to widen the possible audience.

I currently allow a user to play with either a game pad or a keyboard and show various settings related to the keyboard input. For the UWP version, I've added a flag which is permanently set to false in the UWP version to say whether to show the keyboard feature. Obviously this approach isn't ideal if I do want to allow the UWP version to run on the PC. So the questions are...

1. How does one detect that the app is running on a device without a keyboard / an X1 (this presumes that they're the same question, but I don't think that that's true for reasons in #3)?
2. If you were an X1 player and you saw the option to view the keyboard settings would this be irritating or would you simply not care?
3. Given that one can plug in a keyboard to an X1 and it appears to work (at least in 'Dev Home'), would you expect to go with the simple option and just allow them?

Assuming that this was to be allowed, is there a message that I can subscribe to to say that the keyboard is now attached or is it a question of simply polling (assuming that I went for the approach of not showing keyboard options unless one was attached).

Any thoughts?

Thanks

Steve

Advertisement

Disclaimer: I also made a UWP game, but didn't enable XBox support (no XBox to test on, so it's pretty difficult to verify if any problems arise). So I can't verify the snippet below.

Anyhow, on Stack Overflow this snippet was found:


private void GetKeyboardProperties()
{
    KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
    KeyboardPresent.Text = keyboardCapabilities.KeyboardPresent != 0 ? "Yes" : "No";
}

 

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thanks squire; looks to be trivial to enable it [support] and removing it seems to cause more hassle than it's worth so might as well leave it in. Doesn't cost me much.

Just adding a code snippet of how this [handling of keyboard inputs] was done in case it's useful to anyone else (and me for later reference ? ).

Look at the following Forum Post ( @Endurion 's one) to see a subset of the possible inputs. To do these in C++/winrt; the following syntax can be used


// SetWindow from templates
// Window = CoreWindow

		// Tokens which can be used to remove the event listeners later
		winrt::event_token _keyDownToken, _keyUpToken;

		_keyDownToken = window.KeyDown([this](auto&& /*sender*/, auto&& args) {
			int keyCode = (int)args.VirtualKey();
			args.Handled(this->handleKeyDown(keyCode));
		});

		_keyUpToken = window.KeyUp([this](auto&& /*sender*/, auto&& args) {
			int keyCode = (int)args.VirtualKey();
			args.Handled(this->handleKeyUp(keyCode));
		});

 

This topic is closed to new replies.

Advertisement