I can't get my 16 bit Axis operation to work on 2 out of 4 channels

I am using a BEETLE LEONARDO USB ATMEGA32U4 DEVELOPMENT BOARD with a ADS1115 over I2C to create a 4 axis HID game controller. That was fun to get set up, this is my first Arduino project so I'm super new to all of this.

#include <Wire.h>
#include <Arduino.h>
#include <Adafruit_ADS1015.h>
#define I2Caddress 0x48
Adafruit_ADS1115 ads;

#include <Joystick.h>

void setup()


void loop()

{int16_t adc0, adc1, adc2, adc3;
  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);
  //Serial.println(adc0); Serial.println(adc1); Serial.println(adc2); Serial.println(adc3); Serial.println(" ");

int hbrake = map(adc0,1690,23000,0,65535);
int accel = map(adc1,1690,23000,0,65535);
int brake = map(adc2,1690,23000,0,65535);
int clutch = map(adc3,1690,23000,0,65535);



I have been calibrating it with a old 5v senor (0.5-4.5v) I had laying around until i get my pressure transducer setup, so I've set the limits for this potentiometer and doubled it up from the 15 bit ads11115 to 16 bit readout to windows. I have taken some joystick HID code and have been removing the buttons and hat switches. I am having troubles getting the Y and X rotation to work correctly in game and the windows calibration screen. I was able to get my Throttle and Rudder to work correctly from 0-65535 (raw data value) and it displays a % in the blue bar of the windows calibration screen. The X an Y rotation raw data is reading 0-65535 but the blue bar shows a number value instead of a %.

#include "Joystick.h"

#if defined(_USING_HID)


static const uint8_t _hidReportDescriptor[] PROGMEM = {

	// Joystick
	0x05, 0x01,			      // USAGE_PAGE (Generic Desktop)
	0x09, 0x04,			      // USAGE (Joystick)
	0xa1, 0x01,			      // COLLECTION (Application)

	// 16 bit Throttle and Steering
	0x05, 0x02,			      //   USAGE_PAGE (Simulation Controls)
	0x15, 0x00,			      //   LOGICAL_MINIMUM (0)
	0x27, 0xff, 0xff, 0x00, 0x00,	      //   LOGICAL_MAXIMUM (65535)
	0xA1, 0x00,			      //   COLLECTION (Physical)
	0x09, 0xBB,			      //     USAGE (Throttle)
	0x09, 0xBA,			      //     USAGE (Rudder)
	0x75, 0x10,			      //     REPORT_SIZE (16)
	0x95, 0x02,			      //     REPORT_COUNT (2)
	0x81, 0x02,			      //     INPUT (Data,Var,Abs)
	0xc0,				      //   END_COLLECTION

	// rx, ry, Axis
	0x05, 0x01,			        // Usage Page (Generic Desktop)
	//0x09, 0x01,           // Usage (Pointer)
	0x15, 0x00,			        //   LOGICAL_MINIMUM (0)
	0x27, 0xff, 0xff, 0x00, 0x00,	      //   LOGICAL_MAXIMUM (65535)
	//0x35, 0x00,               //     Physical Minimum (0)
	//0x47, 0xff, 0xff, 0x00, 0x00,         //     Physical Maximum (360)
	0xA1, 0x00,		          //   COLLECTION (Physical)
	0x09, 0x33,		          //     USAGE (rx)
	0x09, 0x34,		          //     USAGE (ry)
	0x75, 0x10,			        //        REPORT_SIZE (16)
	0x95, 0x02,		          //     REPORT_COUNT (2)
	0x81, 0x02,		          //     INPUT (Data,Var,Abs)
	0xc0,				      //   END_COLLECTION

	0xc0				      // END_COLLECTION

	// Setup HID report structure
	static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));

	// Initalize State
	xAxisRotation = 0;
	yAxisRotation = 0;
	throttle = 0;
	rudder = 0;


void Joystick_::begin(bool initAutoSendState)
	autoSendState = initAutoSendState;

void Joystick_::end()

void Joystick_::setThrottle(uint16_t value)
	throttle = value;
	if (autoSendState) sendState();
void Joystick_::setRudder(uint16_t value)
	rudder = value;
	if (autoSendState) sendState();

void Joystick_::setXAxisRotation(uint16_t value)
	xAxisRotation = value;
	if (autoSendState) sendState();
void Joystick_::setYAxisRotation(uint16_t value)
	yAxisRotation = value;
	if (autoSendState) sendState();

void Joystick_::sendState()
	uint8_t data[JOYSTICK_STATE_SIZE];

  data[0] = throttle; //lsb
  data[1] = throttle >> 8; //msb
  data[2] = rudder;
  data[3] = rudder >> 8;
	data[4] = xAxisRotation;
	data[5] = xAxisRotation >> 8;
	data[6] = yAxisRotation;
	data[7] = yAxisRotation >> 8;

	// HID().SendReport(Report number, array of values in same order as HID descriptor, length)

Joystick_ Joystick;


I tried increasing the physicals maximum but it didn't seem to do anything so I put a // for now. I also tried to switch it to simulation controls usage page but that made the x and y disappear. I feel like I'm not quite understanding the bit shift or masking correctly for it to read in windows. But then why is my throttle and rudder working with this bit shift? I really would like to learn how to fix this before giving up and just using someone else code files completely again, as i only want 4 axis' and I feel I'm very close to making to work.

My throttle and rudder values are in line with the raw data with it starting at 67 and its 0% and doesn't hit 1% until 658.
The X and Y rotation shows the raw data 67 = 26% and 166 = 45% then at 2577 it changes to 1010 with no % (but I'm assuming that calibration screen can only show 4 characters on the blue bar as at 25555 it goes back to 1001). Why is the scaling so off on these two axis'?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.