I'm working on making a 'joystick' which has many throttle-like controls. ie. analogue inputs.
The joystick example that i have looked at is the one that come with the teensyduino. I realised this is limited to 6 axes(also stated on the website http://www.pjrc.com/teensy/td_joystick.html)
I am trying to work out if I can increase the amount of axes by editing the usb_joystick.h to include more axes. Is this functionality limited by windows, by the example provided or by the device itself?
Below is an extract of the file and I curious if I can modify the sliderLeft/sliderRight to slider1, slider2 etc then add more sliders (slider3, slider4...)
If so how do I modifiy the rest of the data (Coloured text) for each new axes I add?
I'm using a teensy3 on win7 using teensyduino.
Any advice would be appreciated.
Cheers
lil
The joystick example that i have looked at is the one that come with the teensyduino. I realised this is limited to 6 axes(also stated on the website http://www.pjrc.com/teensy/td_joystick.html)
I am trying to work out if I can increase the amount of axes by editing the usb_joystick.h to include more axes. Is this functionality limited by windows, by the example provided or by the device itself?
Below is an extract of the file and I curious if I can modify the sliderLeft/sliderRight to slider1, slider2 etc then add more sliders (slider3, slider4...)
If so how do I modifiy the rest of the data (Coloured text) for each new axes I add?
I'm using a teensy3 on win7 using teensyduino.
Code:
void X(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[1] = (usb_joystick_data[1] & 0xFFFFC00F) | (val << 4);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void Y(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[1] = (usb_joystick_data[1] & 0xFF003FFF) | (val << 14);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void position(unsigned int x, unsigned int y) {
if (x > 1023) x = 1023;
if (y > 1023) y = 1023;
usb_joystick_data[1] = (usb_joystick_data[1] & 0xFFF00000)
| (x << 4) | (y << 14);
if (!manual_mode) usb_joystick_send();
}
void Z(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[1] = (usb_joystick_data[1] & 0x00FFFFFF) | (val << 24);
usb_joystick_data[2] = (usb_joystick_data[2] & 0xFFFFFFFC) | (val >> 8);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void Zrotate(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[2] = (usb_joystick_data[2] & 0xFFFFF003) | (val << 2);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void sliderLeft(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[2] = (usb_joystick_data[2] & 0xFFC00FFF) | (val << 12);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void sliderRight(unsigned int val) {
if (val > 1023) val = 1023;
[COLOR="#FF0000"]usb_joystick_data[2] = (usb_joystick_data[2] & 0x003FFFFF) | (val << 22);[/COLOR]
if (!manual_mode) usb_joystick_send();
}
void slider(unsigned int val) {
if (val > 1023) val = 1023;
usb_joystick_data[2] = (usb_joystick_data[2] & 0x00000FFF)
[COLOR="#FF0000"] | (val << 12) | (val << 22);[/COLOR]
if (!manual_mode) usb_joystick_send();
Any advice would be appreciated.
Cheers
lil