More Android changes. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5066 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-03-24 00:40:01 +00:00
parent 61f35b827a
commit c725da4829
4 changed files with 44 additions and 59 deletions

View file

@ -20,12 +20,10 @@ LOCAL_MODULE := duke
# -O2 -fvisibility=hidden
LOCAL_CFLAGS := -x c++ -std=gnu++03 -fvisibility=hidden -fPIC -O2 -funswitch-loops -fomit-frame-pointer -DNDEBUG -DUSING_LTO -flto -fno-stack-protector -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=0 -fjump-tables -pthread -DHAVE_INTTYPES -D_GNU_SOURCE=1 -D_REENTRANT
LOCAL_CFLAGS := -x c++ -std=gnu++03 -fvisibility=hidden -fPIC -O2 -DNDEBUG -DUSING_LTO -flto -fno-stack-protector -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=0 -pthread -DHAVE_INTTYPES -D_GNU_SOURCE=1 -D_REENTRANT
LOCAL_CFLAGS += -W -Werror-implicit-function-declaration -Wpointer-arith -Wextra -Wno-unused-result -Wno-char-subscripts -Wno-strict-overflow -Wno-attributes -Wno-write-strings
LOCAL_CPPFLAGS := -std=gnu++03
#-DUSE_LIBPNG
LOCAL_CFLAGS += -DHAVE_SDL -DHAVE_VORBIS -DHAVE_JWZGLES -DHAVE_ANDROID -DRENDERTYPESDL=1 -DUSE_OPENGL -DNETCODE_DISABLE -DUSE_LIBVPX
#LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1
@ -40,7 +38,8 @@ ANDROID_SRC = \
source/android/android-jni.cpp \
source/android/in_android.c \
build/src/glbuild_android.c \
build/src/jwzgles.c
build/src/jwzgles.c \
source/android/rg_etc1.cpp
BUILD_SRC = \
build/src/a-c.c \

View file

@ -24,9 +24,6 @@ extern "C" {
#define DEFAULT_FADE_FRAMES 10
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
// This is a new function I put into SDL2, file SDL_androidgl.c
extern void SDL_SetSwapBufferCallBack(void (*pt2Func)(void));
extern char const *G_GetStringFromSavegame(const char *filename, int type);
extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
@ -80,13 +77,13 @@ static int weaponWheelVisible = false;
static int controlsCreated = 0;
touchcontrols::TouchControlsContainer controlsContainer;
touchcontrols::TouchControls *tcBlankTap = 0;
touchcontrols::TouchControls *tcYesNo = 0;
touchcontrols::TouchControls *tcMenuMain = 0;
touchcontrols::TouchControls *tcGameMain = 0;
touchcontrols::TouchControls *tcGameWeapons = 0;
// touchcontrols::TouchControls *tcInventory=0;
touchcontrols::TouchControls *tcAutomap = 0;
touchcontrols::TouchControls *tcBlankTap;
touchcontrols::TouchControls *tcYesNo;
touchcontrols::TouchControls *tcMenuMain;
touchcontrols::TouchControls *tcGameMain;
touchcontrols::TouchControls *tcGameWeapons;
// touchcontrols::TouchControls *tcInventory;
touchcontrols::TouchControls *tcAutomap;
touchcontrols::TouchJoy *touchJoyLeft;
@ -97,8 +94,7 @@ JavaVM *jvm_;
touchcontrols::Button *inv_buttons[GET_MAX];
std::string obbPath;
std::string gamePath;
std::string obbPath, gamePath;
void openGLStart()
{
@ -204,9 +200,7 @@ void showWeaponsInventory(bool show)
if (show)
{
for (int n = 0; n < 10; n++)
{
weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1);
}
// Show inventory buttons
tcGameWeapons->setAllButtonsEnable(true);

View file

@ -20,8 +20,6 @@
#ifdef __cplusplus
extern "C" {
#endif
// #include "../src/video/android/SDL_androidkeyboard.h" // FIXME: include header locally if necessary
//#include "../src/events/SDL_mouse_c.h"
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
extern int SDL_SendKeyboardText(const char *text);
extern int SDL_SendMouseMotion(SDL_Window * window, Uint32 mouseID, int relative, int x, int y);
@ -171,6 +169,18 @@ void PortableAction(int state, int action)
}
}
int const deadRegion = 0.3;
float analogCalibrate(float v)
{
float rv = 0;
if (v > deadRegion) rv = (v - deadRegion) * (v - deadRegion);
else if (-v > deadRegion) rv = -(-v - deadRegion) * (-v - deadRegion);
return rv;
}
//Need these NAN check as not cumulative.
void PortableMove(float fwd, float strafe)
{
@ -181,33 +191,32 @@ void PortableMove(float fwd, float strafe)
}
if (!isnan(fwd))
droidinput.forwardmove = fclamp2(fwd, -1.f, 1.f);
droidinput.forwardmove = fclamp2(analogCalibrate(fwd), -1.f, 1.f);
if (!isnan(strafe))
droidinput.sidemove = fclamp2(strafe, -1.f, 1.f);
droidinput.sidemove = fclamp2(analogCalibrate(strafe), -1.f, 1.f);
}
void PortableLook(double yaw, double pitch)
void PortableLook(float yaw, float pitch)
{
// LOGI("PortableLookPitch %f %f",yaw, pitch);
droidinput.pitch += pitch;
droidinput.yaw += yaw;
}
void PortableLookJoystick(double yaw, double pitch)
void PortableLookJoystick(float yaw, float pitch)
{
if (!isnan(pitch))
droidinput.pitch_joystick = pitch;
droidinput.pitch_joystick = analogCalibrate(pitch);
if (!isnan(yaw))
droidinput.yaw_joystick = yaw;
droidinput.yaw_joystick = analogCalibrate(yaw);
}
void PortableCommand(const char * cmd)
{
OSD_Dispatch(cmd);
}
void PortableInit(int argc, const char ** argv)
{
main(argc, ( char **)argv);
@ -233,8 +242,10 @@ int32_t PortableRead(portableread_t r)
rv = TOUCH_SCREEN_CONSOLE;
else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU)
rv = (m_currentMenu->type == Verify) ? TOUCH_SCREEN_YES_NO : TOUCH_SCREEN_MENU;
/*
else if (ud.overhead_on == 2)
rv = TOUCH_SCREEN_AUTOMAP;
*/
else if ((g_player[myconnectindex].ps->gm & MODE_GAME))
if (PortableRead(READ_IS_DEAD))
rv = TOUCH_SCREEN_BLANK_TAP;
@ -246,7 +257,7 @@ int32_t PortableRead(portableread_t r)
case READ_WEAPONS:
rv = g_player[myconnectindex].ps->gotweapon; break;
case READ_AUTOMAP:
rv = ud.overhead_on != 0; break;// ud.overhead_on ranges from 0-2
rv = 0; break;//ud.overhead_on != 0; break;// ud.overhead_on ranges from 0-2
case READ_MAPFOLLOWMODE:
rv = ud.scrollmode; break;
case READ_RENDERER:
@ -302,7 +313,6 @@ extern void CONTROL_Android_ScrollMap(int32_t *angle,int32_t *x, int32_t *y, ui
void CONTROL_Android_SetLastWeapon(int w)
{
LOGI("setLastWeapon %d",w);
droidinput.lastWeapon = w;
}
@ -312,36 +322,20 @@ void CONTROL_Android_ClearButton(int32_t whichbutton)
droidinput.functionHeld &= ~((uint64_t)1<<((uint64_t)(whichbutton)));
}
int clearCtrl=1;
void CONTROL_Android_PollDevices(ControlInfo *info)
{
//LOGI("CONTROL_Android_PollDevices %f %f",forwardmove,sidemove);
//LOGI("CONTROL_Android_PollDevices %f %f",droidinput.pitch,droidinput.yaw);
info->dz = (int32_t)nearbyintf(-droidinput.forwardmove * ANDROIDFORWARDMOVEFACTOR);
info->dx = (int32_t)nearbyintf(droidinput.sidemove * ANDROIDSIDEMOVEFACTOR);
info->dpitch = (int32_t)nearbyint(droidinput.pitch * ANDROIDPITCHFACTOR +
droidinput.pitch_joystick * ANDROIDPITCHFACTORJOYSTICK);
info->dyaw = (int32_t)nearbyint(-droidinput.yaw * ANDROIDYAWFACTOR -
droidinput.yaw_joystick * ANDROIDYAWFACTORJOYSTICK);
/*
if (clearCtrl == 0)
clearCtrl = 1;
LOGI("ctrl = %d",clearCtrl);
info->dpitch *= clearCtrl;
info->dyaw *= clearCtrl;
*/
info->dz = (int32_t)nearbyintf(-droidinput.forwardmove * ANDROIDMOVEFACTOR);
info->dx = (int32_t)nearbyintf(droidinput.sidemove * ANDROIDMOVEFACTOR) >> 5;
info->dpitch =
(int32_t)nearbyint(droidinput.pitch * ANDROIDLOOKFACTOR + droidinput.pitch_joystick * ANDROIDPITCHFACTORJOYSTICK);
info->dyaw =
(int32_t)nearbyint(-droidinput.yaw * ANDROIDLOOKFACTOR - droidinput.yaw_joystick * ANDROIDYAWFACTORJOYSTICK);
droidinput.pitch = droidinput.yaw = 0.f;
clearCtrl = 0;
CONTROL_ButtonState = 0;
CONTROL_ButtonState |= droidinput.functionSticky;
CONTROL_ButtonState |= droidinput.functionHeld;
CONTROL_ButtonState = droidinput.functionSticky | droidinput.functionHeld;
droidinput.functionSticky = 0;
//LOGI("poll state = 0x%016llX",CONTROL_ButtonState);

View file

@ -30,10 +30,8 @@ extern "C"
#define PRECISIONSHOOTFACTOR 0.3f
// where do these numbers come from?
#define ANDROIDFORWARDMOVEFACTOR 5000
#define ANDROIDSIDEMOVEFACTOR 200
#define ANDROIDPITCHFACTOR 100000
#define ANDROIDYAWFACTOR 160000
#define ANDROIDMOVEFACTOR 6400
#define ANDROIDLOOKFACTOR 160000
#define ANDROIDPITCHFACTORJOYSTICK 2000
#define ANDROIDYAWFACTORJOYSTICK 4000
@ -112,8 +110,8 @@ void PortableMouseMenu(float x,float y);
void PortableMouseMenuButton(int state,int button);
void PortableMove(float fwd, float strafe);
void PortableLook(double yaw, double pitch);
void PortableLookJoystick(double yaw, double pitch);
void PortableLook(float yaw, float pitch);
void PortableLookJoystick(float yaw, float pitch);
void PortableCommand(const char * cmd);
void PortableAutomapControl(float zoom,float dx,float dy);