-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.cs
executable file
·54 lines (53 loc) · 2.1 KB
/
Input.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using Structures;
using static Program.Constants;
using static Program.Globals;
using Gtk;
using Gdk;
using Cairo;
using Graphics;
namespace Program {
static class Input {
private static bool canMove = false;
private static Vector3 rootPos = null;
private static Vector3 rootAngle = null;
public static readonly double mouse_sensitivity = 1;
public static readonly double scroll_sensitivity = 1.1;
[GLib.ConnectBefore]
public static void KeyPress(object sender, KeyPressEventArgs args) {
if (args.Event.Key == Gdk.Key.r) {
double d = Vector3.Magnitude(active_syswindow.camera.position);
active_syswindow.camera = new Camera(d,Vector3.zero);
} else if (args.Event.Key == Gdk.Key.l) {
canMove = !canMove;
if (!canMove) {
rootPos = null;
}
}
}
[GLib.ConnectBefore]
public static void MouseMovement(Object sender, MotionNotifyEventArgs args) {
if (canMove) {
if (rootPos == null || rootAngle == null ) {
rootPos = new Vector3(args.Event.X,args.Event.Y,0);
rootAngle = active_syswindow.camera.angle;
} else {
double d = Vector3.Magnitude(active_syswindow.camera.position);
active_syswindow.camera = new Camera(d,rootAngle + deg*mouse_sensitivity* new Vector3(rootPos.y - args.Event.Y,args.Event.X - rootPos.x, 0));
} args.RetVal = true;
}
}
[GLib.ConnectBefore]
public static void Scroll(Object sender, ScrollEventArgs args) {
if (args.Event.Direction == Gdk.ScrollDirection.Up) {
active_syswindow.bounds_multiplier /= scroll_sensitivity;
} else if (args.Event.Direction == Gdk.ScrollDirection.Down) {
active_syswindow.bounds_multiplier *= scroll_sensitivity;
}
}
}
}