mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Android code updates, pay no attention. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4434 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5645858a64
commit
2293aa5f59
3 changed files with 561 additions and 629 deletions
File diff suppressed because it is too large
Load diff
|
@ -21,148 +21,145 @@
|
||||||
|
|
||||||
extern int32_t main(int32_t argc, char *argv []);
|
extern int32_t main(int32_t argc, char *argv []);
|
||||||
|
|
||||||
#define BUTTONSET(x,value) (CONTROL_ButtonState |= ((uint64_t)value<<((uint64_t)(x))))
|
|
||||||
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1<<((uint64_t)(x))))
|
|
||||||
|
|
||||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
|
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
|
||||||
extern int SDL_SendKeyboardText(const char *text);
|
extern int SDL_SendKeyboardText(const char *text);
|
||||||
|
|
||||||
static float forwardmove, sidemove; //Joystick mode
|
|
||||||
static char sdl_text[2];
|
static char sdl_text[2];
|
||||||
|
|
||||||
|
static droidinput_t droidinput;
|
||||||
|
|
||||||
int PortableKeyEvent(int state, int code,int unicode)
|
int PortableKeyEvent(int state, int code,int unicode)
|
||||||
{
|
{
|
||||||
LOGI("PortableKeyEvent %d %d %d",state,code,unicode);
|
LOGI("PortableKeyEvent %d %d %d",state,code,unicode);
|
||||||
|
|
||||||
SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, code);
|
SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, code);
|
||||||
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
|
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
|
||||||
|
|
||||||
if (code == 42)
|
if (code == 42)
|
||||||
unicode = 42;
|
unicode = 42;
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
//if (unicode < 128)
|
//if (unicode < 128)
|
||||||
{
|
{
|
||||||
sdl_text[0] = unicode;
|
sdl_text[0] = unicode;
|
||||||
sdl_text[1] = 0;
|
sdl_text[1] = 0;
|
||||||
|
|
||||||
int posted = SDL_SendKeyboardText((const char*)sdl_text);
|
int posted = SDL_SendKeyboardText((const char*)sdl_text);
|
||||||
LOGI("posted = %d",posted);
|
LOGI("posted = %d",posted);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
if (state == 2)
|
||||||
|
PortableKeyEvent(0, code, unicode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void changeActionState(int state, int action)
|
void changeActionState(int state, int action)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
//BUTTONSET(action,1);
|
//BUTTONSET(action,1);
|
||||||
droidplayer.functionSticky |= ((uint64_t)1<<((uint64_t)(action)));
|
droidinput.functionSticky |= ((uint64_t)1<<((uint64_t)(action)));
|
||||||
droidplayer.functionHeld |= ((uint64_t)1<<((uint64_t)(action)));
|
droidinput.functionHeld |= ((uint64_t)1<<((uint64_t)(action)));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BUTTONCLEAR(action);
|
//BUTTONCLEAR(action);
|
||||||
droidplayer.functionHeld &= ~((uint64_t) 1<<((uint64_t) (action)));
|
droidinput.functionHeld &= ~((uint64_t) 1<<((uint64_t) (action)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortableAction(int state, int action)
|
void PortableAction(int state, int action)
|
||||||
{
|
{
|
||||||
LOGI("PortableAction action = %d, state = %d",action,state);
|
LOGI("PortableAction action = %d, state = %d", action, state);
|
||||||
|
|
||||||
//Special toggle for crouch, NOT when using jetpack or in water
|
//Action is for the menu
|
||||||
if (!g_player[myconnectindex].ps->jetpack_on &&
|
if (action >= MENU_UP)
|
||||||
g_player[myconnectindex].ps->on_ground &&
|
|
||||||
(sector[g_player[myconnectindex].ps->cursectnum].lotag != ST_2_UNDERWATER))
|
|
||||||
{
|
|
||||||
|
|
||||||
if (action == gamefunc_Crouch)
|
|
||||||
{
|
|
||||||
if (state)
|
|
||||||
droidplayer.crouchToggleState = !droidplayer.crouchToggleState;
|
|
||||||
|
|
||||||
state = droidplayer.crouchToggleState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if jumping while crouched
|
|
||||||
if (action == gamefunc_Jump)
|
|
||||||
{
|
{
|
||||||
droidplayer.crouchToggleState = 0;
|
if (PortableRead(READ_MENU))
|
||||||
changeActionState(0, gamefunc_Crouch);
|
{
|
||||||
|
int sdl_code = 0;
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case MENU_UP:
|
||||||
|
sdl_code = SDL_SCANCODE_UP;
|
||||||
|
break;
|
||||||
|
case MENU_DOWN:
|
||||||
|
sdl_code = SDL_SCANCODE_DOWN;
|
||||||
|
break;
|
||||||
|
case MENU_LEFT:
|
||||||
|
sdl_code = SDL_SCANCODE_LEFT;
|
||||||
|
break;
|
||||||
|
case MENU_RIGHT:
|
||||||
|
sdl_code = SDL_SCANCODE_RIGHT;
|
||||||
|
break;
|
||||||
|
case MENU_SELECT:
|
||||||
|
sdl_code = SDL_SCANCODE_RETURN;
|
||||||
|
break;
|
||||||
|
case MENU_BACK:
|
||||||
|
sdl_code = SDL_SCANCODE_ESCAPE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortableKeyEvent(state, sdl_code, 0);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (PortableRead(READ_MENU)) //If in the menu, dont do any game actions
|
||||||
|
return;
|
||||||
|
|
||||||
changeActionState(state,action);
|
//Special toggle for crouch, NOT when using jetpack or in water
|
||||||
LOGI("PortableAction state = 0x%016llX",CONTROL_ButtonState);
|
if (!g_player[myconnectindex].ps->jetpack_on &&
|
||||||
|
g_player[myconnectindex].ps->on_ground &&
|
||||||
|
(sector[g_player[myconnectindex].ps->cursectnum].lotag != ST_2_UNDERWATER))
|
||||||
|
{
|
||||||
|
if (toggleCrouch)
|
||||||
|
{
|
||||||
|
if (action == gamefunc_Crouch)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
droidinput.crouchToggleState = !droidinput.crouchToggleState;
|
||||||
|
|
||||||
|
state = droidinput.crouchToggleState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if jumping while crouched
|
||||||
|
if (action == gamefunc_Jump)
|
||||||
|
{
|
||||||
|
crouchToggleState = 0;
|
||||||
|
changeActionState(0, gamefunc_Crouch);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeActionState(state, action);
|
||||||
|
|
||||||
|
LOGI("PortableAction state = 0x%016llX", CONTROL_ButtonState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== FORWARD and SIDE MOVMENT ==============
|
// =================== FORWARD and SIDE MOVMENT ==============
|
||||||
|
|
||||||
void PortableMoveFwd(float fwd)
|
|
||||||
{
|
|
||||||
forwardmove = fclamp2(fwd, -1.f, 1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PortableMoveSide(float strafe)
|
|
||||||
{
|
|
||||||
sidemove = fclamp2(strafe, -1.f, 1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PortableMove(float fwd, float strafe)
|
void PortableMove(float fwd, float strafe)
|
||||||
{
|
{
|
||||||
PortableMoveFwd(fwd);
|
droidinput.forwardmove = fclamp2(fwd + droidinput.forwardmove, -1.f, 1.f);
|
||||||
PortableMoveSide(strafe);
|
droidinput.sidemove = fclamp2(strafe + droidinput.sidemove, -1.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
//Look up and down
|
void PortableLook(double yaw, double pitch)
|
||||||
int look_pitch_mode;
|
|
||||||
float look_pitch_mouse,look_pitch_abs,look_pitch_joy;
|
|
||||||
void PortableLookPitch(int mode, float pitch)
|
|
||||||
{
|
{
|
||||||
//LOGI("PortableLookPitch %d %f",mode, pitch);
|
//LOGI("PortableLookPitch %d %f",mode, pitch);
|
||||||
look_pitch_mode = mode;
|
droidinput.pitch += pitch;
|
||||||
switch(mode)
|
droidinput.yaw += yaw;
|
||||||
{
|
|
||||||
case LOOK_MODE_MOUSE:
|
|
||||||
look_pitch_mouse += pitch;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_ABSOLUTE:
|
|
||||||
look_pitch_abs = pitch;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_JOYSTICK:
|
|
||||||
look_pitch_joy = pitch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//left right
|
|
||||||
int look_yaw_mode;
|
|
||||||
float look_yaw_mouse,look_yaw_joy;
|
|
||||||
void PortableLookYaw(int mode, float yaw)
|
|
||||||
{
|
|
||||||
look_yaw_mode = mode;
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
case LOOK_MODE_MOUSE:
|
|
||||||
look_yaw_mouse += yaw;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_JOYSTICK:
|
|
||||||
look_yaw_joy = yaw;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PortableCommand(const char * cmd)
|
void PortableCommand(const char * cmd)
|
||||||
{
|
{
|
||||||
OSD_Dispatch(cmd);
|
OSD_Dispatch(cmd);
|
||||||
|
@ -170,13 +167,7 @@ void PortableCommand(const char * cmd)
|
||||||
|
|
||||||
void PortableInit(int argc,const char ** argv)
|
void PortableInit(int argc,const char ** argv)
|
||||||
{
|
{
|
||||||
main(argc, argv);
|
main(argc, argv);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PortableFrame()
|
|
||||||
{
|
|
||||||
//NOT USED for DUKE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t PortableRead(portableread_t r)
|
int32_t PortableRead(portableread_t r)
|
||||||
|
@ -194,7 +185,7 @@ int32_t PortableRead(portableread_t r)
|
||||||
case READ_RENDERER:
|
case READ_RENDERER:
|
||||||
return getrendermode();
|
return getrendermode();
|
||||||
case READ_LASTWEAPON:
|
case READ_LASTWEAPON:
|
||||||
return droidplayer.lastWeapon;
|
return droidinput.lastWeapon;
|
||||||
case READ_PAUSED:
|
case READ_PAUSED:
|
||||||
return ud.pause_on != 0;
|
return ud.pause_on != 0;
|
||||||
default:
|
default:
|
||||||
|
@ -206,54 +197,35 @@ int32_t PortableRead(portableread_t r)
|
||||||
|
|
||||||
void CONTROL_Android_SetLastWeapon(int w)
|
void CONTROL_Android_SetLastWeapon(int w)
|
||||||
{
|
{
|
||||||
LOGI("setLastWeapon %d",w);
|
LOGI("setLastWeapon %d",w);
|
||||||
droidplayer.lastWeapon = w;
|
droidinput.lastWeapon = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CONTROL_Android_ClearButton(int32_t whichbutton)
|
void CONTROL_Android_ClearButton(int32_t whichbutton)
|
||||||
{
|
{
|
||||||
BUTTONCLEAR(whichbutton);
|
BUTTONCLEAR(whichbutton);
|
||||||
droidplayer.functionHeld &= ~((uint64_t)1<<((uint64_t)(whichbutton)));
|
droidinput.functionHeld &= ~((uint64_t)1<<((uint64_t)(whichbutton)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CONTROL_Android_PollDevices(ControlInfo *info)
|
void CONTROL_Android_PollDevices(ControlInfo *info)
|
||||||
{
|
{
|
||||||
//LOGI("CONTROL_Android_PollDevices %f %f",forwardmove,sidemove);
|
//LOGI("CONTROL_Android_PollDevices %f %f",forwardmove,sidemove);
|
||||||
|
|
||||||
info->dz = -forwardmove * 5000;
|
info->dz = -droidinput.forwardmove * 5000;
|
||||||
info->dx = sidemove * 200;
|
info->dx = droidinput.sidemove * 200;
|
||||||
|
info->dpitch = droidinput.pitch * 100000;
|
||||||
|
info->dyaw = -droidinput.yaw * 80000;
|
||||||
|
|
||||||
switch(look_pitch_mode)
|
droidinput.forwardmove = droidinput.sidemove = 0.f;
|
||||||
{
|
droidinput.pitch = droidinput.yaw = 0.f;
|
||||||
case LOOK_MODE_MOUSE:
|
|
||||||
info->dpitch = look_pitch_mouse * 100000;
|
|
||||||
look_pitch_mouse = 0;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_ABSOLUTE:
|
|
||||||
//cl.viewangles[0] = look_pitch_abs * 80;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_JOYSTICK:
|
|
||||||
info->dpitch = look_pitch_joy * 2000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(look_yaw_mode)
|
CONTROL_ButtonState = 0;
|
||||||
{
|
CONTROL_ButtonState |= droidinput.functionSticky;
|
||||||
case LOOK_MODE_MOUSE:
|
CONTROL_ButtonState |= droidinput.functionHeld;
|
||||||
info->dyaw = -look_yaw_mouse * 80000;
|
|
||||||
look_yaw_mouse = 0;
|
|
||||||
break;
|
|
||||||
case LOOK_MODE_JOYSTICK:
|
|
||||||
info->dyaw = -look_yaw_joy * 4000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
CONTROL_ButtonState = 0;
|
|
||||||
CONTROL_ButtonState |= droidplayer.functionSticky;
|
|
||||||
CONTROL_ButtonState |= droidplayer.functionHeld;
|
|
||||||
|
|
||||||
droidplayer.functionSticky = 0;
|
droidinput.functionSticky = 0;
|
||||||
|
|
||||||
//LOGI("poll state = 0x%016llX",CONTROL_ButtonState);
|
//LOGI("poll state = 0x%016llX",CONTROL_ButtonState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,55 @@
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
enum {
|
|
||||||
LOOK_MODE_MOUSE = 0,
|
|
||||||
LOOK_MODE_ABSOLUTE,
|
|
||||||
LOOK_MODE_JOYSTICK
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
#define MENU_UP 0x200
|
||||||
READ_MENU,
|
#define MENU_DOWN 0x201
|
||||||
READ_WEAPONS,
|
#define MENU_LEFT 0x202
|
||||||
READ_AUTOMAP,
|
#define MENU_RIGHT 0x203
|
||||||
READ_KEYBOARD,
|
#define MENU_SELECT 0x204
|
||||||
READ_RENDERER,
|
#define MENU_BACK 0x205
|
||||||
READ_LASTWEAPON,
|
|
||||||
READ_PAUSED
|
|
||||||
} portableread_t;
|
|
||||||
|
|
||||||
int32_t PortableRead(portableread_t r);
|
#define BUTTONSET(x,value) (CONTROL_ButtonState |= ((uint64_t)value<<((uint64_t)(x))))
|
||||||
|
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1<<((uint64_t)(x))))
|
||||||
|
|
||||||
typedef struct
|
#define PRECISIONSHOOTFACTOR 0.3f
|
||||||
{
|
|
||||||
int32_t crouchToggleState;
|
|
||||||
int32_t lastWeapon;
|
|
||||||
uint64_t functionSticky; //To let at least one tick
|
|
||||||
uint64_t functionHeld;
|
|
||||||
} androidplayer_t;
|
|
||||||
|
|
||||||
extern androidplayer_t droidplayer;
|
typedef enum {
|
||||||
|
READ_MENU,
|
||||||
|
READ_WEAPONS,
|
||||||
|
READ_AUTOMAP,
|
||||||
|
READ_KEYBOARD,
|
||||||
|
READ_RENDERER,
|
||||||
|
READ_LASTWEAPON,
|
||||||
|
READ_PAUSED
|
||||||
|
} portableread_t;
|
||||||
|
|
||||||
int PortableKeyEvent(int state, int code, int unicode);
|
typedef struct
|
||||||
void PortableAction(int state, int action);
|
{
|
||||||
|
int32_t crouchToggleState;
|
||||||
|
int32_t lastWeapon;
|
||||||
|
|
||||||
void PortableMove(float fwd, float strafe);
|
uint64_t functionSticky; //To let at least one tick
|
||||||
void PortableMoveFwd(float fwd);
|
uint64_t functionHeld;
|
||||||
void PortableMoveSide(float strafe);
|
|
||||||
void PortableLookPitch(int mode, float pitch);
|
|
||||||
void PortableLookYaw(int mode, float pitch);
|
|
||||||
void PortableCommand(const char * cmd);
|
|
||||||
|
|
||||||
void PortableInit(int argc, const char ** argv);
|
double pitch, yaw;
|
||||||
void PortableFrame();
|
float forwardmove, sidemove;
|
||||||
|
} droidinput_t;
|
||||||
|
|
||||||
|
int PortableKeyEvent(int state, int code, int unicode);
|
||||||
|
int PortableRead(portableread_t r);
|
||||||
|
|
||||||
|
void PortableAction(int state, int action);
|
||||||
|
|
||||||
|
void PortableMove(float fwd, float strafe);
|
||||||
|
void PortableLook(double yaw, double pitch);
|
||||||
|
void PortableCommand(const char * cmd);
|
||||||
|
|
||||||
|
void PortableInit(int argc, const char ** argv);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue