Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Nintendo.h>
- CGamecubeController controller(6); // reads from controller on D6
- CGamecubeConsole console(12); // writes to console on D12
- Gamecube_Report_t gcc = defaultGamecubeData.report;
- const unsigned char JOYSTICK_MEDIAN = 128; // middle position of joystick
- const unsigned char JOYSTICK_MAX_LEFT = 0; // maximum X position left
- const unsigned char JOYSTICK_MAX_DOWN = 0; // maximum Y position down
- const unsigned char JOYSTICK_MAX_RIGHT = 255; // maximum X position right
- const unsigned char JOYSTICK_MAX_UP = 255; // maximum Y position up
- const unsigned char SMASH_START_LEFT = 73; // 73/255 = 0.2863 left
- const unsigned char SMASH_START_DOWN = 73; // 73/255 = 0.2863 down
- const unsigned char SMASH_START_RIGHT = 204; // 204/255 = 0.8000 right
- const unsigned char SMASH_START_UP = 204; // 204/255 = 0.8000 up
- const unsigned char SMASH_ALMOST_MAX_UP = 245; // 245/255 = 0.9608 up
- const unsigned char LIGHT_SHIELD = 85; // 85/255 = 33% pressed
- int analog_x, analog_y, cstick_x, cstick_y; // analog and cstick positions
- unsigned char analog_x_abs, analog_y_abs; // absolute analog values
- unsigned char cstick_x_abs, cstick_y_abs; // absolute cstick values
- //tiktok boiio
- const unsigned char TURN_TIME= 330;
- void setup(){
- // calibrates initial state of controller
- gcc.origin = 0;
- gcc.errlatch = 0;
- gcc.high1 = 0;
- gcc.errstat = 0;
- }
- void loop(){
- // read from the controller
- controller.read();
- // store the current state
- gcc = controller.getReport();
- // calculates the x and y coordinates of the joysticks
- // NOTE: joysticks go from 0 to 255 from left to right and bottom to top,
- // subtracting 128 from these values shifts the origin to the middle.
- analog_x = gcc.xAxis - JOYSTICK_MEDIAN;
- analog_y = gcc.yAxis - JOYSTICK_MEDIAN;
- cstick_x = gcc.cxAxis - JOYSTICK_MEDIAN;
- cstick_y = gcc.cyAxis - JOYSTICK_MEDIAN;
- analog_x_abs = abs(analog_x);
- analog_y_abs = abs(analog_y);
- cstick_x_abs = abs(cstick_x);
- cstick_y_abs = abs(cstick_y);
- // write data to console
- console.write(gcc);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement