diff options
author | David Walter Seikel | 2014-05-03 23:39:04 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-03 23:39:04 +1000 |
commit | a921d6a43e9517bdbb6d609d5934f46853980b1c (patch) | |
tree | 750788ba4016d719f78b1d4e98d7058e77127058 /src/extantz/camera.c | |
parent | Using elm_obj_widget_part_text_set() works, but it's really private API that ... (diff) | |
download | SledjHamr-a921d6a43e9517bdbb6d609d5934f46853980b1c.zip SledjHamr-a921d6a43e9517bdbb6d609d5934f46853980b1c.tar.gz SledjHamr-a921d6a43e9517bdbb6d609d5934f46853980b1c.tar.bz2 SledjHamr-a921d6a43e9517bdbb6d609d5934f46853980b1c.tar.xz |
White space clean ups from uncrustify.
Diffstat (limited to 'src/extantz/camera.c')
-rw-r--r-- | src/extantz/camera.c | 251 |
1 files changed, 114 insertions, 137 deletions
diff --git a/src/extantz/camera.c b/src/extantz/camera.c index 41ce25c..e566fbb 100644 --- a/src/extantz/camera.c +++ b/src/extantz/camera.c | |||
@@ -1,94 +1,83 @@ | |||
1 | #include "extantz.h" | 1 | #include "extantz.h" |
2 | 2 | ||
3 | |||
4 | static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | 3 | static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) |
5 | { | 4 | { |
6 | GLData *gld = data; | 5 | globals *ourGlobals = data; |
7 | Evas_Event_Key_Down *ev = event_info; | 6 | GLData *gld = &ourGlobals->gld; |
7 | Evas_Event_Key_Down *ev = event_info; | ||
8 | 8 | ||
9 | if (gld->move) | 9 | if (gld->move) |
10 | { | 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. | 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 | 12 | ||
13 | // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... | 13 | // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... |
14 | // TODO - make this a hash lookup dammit. | 14 | // TODO - make this a hash lookup dammit. |
15 | if (0 == strcmp(ev->key, "Escape")) | 15 | if (0 == strcmp(ev->key, "Escape")) |
16 | { | 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 | gld->move->z = -2.0; | ||
28 | else if (0 == strcmp(ev->key, "Next")) | ||
29 | gld->move->z = 2.0; | ||
30 | else if (0 == strcmp(ev->key, "Home")) | ||
31 | gld->move->y = 2.0; | ||
32 | else if (0 == strcmp(ev->key, "End")) | ||
33 | gld->move->y = -2.0; | ||
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 | } | 17 | } |
39 | else | 18 | else if (0 == strcmp(ev->key, "Left")) gld->move->r = 2.0; |
40 | printf("Camera input not ready\n"); | 19 | else if (0 == strcmp(ev->key, "Right")) gld->move->r = -2.0; |
20 | else if (0 == strcmp(ev->key, "Up")) gld->move->x = 2.0; | ||
21 | else if (0 == strcmp(ev->key, "Down")) gld->move->x = -2.0; | ||
22 | else if (0 == strcmp(ev->key, "Prior")) gld->move->z = -2.0; | ||
23 | else if (0 == strcmp(ev->key, "Next")) gld->move->z = 2.0; | ||
24 | else if (0 == strcmp(ev->key, "Home")) gld->move->y = 2.0; | ||
25 | else if (0 == strcmp(ev->key, "End")) gld->move->y = -2.0; | ||
26 | else if (0 == strcmp(ev->key, "space")) gld->move->jump = 1.0; | ||
27 | else printf("Unexpected down keystroke - %s\n", ev->key); | ||
28 | } | ||
29 | else printf("Camera input not ready\n"); | ||
41 | } | 30 | } |
42 | 31 | ||
43 | /* SL / OS camera controls | 32 | /* SL / OS camera controls |
44 | up / down / w / s moves avatar forward / backward | 33 | * up / down / w / s moves avatar forward / backward |
45 | shifted version does the same | 34 | * shifted version does the same |
46 | double tap triggers run mode / or fast fly mode | 35 | * double tap triggers run mode / or fast fly mode |
47 | Running backwards turns your avatar to suit, walking does not. | 36 | * Running backwards turns your avatar to suit, walking does not. |
48 | left / right / a / d rotates avatar left / right, strafes in mouselook | 37 | * 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. | 38 | * 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? | 39 | * 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 | 40 | * PgDn / c crouch while it is held down move up in flight mode |
52 | PgUp jump move down in flight mode | 41 | * PgUp jump move down in flight mode |
53 | Home toggle flying | 42 | * Home toggle flying |
54 | End Nothing? | 43 | * End Nothing? |
55 | Esc return to third person view | 44 | * Esc return to third person view |
56 | m toggle mouse look | 45 | * m toggle mouse look |
57 | mouse wheel move view closer / further away from current focused object or avatar | 46 | * mouse wheel move view closer / further away from current focused object or avatar |
58 | Alt left click focus on some other object | 47 | * Alt left click focus on some other object |
59 | Ins ??? | 48 | * Ins ??? |
60 | Del ??? | 49 | * Del ??? |
61 | BS ??? | 50 | * BS ??? |
62 | Tab ??? | 51 | * Tab ??? |
63 | 52 | * | |
64 | Mouse look is just first person view, moving mouse looks left / right / up / down. | 53 | * 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. | 54 | * Not sure if the avatar rotates with left / right, but that's likely. |
66 | 55 | * | |
67 | mouse moves With the left mouse button held down - | 56 | * mouse moves With the left mouse button held down - |
68 | left / right up / down | 57 | * left / right up / down |
69 | --------------------------------- | 58 | * --------------------------------- |
70 | for avatar swings avatar around zoom in and out of avatar | 59 | * for avatar swings avatar around zoom in and out of avatar |
71 | for object nothing | 60 | * for object nothing |
72 | alt orbit left / right zoom in and out | 61 | * alt orbit left / right zoom in and out |
73 | alt ctrl orbit left / right orbit up / down | 62 | * alt ctrl orbit left / right orbit up / down |
74 | alt shift orbit left / right zoom in and out | 63 | * alt shift orbit left / right zoom in and out |
75 | alt ctrl shift shift view left / right / up / down | 64 | * alt ctrl shift shift view left / right / up / down |
76 | ctrl Nothing? | 65 | * ctrl Nothing? |
77 | shift Nothing? | 66 | * shift Nothing? |
78 | ctrl shift Nothing? | 67 | * ctrl shift Nothing? |
79 | 68 | * | |
80 | Need to also consider when looking at a moving object / avatar. | 69 | * Need to also consider when looking at a moving object / avatar. |
81 | 70 | * | |
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. | 71 | * 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. | 72 | * 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 | 73 | * 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. | 74 | * Keypad keys? Not interested, I don't have them. |
86 | Print Screen / SysRq, Pause / Break, other oddball keys, also not interested. | 75 | * 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. | 76 | * 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. | 77 | * Should even let them be saveable so people can swap them with other people easily. |
89 | 78 | * | |
90 | TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc. | 79 | * TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc. |
91 | */ | 80 | */ |
92 | 81 | ||
93 | /* A moveRotate array of floats. | 82 | /* A moveRotate array of floats. |
94 | * X, Y, Z, and whatever the usual letters are for rotations. lol | 83 | * X, Y, Z, and whatever the usual letters are for rotations. lol |
@@ -106,77 +95,65 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void | |||
106 | 95 | ||
107 | static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) | 96 | static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) |
108 | { | 97 | { |
109 | GLData *gld = data; | 98 | globals *ourGlobals = data; |
110 | Evas_Event_Key_Up *ev = event_info; | 99 | GLData *gld = &ourGlobals->gld; |
100 | Evas_Event_Key_Up *ev = event_info; | ||
111 | 101 | ||
112 | if (gld->move) | 102 | if (gld->move) |
113 | { | 103 | { |
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. | 104 | // 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 | 105 | ||
116 | // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... | 106 | // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... |
117 | // TODO - make this a hash lookup dammit. | 107 | // TODO - make this a hash lookup dammit. |
118 | if (0 == strcmp(ev->key, "Escape")) | 108 | if (0 == strcmp(ev->key, "Escape")) |
119 | { | 109 | { |
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 | gld->move->z = 0.0; | ||
131 | else if (0 == strcmp(ev->key, "Next")) | ||
132 | gld->move->z = 0.0; | ||
133 | else if (0 == strcmp(ev->key, "Home")) | ||
134 | gld->move->y = 0.0; | ||
135 | else if (0 == strcmp(ev->key, "End")) | ||
136 | gld->move->y = 0.0; | ||
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 | } | 110 | } |
142 | else | 111 | else if (0 == strcmp(ev->key, "Left")) gld->move->r = 0.0; |
143 | printf("Camera input not ready\n"); | 112 | else if (0 == strcmp(ev->key, "Right")) gld->move->r = 0.0; |
113 | else if (0 == strcmp(ev->key, "Up")) gld->move->x = 0.0; | ||
114 | else if (0 == strcmp(ev->key, "Down")) gld->move->x = 0.0; | ||
115 | else if (0 == strcmp(ev->key, "Prior")) gld->move->z = 0.0; | ||
116 | else if (0 == strcmp(ev->key, "Next")) gld->move->z = 0.0; | ||
117 | else if (0 == strcmp(ev->key, "Home")) gld->move->y = 0.0; | ||
118 | else if (0 == strcmp(ev->key, "End")) gld->move->y = 0.0; | ||
119 | else if (0 == strcmp(ev->key, "space")) gld->move->jump = 0.0; | ||
120 | else printf("Unexpected up keystroke - %s\n", ev->key); | ||
121 | } | ||
122 | else printf("Camera input not ready\n"); | ||
144 | } | 123 | } |
145 | 124 | ||
146 | // Elm style event callback. | 125 | // Elm style event callback. |
147 | static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info) | 126 | static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info) |
148 | { | 127 | { |
149 | GLData *gld = data; | 128 | Eina_Bool processed = EINA_FALSE; |
150 | Eina_Bool processed = EINA_FALSE; | ||
151 | 129 | ||
152 | switch (type) | 130 | switch (type) |
131 | { | ||
132 | case EVAS_CALLBACK_KEY_DOWN : | ||
153 | { | 133 | { |
154 | case EVAS_CALLBACK_KEY_DOWN : | 134 | _on_camera_input_down(data, evas_object_evas_get(obj), obj, event_info); |
155 | { | 135 | processed = EINA_TRUE; |
156 | _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info); | 136 | break; |
157 | processed = EINA_TRUE; | 137 | } |
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 | 138 | ||
168 | default : | 139 | case EVAS_CALLBACK_KEY_UP : |
169 | printf("Unknown GL input event.\n"); | 140 | { |
141 | _on_camera_input_up(data, evas_object_evas_get(obj), obj, event_info); | ||
142 | processed = EINA_TRUE; | ||
143 | break; | ||
170 | } | 144 | } |
171 | 145 | ||
172 | return processed; | 146 | default : |
173 | } | 147 | printf("Unknown GL input event.\n"); |
148 | } /* switch */ | ||
174 | 149 | ||
150 | return processed; | ||
151 | } | ||
175 | 152 | ||
176 | void cameraAdd(Evas_Object *win, GLData *gld) | 153 | void cameraAdd(globals *ourGlobals, Evas_Object *win) |
177 | { | 154 | { |
178 | // In this code, we are making our own camera, so grab it's input when we are focused. | 155 | // In this code, we are making our own camera, so grab it's input when we are focused. |
179 | evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld); | 156 | evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, ourGlobals); |
180 | evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld); | 157 | evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, ourGlobals); |
181 | elm_object_event_callback_add(win, _cb_event_GL, gld); | 158 | elm_object_event_callback_add(win, _cb_event_GL, ourGlobals); |
182 | } | 159 | } |