2014-03-22 09:25:51 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Designed by Emile Belanger
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#include "SDL_scancode.h"
|
2014-04-12 22:10:36 +00:00
|
|
|
#include "SDL_main.h"
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
#include "TouchControlsContainer.h"
|
2014-04-12 22:10:36 +00:00
|
|
|
#include "JNITouchControlsUtils.h"
|
|
|
|
|
2014-04-15 19:02:48 +00:00
|
|
|
#ifdef GP_LIC
|
|
|
|
#include "s-setup/s-setup.h"
|
|
|
|
#endif
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
extern "C" {
|
2014-07-06 00:10:33 +00:00
|
|
|
#define DEFAULT_FADE_FRAMES 10
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
|
|
|
|
extern char const *G_GetStringFromSavegame(const char *filename, int type);
|
|
|
|
extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
|
|
|
|
|
2014-03-22 09:25:51 +00:00
|
|
|
#include "in_android.h"
|
2014-04-12 08:45:50 +00:00
|
|
|
#include "../function.h"
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
#include "../GL/gl.h"
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Copied from build.h, which didnt include here
|
|
|
|
enum rendmode_t
|
|
|
|
{
|
2014-04-15 19:02:48 +00:00
|
|
|
REND_CLASSIC,
|
|
|
|
REND_POLYMOST = 3,
|
|
|
|
REND_POLYMER
|
|
|
|
};
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
enum dukeinv_t
|
|
|
|
{
|
|
|
|
GET_STEROIDS, // 0
|
|
|
|
GET_SHIELD,
|
|
|
|
GET_SCUBA,
|
|
|
|
GET_HOLODUKE,
|
|
|
|
GET_JETPACK,
|
|
|
|
GET_DUMMY1, // 5
|
|
|
|
GET_ACCESS,
|
|
|
|
GET_HEATS,
|
|
|
|
GET_DUMMY2,
|
|
|
|
GET_FIRSTAID,
|
|
|
|
GET_BOOTS, // 10
|
|
|
|
GET_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-22 09:25:51 +00:00
|
|
|
#ifndef LOGI
|
2015-02-11 05:22:19 +00:00
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DUKE", __VA_ARGS__))
|
2014-03-22 09:25:51 +00:00
|
|
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
|
2015-02-11 05:22:19 +00:00
|
|
|
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "DUKE", __VA_ARGS__))
|
2014-03-22 09:25:51 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
#define REND_SOFT 0
|
|
|
|
#define REND_GL 1
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-13 03:20:17 +00:00
|
|
|
droidsysinfo_t droidinfo;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-13 03:20:17 +00:00
|
|
|
static int curRenderer;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-10-29 17:03:50 +00:00
|
|
|
static bool hideTouchControls = true;
|
|
|
|
static int weaponWheelVisible = false;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int controlsCreated = 0;
|
|
|
|
touchcontrols::TouchControlsContainer controlsContainer;
|
|
|
|
|
2015-03-24 00:40:01 +00:00
|
|
|
touchcontrols::TouchControls *tcBlankTap;
|
|
|
|
touchcontrols::TouchControls *tcYesNo;
|
|
|
|
touchcontrols::TouchControls *tcMenuMain;
|
|
|
|
touchcontrols::TouchControls *tcGameMain;
|
|
|
|
touchcontrols::TouchControls *tcGameWeapons;
|
|
|
|
// touchcontrols::TouchControls *tcInventory;
|
|
|
|
touchcontrols::TouchControls *tcAutomap;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
touchcontrols::TouchJoy *touchJoyLeft;
|
|
|
|
touchcontrols::WheelSelect *weaponWheel;
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
extern JNIEnv *env_;
|
|
|
|
JavaVM *jvm_;
|
|
|
|
|
|
|
|
touchcontrols::Button *inv_buttons[GET_MAX];
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-03-24 00:40:01 +00:00
|
|
|
std::string obbPath, gamePath;
|
2015-02-11 05:22:59 +00:00
|
|
|
|
2014-03-22 09:25:51 +00:00
|
|
|
void openGLStart()
|
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
if (curRenderer == REND_GL)
|
|
|
|
{
|
|
|
|
glPushMatrix();
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
2015-02-11 05:22:19 +00:00
|
|
|
glOrthof(0, droidinfo.screen_width, droidinfo.screen_height, 0, 0, 1);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
// glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
// LOGI("openGLStart");
|
2014-04-12 22:10:36 +00:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_FOG);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
2015-02-11 05:22:19 +00:00
|
|
|
glEnable(GL_BLEND);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
glColor4f(1, 1, 1, 1);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2015-02-11 05:22:19 +00:00
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glDisable(GL_CULL_FACE);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// nanoPushState();
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
/*
|
|
|
|
else // software mode
|
2014-04-12 22:10:36 +00:00
|
|
|
{
|
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2015-02-11 05:22:19 +00:00
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2014-04-12 22:10:36 +00:00
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
2015-02-11 05:22:19 +00:00
|
|
|
glEnable(GL_BLEND);
|
2014-04-12 22:10:36 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
*/
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void openGLEnd()
|
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
if (curRenderer == REND_GL)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// glPopMatrix();
|
|
|
|
// nanoPopState();
|
2014-04-12 22:10:36 +00:00
|
|
|
glPopMatrix();
|
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
/*
|
|
|
|
else // Software mode
|
2014-04-12 22:10:36 +00:00
|
|
|
{
|
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
*/
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gameSettingsButton(int state)
|
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
if (state == 1)
|
|
|
|
{
|
|
|
|
showTouchSettings();
|
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon
|
|
|
|
// selection
|
|
|
|
// NOT needed actually, weapon wheel disabled before is get finger up anyway
|
|
|
|
// static bool invWasSelected = false;
|
2014-10-29 17:03:50 +00:00
|
|
|
|
|
|
|
void showWeaponsInventory(bool show)
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
for (int n = 0; n < 10; n++)
|
2014-10-29 17:03:50 +00:00
|
|
|
weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1);
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Show inventory buttons
|
2014-10-29 17:03:50 +00:00
|
|
|
tcGameWeapons->setAllButtonsEnable(true);
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameWeapons->fade(touchcontrols::FADE_IN, 5); // fade in
|
2014-10-29 17:03:50 +00:00
|
|
|
weaponWheelVisible = true;
|
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
else // hide
|
2014-10-29 17:03:50 +00:00
|
|
|
{
|
|
|
|
tcGameWeapons->setAllButtonsEnable(false);
|
|
|
|
weaponWheel->setTapMode(false);
|
|
|
|
weaponWheelVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 08:45:50 +00:00
|
|
|
void gameButton(int state, int code)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 08:45:50 +00:00
|
|
|
switch (code)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
case gamefunc_Fire:
|
|
|
|
if (state && PortableRead(READ_SOMETHINGONPLAYER))
|
|
|
|
{
|
|
|
|
PortableAction(1, gamefunc_Quick_Kick);
|
|
|
|
PortableAction(0, gamefunc_Quick_Kick);
|
|
|
|
}
|
|
|
|
else PortableAction(state, code);
|
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
case KEY_SHOW_KBRD:
|
|
|
|
if (state)
|
|
|
|
toggleKeyboard();
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableKeyEvent(state, SDL_SCANCODE_GRAVE, 0);
|
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
case KEY_QUICK_CMD:
|
|
|
|
if (state == 1)
|
|
|
|
showCustomCommands();
|
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
case KEY_SHOW_INVEN:
|
|
|
|
if (state)
|
2014-10-29 17:03:50 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
if (!weaponWheelVisible)
|
|
|
|
{
|
|
|
|
weaponWheel->setTapMode(true);
|
|
|
|
showWeaponsInventory(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
showWeaponsInventory(false);
|
2014-10-29 17:03:50 +00:00
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
case KEY_QUICK_SAVE:
|
|
|
|
LOGI("QUICK SAVE");
|
|
|
|
PortableKeyEvent(state, SDL_SCANCODE_F6, 0);
|
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
case KEY_QUICK_LOAD:
|
|
|
|
LOGI("QUICK LOAD");
|
|
|
|
PortableKeyEvent(state, SDL_SCANCODE_F9, 0);
|
|
|
|
break;
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
default: PortableAction(state, code); break;
|
2014-04-12 08:45:50 +00:00
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void automapButton(int state, int code) { PortableAction(state, code); }
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void inventoryButton(int state, int code)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableAction(state, code);
|
2014-04-12 22:10:36 +00:00
|
|
|
if (state == 0)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// Inventory chosen, hide them and wheel
|
2014-10-29 17:03:50 +00:00
|
|
|
showWeaponsInventory(false);
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void menuButton(int state, int code) { PortableKeyEvent(state, code, code); }
|
|
|
|
|
|
|
|
void menuMouse(int action, float x, float y, float dx, float dy)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// PortableMouse(dx,dy);
|
|
|
|
PortableMouseMenu(x * droidinfo.screen_width, y * droidinfo.screen_height);
|
|
|
|
|
|
|
|
if (action == MULTITOUCHMOUSE_DOWN || action == MULTITOUCHMOUSE_UP)
|
|
|
|
PortableMouseMenuButton(action == MULTITOUCHMOUSE_DOWN, 0);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void blankTapButton(int state, int code)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
if (PortableRead(READ_IS_DEAD)) // if the player is dead we need to send a 'open' button
|
2014-04-12 08:45:50 +00:00
|
|
|
{
|
2014-10-29 17:03:50 +00:00
|
|
|
if (state)
|
2014-07-06 00:10:33 +00:00
|
|
|
{
|
2014-10-29 17:03:50 +00:00
|
|
|
PortableAction(1, gamefunc_Open);
|
|
|
|
PortableAction(0, gamefunc_Open);
|
2014-07-06 00:10:33 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-11 05:22:19 +00:00
|
|
|
else // everything else send a return key
|
|
|
|
PortableKeyEvent(state, SDL_SCANCODE_RETURN, 0);
|
2014-10-29 17:03:50 +00:00
|
|
|
}
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void weaponWheelSelected(int enabled) { showWeaponsInventory(enabled ? true : false); }
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2014-03-22 09:25:51 +00:00
|
|
|
void weaponWheelChosen(int segment)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI("weaponWheel %d",segment);
|
|
|
|
if (segment == -1 && droidinput.quickSelectWeapon)
|
|
|
|
segment = PortableRead(READ_LASTWEAPON);
|
2014-04-12 08:45:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
if (segment != -1)
|
2014-10-29 17:03:50 +00:00
|
|
|
PortableAction(2, gamefunc_Weapon_1 + segment);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void left_double_tap(int state)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action);
|
2014-04-14 16:30:23 +00:00
|
|
|
if (droidinput.left_double_action != -1)
|
|
|
|
PortableAction(state, droidinput.left_double_action);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void right_double_tap(int state)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGTOUCH("R double %d",state);
|
2014-04-14 16:30:23 +00:00
|
|
|
if (droidinput.right_double_action != -1)
|
|
|
|
PortableAction(state, droidinput.right_double_action);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
void mouseMove(int action, float x, float y, float dx, float dy)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI(" mouse dx = %f, dy = %f",dx,dy);
|
2014-04-12 22:10:36 +00:00
|
|
|
if (weaponWheelVisible)
|
|
|
|
return;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
float const scale = .1f;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableLook(dx * droidinput.yaw_sens * scale, -dy * droidinput.pitch_sens * scale * (droidinput.invertLook ? -1.f : 1.f));
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void automap_multitouch_mouse_move(int action, float x, float y, float dx, float dy)
|
2014-10-29 17:03:50 +00:00
|
|
|
{
|
|
|
|
if (action == MULTITOUCHMOUSE_MOVE)
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableAutomapControl(0, dx, dy);
|
2014-10-29 17:03:50 +00:00
|
|
|
else if (action == MULTITOUCHMOUSE_ZOOM)
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableAutomapControl(x, 0, 0);
|
2014-10-29 17:03:50 +00:00
|
|
|
}
|
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI("left_stick joy_x = %f, joy_y = %f",joy_x,joy_y);
|
|
|
|
PortableMove(joy_y * droidinput.forward_sens, -joy_x * droidinput.strafe_sens);
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
void setHideSticks(bool v)
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
if (touchJoyLeft)
|
|
|
|
touchJoyLeft->setHideGraphics(v);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void touchSettingsButton(int state)
|
|
|
|
{
|
2014-07-06 00:10:33 +00:00
|
|
|
/*
|
2014-04-12 08:45:50 +00:00
|
|
|
int32_t paused = PortableRead(READ_PAUSED);
|
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
//We wanna pause the game when doing settings
|
|
|
|
if (state && !paused || !state && paused)
|
|
|
|
{
|
2014-04-13 03:20:17 +00:00
|
|
|
PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
2014-07-06 00:10:33 +00:00
|
|
|
*/
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
void initControls(int width, int height, const char *graphics_path)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
touchcontrols::GLScaleWidth = (float)width;
|
2015-02-11 05:22:59 +00:00
|
|
|
touchcontrols::GLScaleHeight = (float)-height;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
LOGI("initControls %d x %d,x path = %s", width, height, graphics_path);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
if (!controlsCreated)
|
|
|
|
{
|
|
|
|
LOGI("creating controls");
|
|
|
|
|
|
|
|
touchcontrols::setGraphicsBasePath(graphics_path);
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
controlsContainer.openGL_start.connect(sigc::ptr_fun(&openGLStart));
|
|
|
|
controlsContainer.openGL_end.connect(sigc::ptr_fun(&openGLEnd));
|
|
|
|
controlsContainer.signal_settings.connect(sigc::ptr_fun(&touchSettingsButton));
|
2014-04-12 22:10:36 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false);
|
|
|
|
tcYesNo = new touchcontrols::TouchControls("yes_no", false, false);
|
|
|
|
tcMenuMain = new touchcontrols::TouchControls("menu", false, false);
|
|
|
|
tcGameMain = new touchcontrols::TouchControls("game", false, true, 1, true);
|
|
|
|
tcGameWeapons = new touchcontrols::TouchControls("weapons", false, true, 1, false);
|
|
|
|
tcAutomap = new touchcontrols::TouchControls("automap", false, false);
|
2014-10-29 17:03:50 +00:00
|
|
|
// tcInventory = new touchcontrols::TouchControls("inventory", false,true,1,false);
|
2014-04-12 22:10:36 +00:00
|
|
|
|
2014-07-06 00:10:33 +00:00
|
|
|
///////////////////////// BLANK TAP SCREEN //////////////////////
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// One button on whole screen with no graphic, send a return key
|
|
|
|
tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0, 0, 26, 16),
|
|
|
|
"" /*std::string("test")*/, SDL_SCANCODE_RETURN));
|
|
|
|
tcBlankTap->signal_button.connect(sigc::ptr_fun(&blankTapButton)); // Just reuse the menuButton function
|
2014-07-06 00:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////// YES NO SCREEN /////////////////////
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcYesNo->addControl(
|
2015-02-11 05:22:59 +00:00
|
|
|
new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN));
|
2015-02-11 05:22:19 +00:00
|
|
|
tcYesNo->addControl(
|
2015-02-11 05:22:59 +00:00
|
|
|
new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE));
|
2015-02-11 05:22:19 +00:00
|
|
|
tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton)); // Just reuse the menuButton function
|
2014-07-06 00:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////// MAIN MENU SCREEN /////////////////////
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
tcMenuMain->addControl(new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left",
|
|
|
|
SDL_SCANCODE_ESCAPE));
|
|
|
|
tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton));
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
touchcontrols::MultitouchMouse *mouseMenu =
|
|
|
|
new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), "");
|
|
|
|
mouseMenu->setHideGraphics(true);
|
|
|
|
tcMenuMain->addControl(mouseMenu);
|
|
|
|
mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse));
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
touchcontrols::Button *console_button = new touchcontrols::Button(
|
|
|
|
"keyboard", "Development console", touchcontrols::RectF(8, 0, 10, 2), "keyboard", KEY_SHOW_KBRD, false, true);
|
|
|
|
|
|
|
|
tcMenuMain->addControl(console_button);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-07-06 00:10:33 +00:00
|
|
|
//////////////////////////// GAME SCREEN /////////////////////
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
|
|
|
|
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
|
2015-02-11 05:22:59 +00:00
|
|
|
|
|
|
|
tcGameMain->addControl(
|
|
|
|
new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK));
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameMain->addControl(
|
|
|
|
new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open));
|
|
|
|
tcGameMain->addControl(
|
|
|
|
new touchcontrols::Button("attack", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire));
|
|
|
|
tcGameMain->addControl(
|
|
|
|
new touchcontrols::Button("jump", touchcontrols::RectF(23, 6, 26, 9), "jump", gamefunc_Jump));
|
|
|
|
tcGameMain->addControl(
|
|
|
|
new touchcontrols::Button("crouch", touchcontrols::RectF(24, 12, 26, 14), "crouch", gamefunc_Crouch));
|
|
|
|
tcGameMain->addControl(new touchcontrols::Button("kick", "Mighty Foot", touchcontrols::RectF(23, 3, 26, 6),
|
|
|
|
"boot", gamefunc_Quick_Kick, false, true));
|
|
|
|
|
|
|
|
touchcontrols::Button *map_button = new touchcontrols::Button(
|
|
|
|
"map", "Overhead map", touchcontrols::RectF(6, 0, 8, 2), "map", gamefunc_Map, false, true);
|
2014-10-29 17:03:50 +00:00
|
|
|
tcGameMain->addControl(map_button);
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameMain->addControl(new touchcontrols::Button("show_inventory", "Inventory",
|
|
|
|
touchcontrols::RectF(24, 0, 26, 2), "inv", KEY_SHOW_INVEN));
|
|
|
|
tcGameMain->addControl(new touchcontrols::Button("next_weapon", "Next weapon", touchcontrols::RectF(0, 3, 3, 5),
|
|
|
|
"next_weap", gamefunc_Next_Weapon, false, true));
|
|
|
|
tcGameMain->addControl(new touchcontrols::Button("prev_weapon", "Previous weapon",
|
|
|
|
touchcontrols::RectF(0, 5, 3, 7), "prev_weap",
|
|
|
|
gamefunc_Previous_Weapon, false, true));
|
|
|
|
tcGameMain->addControl(new touchcontrols::Button("quick_save", "Save game", touchcontrols::RectF(22, 0, 24, 2),
|
|
|
|
"save", KEY_QUICK_SAVE, false, true));
|
|
|
|
tcGameMain->addControl(new touchcontrols::Button("quick_load", "Load game", touchcontrols::RectF(20, 0, 22, 2),
|
|
|
|
"load", KEY_QUICK_LOAD, false, true));
|
|
|
|
|
|
|
|
tcGameMain->addControl(console_button);
|
2014-04-12 22:10:36 +00:00
|
|
|
/*
|
2015-02-11 05:22:19 +00:00
|
|
|
//quick actions binds
|
|
|
|
tcGameMain->addControl(new
|
|
|
|
touchcontrols::Button("quick_key_1",touchcontrols::RectF(4,3,6,5),"quick_key_1",KEY_QUICK_KEY1,false,true));
|
|
|
|
tcGameMain->addControl(new
|
|
|
|
touchcontrols::Button("quick_key_2",touchcontrols::RectF(6,3,8,5),"quick_key_2",KEY_QUICK_KEY2,false,true));
|
|
|
|
tcGameMain->addControl(new
|
|
|
|
touchcontrols::Button("quick_key_3",touchcontrols::RectF(8,3,10,5),"quick_key_3",KEY_QUICK_KEY3,false,true));
|
|
|
|
tcGameMain->addControl(new
|
|
|
|
touchcontrols::Button("quick_key_4",touchcontrols::RectF(10,3,12,5),"quick_key_4",KEY_QUICK_KEY4,false,true));
|
2014-07-06 00:10:33 +00:00
|
|
|
*/
|
2015-02-11 05:22:19 +00:00
|
|
|
// Left stick
|
|
|
|
touchJoyLeft = new touchcontrols::TouchJoy("stick", touchcontrols::RectF(0, 7, 8, 16), "strafe_arrow");
|
2014-04-12 22:10:36 +00:00
|
|
|
tcGameMain->addControl(touchJoyLeft);
|
2015-02-11 05:22:19 +00:00
|
|
|
touchJoyLeft->signal_move.connect(sigc::ptr_fun(&left_stick));
|
|
|
|
touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&left_double_tap));
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Mouse look for whole screen
|
|
|
|
touchcontrols::Mouse *mouse = new touchcontrols::Mouse("mouse", touchcontrols::RectF(3, 0, 26, 16), "");
|
2014-04-12 22:10:36 +00:00
|
|
|
mouse->signal_action.connect(sigc::ptr_fun(&mouseMove));
|
2015-02-11 05:22:19 +00:00
|
|
|
mouse->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap));
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
mouse->setHideGraphics(true);
|
|
|
|
tcGameMain->addControl(mouse);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameMain->signal_button.connect(sigc::ptr_fun(&gameButton));
|
|
|
|
tcGameMain->signal_settingsButton.connect(sigc::ptr_fun(&gameSettingsButton));
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-10-29 17:03:50 +00:00
|
|
|
///////////////////////// AUTO MAP SCREEN ///////////////////////
|
|
|
|
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Automap
|
|
|
|
touchcontrols::MultitouchMouse *multimouse =
|
|
|
|
new touchcontrols::MultitouchMouse("gamemouse", touchcontrols::RectF(0, 0, 26, 16), "");
|
2014-10-29 17:03:50 +00:00
|
|
|
multimouse->setHideGraphics(true);
|
|
|
|
tcAutomap->addControl(multimouse);
|
2015-02-11 05:22:19 +00:00
|
|
|
multimouse->signal_action.connect(sigc::ptr_fun(&automap_multitouch_mouse_move));
|
2014-10-29 17:03:50 +00:00
|
|
|
tcAutomap->addControl(map_button);
|
2015-02-11 05:22:19 +00:00
|
|
|
tcAutomap->signal_button.connect(sigc::ptr_fun(&gameButton));
|
2014-10-29 17:03:50 +00:00
|
|
|
tcAutomap->setAlpha(0.5);
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Now inventory in the weapons control group!
|
|
|
|
|
|
|
|
inv_buttons[GET_JETPACK] = new touchcontrols::Button("jetpack", touchcontrols::RectF(0, 3, 2, 5), "jetpack",
|
|
|
|
gamefunc_Jetpack, false, false, true);
|
|
|
|
inv_buttons[GET_FIRSTAID] = new touchcontrols::Button("medkit", touchcontrols::RectF(0, 5, 2, 7), "medkit",
|
|
|
|
gamefunc_MedKit, false, false, true);
|
|
|
|
inv_buttons[GET_HEATS] = new touchcontrols::Button("nightv", touchcontrols::RectF(0, 7, 2, 9), "nightvision",
|
|
|
|
gamefunc_NightVision, false, false, true);
|
|
|
|
inv_buttons[GET_HOLODUKE] = new touchcontrols::Button("holoduke", touchcontrols::RectF(0, 9, 2, 11), "holoduke",
|
|
|
|
gamefunc_Holo_Duke, false, false, true);
|
|
|
|
inv_buttons[GET_STEROIDS] = new touchcontrols::Button("steroids", touchcontrols::RectF(0, 11, 2, 13),
|
|
|
|
"steroids", gamefunc_Steroids, false, false, true);
|
|
|
|
|
|
|
|
tcGameWeapons->addControl(inv_buttons[GET_JETPACK]);
|
|
|
|
tcGameWeapons->addControl(inv_buttons[GET_FIRSTAID]);
|
|
|
|
tcGameWeapons->addControl(inv_buttons[GET_HEATS]);
|
|
|
|
tcGameWeapons->addControl(inv_buttons[GET_HOLODUKE]);
|
|
|
|
tcGameWeapons->addControl(inv_buttons[GET_STEROIDS]);
|
|
|
|
// Inventory are the only buttons so safe to do this
|
|
|
|
tcGameWeapons->signal_button.connect(sigc::ptr_fun(&inventoryButton));
|
|
|
|
|
|
|
|
// Weapons
|
|
|
|
weaponWheel = new touchcontrols::WheelSelect("weapon_wheel", touchcontrols::RectF(7, 2, 19, 14),
|
|
|
|
"weapon_wheel_orange_blank", 10);
|
|
|
|
weaponWheel->signal_selected.connect(sigc::ptr_fun(&weaponWheelChosen));
|
2014-04-12 22:10:36 +00:00
|
|
|
weaponWheel->signal_enabled.connect(sigc::ptr_fun(&weaponWheelSelected));
|
|
|
|
tcGameWeapons->addControl(weaponWheel);
|
2014-07-06 00:10:33 +00:00
|
|
|
tcGameWeapons->setAlpha(0.9);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-07-06 00:10:33 +00:00
|
|
|
/////////////////////////////////////////////////////////////
|
2014-03-22 09:25:51 +00:00
|
|
|
|
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
controlsContainer.addControlGroup(tcMenuMain);
|
|
|
|
controlsContainer.addControlGroup(tcGameMain);
|
2014-10-29 17:03:50 +00:00
|
|
|
// controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick
|
2014-04-12 22:10:36 +00:00
|
|
|
controlsContainer.addControlGroup(tcGameWeapons);
|
2014-10-29 17:03:50 +00:00
|
|
|
controlsContainer.addControlGroup(tcAutomap);
|
2014-07-06 00:10:33 +00:00
|
|
|
controlsContainer.addControlGroup(tcYesNo);
|
|
|
|
controlsContainer.addControlGroup(tcBlankTap);
|
2014-04-12 22:10:36 +00:00
|
|
|
controlsCreated = 1;
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
|
|
|
|
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
|
|
|
|
tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
|
|
|
|
tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml");
|
|
|
|
tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml");
|
|
|
|
tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml");
|
2014-10-29 17:03:50 +00:00
|
|
|
// tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml");
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-10-29 17:03:50 +00:00
|
|
|
setControlsContainer(&controlsContainer);
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
LOGI("NOT creating controls");
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// controlsContainer.initGL();
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2014-07-06 00:10:33 +00:00
|
|
|
void updateTouchScreenMode(touchscreemode_t mode)
|
|
|
|
{
|
2014-10-29 17:03:50 +00:00
|
|
|
// LOGI("updateTouchScreenModeA %d",mode);
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
static touchscreemode_t lastMode = TOUCH_SCREEN_BLANK;
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
if (mode != lastMode)
|
|
|
|
{
|
|
|
|
// first disable the last screen and fade out is necessary
|
|
|
|
switch (lastMode)
|
|
|
|
{
|
|
|
|
case TOUCH_SCREEN_BLANK: // Does not exist yet break;
|
|
|
|
case TOUCH_SCREEN_BLANK_TAP:
|
|
|
|
tcBlankTap->resetOutput();
|
|
|
|
tcBlankTap->setEnabled(false); // Dont fade out as no graphics
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_YES_NO:
|
|
|
|
tcYesNo->resetOutput();
|
|
|
|
tcYesNo->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_MENU:
|
|
|
|
tcMenuMain->resetOutput();
|
|
|
|
tcMenuMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_GAME:
|
|
|
|
tcGameMain->resetOutput();
|
|
|
|
|
|
|
|
tcGameMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
|
|
|
|
tcGameWeapons->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_AUTOMAP:
|
|
|
|
tcAutomap->resetOutput();
|
|
|
|
tcAutomap->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_CONSOLE: break;
|
2014-07-06 00:10:33 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Enable the current new screen
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case TOUCH_SCREEN_BLANK: // Does not exist yet break;
|
|
|
|
case TOUCH_SCREEN_BLANK_TAP: tcBlankTap->setEnabled(true); break;
|
|
|
|
case TOUCH_SCREEN_YES_NO:
|
|
|
|
tcYesNo->setEnabled(true);
|
|
|
|
tcYesNo->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_MENU:
|
|
|
|
tcMenuMain->setEnabled(true);
|
|
|
|
tcMenuMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
|
|
|
|
|
|
|
|
// This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not
|
|
|
|
// be seen anyway
|
|
|
|
showWeaponsInventory(true);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_GAME:
|
|
|
|
tcGameMain->setEnabled(true);
|
|
|
|
tcGameMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
|
|
|
|
tcGameWeapons->setEnabled(true);
|
|
|
|
showWeaponsInventory(false);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_AUTOMAP:
|
|
|
|
tcAutomap->setEnabled(true);
|
|
|
|
tcAutomap->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
|
|
|
|
break;
|
|
|
|
case TOUCH_SCREEN_CONSOLE: break;
|
2014-07-06 00:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lastMode = mode;
|
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
int inv = PortableRead(READ_INVENTORY);
|
|
|
|
|
|
|
|
for (int i = 0; i < GET_MAX; ++i)
|
|
|
|
if (inv_buttons[i])
|
|
|
|
inv_buttons[i]->setAlpha(tcGameWeapons->getFadedAlpha() * ((inv & (1 << i)) ? 1.f : 0.3f));
|
2014-07-06 00:10:33 +00:00
|
|
|
}
|
|
|
|
|
2014-04-15 19:02:48 +00:00
|
|
|
|
|
|
|
#ifdef GP_LIC
|
|
|
|
#define GP_LIC_INC 1
|
|
|
|
#include "s-setup/gp_lic_include.h"
|
|
|
|
#endif
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
extern char videomodereset;
|
|
|
|
|
2014-03-22 09:25:51 +00:00
|
|
|
void frameControls()
|
|
|
|
{
|
2014-04-12 08:45:50 +00:00
|
|
|
static int loadedGLImages = 0;
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
if (videomodereset)
|
|
|
|
{
|
|
|
|
loadedGLImages = -1;
|
|
|
|
return;
|
|
|
|
}
|
2014-10-29 17:03:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// We need to do this here now because duke loads a new gl context
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
if (loadedGLImages <= 0)
|
2014-04-12 22:10:36 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
controlsContainer.initGL(loadedGLImages == -1);
|
2014-04-12 22:10:36 +00:00
|
|
|
loadedGLImages = 1;
|
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI("frameControls");
|
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
curRenderer = (PortableRead(READ_RENDERER) != REND_CLASSIC);
|
|
|
|
|
2014-07-06 00:10:33 +00:00
|
|
|
updateTouchScreenMode((touchscreemode_t)PortableRead(READ_SCREEN_MODE));
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
setHideSticks(droidinput.hideStick);
|
|
|
|
|
|
|
|
if (tcGameMain)
|
|
|
|
{
|
|
|
|
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
|
|
|
|
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
|
2015-05-26 00:48:07 +00:00
|
|
|
|
|
|
|
if (tcGameWeapons)
|
|
|
|
tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
|
|
|
|
|
|
|
|
if (tcMenuMain)
|
|
|
|
tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
|
2015-02-11 05:22:19 +00:00
|
|
|
}
|
2014-04-12 22:10:36 +00:00
|
|
|
|
|
|
|
controlsContainer.draw();
|
2014-04-15 19:02:48 +00:00
|
|
|
|
|
|
|
#ifdef GP_LIC
|
2014-07-06 00:10:33 +00:00
|
|
|
#undef GP_LIC_INC
|
2014-04-15 19:02:48 +00:00
|
|
|
#define GP_LIC_INC 2
|
|
|
|
#include "s-setup/gp_lic_include.h"
|
|
|
|
#endif
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void setTouchSettings(int other)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-13 03:20:17 +00:00
|
|
|
// TODO: defined names for these values
|
|
|
|
hideTouchControls = other & 0x80000000 ? true : false;
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// keep in sync with Duke3d/res/values/strings.xml
|
|
|
|
int doubletap_options[5] = { -1, gamefunc_Quick_Kick, gamefunc_AutoRun, gamefunc_MedKit, gamefunc_Jetpack };
|
2014-10-29 17:03:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
droidinput.left_double_action = doubletap_options[((other >> 4) & 0xF)];
|
|
|
|
droidinput.right_double_action = doubletap_options[((other >> 8) & 0xF)];
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
LOGI("setTouchSettings left_double_action = %d", droidinput.left_double_action);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
#define EXPORT_ME __NDK_FPABI__ __attribute__((visibility("default")))
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
JNIEnv *env_;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
int argc = 1;
|
|
|
|
const char *argv[32];
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
static inline const char *getGamePath() { return gamePath.c_str(); }
|
2014-10-29 17:03:50 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir,
|
|
|
|
jint audio_rate, jint audio_buffer_size,
|
|
|
|
jobjectArray argsArray, jint renderer,
|
|
|
|
jstring jduke3d_path)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
env_ = env;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2014-04-15 19:02:48 +00:00
|
|
|
#ifdef GP_LIC
|
2014-07-06 00:10:33 +00:00
|
|
|
getGlobalClasses(env_);
|
2014-04-15 19:02:48 +00:00
|
|
|
#endif
|
|
|
|
|
2014-04-13 03:20:17 +00:00
|
|
|
droidinfo.audio_sample_rate = audio_rate;
|
|
|
|
droidinfo.audio_buffer_size = audio_buffer_size;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// curRenderer = renderer;
|
2014-04-12 22:10:36 +00:00
|
|
|
curRenderer = REND_GL;
|
|
|
|
|
|
|
|
argv[0] = "eduke32";
|
2015-02-11 05:22:19 +00:00
|
|
|
int argCount = (env)->GetArrayLength(argsArray);
|
|
|
|
LOGI("argCount = %d", argCount);
|
|
|
|
for (int i = 0; i < argCount; i++)
|
|
|
|
{
|
|
|
|
jstring string = (jstring)(env)->GetObjectArrayElement(argsArray, i);
|
|
|
|
argv[argc] = (char *)(env)->GetStringUTFChars(string, 0);
|
|
|
|
LOGI("arg = %s", argv[argc]);
|
2014-04-12 22:10:36 +00:00
|
|
|
argc++;
|
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
gamePath = std::string(env->GetStringUTFChars(jduke3d_path, NULL));
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// Change working dir, save games etc
|
2014-04-12 22:10:36 +00:00
|
|
|
// FIXME: potentially conflicts with chdirs in -game_dir support
|
|
|
|
chdir(getGamePath());
|
|
|
|
char timidity_env[512];
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
sprintf(timidity_env, "TIMIDITY_CFG=%s/../timidity.cfg", getGamePath());
|
2014-04-12 22:10:36 +00:00
|
|
|
putenv(timidity_env);
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
LOGI("duke3d_path = %s", getGamePath());
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
const char *p = env->GetStringUTFChars(graphics_dir, NULL);
|
2015-02-11 05:22:59 +00:00
|
|
|
obbPath = std::string(p);
|
|
|
|
|
|
|
|
LOGI("obbPath = %s", obbPath.c_str());
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:59 +00:00
|
|
|
initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str());
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
PortableInit(argc, argv);
|
2014-07-06 00:10:33 +00:00
|
|
|
|
2014-04-12 22:10:36 +00:00
|
|
|
return 0;
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-26 00:48:07 +00:00
|
|
|
/*
|
2015-02-11 05:22:19 +00:00
|
|
|
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_frame(JNIEnv *env, jobject thiz)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
LOGI("Java_com_voidpoint_duke3d_engine_NativeLib_frame");
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// frameControls();
|
2014-04-12 22:10:36 +00:00
|
|
|
return 0;
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
2015-05-26 00:48:07 +00:00
|
|
|
*/
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
__attribute__((visibility("default"))) jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
LOGI("JNI_OnLoad");
|
|
|
|
setTCJNIEnv(vm);
|
|
|
|
jvm_ = vm;
|
|
|
|
return JNI_VERSION_1_4;
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EXPORT_ME
|
2015-05-26 00:48:07 +00:00
|
|
|
Java_com_voidpoint_duke3d_engine_NativeLib_keyPress(JNIEnv *env, jobject obj, jint down, jint keycode, jint unicode)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
LOGI("keypress %d", keycode);
|
2014-04-12 22:10:36 +00:00
|
|
|
if (controlsContainer.isEditing())
|
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
if (down && (keycode == SDL_SCANCODE_ESCAPE))
|
2014-04-12 22:10:36 +00:00
|
|
|
controlsContainer.finishEditing();
|
2014-04-13 03:20:17 +00:00
|
|
|
return;
|
2014-04-12 22:10:36 +00:00
|
|
|
}
|
2014-04-13 03:20:17 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableKeyEvent(down, keycode, unicode);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_touchEvent(JNIEnv *env, jobject obj, jint action, jint pid,
|
|
|
|
jfloat x, jfloat y)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
// LOGI("TOUCHED");
|
|
|
|
controlsContainer.processPointer(action, pid, x, y);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_doAction(JNIEnv *env, jobject obj, jint state, jint action)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
LOGI("doAction %d %d", state, action);
|
2014-04-12 22:10:36 +00:00
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
// gamepadButtonPressed();
|
2014-04-12 22:10:36 +00:00
|
|
|
if (hideTouchControls && tcGameMain)
|
|
|
|
{
|
|
|
|
if (tcGameMain->isEnabled())
|
|
|
|
tcGameMain->animateOut(30);
|
|
|
|
|
2015-05-26 00:48:07 +00:00
|
|
|
if (tcGameWeapons && tcGameWeapons->isEnabled())
|
2014-04-12 22:10:36 +00:00
|
|
|
tcGameWeapons->animateOut(30);
|
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
PortableAction(state, action);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogFwd(JNIEnv *env, jobject obj, jfloat v)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-15 19:02:48 +00:00
|
|
|
PortableMove(v, NAN);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogSide(JNIEnv *env, jobject obj, jfloat v)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-15 19:02:48 +00:00
|
|
|
PortableMove(NAN, v);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogPitch(JNIEnv *env, jobject obj, jint mode, jfloat v)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-15 19:02:48 +00:00
|
|
|
PortableLookJoystick(NAN, v);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogYaw(JNIEnv *env, jobject obj, jint mode, jfloat v)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-15 19:02:48 +00:00
|
|
|
PortableLookJoystick(v, NAN);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME
|
|
|
|
Java_com_voidpoint_duke3d_engine_NativeLib_setTouchSettings(JNIEnv *env, jobject obj, int other)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
setTouchSettings(other);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_resetTouchSettings(JNIEnv *env, jobject obj)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
controlsContainer.resetDefaults();
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string quickCommandString;
|
2015-02-11 05:22:19 +00:00
|
|
|
|
|
|
|
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_quickCommand(JNIEnv *env, jobject obj, jstring command)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2015-02-11 05:22:19 +00:00
|
|
|
const char *p = env->GetStringUTFChars(command, NULL);
|
|
|
|
quickCommandString = std::string(p) + "\n";
|
2014-04-12 22:10:36 +00:00
|
|
|
env->ReleaseStringUTFChars(command, p);
|
|
|
|
PortableCommand(quickCommandString.c_str());
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EXPORT_ME
|
2015-02-11 05:22:19 +00:00
|
|
|
Java_com_voidpoint_duke3d_engine_NativeLib_setScreenSize(JNIEnv *env, jobject thiz, jint width, jint height)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-13 03:20:17 +00:00
|
|
|
droidinfo.screen_width = width;
|
|
|
|
droidinfo.screen_height = height;
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv *env, jclass cls)
|
2014-03-22 09:25:51 +00:00
|
|
|
{
|
2014-04-12 22:10:36 +00:00
|
|
|
/* This interface could expand with ABI negotiation, calbacks, etc. */
|
|
|
|
SDL_Android_Init(env, cls);
|
|
|
|
SDL_SetMainReady();
|
|
|
|
// SDL_EventState(SDL_TEXTINPUT,SDL_ENABLE);
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:19 +00:00
|
|
|
jstring EXPORT_ME
|
2015-05-26 00:48:07 +00:00
|
|
|
Java_com_voidpoint_duke3d_engine_NativeLib_getSaveText(JNIEnv *env, jobject obj, jstring jfile, jint type)
|
2015-02-11 05:22:19 +00:00
|
|
|
{
|
|
|
|
const char *p = env->GetStringUTFChars(jfile, NULL);
|
|
|
|
|
|
|
|
jstring ret = env->NewStringUTF(G_GetStringFromSavegame(p, type));
|
|
|
|
env->ReleaseStringUTFChars(jfile, p);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_getScreenshot(JNIEnv *env, jobject obj, jstring jfile,
|
|
|
|
jobject jpal, jobject jdataOut)
|
|
|
|
{
|
|
|
|
const char *p = env->GetStringUTFChars(jfile, NULL);
|
|
|
|
|
|
|
|
jbyte *bb = (jbyte *)env->GetDirectBufferAddress(jdataOut);
|
|
|
|
jbyte *pb = (jbyte *)env->GetDirectBufferAddress(jpal);
|
|
|
|
|
|
|
|
int ret = G_GetScreenshotFromSavegame(p, (char *)pb, (char *)bb);
|
|
|
|
|
|
|
|
env->ReleaseStringUTFChars(jfile, p);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-04-15 19:02:48 +00:00
|
|
|
#ifdef GP_LIC
|
2014-07-06 00:10:33 +00:00
|
|
|
#undef GP_LIC_INC
|
2014-04-15 19:02:48 +00:00
|
|
|
#define GP_LIC_INC 3
|
|
|
|
#include "s-setup/gp_lic_include.h"
|
|
|
|
#endif
|
2014-03-22 09:25:51 +00:00
|
|
|
}
|