Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #include <Nintendo.h>
  2.  
  3. CGamecubeController controller(6); // reads from controller on D6
  4. CGamecubeConsole console(12); // writes to console on D12
  5.  
  6. Gamecube_Report_t gcc = defaultGamecubeData.report;
  7.  
  8. const unsigned char JOYSTICK_MEDIAN = 128; // middle position of joystick
  9. const unsigned char JOYSTICK_MAX_LEFT = 0; // maximum X position left
  10. const unsigned char JOYSTICK_MAX_DOWN = 0; // maximum Y position down
  11. const unsigned char JOYSTICK_MAX_RIGHT = 255; // maximum X position right
  12. const unsigned char JOYSTICK_MAX_UP = 255; // maximum Y position up
  13.  
  14. const unsigned char SMASH_START_LEFT = 73; // 73/255 = 0.2863 left
  15. const unsigned char SMASH_START_DOWN = 73; // 73/255 = 0.2863 down
  16. const unsigned char SMASH_START_RIGHT = 204; // 204/255 = 0.8000 right
  17. const unsigned char SMASH_START_UP = 204; // 204/255 = 0.8000 up
  18. const unsigned char SMASH_ALMOST_MAX_UP = 245; // 245/255 = 0.9608 up
  19. const unsigned char LIGHT_SHIELD = 85; // 85/255 = 33% pressed
  20.  
  21. int analog_x, analog_y, cstick_x, cstick_y; // analog and cstick positions
  22. unsigned char analog_x_abs, analog_y_abs; // absolute analog values
  23. unsigned char cstick_x_abs, cstick_y_abs; // absolute cstick values
  24.  
  25. //tiktok boiio
  26. const unsigned char TURN_TIME= 330;
  27.  
  28. void setup(){
  29.  
  30. // calibrates initial state of controller
  31. gcc.origin = 0;
  32. gcc.errlatch = 0;
  33. gcc.high1 = 0;
  34. gcc.errstat = 0;
  35. }
  36.  
  37. void loop(){
  38.  
  39.  
  40. // read from the controller
  41. controller.read();
  42.  
  43. // store the current state
  44. gcc = controller.getReport();
  45.  
  46. // calculates the x and y coordinates of the joysticks
  47. // NOTE: joysticks go from 0 to 255 from left to right and bottom to top,
  48. // subtracting 128 from these values shifts the origin to the middle.
  49. analog_x = gcc.xAxis - JOYSTICK_MEDIAN;
  50. analog_y = gcc.yAxis - JOYSTICK_MEDIAN;
  51. cstick_x = gcc.cxAxis - JOYSTICK_MEDIAN;
  52. cstick_y = gcc.cyAxis - JOYSTICK_MEDIAN;
  53.  
  54. analog_x_abs = abs(analog_x);
  55. analog_y_abs = abs(analog_y);
  56. cstick_x_abs = abs(cstick_x);
  57. cstick_y_abs = abs(cstick_y);
  58.  
  59. // write data to console
  60. console.write(gcc);
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement