aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/fangWin.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-03 01:47:19 +1000
committerDavid Walter Seikel2014-05-03 01:47:19 +1000
commite8678fdfe62bf62113baef2948874c0adfc82045 (patch)
treee2f0e4a14126fb5e9637802a42db9205be2897cf /src/extantz/fangWin.c
parentMajor cleanup of extantz, part one. (diff)
downloadSledjHamr-e8678fdfe62bf62113baef2948874c0adfc82045.zip
SledjHamr-e8678fdfe62bf62113baef2948874c0adfc82045.tar.gz
SledjHamr-e8678fdfe62bf62113baef2948874c0adfc82045.tar.bz2
SledjHamr-e8678fdfe62bf62113baef2948874c0adfc82045.tar.xz
Major extantz clean up part 2. Including new Evas_3d style camera.
Diffstat (limited to 'src/extantz/fangWin.c')
-rw-r--r--src/extantz/fangWin.c174
1 files changed, 1 insertions, 173 deletions
diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c
index 06bfde4..8f68658 100644
--- a/src/extantz/fangWin.c
+++ b/src/extantz/fangWin.c
@@ -1,176 +1,6 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3 3
4static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
5{
6 GLData *gld = data;
7 Evas_Event_Key_Down *ev = event_info;
8
9 if (gld->move)
10 {
11 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
12
13 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
14 // TODO - make this a hash lookup dammit.
15 if (0 == strcmp(ev->key, "Escape"))
16 {
17 }
18 else if (0 == strcmp(ev->key, "Left"))
19 gld->move->r = 2.0;
20 else if (0 == strcmp(ev->key, "Right"))
21 gld->move->r = -2.0;
22 else if (0 == strcmp(ev->key, "Up"))
23 gld->move->x = 2.0;
24 else if (0 == strcmp(ev->key, "Down"))
25 gld->move->x = -2.0;
26// else if (0 == strcmp(ev->key, "Prior"))
27// ;
28// else if (0 == strcmp(ev->key, "Next"))
29// ;
30// else if (0 == strcmp(ev->key, "Home"))
31// ;
32// else if (0 == strcmp(ev->key, "End"))
33// ;
34 else if (0 == strcmp(ev->key, "space"))
35 gld->move->jump = 1.0;
36 else
37 printf("Unexpected down keystroke - %s\n", ev->key);
38 }
39 else
40 printf("Camera input not ready\n");
41}
42
43/* SL / OS camera controls
44 up / down / w / s moves avatar forward / backward
45 shifted version does the same
46 double tap triggers run mode / or fast fly mode
47 Running backwards turns your avatar to suit, walking does not.
48 left / right / a / d rotates avatar left / right, strafes in mouselook
49 shifted version turns the avatar to walk sideways, so not really a strafe.
50 So not sure if the "strafe" in mouse look turns the avatar as well?
51 PgDn / c crouch while it is held down move up in flight mode
52 PgUp jump move down in flight mode
53 Home toggle flying
54 End Nothing?
55 Esc return to third person view
56 m toggle mouse look
57 mouse wheel move view closer / further away from current focused object or avatar
58 Alt left click focus on some other object
59 Ins ???
60 Del ???
61 BS ???
62 Tab ???
63
64 Mouse look is just first person view, moving mouse looks left / right / up / down.
65 Not sure if the avatar rotates with left / right, but that's likely.
66
67 mouse moves With the left mouse button held down -
68 left / right up / down
69 ---------------------------------
70 for avatar swings avatar around zoom in and out of avatar
71 for object nothing
72 alt orbit left / right zoom in and out
73 alt ctrl orbit left / right orbit up / down
74 alt shift orbit left / right zoom in and out
75 alt ctrl shift shift view left / right / up / down
76 ctrl Nothing?
77 shift Nothing?
78 ctrl shift Nothing?
79
80 Need to also consider when looking at a moving object / avatar.
81
82 I think there are other letter keys that duplicate arrow keys and such. I'll look for them later, but I don't use them.
83 No idea what the function keys are mapped to, but think it's various non camera stuff.
84 I'm damn well leaving the Win/Command and Menu keys for the OS / window manager. lol
85 Keypad keys? Not interested, I don't have them.
86 Print Screen / SysRq, Pause / Break, other oddball keys, also not interested.
87 NOTE - gonna have an easily programmable "bind key to command" thingy, like E17s, so that can deal with other keys.
88 Should even let them be saveable so people can swap them with other people easily.
89
90 TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc.
91*/
92
93/* A moveRotate array of floats.
94 * X, Y, Z, and whatever the usual letters are for rotations. lol
95 * Each one means "move or rotate this much in this direction".
96 * Where 1.0 means "what ever the standard move is if that key is held down".
97 * So a keyboard move would just change it's part to 1.0 or -1.0 on key down,
98 * and back to 0.0 on key up. Or 2.0 / -2.0 if in run mode.
99 * Which would even work in fly mode.
100 * A joystick could be set to range over -2.0 to 2.0, and just set it's part directly.
101 * A mouse look rotate, well will come to that when we need to. B-)
102 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame.
103 *
104 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL.
105 */
106
107static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
108{
109 GLData *gld = data;
110 Evas_Event_Key_Up *ev = event_info;
111
112 if (gld->move)
113 {
114 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
115
116 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
117 // TODO - make this a hash lookup dammit.
118 if (0 == strcmp(ev->key, "Escape"))
119 {
120 }
121 else if (0 == strcmp(ev->key, "Left"))
122 gld->move->r = 0.0;
123 else if (0 == strcmp(ev->key, "Right"))
124 gld->move->r = 0.0;
125 else if (0 == strcmp(ev->key, "Up"))
126 gld->move->x = 0.0;
127 else if (0 == strcmp(ev->key, "Down"))
128 gld->move->x = 0.0;
129// else if (0 == strcmp(ev->key, "Prior"))
130// ;
131// else if (0 == strcmp(ev->key, "Next"))
132// ;
133// else if (0 == strcmp(ev->key, "Home"))
134// ;
135// else if (0 == strcmp(ev->key, "End"))
136// ;
137 else if (0 == strcmp(ev->key, "space"))
138 gld->move->jump = 0.0;
139 else
140 printf("Unexpected up keystroke - %s\n", ev->key);
141 }
142 else
143 printf("Camera input not ready\n");
144}
145
146// Elm style event callback.
147static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
148{
149 GLData *gld = data;
150 Eina_Bool processed = EINA_FALSE;
151
152 switch (type)
153 {
154 case EVAS_CALLBACK_KEY_DOWN :
155 {
156 _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info);
157 processed = EINA_TRUE;
158 break;
159 }
160
161 case EVAS_CALLBACK_KEY_UP :
162 {
163 _on_camera_input_up(gld, evas_object_evas_get(obj), obj, event_info);
164 processed = EINA_TRUE;
165 break;
166 }
167
168 default :
169 printf("Unknown GL input event.\n");
170 }
171
172 return processed;
173}
174 4
175// Elm inlined image windows needs this to change focus on mouse click. 5// Elm inlined image windows needs this to change focus on mouse click.
176// Evas style event callback. 6// Evas style event callback.
@@ -305,9 +135,7 @@ void overlay_add(GLData *gld)
305 // According to the Elm inlined image window example, this is what's needed to. 135 // According to the Elm inlined image window example, this is what's needed to.
306 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld); 136 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
307 // In this code, we are making our own camera, so grab it's input when we are focused. 137 // In this code, we are making our own camera, so grab it's input when we are focused.
308 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld); 138 cameraAdd(gld->winwin, gld);
309 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
310 elm_object_event_callback_add(gld->winwin, _cb_event_GL, gld);
311 139
312 elm_win_alpha_set(gld->winwin, EINA_TRUE); 140 elm_win_alpha_set(gld->winwin, EINA_TRUE);
313 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. 141 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.