青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當(dāng)自強(qiáng)而不息

使用DirectInput進(jìn)行交互(1)


輸入設(shè)備簡(jiǎn)介

計(jì)算機(jī)通常使用三種輸入設(shè)備:鍵盤、鼠標(biāo)和游戲桿。三種輸入設(shè)備都是其他設(shè)備所無法替代的,同時(shí)每種設(shè)備都各有優(yōu)缺點(diǎn)。鍵盤適用于輸入,但無法取代鼠標(biāo),而且和游戲桿相比,鍵盤也不如游戲桿那么靈巧。鼠標(biāo)適用于定位和移動(dòng),但是和游戲桿相比,又缺少控制上的簡(jiǎn)易性。至于游戲桿,它適用于簡(jiǎn)單的移動(dòng)----向上、向下、向左和向右移動(dòng),除此之外幾乎無任何用途。


通過鍵盤進(jìn)行交互

基本上,鍵盤是按照一定邏輯格式排列的按鍵矩陣。除開一些微小差別之外,大多數(shù)鍵盤都有一種標(biāo)準(zhǔn)布局。鍵盤上的每個(gè)鍵實(shí)際上都是一個(gè)開關(guān),當(dāng)按下或者釋放一個(gè)鍵的時(shí)候,就觸發(fā)了這個(gè)開關(guān)。按下或者釋放一個(gè)鍵就向鍵盤的微處理器發(fā)送了一個(gè)信號(hào),這樣就在計(jì)算機(jī)系統(tǒng)上產(chǎn)生了一個(gè)中段(interrupt)。系統(tǒng)從鍵盤的微處理器接收數(shù)據(jù),從而確定按下或者釋放了哪個(gè)鍵,接收的數(shù)據(jù)被稱為掃描碼(scan code)。

中斷是各種各樣的信號(hào),它通知系統(tǒng)一個(gè)設(shè)備或程序需要立即進(jìn)行處理,使用中斷確保了系統(tǒng)知道設(shè)備的狀態(tài)已經(jīng)發(fā)生了改變。掃描碼是一些值,它們確定了鍵盤上的哪個(gè)鍵被按下或釋放了。這些掃描碼都是一個(gè)字節(jié)(操作系統(tǒng)可以使用很多方法來表示掃描碼),字節(jié)的一部分表示包含了哪個(gè)按鍵,一個(gè)位表示鍵是否被按下或釋放。掃描碼只能識(shí)別單個(gè)按鍵,無法區(qū)分大寫和小寫字母。因此,大寫字母A和小寫字母a擁有相同的掃描碼,通過跟蹤是否按住了Shift鍵,操作系統(tǒng)自動(dòng)檢測(cè)和區(qū)分大小寫字母。

如下圖所示,這是一個(gè)典型的101-102鍵盤,鍵盤的局部放大圖顯示了一些帶有相應(yīng)掃描碼的鍵,掃描碼是位編碼數(shù)字。

注意掃描碼是按照鍵盤上的順序進(jìn)行排列的,每行中位于右邊的鍵通常是更高的掃描碼。掃描碼的最低7位(位0--6)表示了鍵值(被按下或者釋放的那個(gè)鍵),同時(shí)掃描碼的最高位(位7)表示此鍵是否被按下(該位被設(shè)置)或者釋放(該位被清除)。字節(jié)最高能夠表示的數(shù)字是255,且最高位保留,這樣就給出了128個(gè)鍵的空間。


在windows中處理鍵盤

windows能夠處理檢索鍵盤輸入的一般性任務(wù),為了使工作變得更加容易,windows將從鍵盤接收到的掃描碼轉(zhuǎn)化成虛擬鍵碼以及ASCII碼的標(biāo)準(zhǔn)碼。windows采用許多方法將這些值報(bào)告給程序員,不過通常使用消息過程函數(shù)。

虛擬鍵碼是windows版本的掃描碼,舉例來說,字母A的掃描碼為30,但是虛擬鍵碼不使用這個(gè)值,而是使用虛擬鍵碼宏VK_A來表示字母A,不管使用什么樣的鍵盤(以及鍵盤報(bào)告的掃描碼),VK_A總是表示字母A。

ASCII(美國(guó)信息交換標(biāo)準(zhǔn)碼,American Standard Code for Information Interchange)是一個(gè)標(biāo)準(zhǔn),它規(guī)定了哪個(gè)值被映射到哪個(gè)字符。使用ASCII能夠?yàn)槎噙_(dá)128個(gè)不同字符映射值,這些字符包括數(shù)字、字母表、一般符號(hào)以及控制碼。

windows實(shí)際使用的是擴(kuò)展ASCII碼以及unicode字符(或?qū)捵止?jié)字符)。擴(kuò)展ASCII碼在規(guī)則ASCII上添加了信息的額外位,因此將字母的最大數(shù)目提升到了256。這樣做也帶來了不利的方面----擴(kuò)展字符可以是任何東西,因?yàn)闆]有實(shí)質(zhì)標(biāo)準(zhǔn)來約束這些字符。當(dāng)然,因?yàn)橛行┢渌Z(yǔ)言需要更多的字符,因此Unicode就應(yīng)運(yùn)而生,它將字符的最大數(shù)目擴(kuò)展到了16位,足夠存儲(chǔ)65536個(gè)字符。


使用DirectInput

DirectInput是一些COM對(duì)象的集合(和所有DirectX組件相同),這些COM對(duì)象描繪了輸入系統(tǒng)和各個(gè)輸入設(shè)備。最主要的對(duì)象是DirectInput8,它用于初始化系統(tǒng)以及創(chuàng)建輸入設(shè)備接口。

DirectInput COM對(duì)象:

IDirectInput8:主要的DirectInput8 COM接口,其他所有接口都通過這個(gè)接口進(jìn)行查詢。
DirectInputDevice8:用于輸入設(shè)備的COM接口,每個(gè)設(shè)備都有自己?jiǎn)为?dú)的接口可供使用。
DirectInputEffect:用于力反饋效果的 COM接口,比如某些游戲桿和某些鼠標(biāo)上的力反饋效果。

各種輸入設(shè)備(比如鍵盤、鼠標(biāo)和游戲桿)都使用相同的接口對(duì)象IDirectInputDevice8。某些設(shè)備,比如游戲桿和鼠標(biāo),能夠通過查詢各自的 IDirectInputDevice8對(duì)象以得到另外一個(gè)接口IDirectInputEffect,這個(gè)接口用于控制設(shè)備的力反饋效果。

IDirectInput8、IDirectInputDevice8、IDirectInputEffect接口之間的關(guān)系如下圖所示:

IDirectInput8組件對(duì)象包含了很多用于初始化輸入系統(tǒng)以及獲得設(shè)備接口的函數(shù),在這些函數(shù)中,常用的只有兩個(gè),它們是 IDirectInput8::EnumDevices和IDirectInput8::CreateDevice。

初始化DirectInput

要使用DirectInput,需要確保包含了DInput.h和在工程中鏈接了DInput8.lib,一個(gè)IDirectInput8對(duì)象就代表了主要DirectInput對(duì)象。
DirectInput提供了幫助函數(shù)DirectInput8Create用于初始化IDirectInput8接口。

Creates a DirectInput object and returns an IDirectInput8 Interface or later interface.

HRESULT DirectInput8Create(
HINSTANCE hinst,
DWORD dwVersion,
REFIID riidltf,
LPVOID * ppvOut,
LPUNKNOWN punkOuter
);

Parameters

hinst
Instance handle to the application or dynamic-link library (DLL) that is creating the DirectInput object. DirectInput uses this value to determine whether the application or DLL has been certified and to establish any special behaviors that might be necessary for backward compatibility. It is an error for a DLL to pass the handle to the parent application. For example, an Microsoft ActiveX control embedded in a Web page that uses DirectInput must pass its own instance handle, and not the handle to the browser. This ensures that DirectInput recognizes the control and can enable any special behaviors that might be necessary.
dwVersion
Version number of DirectInput for which the application is designed. This value is normally DIRECTINPUT_VERSION. If the application defines DIRECTINPUT_VERSION before including Dinput.h, the value must be greater than 0x0800. For earlier versions, use DirectInputCreateEx, which is in Dinput.lib.
riidltf
Unique identifier of the desired interface. This value is IID_IDirectInput8A or IID_IDirectInput8W. Passing the IID_IDirectInput8 define selects the ANSI or Unicode version of the interface, depending on whether UNICODE is defined during compilation.
ppvOut
Address of a pointer to a variable to receive the interface pointer if the call succeeds.
punkOuter
Pointer to the address of the controlling object's IUnknown interface for COM aggregation, or NULL if the interface is not aggregated. Most calling applications pass NULL. If aggregation is requested, the object returned in ppvOut is a pointer to IUnknown, as required by COM aggregation.

Return Values

If the function succeeds, the return value is DI_OK. If the function fails, the return value can be one of the following error values: DIERR_BETADIRECTINPUTVERSION, DIERR_INVALIDPARAM, DIERR_OLDDIRECTINPUTVERSION, DIERR_OUTOFMEMORY.

Remarks

The DirectInput object created by this function is implemented in Dinput8.dll. Versions of interfaces earlier than DirectX 8.0 cannot be obtained in this implementation.

To create a DirectX 8.x interface with the latest DirectX SDK without using CoCreateInstance:

  1. Set "#define DIRECTINPUT_VERSION 0x0800" before the include statement for Dinput8.h.
  2. Call DirectInput8Create instead of DirectInputCreateEx.
  3. Link to the Dinput8.lib library instead of Dinput.lib.

To create a DirectX 8.x interface with the DirectX 8.x SDK without using CoCreateInstance:

  1. Call DirectInput8Create instead of DirectInputCreateEx.
  2. Link to the Dinput8.lib library instead of Dinput.lib.

To create a DirectX 7.0 interface from the DirectX 8.x or latest DirectX SDK without using CoCreateInstance:

  1. Set "#define DIRECTINPUT_VERSION 0x0700" before the include statement for dinput.h.
  2. Call DirectInputCreateEx instead of DirectInput8Create.
  3. Link to the Dinput.lib library instead of Dinput8.lib.

To create a DirectX 7.0 interface from the DirectX 8.x or latest DirectX SDK using CoCreateInstance:

  1. Call CoInitializeEx.
  2. Call CoCreateInstance using CLISID_DirectInput.
  3. Use IDirectInput7::Initialize to initialize the DirectInput object.

To create a DirectX 8.x or DirectX 9.0 interface from the DirectX 8.x or latest DirectX SDK using CoCreateInstance:

  1. Call CoInitializeEx.
  2. Call CoCreateInstance using CLISID_DirectInput8.
  3. Use IDirectInput8::Initialize to initialize the DirectInput object.

Calling the function with pUnkOuter = NULL is equivalent to creating the object through CoCreateInstance( &CLSID_DirectInput8, punkOuter, CLSCTX_INPROC_SERVER, &IID_IDirectInput8W, lplpDirectInput), then initializing it with IDirectInput8::Initialize.

Calling the function with pUnkOuter != NULL is equivalent to creating the object through CoCreateInstance( &CLSID_DirectInput8, punkOuter, CLSCTX_INPROC_SERVER, &IID_IUnknown, lplpDirectInput). The aggregated object must be initialized manually.


使用DirectInput設(shè)備的步驟

1、獲取設(shè)備GUID,調(diào)用IDirectInput8::EnumDevice來實(shí)現(xiàn)。
2、創(chuàng)建設(shè)備COM對(duì)象,調(diào)用IDirectInput8::CreateDevice來實(shí)現(xiàn)。
3、設(shè)置數(shù)據(jù)格式,調(diào)用IDirectInputDevice8::SetDataFormat來實(shí)現(xiàn)。
4、設(shè)置協(xié)作級(jí)別,調(diào)用IDirectInputDevice8::SetCooperativeLevel來實(shí)現(xiàn)。
5、設(shè)置任何特殊屬性,調(diào)用IDirectInputDevice8::SetProperty來實(shí)現(xiàn)。
6、獲得設(shè)備,調(diào)用IDirectInputDevice8::Acquire來實(shí)現(xiàn)。
7、輪詢?cè)O(shè)備,調(diào)用IDirectInputDevice8::Poll來實(shí)現(xiàn)。
8、讀取數(shù)據(jù),調(diào)用IDirectInputDevice8::GetDeviceState來實(shí)現(xiàn)。

在進(jìn)行這些步驟前,要確保聲明了一個(gè)IDirectInput設(shè)備對(duì)象,即IDirectInputDevice8對(duì)象。

獲取設(shè)備GUID

每個(gè)安裝的設(shè)備都有一個(gè)系統(tǒng)分配的全局惟一標(biāo)識(shí)符(global unique identification, GUID)數(shù)字。要使用一個(gè)設(shè)備,首先必須知道它的GUID。對(duì)于連接到系統(tǒng)上的鼠標(biāo)和鍵盤,得到他們的GUID非常容易,DirectInput分別為鼠標(biāo)和鍵盤的GUID定義成GUID_SysKeyboard和GUID_SysMouse。要使用GUID_SysKeyboard或 GUID_SysMouse,必須在所有其他的預(yù)處理程序指令前定義INITGUID,或者將DXGuid.lib庫(kù)鏈接到項(xiàng)目中。至于其他設(shè)備,必須枚舉出這些設(shè)備,才能得到需要的那些設(shè)備的GUID。枚舉就是遍歷一個(gè)含有數(shù)據(jù)項(xiàng)的列表的過程,數(shù)據(jù)項(xiàng)就是諸如游戲桿之類的輸入設(shè)備。假設(shè)有5個(gè)游戲桿連接到了系統(tǒng)上,那么在枚舉的過程中,DirectInput就會(huì)傳遞各個(gè)游戲桿的相關(guān)信息,而且每次只傳遞一個(gè)游戲桿的信息,直到所有的游戲桿都已經(jīng)被列出來或者列舉被強(qiáng)行終止。

用于枚舉設(shè)備的函數(shù)是IDirectInput8::EnumDevice。

Enumerates available devices.

HRESULT EnumDevices(
DWORD dwDevType,
LPDIENUMDEVICESCALLBACK lpCallback,
LPVOID pvRef,
DWORD dwFlags
);

Parameters

dwDevType

Device type filter.

To restrict the enumeration to a particular type of device, set this parameter to a DI8DEVTYPE_* value. See DIDEVICEINSTANCE.

To enumerate a class of devices, use one of the following values.

 

DI8DEVCLASS_ALL
All devices.
DI8DEVCLASS_DEVICE
All devices that do not fall into another class.
DI8DEVCLASS_GAMECTRL
All game controllers.
DI8DEVCLASS_KEYBOARD
All keyboards. Equivalent to DI8DEVTYPE_KEYBOARD.
DI8DEVCLASS_POINTER
All devices of type DI8DEVTYPE_MOUSE and DI8DEVTYPE_SCREENPOINTER.
lpCallback
Address of a callback function to be called once for each device enumerated. See DIEnumDevicesCallback.
pvRef
Application-defined 32-bit value to be passed to the enumeration callback each time it is called.
dwFlags
Flag value that specifies the scope of the enumeration. This parameter can be one or more of the following values:
DIEDFL_ALLDEVICES
All installed devices are enumerated. This is the default behavior.
DIEDFL_ATTACHEDONLY
Only attached and installed devices.
DIEDFL_FORCEFEEDBACK
Only devices that support force feedback.
DIEDFL_INCLUDEALIASES
Include devices that are aliases for other devices.
DIEDFL_INCLUDEHIDDEN
Include hidden devices. For more information about hidden devices, see DIDEVCAPS.
DIEDFL_INCLUDEPHANTOMS
Include phantom (placeholder) devices.

Return Values

If the method succeeds, the return value is DI_OK. If the method fails, the return value can be one of the following error values: DIERR_INVALIDPARAM, DIERR_NOTINITIALIZED.

Remarks

All installed devices can be enumerated, even if they are not present. For example, a flight stick might be installed on the system but not currently plugged into the computer. Set the dwFlags parameter to indicate whether only attached or all installed devices should be enumerated. If the DIEDFL_ATTACHEDONLY flag is not present, all installed devices are enumerated.

A preferred device type can be passed as a dwDevType filter so that only the devices of that type are enumerated.

On Microsoft Windows XP, DirectInput enumerates only one mouse and one keyboard device, referred to as the system mouse and the system keyboard. These devices represent the combined output of all mice and keyboards respectively on a system. For information about how to read from multiple mice or keyboards individually on Windows XP, see the WM_INPUT documentation.

Note    The order in which devices are enumerated by DirectInput is not guaranteed.



lpCallback是一個(gè)指向枚舉函數(shù)的指針,在系統(tǒng)上每找到一個(gè)匹配的設(shè)備時(shí),就會(huì)調(diào)用該函數(shù)。
 

Application-defined callback function that receives DirectInput devices as a result of a call to the IDirectInput8::EnumDevices method.

BOOL DIEnumDevicesCallback(
LPCDIDEVICEINSTANCE lpddi,
LPVOID pvRef
);

Parameters

lpddi
Address of a DIDEVICEINSTANCE structure that describes the device instance.
pvRef
The application-defined value passed to IDirectInput8::EnumDevices or IDirectInput8::EnumDevicesBySemantics as the pvRef parameter.

Return Values

Returns DIENUM_CONTINUE to continue the enumeration or DIENUM_STOP to stop the enumeration.

Remarks

If a single hardware device can function as more than one DirectInput device type, it is enumerated as each device type that it supports. For example, a keyboard with a built-in mouse is enumerated twice: once as a keyboard and once as a mouse. The product globally unique identifier (GUID) is the same for each device, however.



lpddi是一個(gè)指向DIDEVICEINSTANCE結(jié)構(gòu)體的指針,此結(jié)構(gòu)體包含了此次調(diào)用時(shí)當(dāng)前枚舉設(shè)備上的信息。

Describes an instance of a DirectInput device. This structure is used with the IDirectInput8::EnumDevices, IDirectInput8::EnumDevicesBySemantics, and IDirectInputDevice8::GetDeviceInfo methods.

typedef struct DIDEVICEINSTANCE {
DWORD dwSize;
GUID guidInstance;
GUID guidProduct;
DWORD dwDevType;
TCHAR tszInstanceName[MAX_PATH];
TCHAR tszProductName[MAX_PATH];
GUID guidFFDriver;
WORD wUsagePage;
WORD wUsage;
} DIDEVICEINSTANCE, *LPDIDEVICEINSTANCE;

Members

dwSize
Size of this structure, in bytes. This member must be initialized before the structure is used.
guidInstance
Unique identifier for the instance of the device. An application can save the instance globally unique identifier (GUID) into a configuration file and use it at a later time. Instance GUIDs are specific to a particular computer. An instance GUID obtained from one computer is unrelated to instance GUIDs on another.
guidProduct
Unique identifier for the product. This identifier is established by the manufacturer of the device.
dwDevType
Device type specifier. The least-significant byte of the device type description code specifies the device type. The next-significant byte specifies the device subtype. This value can also be combined with DIDEVTYPE_HID, which specifies a Human Interface Device (human interface device).
tszInstanceName
Friendly name for the instance. For example, "Joystick 1."
tszProductName
Friendly name for the product.
guidFFDriver
Unique identifier for the driver being used for force feedback. The driver's manufacturer establishes this identifier.
wUsagePage
If the device is a Human Interface Device (HID), this member contains the HID usage page code.
wUsage
If the device is a Human Interface Device (HID), this member contains the HID usage code.

Remarks

The following device types and subtypes are defined for use in the dwDevType member.

  • DI8DEVTYPE_1STPERSON

    First-person action game device. The following subtypes are defined.

    • DI8DEVTYPE1STPERSON_LIMITED

      Device that does not provide the minimum number of device objects for action mapping.

    • DI8DEVTYPE1STPERSON_SHOOTER

      Device designed for first-person shooter games.

    • DI8DEVTYPE1STPERSON_SIXDOF

      Device with six degrees of freedom; that is, three lateral axes and three rotational axes.

    • DI8DEVTYPE1STPERSON_UNKNOWN

      Unknown subtype.

  • DI8DEVTYPE_DEVICE

    Device that does not fall into another category.

  • DI8DEVTYPE_DEVICECTRL

    Input device used to control another type of device from within the context of the application. The following subtypes are defined.

    • DI8DEVTYPEDEVICECTRL_COMMSSELECTION

      Control used to make communications selections.

    • DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED

      Device that must use its default configuration and cannot be remapped.

    • DI8DEVTYPEDEVICECTRL_UNKNOWN

      Unknown subtype.

  • DI8DEVTYPE_DRIVING

    Device for steering. The following subtypes are defined.

    • DI8DEVTYPEDRIVING_COMBINEDPEDALS

      Steering device that reports acceleration and brake pedal values from a single axis.

    • DI8DEVTYPEDRIVING_DUALPEDALS

      Steering device that reports acceleration and brake pedal values from separate axes.

    • DI8DEVTYPEDRIVING_HANDHELD

      Hand-held steering device.

    • DI8DEVTYPEDRIVING_LIMITED

      Steering device that does not provide the minimum number of device objects for action mapping.

    • DI8DEVTYPEDRIVING_THREEPEDALS

      Steering device that reports acceleration, brake, and clutch pedal values from separate axes.

  • DI8DEVTYPE_FLIGHT

    Controller for flight simulation. The following subtypes are defined.

    • DI8DEVTYPEFLIGHT_LIMITED

      Flight controller that does not provide the minimum number of device objects for action mapping.

    • DI8DEVTYPEFLIGHT_RC

      Flight device based on a remote control for model aircraft.

    • DI8DEVTYPEFLIGHT_STICK

      Joystick.

    • DI8DEVTYPEFLIGHT_YOKE

      Yoke.

  • DI8DEVTYPE_GAMEPAD

    Gamepad. The following subtypes are defined.

    • DI8DEVTYPEGAMEPAD_LIMITED

      Gamepad that does not provide the minimum number of device objects for action mapping.

    • DI8DEVTYPEGAMEPAD_STANDARD

      Standard gamepad that provides the minimum number of device objects for action mapping.

    • DI8DEVTYPEGAMEPAD_TILT

      Gamepad that can report x-axis and y-axis data based on the attitude of the controller.

  • DI8DEVTYPE_JOYSTICK

    Joystick. The following subtypes are defined.

    • DI8DEVTYPEJOYSTICK_LIMITED

      Joystick that does not provide the minimum number of device objects for action mapping.

    • DI8DEVTYPEJOYSTICK_STANDARD

      Standard joystick that provides the minimum number of device objects for action mapping.

  • DI8DEVTYPE_KEYBOARD

    Keyboard or keyboard-like device. The following subtypes are defined.

    • DI8DEVTYPEKEYBOARD_UNKNOWN

      Subtype could not be determined.

    • DI8DEVTYPEKEYBOARD_PCXT

      IBM PC/XT 83-key keyboard.

    • DI8DEVTYPEKEYBOARD_OLIVETTI

      Olivetti 102-key keyboard.

    • DI8DEVTYPEKEYBOARD_PCAT

      IBM PC/AT 84-key keyboard.

    • DI8DEVTYPEKEYBOARD_PCENH

      IBM PC Enhanced 101/102-key or Microsoft Natural keyboard.

    • DI8DEVTYPEKEYBOARD_NOKIA1050

      Nokia 1050 keyboard.

    • DI8DEVTYPEKEYBOARD_NOKIA9140

      Nokia 9140 keyboard.

    • DI8DEVTYPEKEYBOARD_NEC98

      Japanese NEC PC98 keyboard.

    • DI8DEVTYPEKEYBOARD_NEC98LAPTOP

      Japanese NEC PC98 laptop keyboard.

    • DI8DEVTYPEKEYBOARD_NEC98106

      Japanese NEC PC98 106-key keyboard.

    • DI8DEVTYPEKEYBOARD_JAPAN106

      Japanese 106-key keyboard.

    • DI8DEVTYPEKEYBOARD_JAPANAX

      Japanese AX keyboard.

    • DI8DEVTYPEKEYBOARD_J3100

      Japanese J3100 keyboard.

  • DI8DEVTYPE_MOUSE

    A mouse or mouse-like device (such as a trackball). The following subtypes are defined.

    • DI8DEVTYPEMOUSE_ABSOLUTE

      Mouse that returns absolute axis data.

    • DI8DEVTYPEMOUSE_FINGERSTICK

      Fingerstick.

    • DI8DEVTYPEMOUSE_TOUCHPAD

      Touchpad.

    • DI8DEVTYPEMOUSE_TRACKBALL

      Trackball.

    • DI8DEVTYPEMOUSE_TRADITIONAL

      Traditional mouse.

    • DI8DEVTYPEMOUSE_UNKNOWN

      Subtype could not be determined.

  • DI8DEVTYPE_REMOTE

    Remote-control device. The following subtype is defined.

    • DI8DEVTYPEREMOTE_UNKNOWN

      Subtype could not be determined.

  • DI8DEVTYPE_SCREENPOINTER

    Screen pointer. The following subtypes are defined.

    • DI8DEVTYPESCREENPTR_UNKNOWN

      Unknown subtype.

    • DI8DEVTYPESCREENPTR_LIGHTGUN

      Light gun.

    • DI8DEVTYPESCREENPTR_LIGHTPEN

      Light pen.

    • DI8DEVTYPESCREENPTR_TOUCH

      Touch screen.

  • DI8DEVTYPE_SUPPLEMENTAL

    Specialized device with functionality unsuitable for the main control of an application, such as pedals used with a wheel. The following subtypes are defined.

    • DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER

      Secondary handheld controller.

    • DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS

      Device whose primary function is to report acceleration and brake pedal values from a single axis.

    • DI8DEVTYPESUPPLEMENTAL_DUALPEDALS

      Device whose primary function is to report acceleration and brake pedal values from separate axes.

    • DI8DEVTYPESUPPLEMENTAL_HANDTRACKER

      Device that tracks hand movement.

    • DI8DEVTYPESUPPLEMENTAL_HEADTRACKER

      Device that tracks head movement.

    • DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS

      Device with rudder pedals.

    • DI8DEVTYPESUPPLEMENTAL_SHIFTER

      Device that reports gear selection from an axis.

    • DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE

      Device that reports gear selection from button states.

    • DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE

      Device whose primary function is to report at least two throttle values. It may have other controls.

    • DI8DEVTYPESUPPLEMENTAL_THREEPEDALS

      Device whose primary function is to report acceleration, brake, and clutch pedal values from separate axes.

    • DI8DEVTYPESUPPLEMENTAL_THROTTLE

      Device whose primary function is to report a single throttle value. It may have other controls.

    • DI8DEVTYPESUPPLEMENTAL_UNKNOWN

      Unknown subtype.

Versions of DirectInput earlier than DirectX 8.0 have a somewhat different scheme of device types and subtypes. See the DIDEVTYPExxx defines in Dinput.h.


創(chuàng)建設(shè)備COM對(duì)象

有了設(shè)備GUID,就能創(chuàng)建實(shí)際的IDirectInputDevice8 COM對(duì)象了,用于創(chuàng)建此COM對(duì)象的函數(shù)是IDirectInput8::CreateDevice。

Creates and initializes an instance of a device based on a given globally unique identifier (GUID), and obtains an IDirectInputDevice8 Interface interface.

HRESULT CreateDevice(
REFGUID rguid,
LPDIRECTINPUTDEVICE * lplpDirectInputDevice,
LPUNKNOWN pUnkOuter
);

Parameters

rguid
Reference to the GUID for the desired input device (see Remarks). The GUID is retrieved through the IDirectInput8::EnumDevices method, or it can be one of the predefined GUIDs listed below. For the following GUID values to be valid, your application must define INITGUID before all other preprocessor directives at the beginning of the source file, or link to Dxguid.lib.
GUID_SysKeyboard
The default system keyboard.
GUID_SysMouse
The default system mouse.
lplpDirectInputDevice
Address of a variable to receive the IDirectInputDevice8 Interface interface pointer if successful.
pUnkOuter
Address of the controlling object's IUnknown interface for COM aggregation, or NULL if the interface is not aggregated. Most calling applications pass NULL.

Return Values

If the method succeeds, the return value is DI_OK. If the method fails, the return value can be one of the following: DIERR_DEVICENOTREG, DIERR_INVALIDPARAM, DIERR_NOINTERFACE, DIERR_NOTINITIALIZED, DIERR_OUTOFMEMORY.

Remarks

Calling this method with pUnkOuter = NULL is equivalent to creating the object by CoCreateInstance (&CLSID_DirectInputDevice, NULL, CLSCTX_INPROC_SERVER, riid, lplpDirectInputDevice) and then initializing it with Initialize.

Calling this method with pUnkOuter != NULL is equivalent to creating the object by CoCreateInstance (&CLSID_DirectInputDevice, punkOuter, CLSCTX_INPROC_SERVER, &IID_IUnknown, lplpDirectInputDevice). The aggregated object must be initialized manually.

 

閱讀下篇:使用DirectInput進(jìn)行交互(2)

posted on 2007-07-24 01:23 lovedday 閱讀(3671) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲黄色尤物视频| 亚洲激情一区二区三区| 欧美主播一区二区三区| 亚洲一卡久久| 亚洲一区在线观看视频| 香蕉成人久久| 久久久国产一区二区| 久久精品国产亚洲一区二区| 久久深夜福利| 欧美国产视频在线| 国产精品久久久久999| 国产欧美综合一区二区三区| 国产精品一区二区在线| 国产亚洲精品v| 欧美成人性生活| 欧美亚洲尤物久久| 欧美综合国产| 欧美在线亚洲综合一区| 久久久久亚洲综合| 免费成人高清视频| 欧美三级乱码| 国产在线精品二区| 一区免费视频| 亚洲狼人综合| 午夜亚洲福利| 亚洲国产日韩在线一区模特| 亚洲精品人人| 久久er精品视频| 欧美电影在线观看| 国产精品区二区三区日本| 激情亚洲成人| 亚洲一区在线观看视频| 女女同性女同一区二区三区91| 99精品福利视频| 久久亚洲精品一区| 国产精品欧美久久| 亚洲精品视频一区二区三区| 欧美在线视频a| 亚洲美女视频| 欧美aⅴ99久久黑人专区| 国产日韩欧美a| 亚洲免费小视频| 亚洲人人精品| 免费在线欧美黄色| 韩国美女久久| 久久久国产亚洲精品| 亚洲视频大全| 欧美日本中文| 亚洲肉体裸体xxxx137| 久久―日本道色综合久久| 亚洲亚洲精品在线观看| 欧美日韩久久久久久| 99精品久久免费看蜜臀剧情介绍| 免费不卡在线视频| 欧美主播一区二区三区美女 久久精品人| 欧美色精品天天在线观看视频| 亚洲日本电影在线| 欧美国产激情| 欧美成人精品不卡视频在线观看| 尤物精品在线| 欧美顶级大胆免费视频| 开心色5月久久精品| 在线欧美电影| 欧美成人亚洲成人| 欧美a级片一区| 日韩亚洲精品在线| 亚洲精品欧美一区二区三区| 蜜臀av在线播放一区二区三区| 91久久久亚洲精品| 久久精品国产精品亚洲| 国产一区二区三区四区hd| 欧美永久精品| 亚洲欧美在线一区| 国产日韩欧美亚洲一区| 久久经典综合| 久久免费精品视频| 亚洲精品五月天| 日韩亚洲综合在线| 欧美午夜欧美| 久久精品系列| 欧美国产日韩视频| 亚洲一区二区三区中文字幕| 亚洲一区二区伦理| 狠狠色综合色综合网络| 亚洲国产精品传媒在线观看| 欧美激情国产日韩精品一区18| 一区二区三区鲁丝不卡| 亚洲字幕在线观看| 亚洲丁香婷深爱综合| 亚洲黄色成人久久久| 国产精品女同互慰在线看| 久久综合久久美利坚合众国| 欧美高清视频一区| 欧美一区二粉嫩精品国产一线天| 久久黄色级2电影| 99精品国产高清一区二区| 亚洲综合三区| 亚洲精品视频免费观看| 亚洲一区二区三区精品在线观看| 国产无一区二区| 亚洲欧洲一区二区三区在线观看 | 亚洲无线视频| 在线播放日韩专区| 夜夜夜久久久| 亚洲欧洲日夜超级视频| 亚洲一区二区视频在线观看| 在线激情影院一区| 亚洲一区二区高清| 亚洲看片一区| 久久亚洲欧美| 久久福利影视| 欧美日韩四区| 欧美成人一区在线| 国产日本欧美在线观看| 99在线精品视频在线观看| 亚洲高清视频一区二区| 亚洲一区二区在| 中文在线资源观看网站视频免费不卡 | 久久天天躁狠狠躁夜夜爽蜜月| 欧美区一区二| 蜜桃精品一区二区三区| 国产美女扒开尿口久久久| 亚洲美女精品成人在线视频| 精品成人在线视频| 亚洲欧美成人网| 亚洲二区在线观看| 欧美一区二区三区精品| 欧美精品一区视频| 欧美成人网在线| 黑丝一区二区| 亚洲欧美在线磁力| 亚洲欧美激情在线视频| 欧美片网站免费| 亚洲国产成人高清精品| 国内成人在线| 久久久www成人免费无遮挡大片| 亚洲欧美日韩综合一区| 欧美人与禽性xxxxx杂性| 亚洲欧洲精品成人久久奇米网| 91久久精品一区二区别| 麻豆精品视频在线观看视频| 久久亚洲高清| 亚洲第一页在线| 欧美肥婆在线| 亚洲人成精品久久久久| 一区二区精品| 欧美日韩一区二区三区在线看| 亚洲精品综合| 性亚洲最疯狂xxxx高清| 国产欧美一区二区三区另类精品 | 亚洲影视在线播放| 久久精品免费| 亚洲国产欧美一区二区三区丁香婷| 久久成人国产精品| 欧美成人激情视频免费观看| 亚洲国产午夜| 欧美日韩中文精品| 亚洲欧美一级二级三级| 久久精品日韩| 亚洲欧洲精品一区二区三区| 欧美黄色日本| 亚洲午夜免费视频| 久久本道综合色狠狠五月| 国内成人精品2018免费看| 欧美aa国产视频| 亚洲一区二区欧美| 蜜桃av综合| 亚洲一区二区三区四区五区午夜 | 制服丝袜亚洲播放| 久久国产一区| 99re6热只有精品免费观看| 国产精品劲爆视频| 久久免费观看视频| 99热在线精品观看| 久久亚洲一区二区三区四区| 最新国产成人av网站网址麻豆 | 午夜精品理论片| 欧美激情精品久久久久久久变态| 日韩一级大片| 国产亚洲福利| 欧美日韩一区二区三区在线 | 欧美一区三区二区在线观看| 噜噜噜91成人网| 亚洲午夜久久久久久久久电影院 | 欧美亚洲免费电影| 亚洲电影视频在线| 欧美一区三区三区高中清蜜桃 | 精品成人a区在线观看| 欧美日韩亚洲精品内裤| 久久大香伊蕉在人线观看热2| 亚洲欧洲一区二区在线播放| 久久九九全国免费精品观看| 亚洲精品美女在线观看播放| 国产美女诱惑一区二区| 欧美日韩国产探花| 久久人人爽国产| 亚洲欧美大片| 亚洲精品中文字| 亚洲高清在线观看一区| 老司机免费视频久久|