We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › PControll on Linux with Logitech RumblePad 2 USB
Page Index Toggle Pages: 1
PControll on Linux with Logitech RumblePad 2 USB (Read 1531 times)
PControll on Linux with Logitech RumblePad 2 USB
Sep 15th, 2009, 6:01pm
 
I'm having difficulty using the PControll library with this standard controller. My controller is correctly configured in ubuntu jaunty. When I run the standard example "procontroll_cooliehat", I get the error Code:
ClassCastException: procontroll.ControllButton cannot be cast to procontroll.ControllCoolieHat 

. When I run the "procontroll" example, I get the error Code:
Error on plug: >handleMovement< proControll found no method with that name in the given object. 

.  What gives?
Re: PControll on Linux with Logitech RumblePad 2 USB
Reply #1 - Sep 17th, 2009, 2:37pm
 
Ok, I figured out the problem. For all the rest of you that get this exception, it's because every CoolieHat (D-Pad) is also a ControllButton, but not every ControllButton is a ControllCoolieHat in PControll. You have to use ControllDevice.printButtons() to find out what the number of the button is that is called a cooliehat is, and then you have to call ControllDevice.getCoolieHat( # ) where # is the number of the button that you identified as a cooliehat from ControllDevice.printButtons(). If you have the wrong #, then you'll get that error.

It's NOT a linux problem at all - I have all the buttons, sticks, sliders, and cooliehats working on the RumblePad 2 USB in ubuntu 9.0.4.  

Example:

Quote:
import procontroll.*;

// works with ubuntu 9.0.4

String deviceName = "Logitech Logitech RumblePad 2 USB";

ControllIO controllIO;
ControllDevice device;
ControllButton[] buttons;
ControllSlider[] sliders;
ControllStick[] sticks;
ControllCoolieHat cooliehat;

int buttonHeight;
int sliderWidth;
int sliderHeight;

void setup() {
  size( 300, 300 );
  controllIO = ControllIO.getInstance( this );
  device = controllIO.getDevice( deviceName );
  device.setTolerance( 0.05 );
  int numButtons = device.getNumberOfButtons();
  int numSliders = device.getNumberOfSliders();
  int numSticks = device.getNumberOfSticks();
  buttons = new ControllButton[numButtons];
  sliders = new ControllSlider[numSliders];
  sticks = new ControllStick[numSticks];
  for( int i = 0; i < buttons.length; i++ ) {
    buttons[i] = device.getButton(i);
  }
  for( int i = 0; i < sliders.length; i++ ) {
    sliders[i] = device.getSlider(i);
  }
  for( int i = 0; i < sticks.length; i++ ) {
    sticks[i] = new ControllStick( sliders[2*i], sliders[2*i+1] );
  }
  cooliehat = device.getCoolieHat(12);
  buttonHeight = height / buttons.length;
  sliderWidth = ( width / 2 ) / sliders.length;
  sliderHeight = height / 2;
}

void draw() {
  stroke( 0 );
  background( 0 );
  for( int i = 0; i < buttons.length; i++ ) {
    if( buttons[i].pressed() ) {
      fill( 255, 0, 0 );
    } 
    else {
      fill( 0 );
    }
    rect( 0, buttonHeight * i, width/2, buttonHeight );
  }
  stroke( 255 );
  fill( 0 );
  for( int i = 0; i < sliders.length; i++ ) {
    rect( width/2 + i * sliderWidth,
      sliderHeight*( 1 - sliders[i].getValue() ), 
      sliderWidth, 
      sliderHeight * sliders[i].getValue() 
    );
  }
  pushStyle();
  pushMatrix();
  strokeWeight( 20 );
  stroke( 255, 255, 0 );
  translate( width/2, height/2 );
  line( 0, 0, width/4 * cooliehat.getX(), width/4 * cooliehat.getY() );
  popMatrix();
  popStyle();
}


Page Index Toggle Pages: 1