Some improvements on Teeworlds port - it still crashes for no reason when I'm pressing 5-th button
This commit is contained in:
@@ -29,7 +29,7 @@ APPLICATION_ADDITIONAL_CFLAGS := -O2
|
||||
|
||||
APPLICATION_ADDITIONAL_LDFLAGS := -Lbin/ndk/local/armeabi -lfreetype
|
||||
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=SPACE -DSDL_ANDROID_KEYCODE_1=RETURN -DSDL_ANDROID_KEYCODE_2=LEFT -DSDL_ANDROID_KEYCODE_3=RIGHT -DSDL_ANDROID_KEYCODE_4=SPACE -DSDL_ANDROID_KEYCODE_5=ESCAPE
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=SPACE -DSDL_ANDROID_KEYCODE_1=RETURN -DSDL_ANDROID_KEYCODE_2=LEFT -DSDL_ANDROID_KEYCODE_3=RIGHT -DSDL_ANDROID_KEYCODE_4=q -DSDL_ANDROID_KEYCODE_5=ESCAPE -DSDL_ANDROID_KEYCODE_6=q -DSDL_ANDROID_KEYCODE_7=e
|
||||
|
||||
# If SDL_Mixer should link to libMAD
|
||||
SDL_MIXER_USE_LIBMAD :=
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -67,6 +67,8 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardAutoFireButtonsAmount()
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardShown(int shown);
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardShown();
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardSize();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,7 +60,8 @@ int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
|
||||
static int touchscreenKeyboardTheme = 0;
|
||||
static int touchscreenKeyboardShown = 1;
|
||||
static int AutoFireButtonsNum = 0;
|
||||
static int nbuttons;
|
||||
static int nbuttons = 4;
|
||||
static int buttonsize = 1;
|
||||
|
||||
static SDL_Rect arrows, buttons[MAX_BUTTONS];
|
||||
static SDLKey buttonKeysyms[MAX_BUTTONS] = {
|
||||
@@ -551,6 +552,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
|
||||
if( AutoFireButtonsNum > MAX_BUTTONS_AUTOFIRE )
|
||||
AutoFireButtonsNum = MAX_BUTTONS_AUTOFIRE;
|
||||
// TODO: works for horizontal screen orientation only!
|
||||
buttonsize = size;
|
||||
|
||||
if(touchscreenKeyboardTheme == 0)
|
||||
{
|
||||
@@ -785,3 +787,8 @@ int SDL_ANDROID_GetScreenKeyboardShown()
|
||||
{
|
||||
return touchscreenKeyboardShown;
|
||||
};
|
||||
|
||||
int SDL_ANDROID_GetScreenKeyboardSize()
|
||||
{
|
||||
return buttonsize;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ class Globals {
|
||||
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 6;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 0;
|
||||
|
||||
|
||||
@@ -300,8 +300,8 @@ class Settings
|
||||
return;
|
||||
}
|
||||
final CharSequence[] items = {
|
||||
"On-screen keyboard" + ( Globals.AppUsesMouse ? " (disables mouse input)" : ""),
|
||||
"Accelerometer as navigation keys" + ( Globals.AppUsesJoystick ? " (disables joystick input)" : "" ),
|
||||
"On-screen keyboard" /* + ( Globals.AppUsesMouse ? " (disables mouse input)" : "") */ ,
|
||||
"Accelerometer as navigation keys" /* + ( Globals.AppUsesJoystick ? " (disables joystick input)" : "" ) */ ,
|
||||
"Both accelerometer and on-screen keyboard",
|
||||
"No additional controls"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user