actually i’m not currently using DInput. I want to, and tried to at first but literally didn’t know where to start. I need to learn how to make use of directX features, and that will of course involve reinstalling the DXSDK it’s not been reinstalled since my last reformat as the newer juce doesn’t need the headers anymore. I’m currently using the winmm system, and have a polling thread that makes use of JOYINFOEX structures for state data.
The way it’s coded though, it shouldn’t be a problem to change to a directX implementation when i figure out how. I’ve got it working fine with the winmm set on my joypad- every feature except vibration is implemented and functional. my main issue is compatibility with other controllers, specifically getting general things like axes and digital directions operate in the same way across controls (some use axes for their dpads, others use a POV hat representation, etc). I have a feeling that directX will help eliminate such compatibility woes.
I’ve got a little midi plugin working with it on my pad. Midi notes are triggered by button presses, and the pov hat (which is a d-pad on the PS2 controllers) transposes the note value of any buttons that are held when pressing up or down. This makes it really quick to select notes that you want to play, without using any other interface than the one in your hand. A bit like a keyboard, but easier to play. And the XY sticks control CCs. I’m going to add a LEFT/RIGHT feature to cycle thru programs of button/note assignment groups, so you can quickly build your own scales and flick between them while playing over a song.
So far it doesn’t have a GUI, and doesn’t need one yet.
To show you the sort of way the Joystick classes are currently used (and how easy it is), here’s the code for the main app class that drives the plugin (and sits inside a totally basic JuceAudioPlugin Filter). I.e. to make use of joysticks, this is all you need to do:
[code]
MidiJoystickSystem::MidiJoystickSystem (MidiBuffer& output)
: midiOutput (output)
{
joystick = 0;
}
MidiJoystickSystem::~MidiJoystickSystem ()
{
if (joystick) deleteAndZero (joystick);
}
//===================================================================
void MidiJoystickSystem::openJoystick (int id)
{
joystick = Joystick::openJoystick (id, this);
}
void MidiJoystickSystem::start ()
{
if (joystick) joystick->start ();
}
void MidiJoystickSystem::start ()
{
if (joystick) joystick->stop ();
}
//===================================================================
void MidiJoystickSystem::sendMidiMessage (const MidiMessage& msg)
{
midiOutput.addEvent (msg, 0);
}
//===================================================================
void MidiJoystickSystem::buttonPressed (const JoystickEvent& j)
{
for (int i=0; i<buttonAssignments.getNumberOfButtons (); i++)
{
JoystickMidiButton* button = buttonAssignments.getButton (i);
if (j.buttonPressed (button->getAssignedJoystickButton ()))
{
sendMidiMessage (button->getNoteOn ());
}
}
}
void MidiJoystickSystem::buttonReleased (const JoystickEvent& j)
{
for (int i=0; i<buttonAssignments.getNumberOfButtons (); i++)
{
JoystickMidiButton* button = buttonAssignments.getButton (i);
if (j.buttonReleased (button->getAssignedJoystickButton ()))
{
sendMidiMessage (button->getNoteOff ());
}
}
}
void MidiJoystickSystem::axisMoved (const JoystickEvent& j)
{
for (int i=0; i<axisAssignments.getNumberOfAxes(); i++)
{
JoystickMidiAxis* axis = axisAssignments.getAxis (i);
Joystick::AxisID id = axis->getAssignedJoystickAxis ();
if (j.axisHasChanged (id))
{
sendMidiMessage (axis->getMessage (j.getAxisProportion(id)*127));
}
}
}
void MidiJoystickSystem::povMoved (const JoystickEvent &j)
{
if (j.getPovDirection () == up)
{
DBG (T(“UP pressed”));
// pressed D-Pad up… any buttons held?
for (int i=0; i<buttonAssignments.getNumberOfButtons (); i++)
{
JoystickMidiButton* button = buttonAssignments.getButton (i);
if (button)
{
if (j.isButtonDown (button->getAssignedJoystickButton ()))
{
sendMidiMessage (button->getNoteOff ());
button->incrementNoteNumber ();
sendMidiMessage (button->getNoteOn ());
}
}
}
}
else if (j.getPovDirection () == down)
{
DBG (T(“DOWN pressed”));
// pressed D-Pad up… any buttons held?
for (int i=0; i<buttonAssignments.getNumberOfButtons (); i++)
{
JoystickMidiButton* button = buttonAssignments.getButton (i);
if (button)
{
if (j.isButtonDown (button->getAssignedJoystickButton ()))
{
sendMidiMessage (button->getNoteOff ());
button->decrementNoteNumber ();
sendMidiMessage (button->getNoteOn ());
}
}
}
}
}[/code]