[SOLVED]Arcade trackball to usb mouse help

Riva:
And this sketch is your code modified to allow the reading of all buttons.

#include <Encoder.h>

#include <Joystick.h>

Encoder axisX(0, 1);
Encoder axisY(2, 3);
Encoder axisZ(4, 5);

const byte buttonArray[] = {6, 7, 8, 9, 10, 14, 15, 16, 18, 19, 20, 21};

void setup() {
  // Initialize Buttons
  for(byte x = 0; x < sizeof(buttonArray); x++)
  {
    pinMode(buttonArray[x], INPUT_PULLUP);
  }
 
  // Initialize Joystick Library
  Joystick.begin(false);
}

void loop() {
  Joystick.setXAxis(0);              // Center joystick X
  int newX = axisX.read();            // Read X encoder
  if (newX > 0)                      // Has the value increased since last read
  {
    Joystick.setXAxis(127);          // Set joystick X hard over to right
    axisX.write(0);                  // Zero encoder count for next time
  }
  if (newX < 0)                      // Has encoder decreased since last read
  {
    Joystick.setXAxis(-127);          // Set joystick hard left
    axisX.write(0);                  // Zero encoder count
  }
 
  Joystick.setYAxis(0);              // Center joystick Y
  int newY = axisY.read();
  if (newY > 0)
  {
    Joystick.setYAxis(127);
    axisY.write(0);
  }
  if (newY < 0)
  {
    Joystick.setYAxis(-127);
    axisY.write(0);
  }
 
  Joystick.setZAxis(0);              // Center joystick Z
  int newZ = axisZ.read();
  if (newZ > 0)
  {
    Joystick.setZAxis(63);
    delay(50);
    axisZ.write(0);
  }
  if (newZ < 0)
  {
    Joystick.setZAxis(-63);
    delay(50);
    axisZ.write(0);
  }
 
  // Read button pin values
  for(byte x = 0; x < sizeof(buttonArray); x++)
  {
    byte currentButtonState = !digitalRead(buttonArray[x]);  // Read button state
    Joystick.setButton(x, currentButtonState);                // Set state in joystick
  }
 
  Joystick.sendState();              // Send the joystick data
  delay(50);                          // Wait a bit
}

So over a length of about ten to fifteen feet away from the arduino cable length, would i need to add some 1k pullup resistors as well as the internal pullups for the buttons and the encoders? Now because of you i understand the button code fully, thank you. Okay for the trackball encoders, would i be able to use the same counting technique as the normal encoder knob? I havent tried the code you posted yet as i just changed benches and some things are shuffeled around lol. I should be able to trt your code and report back to you with the results.