Pixel-Composer/scripts/mouse_input/mouse_input.gml

109 lines
2.5 KiB
Text
Raw Normal View History

2022-12-23 04:45:52 +01:00
#region mouse global
2024-03-26 04:03:45 +01:00
globalvar CURSOR, CURSOR_LOCK, CURSOR_IS_LOCK, CURSOR_LOCK_X, CURSOR_LOCK_Y;
2024-01-16 11:00:39 +01:00
globalvar MOUSE_WRAP, MOUSE_WRAPPING, MOUSE_BLOCK, _MOUSE_BLOCK;
2023-04-07 21:25:27 +02:00
2023-12-05 09:51:24 +01:00
MOUSE_WRAP = false;
2022-12-23 04:45:52 +01:00
MOUSE_WRAPPING = false;
2024-01-16 11:00:39 +01:00
MOUSE_BLOCK = false;
_MOUSE_BLOCK = false;
2024-03-02 10:08:44 +01:00
PEN_RELEASED = false;
2022-12-23 04:45:52 +01:00
2023-10-31 05:30:42 +01:00
#macro SCROLL_SPEED PREFERENCES.mouse_wheel_speed
2023-04-07 21:25:27 +02:00
2022-12-23 04:45:52 +01:00
function setMouseWrap() {
2023-12-05 09:51:24 +01:00
INLINE
2022-12-23 04:45:52 +01:00
MOUSE_WRAP = true;
}
2024-01-16 11:00:39 +01:00
#endregion
2024-03-02 10:08:44 +01:00
function mouse_click(mouse, focus = true) { #region
2024-01-16 11:00:39 +01:00
INLINE
2024-03-02 10:08:44 +01:00
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_CLICK) return mouse == mb_right;
return mouse_check_button(mouse);
} #endregion
function mouse_press(mouse, focus = true) { #region
INLINE
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_PRESS) return mouse == mb_right;
return mouse_check_button_pressed(mouse);
} #endregion
function mouse_release(mouse, focus = true) { #region
INLINE
if(!focus) return false;
if(PEN_RIGHT_RELEASE) return mouse == mb_right;
return mouse_check_button_released(mouse) || (mouse == mb_left && PEN_RELEASED);
} #endregion
function mouse_lclick(focus = true) { #region
INLINE
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_CLICK || PEN_RIGHT_RELEASE) return false;
return mouse_check_button(mb_left);
} #endregion
function mouse_lpress(focus = true) { #region
INLINE
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_PRESS) return false;
return mouse_check_button_pressed(mb_left);
} #endregion
function mouse_lrelease(focus = true) { #region
INLINE
if(!focus) return false;
if(PEN_RIGHT_RELEASE) return false;
if(PEN_RELEASED) return true;
return mouse_check_button_released(mb_left);
} #endregion
function mouse_rclick(focus = true) { #region
INLINE
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_CLICK) return true;
return mouse_check_button(mb_right);
} #endregion
2024-01-16 11:00:39 +01:00
2024-03-02 10:08:44 +01:00
function mouse_rpress(focus = true) { #region
2024-01-16 11:00:39 +01:00
INLINE
2024-03-02 10:08:44 +01:00
if(MOUSE_BLOCK) return false;
if(!focus) return false;
if(PEN_RIGHT_PRESS) return true;
return mouse_check_button_pressed(mb_right);
} #endregion
2024-01-16 11:00:39 +01:00
2024-03-02 10:08:44 +01:00
function mouse_rrelease(focus = true) { #region
2024-01-16 11:00:39 +01:00
INLINE
2024-03-02 10:08:44 +01:00
if(!focus) return false;
if(PEN_RIGHT_RELEASE) return true;
return mouse_check_button_released(mb_right);
2024-03-26 04:03:45 +01:00
} #endregion
function mouse_lock(mx = CURSOR_LOCK_X, my = CURSOR_LOCK_Y) { #region
INLINE
CURSOR_LOCK = true;
CURSOR_LOCK_X = mx;
CURSOR_LOCK_Y = my;
window_mouse_set(CURSOR_LOCK_X, CURSOR_LOCK_Y);
2024-03-02 10:08:44 +01:00
} #endregion