上面的兩個API函數,我們可以從中任選一個,但joyGetPos函數只能取得1,2,3,4號四個按鈕的狀態。 所以建議不用,下面只重講解joyGetPosEx函數!
JOYINFO 與 JOYINFOEX 是屬於結構體,它們的定義如下:
#region 游戲手柄的位置與按鈕狀態
/// <summary>
/// 游戲手柄的位置與按鈕狀態
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct JOYINFO
{
public int wXpos;
public int wYpos;
public int wZpos;
public int wButtons;
}
/// <summary>
/// 游戲手柄的位置與按鈕狀態
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct JOYINFOEX
{
/// <summary>
/// Size, in bytes, of this structure.
/// </summary>
public int dwSize;
/// <summary>
/// Flags indicating the valid information returned in this structure. Members that do not contain valid information are set to zero.
/// </summary>
public int dwFlags;
/// <summary>
/// Current X-coordinate.
/// </summary>
public int dwXpos;
/// <summary>
/// Current Y-coordinate.
/// </summary>
public int dwYpos;
/// <summary>
/// Current Z-coordinate.
/// </summary>
public int dwZpos;
/// <summary>
/// Current position of the rudder or fourth joystick axis.
/// </summary>
public int dwRpos;
/// <summary>
/// Current fifth axis position.
/// </summary>
public int dwUpos;
/// <summary>
/// Current sixth axis position.
/// </summary>
public int dwVpos;
/// <summary>
/// Current state of the 32 joystick buttons. The value of this member can be set to any combination of JOY_BUTTONn flags, where n is a value in the range of 1 through 32 corresponding to the button that is pressed.
/// </summary>
public int dwButtons;
/// <summary>
/// Current button number that is pressed.
/// </summary>
public int dwButtonNumber;
/// <summary>
/// Current position of the point-of-view control. Values for this member are in the range 0 through 35,900. These values represent the angle, in degrees, of each view multiplIEd by 100.
/// </summary>
public int dwPOV;
/// <summary>
/// Reserved; do not use.
/// </summary>
public int dwReserved1;
/// <summary>
/// Reserved; do not use.
/// </summary>
public int dwReserved2;
}
#endregion