This article applies to:
This item was introduced in E-Prime 2.0 (22.214.171.124).
E-Prime has the ability to create a Joystick Device from Experiment Object's Devices tab so that responses can be made through the joystick without using port communications. USB joysticks and gamepads are fully supported. The device must be recognized in Windows as a Human Interface Device, Joystick, or Gamepad. The Joystick Device currently supports 8 separate button responses, polling for X/Y coordinates, and access to POV and slider controls in E-Prime.
NOTE: The device supports four separate button responses as well as polling for X/Y coordinates in E-Prime 2.0 Standard.
The device appears in the "Add Devices" dialog. To access it, double-click the Experiment Object at the top of the Structure window, navigate to the Devices tab, and click the "Add" button.
NOTE: The use of more than one JoyStick Device is supported in E-Prime 3.0 and E-Prime 2.0 Professional.
Adding the Joystick device as an Input Mask
The Joystick device can be added as an input mask in E-Prime to any RteRunnableInputObject (e.g., Wait, TextDisplay, ImageDisplay, Slide, SoundOut, MovieDisplay) in the same manner as any other response collection device. Open the RteRunnableInputObject's Property Pages, navigate to the Duration/Input tab, and click the "Add" button immediately below the list of Input Mask Devices. In the Add Input Device dialog box, select the Joystick and click "OK".
Controlling the Mouse cursor with the Joystick
The Joystick device can be used to control the system mouse cursor. To do this, first ensure that the Mouse device is enabled in the experiment (it is by default) via the Devices tab in the Experiment Object Property Pages. Open the Mouse Device properties and set Show Cursor to "Yes." Alternatively, Mouse.ShowCursor can be used in an InLine during the experiment to show the mouse cursor at certain parts of the experiment (see Mouse.ShowCursor in the E-Prime Command Reference (https://pstnet.com/ecr). Then, in an InLine at the start of the experiment, enter the following script:
Joystick.AttachToMouseCursor = True
The Joystick device will be attached to the mouse cursor and controlled by the joystick/gamepad.
NOTE: The Joystick Device contains a property to attach the position of the Joystick to the Cursor. The image below shows this property.
Using the JoystickResponseData Object
Once the Joystick device has been added to the Experiment Object, it can be added as an input mask on any response object. The allowable buttons (1-8) can be specified. However, only button responses can be accessed directly through the graphical interface. To gain access to the joystick/gampepad X/Y coordinates or POV/slider controls the JoystickResponseData object must be used which has the following properties:
|RESP||The number corresponding to the button pressed for this particular response.|
|RT||The reaction time value of the response in relation to the onset time of the object collecting the response.|
|RTTime||The reaction time value of the response in relation to the start of the experiment.|
|IsButton1-8||Returns a Boolean value (i.e. True or False) in regards to whether the specified button was pressed at the time of the response. For example, JoystickResopnseData.IsButton2 returns True if button 2 is pressed at the time of the response. While a JoystickResponseData object corresponds to only a single response, these properties can return True for multiple buttons if they are all depressed at the time of the response. For example, if button 2 is depressed at the start of the experiment and held until the Stimulus object appears, and then button 3 is also pressed, IsButton2 and IsButton3 both return True, even though the RESP property reports only 3.|
|CursorX||Returns the X joystick position as it relates to a pixel on the screen. If using a 1024x768 resolution, this property returns a value between 1024 and 768.|
|CursorY||Returns the Y joystick position as it relates to a pixel on the screen. If using a 1024x768 resolution, this property returns a value between 1024 and 768.|
|PointOfView1-2||Returns the position of the corresponding POV control as a degree value. For example, if the POV control designated as 1 on the joystick is held left (or west), JoystickResponseData.PointOfView1 reports 270. This property returns the following values:|
North - 0
North East - 45
East - 90
South East - 135
South - 180
South West - 225
West - 270
North West - 335
No Position - -1
|Slider1-2||Returns the value of the corresponding slider control from 1-10. For example, if the slider control designated as 1 on the joystick is held in position 7, JoystickResponseData.Slider1 reports 7.|
Below is an example of the script used to access and log the various properties available from a Joystick device response. Note that this script assumes that the object collecting the response is named Stimulus.
Dim nCount As Integer
For nCount = 1 To Stimulus.InputMasks.Responses.Count
Dim stickResponse As JoystickResponseData
Set stickResponse = CJoystickResponseData(Stimulus.InputMasks.Responses(nCount))
If (Not stickResponse Is Nothing) Then
'Log whether button 1 and/or 2 was pressed at the time of this response.
c.SetAttrib "Response" & nCount & "Button1Pressed", stickResponse.IsButton1
c.SetAttrib "Response" & nCount & "Button2Pressed", stickResponse.IsButton2
'Log response, reaction time, and response location.
c.SetAttrib "Response" & nCount & "RESP", stickResponse.RESP
c.SetAttrib "Response" & nCount & "RT", stickResponse.RT
c.SetAttrib "Response" & nCount & "RTTime", stickResponse.RTTime
c.SetAttrib "Response" & nCount & "XPosition", stickResponse.CursorX
c.SetAttrib "Response" & nCount & "YPosition", stickResponse.CursorY
'Log POV and Slider values.
c.SetAttrib "Response" & nCount & "POV1", stickResponse.PointOfView1
c.SetAttrib "Response" & nCount & "POV2", stickResponse.PointOfView2
c.SetAttrib "Response" & nCount & "Slider1", stickResponse.Slider1
c.SetAttrib "Response" & nCount & "Slider2", stickResponse.Slider2
'Clean up references.
Set stickResponse = Nothing
Collecting Responses Using InLine Script
Adding the Joystick device as an input mask is onlyavailable in E-Prime 2.0 Professional and E-Prime 3.0. Script is necessary to collect joystick responses in E-Prime 2.0 Standard (this can also be done in E-Prime 2.0 Professional and E-Prime 3.0, but using the JoystickResponseData type is preferred).
As an example, a stimulus is presented to the subject using a TextDisplay and is removed from the screen when the subject presses joystick button 1. The response time, the RT relative to the onset of the TextDisplay object, and the joystick cursor's X and Y coordinates are going to be logged. In order to do this, the TextDisplay Object must have a Duration of 0. Then, an InLine must be placed immediately following the TextDisplay. This InLine consists of a loop that runs until a response is detected (this script assumes the TextDisplay object used is named Stimulus):
Loop Until Joystick.Buttons And ebJoystickButton1
c.SetAttrib "JoystickRTTime", Clock.Read
c.SetAttrib "JoystickRT", Clock.Read - Stimulus.OnsetTime
Dim ptCursor As Point
Mouse.GetCursorPos ptCursor.x, ptCursor.y
c.SetAttrib "JoystickX", ptCursor.x
c.SetAttrib "JoystickY", ptCursor.y
NOTE: The joystick is linked to the mouse cursor and thus Mouse.GetCursorPos is used.
Please sign in to leave a comment.