-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseApplication.input.cs
More file actions
159 lines (127 loc) · 4.79 KB
/
BaseApplication.input.cs
File metadata and controls
159 lines (127 loc) · 4.79 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
using MOIS;
using System;
namespace Mogre.TutorialFramework
{
public abstract partial class BaseApplication
{
protected Keyboard mKeyboard;
protected Mouse mMouse;
protected virtual void InitializeInput()
{
LogManager.Singleton.LogMessage("*** Initializing OIS ***");
int windowHnd;
mWindow.GetCustomAttribute("WINDOW", out windowHnd);
var inputMgr = MOIS.InputManager.CreateInputSystem((uint)windowHnd);
mKeyboard = (MOIS.Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true);
mMouse = (MOIS.Mouse) inputMgr.CreateInputObject(MOIS.Type.OISMouse, true);
mKeyboard.KeyPressed += new KeyListener.KeyPressedHandler( OnKeyPressed);
mKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler( OnKeyReleased);
mMouse.MouseMoved += new MouseListener.MouseMovedHandler( OnMouseMoved);
mMouse.MousePressed += new MouseListener.MousePressedHandler( OnMousePressed);
mMouse.MouseReleased += new MouseListener.MouseReleasedHandler(OnMouseReleased);
}
protected void ProcessInput()
{
mKeyboard.Capture();
mMouse.Capture();
}
protected virtual bool OnKeyPressed(KeyEvent evt)
{
switch (evt.key)
{
case KeyCode.KC_W:
case KeyCode.KC_UP:
mCameraMan.GoingForward = true;
break;
case KeyCode.KC_S:
case KeyCode.KC_DOWN:
mCameraMan.GoingBack = true;
break;
case KeyCode.KC_A:
case KeyCode.KC_LEFT:
mCameraMan.GoingLeft = true;
break;
case KeyCode.KC_D:
case KeyCode.KC_RIGHT:
mCameraMan.GoingRight = true;
break;
case KeyCode.KC_E:
case KeyCode.KC_PGUP:
mCameraMan.GoingUp = true;
break;
case KeyCode.KC_Q:
case KeyCode.KC_PGDOWN:
mCameraMan.GoingDown = true;
break;
case KeyCode.KC_LSHIFT:
case KeyCode.KC_RSHIFT:
mCameraMan.FastMove = true;
break;
case KeyCode.KC_T:
CycleTextureFilteringMode();
break;
case KeyCode.KC_R:
CyclePolygonMode();
break;
case KeyCode.KC_F5:
ReloadAllTextures();
break;
case KeyCode.KC_SYSRQ:
TakeScreenshot();
break;
case KeyCode.KC_ESCAPE:
Shutdown();
break;
}
return true;
}
protected virtual bool OnKeyReleased(KeyEvent evt)
{
switch (evt.key)
{
case KeyCode.KC_W:
case KeyCode.KC_UP:
mCameraMan.GoingForward = false;
break;
case KeyCode.KC_S:
case KeyCode.KC_DOWN:
mCameraMan.GoingBack = false;
break;
case KeyCode.KC_A:
case KeyCode.KC_LEFT:
mCameraMan.GoingLeft = false;
break;
case KeyCode.KC_D:
case KeyCode.KC_RIGHT:
mCameraMan.GoingRight = false;
break;
case KeyCode.KC_E:
case KeyCode.KC_PGUP:
mCameraMan.GoingUp = false;
break;
case KeyCode.KC_Q:
case KeyCode.KC_PGDOWN:
mCameraMan.GoingDown = false;
break;
case KeyCode.KC_LSHIFT:
case KeyCode.KC_RSHIFT:
mCameraMan.FastMove = false;
break;
}
return true;
}
protected virtual bool OnMouseMoved(MouseEvent evt)
{
mCameraMan.MouseMovement(evt.state.X.rel, evt.state.Y.rel);
return true;
}
protected virtual bool OnMousePressed(MouseEvent evt, MouseButtonID id)
{
return true;
}
protected virtual bool OnMouseReleased(MouseEvent evt, MouseButtonID id)
{
return true;
}
}
}