// code taken from https://github.com/AM-STUDIO/32-FUNCTION-BUTTON-BOX/blob/master/ARDUINO_BUTTON_BOXV2.ino
//include 2 libraries to manage grid layout and une gamepad features
#include<Keypad.h>
#include<Joystick.h>
//define values
#define ENABLE_PULLUPS
#define NUMROTARIES 4
#define NUMBUTTONS 24
//grid size 5 x 5
#define NUMROWS 5
#define NUMCOLS 5
//this is the matching between the grid and the button number that will be triggered
//for instance , if I physically press the button plug in the grid at the column 1 , row 2
// the program will send the gamepad signal that the button 5 have been pressed
bytebuttons[NUMROWS][NUMCOLS]={
{0,1,2,3,4},
{5,6,7,8,9},
{10,11,12,13,14},
{15,16,17,18,19},
{20,21,22,23},
};
//define a custom structure to manage easily the rotary encoder
structrotariesdef{
bytepin1;// the Arduino pin connected to the A side of the rotary encoder
bytepin2;// the Arduino pin connected to the B side of the rotary encoder
intccwchar;//ccw => counter clockwise this is the character/ the button of the gamepad that will be pressed when user turn the rotary counter clockwise
intcwchar;//cw => clockwise this is the character/ the button of the gamepad that will be pressed when user turn the rotary clockwise