Problema libreria joystick, interferisce con mouse.move()

Buona sera a tutti, posto il mio problema qui perchè ho cercato ovunque senza trovare una soluzione. Sto usando un arduino due, ho dei pulsanti ed un giroscopio per inviare input tastiera e mouse.move al pc, e fin qui tutto ok. Con un tasto passo da comandi tastiera e mouse a joystick, e da qui nasce il problema. Da quando ho aggiunto la libreria joystick per simulare un game pad, ogni volta che chiamo mouse.move() con qualsisi coordinata(anche0) il mouse si muove nell'angolo inferiore destro dello schermo e in game continua a girare verso destra.

Se da _hidReportDescriptorJoystick[] PROGMEM{ tolgo

0x46, 0x3B, 0x01, // PHYSICAL_MAXIMUM (315)

Non ho più il problema con il mouse ma ovviamente non funzionano i tasti corrsispondenti del joystick. Volevo chiedere se cè la possibilità di aggiungere un if(variabile==1) all'interno del file .ccp per richiamare _hidReportDescriptorJoystick[] PROGMEM se tipo la variabile è a 1. oppure di non farlo se la variabile è 0. Io ho provato ma ovunque metto un if mi da errore nella compilazione.

posto i file .h e .cpp della libreria, spero qualcuno posso darmi delle delucidazioni, grazie

Joystick.cpp

#include "joystick.h"

#if defined(_USING_HID)


static const uint8_t _hidReportDescriptorJoystick[] PROGMEM = {

    //32 buttons, 2 8-way hats, and 8 axes.
    0x05, 0x01,           //USAGE_PAGE (Generic Desktop)
    0x09, 0x05,           //USAGE (Game Pad)
    0xa1, 0x01,           //COLLECTION (Application)
    0x85, 0x03,           //  REPORT_ID (3)
    0xa1, 0x00,           //  COLLECTION (Physical)
    //32 buttons
    0x05, 0x09,           //      USAGE_PAGE (Button)
    0x19, 0x01,           //      USAGE_MINIMUM (Button 1)
    0x29, 0x20,           //      USAGE_MAXIMUM (Button 32)
    0x15, 0x00,           //      LOGICAL_MINIMUM (0)
    0x25, 0x01,           //      LOGICAL_MAXIMUM (1)
    0x95, 0x20,           //      REPORT_COUNT (16)
    0x75, 0x01,           //      REPORT_SIZE (1)
    0x81, 0x02,           //      INPUT (Data,Var,Abs)
    //2 8-way hat switches
    0x05, 0x01,         //      USAGE_PAGE (Generic Desktop)
    0x09, 0x39,         //      USAGE (Hat switch)
    0x15, 0x00,         //      LOGICAL_MINIMUM (0)
    0x25, 0x07,         //      LOGICAL_MAXIMUM (7)
    0x35, 0x00,         //      PHYSICAL_MINIMUM (0)
    0x46, 0x3B, 0x01,   //      PHYSICAL_MAXIMUM (315)
    0x65, 0x14,         //      UNIT (Eng Rot:Angular Pos)
    0x75, 0x04,         //      REPORT_SIZE (4)
    0x95, 0x01,         //      REPORT_COUNT (1)
    0x81, 0x02,         //      INPUT (Data,Var,Abs)
    0x09, 0x39,         //      USAGE (Hat switch)
    0x15, 0x00,         //      LOGICAL_MINIMUM (0)
    0x25, 0x07,         //      LOGICAL_MAXIMUM (7)
    0x35, 0x00,         //      PHYSICAL_MINIMUM (0)
    0x46, 0x3B, 0x01,   //      PHYSICAL_MAXIMUM (315)
    0x65, 0x14,         //      UNIT (Eng Rot:Angular Pos)
    0x75, 0x04,         //      REPORT_SIZE (4)
    0x95, 0x01,         //      REPORT_COUNT (1)
    0x81, 0x02,         //      INPUT (Data,Var,Abs)
    //8 16-bit axes
    0xA1, 0x00,         //      COLLECTION (Physical)
    0x05, 0x01,           //          USAGE_PAGE (Generic Desktop)
    0x09, 0x30,           //          USAGE (X)
    0x09, 0x31,           //          USAGE (Y)
    0x09, 0x32,           //          USAGE (Z)
    0x09, 0x33,           //          USAGE (Rx)
    0x09, 0x34,           //          USAGE (Ry)
    0x09, 0x35,           //          USAGE (Rz)
    0x09, 0x36,           //          USAGE (Slider)
    0x09, 0x37,           //          USAGE (Dial)
    0x16, 0x00, 0x80, //          LOGICAL_MINIMUM (-32768)
    0x26, 0xff, 0x7f, //          LOGICAL_MAXIMUM (32767)
    0x75, 0x10,           //          REPORT_SIZE (16)
    0x95, 0x08,           //          REPORT_COUNT (8)
    0x81, 0x02,           //          INPUT (Data,Var,Abs)
    0xc0,               //      END_COLLECTION
    0xc0,             //  END_COLLECTION
    0xc0              //END_COLLECTION

};

//constructor that does nothing
Joystick_::Joystick_(void){
    clearState();   
    //append the discriptor to a thing idk
    static HIDSubDescriptor node(_hidReportDescriptorJoystick, sizeof(_hidReportDescriptorJoystick));
    HID().AppendDescriptor(&node);
}

//reset joy state to defaults
void Joystick_::clearState(void){
    state.x.axis = AXIS_CENTER;
    state.y.axis = AXIS_CENTER;
    state.z.axis = AXIS_CENTER;
    state.xRot.axis = AXIS_CENTER;
    state.yRot.axis = AXIS_CENTER;
    state.zRot.axis = AXIS_CENTER;
    state.slider.axis = AXIS_CENTER;
    state.dial.axis = AXIS_CENTER;
    state.hats.switch1 = HAT_CENTER;
    state.hats.switch2 = HAT_CENTER;
    state.buttons.bitfield = 0;
}
//format and send state report. The report data format must match the one defined in the descriptor exactly
//or it either won't work, or the pc will make a mess of unpacking the data
#define JOY_DATA_SIZE 21
void Joystick_::sendState(void){
    uint8_t data[]{
        //buttons       
        state.buttons.data1,
        state.buttons.data2,
        state.buttons.data3,
        state.buttons.data4,
        //hats
        state.hats.data,
        //axes
        state.x.dataHi,
        state.x.dataLo,
        state.y.dataHi,     
        state.y.dataLo,
        state.z.dataHi,
        state.z.dataLo,
        state.xRot.dataHi,  
        state.xRot.dataLo,
        state.yRot.dataHi,
        state.yRot.dataLo,
        state.zRot.dataHi,  
        state.zRot.dataLo,
        state.slider.dataHi,
        state.slider.dataLo,
        state.dial.dataHi,
        state.dial.dataLo

    };
    //HID_SendReport(Report number, array of values in same order as HID descriptor, length)
    //HID_SendReport(3, data, JOY_DATA_SIZE);
    HID().SendReport(3,data,sizeof(data));
    // The joystick is specified as using report 3 in the descriptor. That's where the "3" comes from
}

Joystick_ Joystick;


#endif

Joystick.h

#ifndef JOYSTICK_H
#define JOYSTICK_H

#include "HID.h"

#if !defined(_USING_HID)

#warning "Using legacy HID core (non pluggable)"

#else

    typedef union button32 {
        uint32_t bitfield;
        struct {
            uint8_t data1;
            uint8_t data2;
            uint8_t data3;
            uint8_t data4;
        };
        struct {
            uint8_t b00 : 1;    uint8_t b01 : 1;    uint8_t b02 : 1;    uint8_t b03 : 1;
            uint8_t b04 : 1;    uint8_t b05 : 1;    uint8_t b06 : 1;    uint8_t b07 : 1;
            uint8_t b08 : 1;    uint8_t b09 : 1;    uint8_t b10 : 1;    uint8_t b11 : 1;
            uint8_t b12 : 1;    uint8_t b13 : 1;    uint8_t b14 : 1;    uint8_t b15 : 1;
            uint8_t b16 : 1;    uint8_t b17 : 1;    uint8_t b18 : 1;    uint8_t b19 : 1;
            uint8_t b20 : 1;    uint8_t b21 : 1;    uint8_t b22 : 1;    uint8_t b23 : 1;
            uint8_t b24 : 1;    uint8_t b25 : 1;    uint8_t b26 : 1;    uint8_t b27 : 1;
            uint8_t b28 : 1;    uint8_t b29 : 1;    uint8_t b30 : 1;    uint8_t b31 : 1;
        };
    }button32_t;

#define HAT_UP          0
#define HAT_UPRIGHT     1
#define HAT_RIGHT       2
#define HAT_DOWNRIGHT   3
#define HAT_DOWN        4
#define HAT_DOWNLEFT    5
#define HAT_LEFT        6
#define HAT_UPLEFT      7
#define HAT_CENTER      8

    typedef union hats8 {

            uint8_t data;
            struct {
                uint8_t switch1 : 4;
                uint8_t switch2 : 4;
            };

    }hats8_t;

#define AXIS_CENTER 0
#define AXIS_MIN    -32768
#define AXIS_MAX    32767

    typedef union axis16 {
        int16_t axis;
        struct {
            uint8_t dataHi;
            uint8_t dataLo;
        };
    }axis16_t;

    typedef struct JoyState {       // Pretty self explanitory. Simple state to store all the joystick parameters
        //8 signed 16-bit axes
        axis16_t    x;
        axis16_t    y;
        axis16_t    z;
        axis16_t    xRot;
        axis16_t    yRot;
        axis16_t    zRot;
        axis16_t    slider;
        axis16_t    dial;
        //2 4-bit hat switches
        hats8_t     hats;
        //uint8_t   hatSw1;
        //uint8_t   hatSw2;
        //32 buttons
        //uint32_t  buttons;
        button32_t  buttons;
    } JoyState_t;

class Joystick_
{
public:
    JoyState_t state;
    Joystick_(void);
    void clearState(void);
    void sendState(void);
};
extern Joystick_ Joystick;

#endif
#endif