1,3 → 1,4 |
#include "compat.h" |
#include "sdl_inc.h" |
#include "baselayer.h" |
#include "keys.h" |
7,16 → 8,30 |
#include "player.h" |
#include "game.h" |
#include "build.h" |
#include "anim.h" |
#include "player.h" |
|
#include "jmact/keyboard.h" |
#include "jmact/control.h" |
#include "jmact/_control.h" |
|
#include "menus.h" |
|
#include "../src/video/android/SDL_androidkeyboard.h" // FIXME: include header locally if necessary |
#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); |
extern int SDL_SendMouseButton(SDL_Window * window, Uint32 mouseID, Uint8 state, Uint8 button); |
|
#ifdef __cplusplus |
} |
#endif |
|
#include "in_android.h" |
|
#include <android/log.h> |
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__)) |
23,9 → 38,6 |
|
extern int32_t main(int32_t argc, char *argv []); |
|
extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode); |
extern int SDL_SendKeyboardText(const char *text); |
|
static char sdl_text[2]; |
|
droidinput_t droidinput; |
32,9 → 44,9 |
|
int PortableKeyEvent(int state, int code,int unicode) |
{ |
LOGI("PortableKeyEvent %d %d %d",state,code,unicode); |
LOGI("PortableKeyEvent %d %d %d",state,(SDL_Scancode)code,unicode); |
|
SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, code); |
SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)code); |
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE); |
|
// if (code == 42) |
58,6 → 70,16 |
return 0; |
} |
|
void PortableMouseMenu(float x,float y) |
{ |
SDL_SendMouseMotion(NULL,0,0,x,y); |
} |
|
void PortableMouseMenuButton(int state,int button) |
{ |
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, state?SDL_PRESSED:SDL_RELEASED, SDL_BUTTON_LEFT); |
} |
|
void changeActionState(int state, int action) |
{ |
if (state) |
102,13 → 124,22 |
#endif |
|
//Special toggle for crouch, NOT when using jetpack or in water |
if (!g_player[myconnectindex].ps->jetpack_on && |
g_player[myconnectindex].ps->on_ground && |
(sector[g_player[myconnectindex].ps->cursectnum].lotag != ST_2_UNDERWATER)) |
if (droidinput.toggleCrouch) |
{ |
if (toggleCrouch) |
int lotag = sector[g_player[myconnectindex].ps->cursectnum].lotag; |
|
if (droidinput.crouchToggleState && (lotag == ST_2_UNDERWATER || lotag == ST_1_ABOVE_WATER)) |
{ |
droidinput.crouchToggleState = 0; |
if (action == gamefunc_Crouch) |
state = 0; |
else PortableAction(0, gamefunc_Crouch); |
} |
|
if (action == gamefunc_Crouch) |
{ |
if (!g_player[myconnectindex].ps->jetpack_on && g_player[myconnectindex].ps->on_ground && |
lotag != ST_2_UNDERWATER && lotag != ST_1_ABOVE_WATER) |
{ |
if (state) |
droidinput.crouchToggleState = !droidinput.crouchToggleState; |
116,19 → 147,25 |
state = droidinput.crouchToggleState; |
} |
} |
|
} |
|
//Check if jumping while crouched |
if (action == gamefunc_Jump) |
{ |
droidinput.crouchToggleState = 0; |
changeActionState(0, gamefunc_Crouch); |
if (droidinput.crouchToggleState) |
{ |
droidinput.crouchToggleState = 0; |
changeActionState(0, gamefunc_Crouch); |
} |
else |
changeActionState(state, action); |
} |
else |
changeActionState(state, action); |
|
changeActionState(state, action); |
|
if (state == 2) |
PortableAction(0,action); |
PortableAction(0, action); |
|
// LOGI("PortableAction state = 0x%016llX", CONTROL_ButtonState); |
} |
137,6 → 174,12 |
//Need these NAN check as not cumulative. |
void PortableMove(float fwd, float strafe) |
{ |
if (!ud.auto_run) |
{ |
fwd *= 0.5f; |
strafe *= 0.5f; |
} |
|
if (!isnan(fwd)) |
droidinput.forwardmove = fclamp2(fwd, -1.f, 1.f); |
|
164,13 → 207,10 |
{ |
OSD_Dispatch(cmd); |
} |
|
|
void PortableInit(int argc, const char ** argv) |
{ |
//droidinput.left_double_action = -1; |
//droidinput.right_double_action = -1; |
|
main(argc, argv); |
main(argc, ( char **)argv); |
} |
|
int consoleShown = 0; |
179,62 → 219,63 |
consoleShown = onf; |
} |
|
extern int animation_playing; |
extern int inExtraScreens; //In game.c |
int32_t PortableRead(portableread_t r) |
{ |
int32_t rv; |
|
switch (r) |
{ |
case READ_SCREEN_MODE: |
|
if (animation_playing) |
return TOUCH_SCREEN_BLANK_TAP; |
else if (inExtraScreens) |
return TOUCH_SCREEN_BLANK_TAP; |
if (g_animPtr || inExtraScreens) |
rv = TOUCH_SCREEN_BLANK_TAP; |
else if (consoleShown) |
return TOUCH_SCREEN_CONSOLE; |
rv = TOUCH_SCREEN_CONSOLE; |
else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU) |
{ |
//Then check if Yes/No menu |
if ((g_currentMenu == MENU_QUITTOTITLE) || |
(g_currentMenu == MENU_RESETPLAYER ) || |
((g_currentMenu == MENU_LOADVERIFY )) || |
(g_currentMenu == MENU_NEWVERIFY ) || |
((g_currentMenu == MENU_SAVEVERIFY )) || |
(g_currentMenu == MENU_QUIT ) || |
(g_currentMenu == MENU_QUITTOTITLE ) |
) |
return TOUCH_SCREEN_YES_NO; |
else |
return TOUCH_SCREEN_MENU; |
} |
rv = (m_currentMenu->type == Verify) ? TOUCH_SCREEN_YES_NO : TOUCH_SCREEN_MENU; |
else if (ud.overhead_on == 2) |
return TOUCH_SCREEN_AUTOMAP; |
rv = TOUCH_SCREEN_AUTOMAP; |
else if ((g_player[myconnectindex].ps->gm & MODE_GAME)) |
if (PortableRead(READ_IS_DEAD)) |
return TOUCH_SCREEN_BLANK_TAP; |
rv = TOUCH_SCREEN_BLANK_TAP; |
else |
return TOUCH_SCREEN_GAME; |
rv = TOUCH_SCREEN_GAME; |
else |
return TOUCH_SCREEN_BLANK_TAP; |
|
rv = TOUCH_SCREEN_BLANK_TAP; |
break; |
case READ_WEAPONS: |
return g_player[myconnectindex].ps->gotweapon; |
rv = g_player[myconnectindex].ps->gotweapon; break; |
case READ_AUTOMAP: |
return ud.overhead_on != 0; // ud.overhead_on ranges from 0-2 |
rv = ud.overhead_on != 0; break;// ud.overhead_on ranges from 0-2 |
case READ_MAPFOLLOWMODE: |
return ud.scrollmode; |
rv = ud.scrollmode; break; |
case READ_RENDERER: |
return getrendermode(); |
rv = getrendermode(); break; |
case READ_LASTWEAPON: |
return droidinput.lastWeapon; |
rv = droidinput.lastWeapon; |
if ((unsigned)rv < MAX_WEAPONS && !g_player[myconnectindex].ps->ammo_amount[rv]) |
rv = -1; |
break; |
case READ_PAUSED: |
return ud.pause_on != 0; |
rv = ud.pause_on != 0; break; |
case READ_IS_DEAD: |
return g_player[myconnectindex].ps->dead_flag; |
rv = g_player[myconnectindex].ps->dead_flag; break; |
case READ_INVENTORY: |
rv = 0; |
for (int i = 0; i < GET_MAX; i++) |
{ |
if (g_player[myconnectindex].ps->inv_amount[i]) |
rv += (1 << i); |
} |
break; |
case READ_SOMETHINGONPLAYER: |
rv = g_player[myconnectindex].ps->somethingonplayer != -1; |
break; |
default: |
return 0; |
rv = 0; break; |
} |
|
return rv; |
} |
|
static float map_zoom,map_dx,map_dy = 0; |
254,7 → 295,7 |
*x += ((int)(map_dx * -30000)*sintable[(512+2048-*angle)&2047])>>14; |
*y += ((int)(map_dy * -30000)*sintable[(512+1024-512-*angle)&2047])>>14; |
|
*zoom += map_zoom * 2000; |
// *zoom += map_zoom * 2000; |
//*angle = 0; |
map_dx = map_dy = map_zoom = 0; |
} |