Menu
Amazon AppStream
Developer Guide

This documentation is for an older version of Amazon AppStream. For information about the latest version, see the Amazon AppStream 2.0 Developer Guide.

Accepting Keyboard, Mouse, and Touch User Input

When a client sends keyboard, mouse, or touch user input to your application, the XStxServer object fires an XStxIInputSinkFcnOnInput event. Your callback function to handle this event uses the mType member of the XStxInputEvent structure it receives to determine the input source (keyboard, mouse, or touch) and handle it appropriately.

The excerpt from HostedApplicatonDirectX.cpp shows an implementation of XStxIInputSink. The file is in the <SDK_dir>\server\windows\XStxDirectXServer directory. The sample streaming application only accepts keyboard input from client application so this implementation ignores mouse and touch input. Code comments show where you would add that functionality.

Copy
XStxResult HostedApplicationImp::XStxIInputSinkOnInput(const XStxInputEvent* event) { if (NULL == event) return XSTX_RESULT_INVALID_ARGUMENTS; if ((event->mType == XSTX_INPUT_EVENT_TYPE_KEYBOARD) && (event->mInfo.mKeyboard.mIsKeyDown) && (event->mInfo.mKeyboard.mVirtualKey == 78)) { printf("Received N-key\n"); std::string msg("Server received N-keyboard input!"); if (XSTX_RESULT_OK == XStxServerSendMessage( mServer, (const unsigned char*) msg.c_str(), (uint32_t)msg.size())) printf("Successfully sent message to client\n"); else printf("Failed to send message to client\n"); } else if (NULL != mGame) { mGame->handleInput(event); // All other input is delegated to the game } return XSTX_RESULT_OK; }