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 › Procontroll on mac with  playstation1 usb joy
Page Index Toggle Pages: 1
Procontroll on mac with  playstation1 usb joy (Read 3560 times)
Procontroll on mac with  playstation1 usb joy
Jul 25th, 2007, 8:49am
 
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: Procontroll on mac with  playstation1 usb joy
Reply #1 - Jul 30th, 2007, 1:01am
 
well i tested the same script on a pc, it works. i suppose proControll library doesn't work on mac.

Has someone a solution for my problem ?
Re: Procontroll on mac with  playstation1 usb joy
Reply #2 - Aug 8th, 2007, 5:40am
 
I am currently programming a video game and attempting to use the procontroll library. I am using a Mac PPC and Intel. I will keep you updated on my progress.
Re: Procontroll on mac with  playstation1 usb
Reply #3 - Aug 8th, 2007, 6:28am
 

//Create gamepad variables
 ControllIO controll;
 ControllDevice device1;
 ControllStick stick;
 ControllButton button;

void setup(){
//setup game display area, background colour and framerate
 size(640, 480);

 
//seek out gamepad controlls
 controll = ControllIO.getInstance(this);
 controll.printDevices();

int devNum = 2;
device1 = controll.getDevice(devNum);

// load values into variables
 stick = device1.getStick(1);
 stick.setTolerance(0.05f);
 button = device1.getButton("0");
 

here is where you need to change your code. you need the device to reference the controll and all buttons and sliders need to reference the device. It looks like they are extensions to the class or inheriting the properties. either way it works on my mac.

Good luck.

- brian
Re: Procontroll on mac with  playstation1 usb joy
Reply #4 - Aug 8th, 2007, 5:20pm
 
hello dioioib,

thanks for your support.
i try the code you posted (changing devices value, because joypad is '4', for me). well, nothing reaally change.
i tried all alvailable values for buttons, sticks, sliders. nothing works.
did you try the code on  ppc or intel ?
What kind of joystick do you use (i use unsuccesfully 3 types of joypad) ?


Re: Procontroll on mac with  playstation1 usb joy
Reply #5 - Aug 9th, 2007, 12:08am
 
I have been able to get the "Logitec Rumblepad 2 USB" to work on the G4 PPC. My program uses only button #1 which has the value 0.

and example of how i am using the button press is bellow:

    ControllIO controll;
    ControllDevice device1;
    ControllButton buttonPunch;

    controll = ControllIO.getInstance(this);
    device1 = controll.getDevice("Logitech RumblePad 2 USB");
    buttonPunch = device1.getButton("0"); //Button Labled #1

    if(  buttonPunch.pressed() == true){
         // do something
     }

As for movement from the sticks or sliders I have not been able to get that working yet. But i have only been using this libarary since last night. Give me some more time and I will be able to figure it out.
Re: Procontroll on mac with  playstation1 usb
Reply #6 - Aug 9th, 2007, 12:23am
 
also this is something i just found that might help.

http://code.compartmental.net/dualanalog/

its a wrapper class for proControll. Should make everything a lot easier.
Re: Procontroll on mac with  playstation1 usb joy
Reply #7 - Sep 13th, 2009, 9:04pm
 
Again,
button = device.getButton("5");

Don't pass a string to a function wanting a number.

button = device.getButton(5);

I have 2 different gamepads, one of them being a PS2, on my Mac OS X and they both work fine.

Page Index Toggle Pages: 1