You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

234 lines
15 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><link rel="stylesheet" type="text/css" href="https://i-msdn.sec.s-msft.com/Combined.css?resources=0:Header,0:HeaderFooterSprite,0:Header.NonMtps,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;amp;v=B6A3E523D12C9136AC9F4C02B9F5CAFF" xmlns="http://www.w3.org/1999/xhtml" />
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />
<link rel="stylesheet" type="text/css" href="https://i-msdn.sec.s-msft.com/Combined.css?resources=0:Footer,0:HeaderFooterSprite,0:Footer.NonMtps,1:FooterSock,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;amp;v=59CEC968CCF63579590CF573D2095884" xmlns="http://www.w3.org/1999/xhtml" />
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DirectInput Samples</title>
<link href="description/Galleries.css" type="text/css" rel="Stylesheet" /><link href="description/Layout.css" type="text/css" rel="Stylesheet" /><link href="description/Brand.css" type="text/css" rel="Stylesheet" />
<link href="https://i1.code.msdn.s-msft.com/content/common/iframedescription.css" rel="Stylesheet" type="text/css" />
<script src="https://i1.code.msdn.s-msft.com/content/common/offline.js" type="text/javascript"></script>
<style type="text/css">
#projectInfo {
overflow: auto;
}
#longDesc {
clear:both;
margin: 25px 0 10px 0;
}
#SampleIndexList{
margin-left: 15px;
}
</style>
</head>
<body>
<div id="offlineDescription">
<h1>DirectInput Samples</h1>
<br/>
<div id="projectInfo">
<div class="section">
<div class="itemBarLong tagsContainer">
<label for="Technologies">Technologies</label>
<div id="Technologies">
Win32, DirectX SDK
</div>
</div>
<div class="itemBarLong tagsContainer">
<label for="Topics">Topics</label>
<div id="Topics">
Games
</div>
</div>
<div class="itemBarLong">
<label for="Platforms">Platforms</label>
<div id="Platforms">
Desktop
</div>
</div>
<div class="itemBarLong">
<label for="Requirements">Requirements</label>
<div id="Requirements">
</div>
</div>
<div class="itemBar">
<label for="LastUpdated">Primary language</label>
<div id="LastUpdated">en-US</div>
</div>
<div class="itemBar">
<label for="LastUpdated">Updated</label>
<div id="LastUpdated">10/12/2015</div>
</div>
<div class="itemBarLong">
<label for="License">License</label>
<div id="License">
<a href="license.rtf">MIT</a></div>
</div>
<div class="itemBar">
<div class="viewonlinecont">
<a data-link="online" href="https://code.msdn.microsoft.com/DirectInput-Samples-8ac6f5e3">View this sample online</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function initializePage() {
var otherTabClass = 'otherTab';
var hiddenPreClass = 'hidden';
var htmlDecode = function(encodedData) {
var decodedData = "";
if (encodedData) {
var div = document.createElement('div');
div.innerHTML = encodedData;
decodedData = div.firstChild.nodeValue.replace( /\\r\\n/ig , '\r\n');
}
return decodedData;
};
Galleries.iterateElem(Galleries.findElem(null, 'div', 'scriptcode'), function (index, scriptBlock) {
var titleElem = Galleries.findElem(scriptBlock, 'div', 'title')[0];
var labelElems = Galleries.findElem(titleElem, 'span');
if (labelElems.length == 0) {
labelElems = titleElem;
}
var languageSpans = Galleries.findElem(scriptBlock, 'span', 'hidden');
var pres = Galleries.findElem(scriptBlock, 'pre');
if (languageSpans.length > 0 && pres.length > 1) {
Galleries.iterateElem(labelElems, function(index, elem) {
var codePre = pres[index];
var labelSpan = elem;
var languageSpan = languageSpans[index];
elem.code = codePre.innerHTML.replace( /(\r(\n)?)|((\r)?\n)/ig , '\\r\\n');
codePre.className = codePre.className.replace(hiddenPreClass, '');
languageSpan.parentNode.removeChild(languageSpan);
});
pres = Galleries.findElem(scriptBlock, 'pre');
Galleries.iterateElem(labelElems, function(index, elem) {
var codePre = pres[index];
var labelSpan = elem;
if (index == 0) {
scriptBlock.activeTab = 0;
}
else {
labelSpan.className += otherTabClass;
codePre.className += hiddenPreClass;
}
Galleries.attachEventHandler(labelSpan, 'click', function(e) {
var activeTab = scriptBlock.activeTab;
labelElems[activeTab].className += otherTabClass;
pres[activeTab].className += hiddenPreClass;
codePre.className = codePre.className.replace(hiddenPreClass, '');
labelSpan.className = labelSpan.className.replace(otherTabClass, '');
scriptBlock.activeTab = index;
});
});
var preview = Galleries.findElem(scriptBlock, 'div', 'preview');
if (preview.length == 0) {
preview.push(pres[pres.length - 1]);
}
Galleries.iterateElem(preview, function(index, elem) {
elem.parentNode.removeChild(elem);
});
if (window.clipboardData && clipboardData.setData) {
var copyLink = document.createElement('a');
copyLink.href = 'javascript:void(0);';
copyLink.className = 'copyCode';
copyLink.innerHTML = 'Copy code';
Galleries.attachEventHandler(copyLink, 'click', function (e) {
clipboardData.setData("Text", htmlDecode(labelElems[scriptBlock.activeTab].code));
return false;
});
scriptBlock.insertBefore(copyLink, scriptBlock.childNodes[0]);
}
}
});
}
Galleries.onWindowLoad(function(){
initializePage();
});
</script>
<div id="longDesc">
<p>The latest version of this sample is hosted on <a href="https://code.msdn.microsoft.com/DirectInput-Samples-8ac6f5e3/https://github.com/walbourn/directx-sdk-samples">
GitHub</a>.</p>
<p>These are the original DirectX SDK Win32 samples for the legacy <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ee418273.aspx">
DirectInput</a> API updated to build with Visual Studio 2012 without using the DirectX SDK.</p>
<p><strong>These samples are based on legacy DirectX SDK DirectInput samples that were shipped as part of the DirectX 8.0 SDK (circa 2000) for Win32 desktop applications running on Windows XP, Windows Vista, Windows 7, and Windows 8. This is not intended for
use with Windows Store apps or Windows RT.</strong></p>
<p><em>The DirectInput API is not available for&nbsp;Windows Store apps or on Windows RT (aka Windows on ARM). The Xbox 360 Common Controller and the XINPUT API is the recommended solution for modern game controllers and is supported on these platforms.</em></p>
<p><em>The DirectInput API is not recommended for use for traditional mouse and keyboard data, and use of standard Win32 messages is preferred. This is why the older DirectX SDK samples &quot;Keyboard&quot; and &quot;Mouse&quot; are not included in the latest DirectX SDK or this&nbsp;
package.</em></p>
<p><em>The DirectInput API's remaining utility is for driving HID-only game controllers, haptic devices, and custom force-feedback devices.</em></p>
<h1>Description</h1>
<h2>CustomFormat</h2>
<p><img src="description/CustomFormat.gif" alt="" width="90" height="93"></p>
<p>This sample illustrates the use of a custom data format.</p>
<p><strong>Note:</strong> If your mouse has more than four buttons, not all of the buttons will be used by this sample.</p>
<p>The comments in CustomFormat.cpp explain how to create, initialize, and retrieve data with a custom data format. You might want to use a custom data format for adding support for a non-standard input device. By enumerating the device objects, you can determine&nbsp;
exactly what data is available. The data format you create specifies how the data you are interested in will be stored.</p>
<p>For compatibility, this sample creates a new format to store mouse data. Usually, you would want to use one of the provided c_dfDIMouse types, but the steps taken to create the custom format will be the same for any hardware device. For more information,&nbsp;
see IDirectInputDevice8::SetDataFormat.</p>
<h2>FFCont</h2>
<p><img src="description/ffconst.gif" alt="" width="90" height="122"></p>
<div class="hxnx1" id="Description">
<p>The FFConst sample program applies raw forces to a force-feedback input device, illustrating how a simulator-type application can use force feedback to generate forces computed by a physics engine.</p>
<p>You must have a force-feedback device connected to your system in order to run the application.</p>
<p>When you run the application, it displays a window with a crosshair and a black spot in it. Click anywhere within the window's client area to move the black spot. (Note that moving the device itself does not do anything.) FFConst exerts&nbsp; a constant&nbsp;
force on the device from the direction of the spot, in proportion to the distance from the crosshair. You can also hold down the mouse button and move the spot continuously.</p>
<p>This sample program enumerates the input devices and acquires the first force-feedback device that it finds. If none are detected, it displays a message and terminates.</p>
<p>When the user moves the black spot, joySetForcesXY function converts the cursor coordinates to a force direction and magnitude. This data is used to modify the parameters of the constant force effect.</p>
</div>
<h2>Joystick</h2>
<p><img src="description/joystick.gif" alt="" width="90" height="101"></p>
<p>The Joystick sample program obtains and displays joystick data.</p>
<p>The application polls the joystick for immediate data in response to a timer set inside the dialog procedure.</p>
<h1>Building for Windows XP</h1>
<p>The DirectInput legacy API is available on Windows XP, so this sample can be built using Visual Studio 2012 with the Windows XP compatible Platform Toolset &quot;v110_xp&quot; included with
<em>Visual Studio 2012 Update 1</em>. Remove the link references to <code>DXGUID.LIB</code>. You will need to locally define the required GUIDs by using
<code>#define INITGUID</code> before including <code>dinput.h</code> in one of the modules.</p>
<h1>Building with Visual Studio 2010</h1>
<p>It is possible to modify these projects to build with Visual Studio 2010 without using the legacy DirectX SDK. Set the Platform Toolset to &quot;v100&quot; for all configurations, and then remove the link references to
<code>DXGUID.LIB</code>. You will need to locally&nbsp; define the required GUIDs by using
<code>#define INITGUID</code> before including <code>dinput.h</code> in one of the modules.</p>
<h1>Building with Visual Studio 2013</h1>
<p>This sample can be modified to build with Visual Studio 2013 using the Windows 8.1 SDK.</p>
<p>You can allow VS 2013 to upgrade the projects in place to use Platform Toolset &quot;v120&quot;</p>
<h1>Notes</h1>
<ul>
<li>These samples use DirectInput8. The DirectInput7 API is not supported for x64 native applications. The Windows 8.0 SDK only includes the DirectInput8 link library (<code>dinput8.lib</code>), and DirectInput7 was last supported by the DirectX SDK (August
2007) release. </li><li>The Xbox 360 Common Controller driver exposes a legacy HID device for compatability with older DirectInput only applications. Such a device can be used with the Joystick sample as a result.
</li><li>This Xbox One driver for Windows also exposes a legacy HID device that behaves exactly as the Xbox 360 Common Controller driver's HID device support.
</li><li>Legacy joysticks using a &quot;gameport&quot; are not supported for Windows Vista, Windows 7, or Windows 8. Only HID-based USB devices are supported.
</li><li>The &quot;ActionMapper&quot; functionality was removed from DirectInput as of Windows Vista and is no longer supported.
</li></ul>
<h1>Version History</h1>
<ul>
<li>July 28, 2014 - Minor code cleanup </li><li>May 21, 2012 - Initial release of cleanup from legacy DirectX SDK </li></ul>
<h1>More Information</h1>
<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014.aspx">XINPUT and DirectInput</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ee418864.aspx">Taking Advantage of High-Definition Mouse Movement</a></p>
<p><a href="http://blogs.msdn.com/b/chuckw/archive/2012/03/22/where-is-the-directx-sdk.aspx">Where is the DirectX SDK?</a></p>
<p><a href="http://blogs.msdn.com/b/chuckw/archive/2013/07/01/where-is-the-directx-sdk-2013-edition.aspx">Where is the DirectX SDK (2013 Edition)?</a></p>
<p><a href="http://blogs.msdn.com/b/chuckw/archive/2012/11/26/visual-studio-2012-update-1.aspx">Visual Studio 2012 Update 1</a></p>
</div>
</div>
</body>
</html>