Sierra Wireless Writing an embedded application loader Instrukcja Użytkownika Strona 86

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 102
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 85
GHI Electronics,LLC Embedded Master User Manual
Hardware and Software Library
Buttons
Joysticks can have many buttons and they are mapped to index '0', to 'number to keys –
1'. The buttons are ordered in their significance. The most significant is button index 0.
At any time, the user can check the status of a button using:
Joystick.GetButtonState(0); // state of the first button
Joystick.GetButtonState(1); // state of the second button
Events
Different events are available when a button is pressed or when a movement has
occurred. The events associated with a button contain EventArgs that hold the index of the
button associated with the event.
Example
Initialization of a joystick:
// *joystick* is connected and *device* refers to the system device, joystick.
Joystick joystick = new Joystick(device);
// Event when the joystick is disconnected
joystick.Disconnected += JoystickDisconnected;
// Set Cursor bounds
joystick.SetCursorBounds(0, screen.Width, 0, screen.Height );
// Event when a X-Y movement has occured
joystick.JoystickXYMove += JoystickMoved;
// Event when a button is preseed
joystick.JoystickButtonDown += JoystickButtonPressed;
Handling Events:
public static void JoystickMoved(Joystick sender, JoystickEventArgs e)
{
// joystick.Cursor holds the position
}
public static void JoystickButtonPressed(Joystick sender, JoystickEventArgs e)
{
e.ChangedButton; // holds the changed button
}
Reference
GHIElectronics.System.SystemDevices.Joystick
GHIElectronics.System.SystemDevices.JoystickButtonState
GHIElectronics.System.SystemDevices.JoystickCursor
GHIElectronics.System.SystemDevices.JoystickEventHandler
GHIElectronics.System.SystemDevices.JoystickEventArgs
Rev. 2.06 TFT Page 86 of 102 www.ghielectronics.com
Przeglądanie stron 85
1 2 ... 81 82 83 84 85 86 87 88 89 90 91 ... 101 102

Komentarze do niniejszej Instrukcji

Brak uwag