Mouse input #13
Answered
by
VectorSatyr
Feli0TheWriter
asked this question in
Q&A
-
Hello again! I was wondering about mouse input in this engine. I tried adding in mouse input via gameinput configuration but it's behaving weirdly. My mouse inputs dont rely on the mouse at all, but if a button on the keyboard gets pressed, it gets registered as true for some reason. I found there's two input objects, keyboard and gamepad. Can you help with making one for mouse? |
Beta Was this translation helpful? Give feedback.
Answered by
VectorSatyr
Feb 13, 2025
Replies: 2 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Thank you so much!
…On Thu, Feb 13, 2025 at 4:16 PM VectorSatyr ***@***.***> wrote:
In GameMaker, mouse input is also touch input.
This is normally handled by DeviceTouch, which coordinates with
TouchUISign to create clickable UI elements on screen. Certain objects
for the file select menu (eg. FSMenuChoice) also directly handle touch
gestures using eventws.
Adding the ability to map mouse buttons to actions the same way keyboard
and gamepad buttons are would interfere with these controls, but if you are
sure this is what you want, here's some steps:
1. Create a child object of InputSource - we'll call it MouseInput.
Then in the Step Event, add the following:
/// @description Registerevent_inherited();for (var index = ds_map_find_first(buttons);
not is_undefined(index);
index = ds_map_find_next(buttons, index)) {
if (device_mouse_check_button(channel, index)) {
ds_list_add(events, buttons[? index]);
}
}
2. Add the following script function - we'll call it
game_input_event_map_mouse:
/// @desc Binds the given mouse button to the given event so that it registers to the given channel/// @param {real} channel input channel/// @param {string} event event name/// @param {real} button mouse button (see GameMaker documentation for more info)
function game_input_event_map_button(channel, event, button)
{
var exists = false;
with (MouseInput) {
if (self.channel == channel) {
exists = true;
if (event == "") {
ds_map_delete(buttons, button);
} else {
ds_map_replace(buttons, button, event);
}
}
}
if (not exists and event != "") {
with (instance_create_layer(0, 0, "general", MouseInput)) {
self.channel = channel;
ds_map_replace(buttons, button, event);
}
}
}
3. Use game_input_event_map_mouse to map mouse buttons as you desire.
—
Reply to this email directly, view it on GitHub
<#13 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNPSI3CNMJXGZ6C7G7GMOPL2PUDSBAVCNFSM6AAAAABXC5J5YKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMJZGI4TMMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In GameMaker, mouse input is also touch input.
This is normally handled by
DeviceTouch
, which coordinates withTouchUISign
to create clickable UI elements on screen. Certain objects for the file select menu (eg.FSMenuChoice
) also directly handle touch gestures using events.Adding the ability to map mouse buttons to actions the same way keyboard and gamepad buttons are would interfere with these controls, but if you are sure this is what you want, here's some steps:
InputSource
- we'll call itMouseInput
. Then in the Step Event, add the following: