Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <XInput.h>
  2. #include <NintendoExtensionCtrl.h>
  3.  
  4.  
  5. GuitarController guitar;
  6.  
  7.  
  8. void setup() {
  9. guitar.begin();
  10. while (!guitar.connect()) {
  11. delay(1000);
  12. }
  13. XInput.begin();
  14. XInput.setRange(JOY_RIGHT, 0, 31);
  15. }
  16.  
  17. void loop() {
  18. while (!guitar.connect()) {
  19. delay(1000);
  20. }
  21.  
  22. boolean success = guitar.update();
  23. if (!success) { // Ruh roh
  24. delay(1000);
  25. }
  26.  
  27. // STRUM
  28. if (guitar.strumUp()) {
  29. XInput.press(DPAD_UP);
  30. XInput.release(DPAD_DOWN);
  31. }
  32. else if (guitar.strumDown()) {
  33. XInput.press(DPAD_DOWN);
  34. XInput.release(DPAD_UP);
  35. }
  36. else {
  37. XInput.release(DPAD_UP);
  38. XInput.release(DPAD_DOWN);
  39. }
  40.  
  41. // FRETS
  42. boolean green = guitar.fretGreen();
  43. boolean red = guitar.fretRed();
  44. boolean yellow = guitar.fretYellow();
  45. boolean blue = guitar.fretBlue();
  46. boolean orange = guitar.fretOrange();
  47.  
  48. if (green == true) {
  49. XInput.press(BUTTON_A);
  50. }
  51. else if (green == false) {
  52. XInput.release(BUTTON_A);
  53. }
  54.  
  55. if (red == true) {
  56. XInput.press(BUTTON_B);
  57. }
  58. else if (red == false) {
  59. XInput.release(BUTTON_B);
  60. }
  61.  
  62. if (yellow == true) {
  63. XInput.press(BUTTON_Y);
  64. }
  65. else if (yellow == false) {
  66. XInput.release(BUTTON_Y);
  67. }
  68.  
  69. if (blue == true) {
  70. XInput.press(BUTTON_X);
  71. }
  72. else if (blue == false) {
  73. XInput.release(BUTTON_X);
  74. }
  75.  
  76. if (orange == true) {
  77. XInput.press(BUTTON_LB);
  78. }
  79. else if (orange == false) {
  80. XInput.release(BUTTON_LB);
  81. }
  82.  
  83. // WHAMMY
  84. uint8_t whammy = guitar.whammyBar();
  85. XInput.setJoystickX(JOY_RIGHT, whammy);
  86.  
  87. // PLUS BUTTON
  88.  
  89. boolean plusButton = guitar.buttonPlus();
  90.  
  91. if (plusButton == true) {
  92. XInput.press(BUTTON_START);
  93. }
  94. else if (plusButton == false) {
  95. XInput.release(BUTTON_START);
  96. }
  97.  
  98. // MINUS BUTTON
  99.  
  100. boolean minusButton = guitar.buttonMinus();
  101.  
  102. if (minusButton == true) {
  103. XInput.press(BUTTON_BACK);
  104. }
  105. else if (minusButton == false) {
  106. XInput.release(BUTTON_BACK);
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement