From 08c416d49b10ba1a30d398980641a9d8b5ce4494 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 27 Jan 2013 11:19:12 +1000 Subject: Make keyboard rotation work. --- ClientHamr/extantz/extantz.c | 18 ++++++++++-------- ClientHamr/extantz/extantzCamera.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'ClientHamr') diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c index 46dc8a3..7e9f353 100644 --- a/ClientHamr/extantz/extantz.c +++ b/ClientHamr/extantz/extantz.c @@ -370,15 +370,16 @@ static Eina_Bool _on_camera_input(void *data, Evas_Object *obj, Evas_Object *src // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... // TODO - make this a hash lookup dammit. // TODO - these are not working, coz Elm is grabbing the Left, Right, Up, and Down KEY_DOWNs. + // TODO - no idea why yet, but can't do Home and Prior / Next at the same time. Don't seem to be a bug in the Irrlicht original at least. if (EVAS_CALLBACK_KEY_DOWN == type) { if (0 == strcmp(ev->keyname, "Escape")) { } else if (0 == strcmp(ev->key, "Left")) - gld->move->y = 1.0; + gld->move->r = 1.0; else if (0 == strcmp(ev->key, "Right")) - gld->move->y = -1.0; + gld->move->r = -1.0; else if (0 == strcmp(ev->key, "Up")) gld->move->x = 1.0; else if (0 == strcmp(ev->key, "Down")) @@ -388,9 +389,9 @@ static Eina_Bool _on_camera_input(void *data, Evas_Object *obj, Evas_Object *src else if (0 == strcmp(ev->key, "Next")) gld->move->x = -1.0; else if (0 == strcmp(ev->key, "Home")) - gld->move->y = 1.0; + gld->move->r = 1.0; else if (0 == strcmp(ev->key, "End")) - gld->move->y = -1.0; + gld->move->r = -1.0; else if (0 == strcmp(ev->key, "space")) gld->move->jump = 1.0; else @@ -402,9 +403,9 @@ static Eina_Bool _on_camera_input(void *data, Evas_Object *obj, Evas_Object *src { } else if (0 == strcmp(ev->key, "Left")) - gld->move->y = 0.0; + gld->move->r = 0.0; else if (0 == strcmp(ev->key, "Right")) - gld->move->y = 0.0; + gld->move->r = 0.0; else if (0 == strcmp(ev->key, "Up")) gld->move->x = 0.0; else if (0 == strcmp(ev->key, "Down")) @@ -414,14 +415,15 @@ static Eina_Bool _on_camera_input(void *data, Evas_Object *obj, Evas_Object *src else if (0 == strcmp(ev->key, "Next")) gld->move->x = 0.0; else if (0 == strcmp(ev->key, "Home")) - gld->move->y = 0.0; + gld->move->r = 0.0; else if (0 == strcmp(ev->key, "End")) - gld->move->y = 0.0; + gld->move->r = 0.0; else if (0 == strcmp(ev->key, "space")) gld->move->jump = 0.0; else printf("Unexpected up keystroke - %s\n", ev->key); } + return EINA_TRUE; } else printf("Camera input not ready\n"); diff --git a/ClientHamr/extantz/extantzCamera.cpp b/ClientHamr/extantz/extantzCamera.cpp index f4554be..8337f8c 100644 --- a/ClientHamr/extantz/extantzCamera.cpp +++ b/ClientHamr/extantz/extantzCamera.cpp @@ -171,6 +171,16 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs) CursorPos = CenterCursor; } } +#else + relativeRotation.Y -= move.r * move.RotateSpeed; + relativeRotation.X -= move.s * move.RotateSpeed * MouseYDirection; + + // X < MaxVerticalAngle or X > 360-MaxVerticalAngle + + if ((relativeRotation.X > (MaxVerticalAngle * 2)) && (relativeRotation.X < (360.0f - MaxVerticalAngle))) + relativeRotation.X = 360.0f - MaxVerticalAngle; + else if ((relativeRotation.X > MaxVerticalAngle) && (relativeRotation.X < (360.0f - MaxVerticalAngle))) + relativeRotation.X = MaxVerticalAngle; #endif // set target -- cgit v1.1