Hi Chris!
I am an intern at the DPZ and I was running a trial experiment. I have created a dot as my cursor, but i want to change the speed of it, because it is too fast to control. How could I achieve that?
Thanks a lot beforehand
Hi Chris!
I am an intern at the DPZ and I was running a trial experiment. I have created a dot as my cursor, but i want to change the speed of it, because it is too fast to control. How could I achieve that?
Thanks a lot beforehand
Hi,
If the problem is the mouse tracking speed, then you’ll need to adjust that in the macOS settings:
https://support.apple.com/guide/mac-help/mouse-settings-mh29222/mac
If that’s not the issue, can you tell me in more detail how you created the cursor?
FYI, I’m away on vacation this week, so I’ll only be able to provide limited assistance until I return.
Cheers,
Chris
Hello!
I don’t think that the issue, because I tried it and it didn’t change anything.
The code for the cursors is this:
var xAgent = 0
var yAgent = 0
mouse_input mouse1(
mouse_position_x = xAgent
mouse_position_y = yAgent
autostart = true
)
mouse_input mouse2(
mouse_position_x = xAgent
mouse_position_y = yAgent
autostart = true
)
var IO_mouseX_pos = 0
var IO_mouseY_pos = 0
var cursor1_x = 0
var cursor1_y = 0
var cursor2_x = 0
var cursor2_y = 0
var IO_mouseX_raw = 0 {
IO_mouseX_pos += IO_mouseX_raw
if (abs(IO_mouseX_pos) > 1024) {
IO_mouseX_pos = IO_mouseX_pos / abs(IO_mouseX_pos) * 1024
}
cursor1_x = IO_mouseX_pos / 1024 * 20
cursor1_y = IO_mouseY_pos / 1024 * -20
}
var IO_mouseY_raw = 0 {
IO_mouseY_pos += IO_mouseY_raw
if (abs(IO_mouseY_pos) > 1024) {
IO_mouseY_pos = IO_mouseY_pos / abs(IO_mouseY_pos) * 1024
}
}
var IO_mouseDown = 0 {
IO_mouseX_pos = 0
IO_mouseY_pos = 0
}
var IO_mouse2X_pos = 0
var IO_mouse2Y_pos = 0
var IO_mouse2X_raw = 0 {
IO_mouse2X_pos += IO_mouse2X_raw
if (abs(IO_mouse2X_pos) > 1024) {
IO_mouse2X_pos = IO_mouse2X_pos / abs(IO_mouse2X_pos) * 1024
}
cursor2_x = IO_mouse2X_pos / 1024 * -20
cursor2_y = IO_mouse2Y_pos / 1024 * -20
}
var IO_mouse2Y_raw = 0 {
IO_mouse2Y_pos += IO_mouse2Y_raw
if (abs(IO_mouse2Y_pos) > 1024) {
IO_mouse2Y_pos = IO_mouse2Y_pos / abs(IO_mouse2Y_pos) * 1024
}
}
var IO_mouse2Down = 0 {
IO_mouse2X_pos = 0
IO_mouse2Y_pos = 0
}
iodevice/usbhid_generic maus1 (
preferred_location_id = 1893965574
usage_page = 1
usage = 1
//log_all_input_values = true
autostart = true
) {
usbhid_generic_input_channel (usage_page = 1; usage = 48; value = IO_mouseX_raw)
usbhid_generic_input_channel (usage_page = 1; usage = 49; value = IO_mouseY_raw)
usbhid_generic_input_channel (usage_page = 9; usage = 1; value = IO_mouseDown)
}
iodevice/usbhid_generic maus2 (
preferred_location_id = 1245184
usage_page = 1
usage = 1
//log_all_input_values = true
autostart = true
) {
usbhid_generic_input_channel (usage_page = 1; usage = 48; value = IO_mouse2X_raw)
usbhid_generic_input_channel (usage_page = 1; usage = 49; value = IO_mouse2Y_raw)
usbhid_generic_input_channel (usage_page = 9; usage = 1; value = IO_mouse2Down)
}
stimulus_display (
background_color = 0,0,0
redraw_on_every_refresh = true
)
circle cursor1 (
color = 0,1,0
x_size = 0.3
x_position = IO_mouseX_pos / 1024 * 20
y_position = IO_mouseY_pos / 1024 * -20
alpha_multiplier = 1 //transparency
)
circle cursor2 (
color = 1,0,0
x_size = 0.3
x_position = IO_mouse2X_pos / 1024 * -20
y_position = IO_mouse2Y_pos / 1024 * -20
alpha_multiplier = 1
)
var dummyX = 0
var dummyY = 0
iodevice/mouse_input mouse (
mouse_position_x = dummyX
mouse_position_y = dummyY
hide_cursor = true
)
When I changed the value of cursor1_x and from IO_mouseX_pos / 1024 * 20 to IO_mouseX_pos / 1024 * 10, it changed the speed, but also the range of the cursor.
Did that help?
Thanks a lot,
Evan
Hi Evan,
Thanks for sharing your code.
I see you’re getting the cursor location via a USB HID device, instead of a mouse input device. That explains why changing the system mouse tracking speed didn’t have any effect. Are you doing this because you need to track two mice independently?
Interfacing with a mouse via a USB HID device is difficult, because you have to translate the data from the mouse in to screen position manually. That said, I think you can control the speed of the cursor by multiplying IO_mouseX_raw
/ IO_mouseY_raw
by a scaling factor before adding it to IO_mouseX_pos
/ IO_mouseY_pos
. For example, in the actions attached to IO_mouseX_raw
, replace
IO_mouseX_pos += IO_mouseX_raw
with this:
IO_mouseX_pos += 0.5 * IO_mouseX_raw
I’m just using a scaling factor of 0.5 as an example. You can experiment to find the right value for the speed you want.
Cheers,
Chris
Hi Chris!
Sorry for the late reply.
It worked perfectly.
Thank you very much!