Joystick.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.jme3.input;
  2. import java.util.List;
  3. /**
  4. * A joystick represents a single joystick that is installed in the system.
  5. *
  6. * @author Paul Speed, Kirill Vainer
  7. */
  8. public interface Joystick {
  9. /**
  10. * Rumbles the joystick for the given amount/magnitude.
  11. *
  12. * @param amount The amount to rumble. Should be between 0 and 1.
  13. */
  14. public void rumble(float amount);
  15. /**
  16. * Assign the mapping name to receive events from the given button index
  17. * on the joystick.
  18. *
  19. * @param mappingName The mapping to receive joystick button events.
  20. * @param buttonId The button index.
  21. *
  22. * @see Joystick#getButtonCount()
  23. * @deprecated Use JoystickButton.assignButton() instead.
  24. */
  25. public void assignButton(String mappingName, int buttonId);
  26. /**
  27. * Assign the mappings to receive events from the given joystick axis.
  28. *
  29. * @param positiveMapping The mapping to receive events when the axis is negative
  30. * @param negativeMapping The mapping to receive events when the axis is positive
  31. * @param axisId The axis index.
  32. *
  33. * @see Joystick#getAxisCount()
  34. * @deprecated Use JoystickAxis.assignAxis() instead.
  35. */
  36. public void assignAxis(String positiveMapping, String negativeMapping, int axisId);
  37. /**
  38. * Returns the JoystickAxis with the specified name.
  39. *
  40. * @param name The name of the axis to search for as returned by JoystickAxis.getName().
  41. */
  42. public JoystickAxis getAxis(String name);
  43. /**
  44. * Returns a read-only list of all joystick axes for this Joystick.
  45. */
  46. public List<JoystickAxis> getAxes();
  47. /**
  48. * Returns the JoystickButton with the specified name.
  49. *
  50. * @param name The name of the button to search for as returned by JoystickButton.getName().
  51. */
  52. public JoystickButton getButton(String name);
  53. /**
  54. * Returns a read-only list of all joystick buttons for this Joystick.
  55. */
  56. public List<JoystickButton> getButtons();
  57. /**
  58. * Returns the X axis for this joystick.
  59. *
  60. * <p>E.g. for most gamepads, the left control stick X axis will be returned.
  61. *
  62. * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String)
  63. */
  64. public JoystickAxis getXAxis();
  65. /**
  66. * Returns the Y axis for this joystick.
  67. *
  68. * <p>E.g. for most gamepads, the left control stick Y axis will be returned.
  69. *
  70. * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String)
  71. */
  72. public JoystickAxis getYAxis();
  73. /**
  74. * Returns the POV X axis for this joystick. This is a convenience axis
  75. * providing an x-axis subview of the HAT axis.
  76. *
  77. * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String)
  78. */
  79. public JoystickAxis getPovXAxis();
  80. /**
  81. * Returns the POV Y axis for this joystick. This is a convenience axis
  82. * providing an y-axis subview of the HAT axis.
  83. *
  84. * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String)
  85. */
  86. public JoystickAxis getPovYAxis();
  87. /**
  88. * Gets the index number for the X axis on the joystick.
  89. *
  90. * <p>E.g. for most gamepads, the left control stick X axis will be returned.
  91. *
  92. * @return The axis index for the X axis for this joystick.
  93. *
  94. * @see Joystick#assignAxis(java.lang.String, java.lang.String, int)
  95. */
  96. public int getXAxisIndex();
  97. /**
  98. * Gets the index number for the Y axis on the joystick.
  99. *
  100. * <p>E.g. for most gamepads, the left control stick Y axis will be returned.
  101. *
  102. * @return The axis index for the Y axis for this joystick.
  103. *
  104. * @see Joystick#assignAxis(java.lang.String, java.lang.String, int)
  105. */
  106. public int getYAxisIndex();
  107. /**
  108. * Returns the number of axes on this joystick.
  109. *
  110. * @return the number of axes on this joystick.
  111. */
  112. public int getAxisCount();
  113. /**
  114. * Returns the number of buttons on this joystick.
  115. *
  116. * @return the number of buttons on this joystick.
  117. */
  118. public int getButtonCount();
  119. /**
  120. * Returns the name of this joystick.
  121. *
  122. * @return the name of this joystick.
  123. */
  124. public String getName();
  125. /**
  126. * Returns the joyId of this joystick.
  127. *
  128. * @return the joyId of this joystick.
  129. */
  130. public int getJoyId();
  131. }