Arduino Pro Micro Digital Pins: 18 Buttons

// Arduino Pro Micro Digital Pins
// Arduino Joystick
// NOTE: This sketch file is for use with Arduino Pro Micro only.
// CODE BY LONGLO (JOLIMS.COM)
// May 8, 2022
//--------------------------------------------------------------------
#include <Joystick.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,18,0,false,false,false,false,false,false,false,false,false,false,false); 
void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
  pinMode(15, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
  pinMode(18, INPUT_PULLUP);
  pinMode(19, INPUT_PULLUP);
  pinMode(20, INPUT_PULLUP);
  pinMode(21, INPUT_PULLUP);
  Joystick.begin();
}
int lastButtonState[18] = {0};
int buttonMap[18] = {1,0,2,3,4,5,6,7,8,9, 10,16,14,15, 18,19,20,21};
void loop() {
  for (int index = 0; index < 18; index++)
  {
    int currentButtonState = !digitalRead(buttonMap[index]);
    if (currentButtonState != lastButtonState[index])
    {
      switch (index) {
        case 0:
          Joystick.setButton(0, currentButtonState);
          break;
        case 1:
          Joystick.setButton(1, currentButtonState);
          break;
        case 2:
          Joystick.setButton(2, currentButtonState);
          break;
        case 3:
          Joystick.setButton(3, currentButtonState);
          break;
        case 4:
          Joystick.setButton(4, currentButtonState);
          break;
        case 5:
          Joystick.setButton(5, currentButtonState);
          break;
        case 6:
          Joystick.setButton(6, currentButtonState);
          break;
        case 7:
          Joystick.setButton(7, currentButtonState);
          break;
        case 8: 
          Joystick.setButton(8, currentButtonState);
          break;
        case 9: 
          Joystick.setButton(9, currentButtonState);
          break;
        case 10: 
          Joystick.setButton(10, currentButtonState);
          break;
        case 11:
          Joystick.setButton(11, currentButtonState);
          break;
        case 12:
          Joystick.setButton(12, currentButtonState);
          break;
        case 13:
          Joystick.setButton(13, currentButtonState);
          break;
        case 14:
          Joystick.setButton(14, currentButtonState);
          break;
        case 15:
          Joystick.setButton(15, currentButtonState);
          break;
        case 16:
          Joystick.setButton(16, currentButtonState);
          break;
        case 17:
          Joystick.setButton(17, currentButtonState);
          break;
      }
      lastButtonState[index] = currentButtonState;
    }
  }
  delay(10);
}