Some improvements on Teeworlds port - it still crashes for no reason when I'm pressing 5-th button
This commit is contained in:
@@ -10,8 +10,8 @@ AppUsesMouse=y
|
||||
AppNeedsArrowKeys=y
|
||||
AppUsesJoystick=n
|
||||
AppUsesMultitouch=n
|
||||
RedefinedKeys="SPACE RETURN LEFT RIGHT SPACE ESCAPE"
|
||||
AppTouchscreenKeyboardKeysAmount=4
|
||||
RedefinedKeys="SPACE RETURN LEFT RIGHT q ESCAPE q e"
|
||||
AppTouchscreenKeyboardKeysAmount=6
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
MultiABI=n
|
||||
AppVersionCode=5201
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <SDL_screenkeyboard.h>
|
||||
#endif
|
||||
|
||||
#include "ec_font.h"
|
||||
|
||||
/* compressed textures */
|
||||
@@ -146,9 +150,35 @@ static void flush()
|
||||
|
||||
for(i = 0; i < num_vertices / 4; i++)
|
||||
{
|
||||
|
||||
|
||||
#define SINGLE_COLOR_PER_TEXTURE 1
|
||||
// #define USE_GL_DRAW_TEX 1
|
||||
// #define USE_GL_DRAW_TEX 1 // Does not work yet
|
||||
#define TEXTURE_OUT_OF_SCREEN_CHECK 1 // Some GLES renderers seems to not have this check
|
||||
|
||||
#ifdef TEXTURE_OUT_OF_SCREEN_CHECK
|
||||
if(
|
||||
( vertices[i * 4 + 0].pos.x < screen_x0 &&
|
||||
vertices[i * 4 + 1].pos.x < screen_x0 &&
|
||||
vertices[i * 4 + 2].pos.x < screen_x0 &&
|
||||
vertices[i * 4 + 3].pos.x < screen_x0 )
|
||||
||
|
||||
( vertices[i * 4 + 0].pos.x > screen_x1 &&
|
||||
vertices[i * 4 + 1].pos.x > screen_x1 &&
|
||||
vertices[i * 4 + 2].pos.x > screen_x1 &&
|
||||
vertices[i * 4 + 3].pos.x > screen_x1 )
|
||||
||
|
||||
( vertices[i * 4 + 0].pos.y < screen_y0 &&
|
||||
vertices[i * 4 + 1].pos.y < screen_y0 &&
|
||||
vertices[i * 4 + 2].pos.y < screen_y0 &&
|
||||
vertices[i * 4 + 3].pos.y < screen_y0 )
|
||||
||
|
||||
( vertices[i * 4 + 0].pos.y > screen_y1 &&
|
||||
vertices[i * 4 + 1].pos.y > screen_y1 &&
|
||||
vertices[i * 4 + 2].pos.y > screen_y1 &&
|
||||
vertices[i * 4 + 3].pos.y > screen_y1 )
|
||||
)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#ifndef SINGLE_COLOR_PER_TEXTURE
|
||||
// GL_COLOR_ARRAY is too damn slow for textures, so we'll set per-texture color
|
||||
@@ -268,6 +298,47 @@ static int try_init()
|
||||
screen_width = config.gfx_screen_width;
|
||||
screen_height = config.gfx_screen_height;
|
||||
|
||||
#if defined(ANDROID)
|
||||
// Redefine button layout
|
||||
{
|
||||
SDL_Rect pos = {0, 0, 0, 0};
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_DPAD, &pos);
|
||||
|
||||
pos.x = screen_width - screen_width / 16;
|
||||
pos.y = screen_height - screen_height / 8;
|
||||
pos.w = screen_width / (SDL_ANDROID_GetScreenKeyboardSize() + 2) / 4;
|
||||
pos.h = pos.w;
|
||||
pos.x -= pos.w/2;
|
||||
pos.y -= pos.h/2;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_0, &pos);
|
||||
|
||||
pos.x -= screen_width / 8;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_1, &pos);
|
||||
|
||||
pos.x = screen_width / 16;
|
||||
pos.x -= pos.w/2;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_2, &pos);
|
||||
|
||||
pos.x += screen_width / 8;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_3, &pos);
|
||||
|
||||
pos.y = screen_height - screen_height / 8 - screen_height / 4;
|
||||
pos.y -= pos.h/2;
|
||||
pos.x = screen_width / 16;
|
||||
pos.x -= pos.w/2;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_4, &pos);
|
||||
|
||||
pos.x = screen_width - screen_width / 16;
|
||||
pos.x -= pos.w/2;
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDRIOD_SCREENKEYBOARD_BUTTON_5, &pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
info = SDL_GetVideoInfo();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ MACRO_CONFIG_INT(b_filter_pure, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter ou
|
||||
MACRO_CONFIG_INT(b_filter_pure_map, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out non-standard maps in browser")
|
||||
MACRO_CONFIG_INT(b_filter_compatversion, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out non-compatible servers in browser")
|
||||
|
||||
MACRO_CONFIG_INT(b_sort, 0, 0, 256, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(b_sort, 1, 0, 256, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") // Sort by ping
|
||||
MACRO_CONFIG_INT(b_sort_order, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(b_max_requests, 10, 0, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Number of requests to use when refreshing server browser")
|
||||
|
||||
|
||||
@@ -111,11 +111,15 @@ void BINDS::set_defaults()
|
||||
bind(KEY_F4, "vote no");
|
||||
|
||||
#ifdef ANDROID
|
||||
unbindall();
|
||||
bind(KEY_LEFT, "+left");
|
||||
bind(KEY_RIGHT, "+right");
|
||||
bind(KEY_UP, "+jump");
|
||||
bind(KEY_DOWN, "+hook");
|
||||
bind(KEY_RETURN, "+jump");
|
||||
bind(KEY_SPACE, "+hook");
|
||||
bind('q', "+nextweapon");
|
||||
bind('e', "+prevweapon");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -182,8 +182,11 @@ bool CONTROLS::on_mousemove(float x, float y)
|
||||
|
||||
if(gameclient.snap.spectate)
|
||||
{
|
||||
if( inp_key_down(KEY_MOUSE_1) )
|
||||
mouse_pos += vec2((x - gfx_screenwidth()/2) * 2, (y - gfx_screenheight()/2) * 2);
|
||||
if( mouse_pos_old != vec2(x, y))
|
||||
{
|
||||
mouse_pos_old = vec2(x, y);
|
||||
mouse_pos += vec2((x - gfx_screenwidth()/2), (y - gfx_screenheight()/2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -219,7 +222,7 @@ bool CONTROLS::on_mousemove(float x, float y)
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
if(l * 2.0f > mouse_max)
|
||||
if(l > gfx_screenheight()/4)
|
||||
{
|
||||
if(input_data.fire&1 != 1)
|
||||
input_data.fire++;
|
||||
|
||||
@@ -6,6 +6,7 @@ class CONTROLS : public COMPONENT
|
||||
public:
|
||||
vec2 mouse_pos;
|
||||
vec2 target_pos;
|
||||
vec2 mouse_pos_old; // for Android
|
||||
|
||||
NETOBJ_PLAYER_INPUT input_data;
|
||||
int input_direction_left;
|
||||
|
||||
Reference in New Issue
Block a user