Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] joystick

edited April 2012 in OpenSesame

Hi Sebastian. I'm trying to configure a gamepad using the psychopy joystick module. However, when I try to import the module using
from psychopy.hardware import joystick
OpenSesame says me that it "cannot import name joystick". Since OpenSesame 0.26 includes the last version of PsychoPy, it sounds strange.

Do you know the source of the problem?

Aside from that, have you ever tried to use a gamepad in OpenSesame? How does it work?

Thanks.

Andrea

Comments

  • edited 11:18PM

    Hi Andrea,

    The joystick module simply hasn't been included (oops), so that's explains the error. Luckily, it has been included in the Python portable distribution: http://osdoc.cogsci.nl/getting-started/running-with-python-portable

    I have personally never used a joystick, so I couldn't say much about it. But you might want to check out this discussion: http://forum.cogsci.nl/index.php?p=/discussion/comment/194

    Good luck!

    Cheers,
    Sebastiaan

  • edited 11:18PM

    Ah ok. I already tried to use the portable distribution, but it crashes when I go to run the experiment. I don't know why.

  • edited 11:18PM

    If you run into any trouble with the portable distribution, please leave a comment here: http://forum.cogsci.nl/index.php?p=/discussion/69/opensesame-portable#Item_17 I'm sure Edwin will be willing to look at it.

    Cheers!

  • edited April 2012

    Ok! I imported the hardware folder from the python portable version (that continues to crash on my computer, I'll write to Edwin about that) to OpenSesame (no installation needed version). I tried the psychopy.hardware.joystick class and it works well in OpenSesame.

    Here is a simple code by which I tested the response time of my gamepad using the PsychoPy backend. It records a gamepad button, but I'm sure it also works for the axes.

    
    from psychopy import visual, core
    from psychopy.hardware import joystick
    
    joy=joystick.Joystick(0)
    
    press = visual.TextStim(self.experiment.window, pos=(0,0), color = 'black', height = 25, font = 'Times', text = 'Press and release the key 2 on the gamepad...')
    
    start=core.Clock()
    
    while joy.getButton(2) == False:
        press.draw()
        self.experiment.window.flip()
        pass
    t1 = start.getTime()
    while joy.getButton(2) == True:
        press.draw()
        self.experiment.window.flip()
        pass
    t2 = start.getTime()
    print('Press time = ', t2-t1)
    

    I mark this post as solved! :)>-

  • edited 11:18PM

    Really, that just worked? That's good to know.

    How exactly did you do it? Did you extract the library.zip, insert the hardware folder, and re-zip it? Or did you simply paste the hardware folder into the OpenSesame folder?

    And thanks for the script, I'm sure it'll be helpful to a lot of people!

  • edited 11:18PM

    I simply first deleted the library.zip from my installation folder, then I just copied the library.zip from the portable version to the installation folder. ;)

    Previously, I tried to use Pygame to read the gamepad, but it didn't work.

Sign In or Register to comment.