Controlling cursor speed when using a joystick

David McFarlane mcfarla9 at msu.edu
Thu May 12 17:58:10 UTC 2011


Erin,

Thanks for posting the full information from PST, that helped (can 
you let us know which staff member helped you?).  I might have come 
up with the Mouse.SetCursorPos approach myself, but not the 
Mouse.SetCursorLimits approach, that approach seems a little wacky to 
me but what do I know?.

As for Mouse.SetCursorPos, this posed a nice little puzzle, so I 
knocked out a quick demo, and here is the inline that I came up 
with.  (Just to have a mouse click to respond to, I preceded the 
inline with a TextDisplay called StimText, set to Duration of 0 and 
mouse with Time Limit of (infinite)):


/----------------------------------------------------------------------\
' Code to modify the rate of mouse movement.

Const  LoopDelay as Long = 0
Const  CursorMoveFactor as Single = 0.5

Dim  x0 as Long, y0 as Long
Dim  x1 as Long, y1 as Long

Mouse.GetCursorPos x0, y0  ' initialize
Do While (StimText.RT = 0)  ' replace this with your exit condition
     Mouse.GetCursorPos x1, y1
     x0 = x0 + (CursorMoveFactor * (x1 - x0))
     y0 = y0 + (CursorMoveFactor * (y1 - y0))
     Mouse.SetCursorPos x0, y0
     Sleep LoopDelay
Loop
\----------------------------------------------------------------------/


I expected to find some cursor movement artifacts, but it really 
worked rather smoothly.  As you can see, I didn't even really need 
the LoopDelay, but I left it there just in case.

-- David McFarlane, Professional Faultfinder


At 5/12/2011 01:03 PM Thursday, you wrote:
>I want to control the speed the cursor moves when controlling it with
>a joystick.  I set the joystick to emulate the mouse in my experiment
>(inline Joystick.AttachToMouseCursor = True).  The joystick is quite
>touchy, and causes the cursor to move very quickly across the screen.
>For my experiment, I need the cursor to only move slowly, no matter
>how much the joystick is moved.
>
>I tried decreasing the mouse sensitivity settings on my computer.
>This slowed the cursor down when using the mouse within my experiment,
>but had no effect on the joystick.  I also tried increasing the
>resolution display of my experiment (giving the cursor "further" to
>travel)- also no effect.  I have also tried adjusting the sensitivity
>of my joystick, but the cursor is still too fast.
>
>E-Prime support suggested the following: "E-Prime does have some
>limited options for positioning the mouse cursor and limiting its
>boundaries. We could try to use a combination of the two to make the
>mouse cursor move more slowly. However, this would require significant
>scripting and could result in the cursor movement not being smooth"
>
>My main question: Is anyone aware of a simpler way of controlling the
>cursor speed in E-Prime?
>
>
>If not, here is further information on this method:
>
>
>E-Prime help suggested the following:
>"I would recommend taking a look at the MouseDevice.SetCursorLimits
>and MouseDevice.SetCursorPos topics in the E-Basic Help (accessed via
>the Help menu). The former will allow you to specify boundaries for
>the cursor, and the latter will allow you to position the mouse cursor
>in a specific area. You could use a combination of the two to first
>limit the movement of the cursor so that it does not immediately move
>to one edge of the screen, and then use SetCursorPos to move the
>cursor move slowly. You could also slowly expand the cursor limits as
>the cursor hits the maximum in one direction. This would allow you to
>give the appearance of the cursor moving more slowly. To do this, you
>would have a loop that continuously checks the cursor position against
>the limits that are set, and expand the limits in one direction as the
>cursor hits that limit. This would require significant scripting and
>could result in the cursor movement not being smooth."
>
>I took a look at the MouseDevice.SetCursorLimits and
>MouseDevice.SetCursorPos help, and I understand how this would work in
>theory.  However, I am very new to programming, and I am afraid that
>the scripting involved is a bit over my head.  If anyone can offer any
>advice or pointers, it would be very appreciated.  thank you!
>
>Erin

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list