summaryrefslogtreecommitdiff
path: root/addons/gut/input_factory.gd
diff options
context:
space:
mode:
authorSophia Pearson <codergal89@gmail.com>2022-10-03 22:22:50 +0200
committerSophia Pearson <codergal89@gmail.com>2022-10-04 22:18:18 +0200
commite127ad39e742396030352240d829bc903b1d4464 (patch)
tree10cc21d70bf13181aef7c8ad0344077ff63579a3 /addons/gut/input_factory.gd
parentddbb045f6387a8ba23b1210b27a745516a387a52 (diff)
downloadtexty-e127ad39e742396030352240d829bc903b1d4464.tar.xz
texty-e127ad39e742396030352240d829bc903b1d4464.zip
godot: inital Godot 4 migration
Diffstat (limited to 'addons/gut/input_factory.gd')
-rw-r--r--addons/gut/input_factory.gd142
1 files changed, 0 insertions, 142 deletions
diff --git a/addons/gut/input_factory.gd b/addons/gut/input_factory.gd
deleted file mode 100644
index 5505553..0000000
--- a/addons/gut/input_factory.gd
+++ /dev/null
@@ -1,142 +0,0 @@
-# ##############################################################################
-#(G)odot (U)nit (T)est class
-#
-# ##############################################################################
-# The MIT License (MIT)
-# =====================
-#
-# Copyright (c) 2020 Tom "Butch" Wesley
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-# ##############################################################################
-# Description
-# -----------
-# ##############################################################################
-
-
-# Implemented InputEvent* convenience methods
-# InputEventAction
-# InputEventKey
-# InputEventMouseButton
-# InputEventMouseMotion
-
-# Yet to implement InputEvents
-# InputEventJoypadButton
-# InputEventJoypadMotion
-# InputEventMagnifyGesture
-# InputEventMIDI
-# InputEventPanGesture
-# InputEventScreenDrag
-# InputEventScreenTouch
-
-
-static func _to_scancode(which):
- var key_code = which
- if(typeof(key_code) == TYPE_STRING):
- key_code = key_code.to_upper().to_ascii()[0]
- return key_code
-
-
-static func new_mouse_button_event(position, global_position, pressed, button_index):
- var event = InputEventMouseButton.new()
- event.position = position
- if(global_position != null):
- event.global_position = global_position
- event.pressed = pressed
- event.button_index = button_index
-
- return event
-
-
-static func key_up(which):
- var event = InputEventKey.new()
- event.scancode = _to_scancode(which)
- event.pressed = false
- return event
-
-
-static func key_down(which):
- var event = InputEventKey.new()
- event.scancode = _to_scancode(which)
- event.pressed = true
- return event
-
-
-static func action_up(which, strength=1.0):
- var event = InputEventAction.new()
- event.action = which
- event.strength = strength
- return event
-
-
-static func action_down(which, strength=1.0):
- var event = InputEventAction.new()
- event.action = which
- event.strength = strength
- event.pressed = true
- return event
-
-
-static func mouse_left_button_down(position, global_position=null):
- var event = new_mouse_button_event(position, global_position, true, BUTTON_LEFT)
- return event
-
-
-static func mouse_left_button_up(position, global_position=null):
- var event = new_mouse_button_event(position, global_position, false, BUTTON_LEFT)
- return event
-
-
-static func mouse_double_click(position, global_position=null):
- var event = new_mouse_button_event(position, global_position, false, BUTTON_LEFT)
- event.doubleclick = true
- return event
-
-
-static func mouse_right_button_down(position, global_position=null):
- var event = new_mouse_button_event(position, global_position, true, BUTTON_RIGHT)
- return event
-
-
-static func mouse_right_button_up(position, global_position=null):
- var event = new_mouse_button_event(position, global_position, false, BUTTON_RIGHT)
- return event
-
-
-static func mouse_motion(position, global_position=null):
- var event = InputEventMouseMotion.new()
- event.position = position
- if(global_position != null):
- event.global_position = global_position
- return event
-
-
-static func mouse_relative_motion(offset, last_motion_event=null, speed=Vector2(0, 0)):
- var event = null
- if(last_motion_event == null):
- event = mouse_motion(offset)
- event.speed = speed
- else:
- event = last_motion_event.duplicate()
- event.position += offset
- event.global_position += offset
- event.relative = offset
- event.speed = speed
- return event