Better on screen keys for Android

This commit is contained in:
def 2014-06-16 14:44:00 +02:00
parent 7875c2ec36
commit 2f491a7d2f
4 changed files with 32 additions and 7 deletions

View file

@ -99,7 +99,6 @@ void CBinds::SetDefaults()
Bind(KEY_MOUSE_1, "+fire");
Bind(KEY_MOUSE_2, "+hook");
Bind(KEY_LSHIFT, "+emote");
Bind(KEY_RSHIFT, "+spectate");
#if defined(__ANDROID__)
Bind(KEY_RCTRL, "+fire");
Bind(KEY_RETURN, "+hook");
@ -109,9 +108,12 @@ void CBinds::SetDefaults()
Bind(KEY_DOWN, "+hook");
Bind(KEY_PAGEUP, "+prevweapon");
Bind(KEY_PAGEDOWN, "+nextweapon");
Bind(KEY_F5, "spectate_previous");
Bind(KEY_F6, "spectate_next");
#else
Bind(KEY_RIGHT, "spectate_next");
Bind(KEY_LEFT, "spectate_previous");
Bind(KEY_RSHIFT, "+spectate");
#endif

View file

@ -134,6 +134,7 @@ void CSpectator::ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData
CSpectator::CSpectator()
{
OnReset();
m_OldMouseX = m_OldMouseY = 0.0f;
}
void CSpectator::OnConsoleInit()
@ -151,6 +152,12 @@ bool CSpectator::OnMouseMove(float x, float y)
#if defined(__ANDROID__) // No relative mouse on Android
m_SelectorMouse = vec2(x,y);
if( m_OldMouseX != x || m_OldMouseY != y )
{
m_OldMouseX = x;
m_OldMouseY = y;
m_SelectorMouse = vec2((x - g_Config.m_GfxScreenWidth/2), (y - g_Config.m_GfxScreenHeight/2));
}
#else
UI()->ConvertMouseMove(&x, &y);
m_SelectorMouse += vec2(x,y);

View file

@ -19,6 +19,9 @@ class CSpectator : public CComponent
int m_SelectedSpectatorID;
vec2 m_SelectorMouse;
float m_OldMouseX;
float m_OldMouseY;
static void ConKeySpectator(IConsole::IResult *pResult, void *pUserData);
static void ConSpectate(IConsole::IResult *pResult, void *pUserData);
static void ConSpectateNext(IConsole::IResult *pResult, void *pUserData);

View file

@ -90,12 +90,6 @@ void CUI::AndroidShowScreenKeys(bool shown)
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2].w;
int ScreenH = Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2].y +
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2].h;
// Weapnext button above right joystick
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].x =
ScreenW - Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].w;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].y =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3].y -
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].h;
// Hide Hook button(it was above Weapnext)
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_0].x =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].x;
@ -122,9 +116,28 @@ void CUI::AndroidShowScreenKeys(bool shown)
// Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_3].w;
//Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT].h =
// Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_3].h;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT].x = 0;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT].y =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_3].y -
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT].h;
// Spec next button
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].x =
ScreenW - Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_4].w;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].y =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2].y -
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].h;
// Spec prev button
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_4].x =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].x -
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_4].w;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_4].y =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].y;
// Weap next button
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].x =
ScreenW - Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].w;
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].y =
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_5].y -
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1].h;
// Bigger joysticks
/*
Buttons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD].w *= 1.25;