C# 클래스 AForge.Controls.Joystick

The class provides simple API for enumerating available joysticks and checking their current status.

The class provides simple access to joysticks (game controllers) through using Win32 API, which allows to enumerate available devices and query their status (state of all buttons, axes, etc).

Sample usage:

// enumerate available devices List<Joystick.DeviceInfo> devices = Joystick.GetAvailableDevices( ); foreach ( Joystick.DeviceInfo di in devices ) { System.Diagnostics.Debug.WriteLine( string.Format( "{0} : {1} ({2} axes, {3} buttons)", di.ID, di.Name, di.Axes, di.Buttons ) ); } // create new joystick and initialize it Joystick joystick = new Joystick( 0 ); // get its current status Joystick.Status status = joystick.GetCurrentStatus( ); // check if 1st button is pressed if ( status.IsButtonPressed( Joystick.Buttons.Button1 ) ) { // 1st button is pressed }
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

공개 메소드들

메소드 설명
GetAvailableDevices ( ) : List

Get list of available joysticks connected to the system.

GetCurrentStatus ( ) : Status

Get joystick's status.

Before using this method the joystick object needs to be initialized using Init method or Joystick(int) constructor.

Init ( int id ) : void

Initialize joystick with the specified ID.

Joystick ( ) : System

Initializes a new instance of the Joystick class.

This constructor does not make initialization of any joystick device, so Init method should be used before querying joystick status or properties.

Joystick ( int id ) : System

Initializes a new instance of the Joystick class.

This constructor initializes joystick with specified ID using Init method, so the object becomes ready for querying joystick's status.

메소드 상세

GetAvailableDevices() 공개 정적인 메소드

Get list of available joysticks connected to the system.
public static GetAvailableDevices ( ) : List
리턴 List

GetCurrentStatus() 공개 메소드

Get joystick's status.

Before using this method the joystick object needs to be initialized using Init method or Joystick(int) constructor.

The requested joystick is not connected to the system. Joystick was not initialized.
public GetCurrentStatus ( ) : Status
리턴 Status

Init() 공개 메소드

Initialize joystick with the specified ID.

Invalid joystick ID was specified. It must be in [0, 15] range. The requested joystick is not connected to the system.
public Init ( int id ) : void
id int Joystick's ID to initialize, [0, 15].
리턴 void

Joystick() 공개 메소드

Initializes a new instance of the Joystick class.

This constructor does not make initialization of any joystick device, so Init method should be used before querying joystick status or properties.

public Joystick ( ) : System
리턴 System

Joystick() 공개 메소드

Initializes a new instance of the Joystick class.

This constructor initializes joystick with specified ID using Init method, so the object becomes ready for querying joystick's status.

public Joystick ( int id ) : System
id int Joystick ID to initialize, [0, 15].
리턴 System