billfisher
Banned
I appropriately modified the usb_desc.c.
Thanks for sharing the solution!
I appropriately modified the usb_desc.c.
#if JOYSTICK_SIZE == 12
static uint8_t joystick_report_desc[] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button #1)
0x29, 0x0A, // Usage Maximum (Button #32) was 0x20, reduced to 10 buttons 0x0A
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x0A, // Report Count (32) was 0x20, reduced to 10 buttons 0x0A
0x81, 0x02, // Input (variable,absolute)
0x75, 0x01, // Report Size (1)
0x95, 0x16, // Report Count (22) to fill the original 32 buttons
0x81, 0x01, // Constant
0x15, 0x00, // Logical Minimum (0)
0x25, 0x07, // Logical Maximum (7)
0x35, 0x00, // Physical Minimum (0)
0x46, 0x3B, 0x01, // Physical Maximum (315)
0x75, 0x04, // Report Size (4)
0x95, 0x01, // Report Count (1)
0x65, 0x14, // Unit (20)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x39, // Usage (Hat switch)
0x81, 0x42, // Input (variable,absolute,null_state)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection ()
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x03, // Logical Maximum (1023)
0x75, 0x0A, // Report Size (10)
0x95, 0x04, // Report Count (4)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x09, 0x35, // Usage (Rz)
0x81, 0x02, // Input (variable,absolute)
0xC0, // End Collection
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x03, // Logical Maximum (1023)
0x75, 0x0A, // Report Size (10)
0x95, 0x02, // Report Count (2)
0x09, 0x36, // Usage (Slider)
0x09, 0x36, // Usage (Slider)
0x81, 0x02, // Input (variable,absolute)
0xC0 // End Collection
};
Hi all, I'm building a Sim control panel.
Just wondering if the post36 attached files are still valid? I don't seem to be able to download them? Maybe it's just me being a noob on this forum.
Edit: I was viewing the forum in mobile mode! All downloads fine when viewing in full site. Lol
#define JOYSTICK_SIZE 12 // 12 = normal, 64 = extreme joystick
Sorry I have not played much with the many axis... But I would not recommend using the files in the posting #36. They are going on 8 years old, and the the files that these would replace have had some significant changes in that time frame.
It has been awhile since I built using the setup, as to mainly test for other things.
But I think the better route is to edit the current source files.
Most of this I believe is now controlled by simply editing the usb_desc.h (either the teensy3 or the teensy4 version)
Then depending on which USB type you wish to use like "Keyboard + Mouse + Joystick" that gives you: #elif defined(USB_HID)
You will find a line like:
Which in my file is about line 289Code:#define JOYSTICK_SIZE 12 // 12 = normal, 64 = extreme joystick
Change it to 64 and I believe this drive the other files that were in the zip file to use the extreme joystick.
// Encoders are just being used to pulse joystick buttons.
// Encoder MODE buttos will be set to loop over three mode per encoder, to change which joystick buttons are pulsed.
// The Mode funtionality hasn't been added yet.
const int numButtons = 10; // Standard Buttons
const int numEncoderIncrementButtons = 8; // Standard Buttons used as encoder up/down
const int numEncoder_MODE_Buttons = 4; // Standard Buttons used as encoder up/down
const int EncIncrBtnPinNum_Min = numButtons + 1;
const int EncIncrBtnPinNum_Max = numButtons + numEncoderIncrementButtons;
const int EncModeBtnPinNum_Min = EncIncrBtnPinNum_Max + 1;
const int EncModeBtnPinNum_Max = EncIncrBtnPinNum_Max + numEncoder_MODE_Buttons;
void setup() {
// you can print to the serial monitor while the joystick is active!
Serial.begin(9600);
Joystick.useManualSend(true);
// assign button pin numbers and pinModes
for (int i=0; i<numButtons; i++) {
pinMode(i, INPUT_PULLUP);
}
// assign EncoderButton pin numbers and pinModes
for (int i=EncIncrBtnPinNum_Min; i<EncIncrBtnPinNum_Max; i++) {
pinMode(i, INPUT_PULLUP);
}
// assign EncoderModeButton pin numbers and pinModes
for (int i=EncModeBtnPinNum_Min; i<EncModeBtnPinNum_Max; i++) {
pinMode(i, INPUT_PULLUP);
}
}
byte allButtons[numButtons];
byte prevButtons[numButtons];
byte allEncoderIncrementButtons[numEncoderIncrementButtons];
byte prevEncoderIncrementButtons[numEncoderIncrementButtons];
byte allEncoder_MODE_Buttons[numEncoder_MODE_Buttons];
byte prevEncoder_MODE_Buttons[numEncoder_MODE_Buttons];
void loop() {
// read pins and use them for the buttons
for (int i=0; i<numButtons; i++) {
if (digitalRead(i)) {
// when a pin reads high, the button is not pressed
// the pullup resistor creates the "on" signal
allButtons[i] = 0;
} else {
// when a pin reads low, the button is connecting to ground.
allButtons[i] = 1;
}
Joystick.button(i + 1, allButtons[i]);
}
for (int i=EncIncrBtnPinNum_Min; i<EncIncrBtnPinNum_Max; i++) {
if (digitalRead(i)) {
// when a pin reads high, the button is not pressed
// the pullup resistor creates the "on" signal
allEncoderIncrementButtons[i] = 0;
} else {
// when a pin reads low, the button is connecting to ground.
allEncoderIncrementButtons[i] = 1;
}
Joystick.button(i + 1, allEncoderIncrementButtons[i]);
}
for (int i=EncModeBtnPinNum_Min; i<EncModeBtnPinNum_Max; i++) {
if (digitalRead(i)) {
// when a pin reads high, the button is not pressed
// the pullup resistor creates the "on" signal
allEncoder_MODE_Buttons[i] = 0;
} else {
// when a pin reads low, the button is connecting to ground.
allEncoder_MODE_Buttons[i] = 1;
}
Joystick.button(i + 1, allEncoder_MODE_Buttons[i]);
}
// Because setup configured the Joystick manual send,
// the computer does not see any of the changes yet.
// This send_now() transmits everything all at once.
Joystick.send_now();
// check to see if any button changed since last time
boolean anyBtnChange = false;
for (int i=0; i<numButtons; i++) {
if (allButtons[i] != prevButtons[i]) anyBtnChange = true;
prevButtons[i] = allButtons[i];
}
// if any Button Changed, print them to the serial monitor
if (anyBtnChange) {
Serial.print("Buttons: ");
for (int i=0; i<numButtons; i++) {
Serial.print(allButtons[i], DEC);
}
Serial.println();
}
// check to see if any Encoder Increment Button Changed since last time
boolean anyEncBtnChange = false;
for (int i=EncIncrBtnPinNum_Min; i<EncIncrBtnPinNum_Max; i++) {
if (allEncoderIncrementButtons[i] != prevEncoderIncrementButtons[i]) anyEncBtnChange = true;
prevEncoderIncrementButtons[i] = allEncoderIncrementButtons[i];
}
// if any button changed, print them to the serial monitor
if (anyEncBtnChange) {
Serial.print("Encoder Increment Buttons: ");
for (int i=EncIncrBtnPinNum_Min; i<EncIncrBtnPinNum_Max; i++) {
Serial.print(allEncoderIncrementButtons[i], DEC);
}
Serial.println();
}
// check to see if any Encoder Increment button changed since last time
boolean anyEncoder_MODE_BtnChange = false;
for (int i=EncModeBtnPinNum_Min; i<EncModeBtnPinNum_Max; i++) {
if (allEncoder_MODE_Buttons[i] != prevEncoder_MODE_Buttons[i]) anyEncoder_MODE_BtnChange = true;
prevEncoder_MODE_Buttons[i] = allEncoder_MODE_Buttons[i];
}
// if any Encoder MODE Button changed, print them to the serial monitor
if (anyEncoder_MODE_BtnChange) {
Serial.print("Encoder MODE Buttons: ");
for (int i=EncModeBtnPinNum_Min; i<EncModeBtnPinNum_Max; i++) {
Serial.print(allEncoder_MODE_Buttons[i], DEC);
}
Serial.println();
}
// A brief delay, so this runs "only" 200 times per second
delay(5);
}
Thanks for your reply.
To my consolation is that Pointy has shown that it works, so there is a solution (although it is still beyond the horizon for me).
Just some more info.
After I edited usb_desc.h (and changed all 4 JOYSTICK_SIZE definitions to 64), I terminated the Arduino IDE, and then started the IDE again, and subsequently compiled my program again. I am sure that the changes are "accepted", because Pointy's JoystickTest.exe (v0.9.2) shows all the sliders.
And I selected "RawInput" in JoystickTest.exe. All DX buttons work, but all sliders and axes just remain 0.
Hoping Kurt or Pointy will read this.
I am using Arduino 1.8.13 and Teensyduino 1.55.
Nope, not yet ...
Hope to get back to the issue next week. At the moment I am down with the flu
Ok, I've updated this code and merged it into the official core library.
https://github.com/PaulStoffregen/cores/commit/f5f05e9adee9ab9eca1ca83897e4114bf6e767fa
If you want to play with it now, you can get the updated files from github and put them into your copy of Arduino. Starting with 1.36-beta2 they will always be there by the installer.
To actually use this (after you have the new files installed), edit usb_desc.h. Change JOYSTICK_SIZE from 12 to 64. Remember, there's 4 copies for the different USB Types which use joystick. Edit the one you need, or all of them if unsure. I've set everything else to automatically adapt.
As always, on Windows your old USB device detection might be cached in the Windows Registry. You might need to increase the BCD version number or change the product ID or do other stuff to get Windows to re-detect the device.
Hi is this still the most recent library?