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.
IndexProgramming Questions & HelpOther Libraries › proControl library on Mac for using PS1 joypad
Page Index Toggle Pages: 1
proControl library on Mac for using PS1 joypad (Read 1831 times)
proControl library on Mac for using PS1 joypad
Jul 27th, 2007, 10:20am
 
hello,

i need to use a PS1 joypad with Processing. To do that i want to use the procontroll library. My computer is a mac.

I used this following script to list the devices, sliders, buttons... :

import procontroll.*;
import java.io.*;


ControllIO controll;

void setup(){
 size(400,400);


 controll = ControllIO.getInstance(this);
 controll.printDevices();

 for(int i = 0; i < controll.getNumberOfDevices(); i++){
   ControllDevice device = controll.getDevice(i);

   println(device.getName()+" has:");
   println(" " + device.getNumberOfSliders() + " sliders");
   println(" " + device.getNumberOfButtons() + " buttons");
   println(" " + device.getNumberOfSticks() + " sticks");

   device.printSliders();
   device.printButtons();
   device.printSticks();
 }
}

It works very well, i get this text (for the joypad) in the console :

<<< available proCONTROLL devices: >>>

    0: Keyboard
    1: Trackpad
    2: Optical USB Mouse
    3: M2452
    4: USB Joystick      

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
USB Joystick      has:
4 sliders
13 buttons
2 sticks

<<< available USB Joystick      sliders: >>>

    0: z absolute
    1: rz absolute
    2: x absolute
    3: y absolute

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<< available USB Joystick      buttons: >>>

    0: 0
    1: 1
    2: 2
    3: 3
    4: 4
    5: 5
    6: 6
    7: 7
    8: 8
    9: 9
    10: 10
    11: 11
    12: cooliehat: pov

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<< available USB Joystick      sticks: >>>

    0: rz z
    1: y x

<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

So I decided to test the joystick with this script (adapted from a code example in procontrol library) :

import procontroll.*;
import java.io.*;

ControllIO controll;
ControllDevice device;
ControllStick stick;
ControllButton button;

void setup(){
 size(400,400);
 
 controll = ControllIO.getInstance(this);

 device = controll.getDevice("USB Joystick     ");
 device.printSticks();
 
 stick = device.getStick(1);
 stick.setTolerance(0.05f);
 
 button = device.getButton("5");
 
 fill(0);
 rectMode(CENTER);
}

void draw(){
 background(255);
 
 if(button.pressed()){
   fill(255,0,0);
 }else{
   fill(0);
 }
 
 float x = stick.getTotalX() + width/2;
 float y = stick.getTotalY() + height/2;
 
 if(x > width + 20 || x < - 20 || y > height + 20 || y < - 20){
   stick.reset();
 }
 
 rect(x,y,20,20);
}

Normally, using the stick and a button of the joypad, the square moves and its color changes.
But nothing happens.

Could somebody help me ?
Re: proControl library on Mac for using PS1 joypad
Reply #1 - Sep 13th, 2009, 9:00pm
 
A late reply I know, but in case someone sees this recently, it's this line:

button = device.getButton("5");

that 5 shouldn't be in quotes.

button = device.getButton(5);

Re: proControl library on Mac for using PS1 joypad
Reply #2 - Sep 16th, 2009, 10:45am
 
Shocked
Page Index Toggle Pages: 1