Skip to content

Commit

Permalink
config controls menu, cstick and nub, and fix shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
elhobbs committed Aug 25, 2016
1 parent a5e79a2 commit 76eccc8
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 41 deletions.
4 changes: 4 additions & 0 deletions 3ds/3ds_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ static void dsp_shutdown() {
snd_init = false;
}

void mix_exit() {
dsp_shutdown();
}

static int dsp_dmapos(void)
{
int s;
Expand Down
70 changes: 57 additions & 13 deletions 3ds/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ extern boolean automapontop;
void keyboard_draw();

void keyboard_init();
void _3ds_shutdown() {
#ifdef _3DS
//gpuExit();
printf("shutting down...maybe...\n");
gfxExit();
#endif
}

int main(int argc, char**argv)
{
Expand All @@ -37,18 +44,15 @@ int main(int argc, char**argv)

printf("gfx init complete\n");

atexit(I_Quit);
atexit(_3ds_shutdown);

//gfxSet3D(true); // uncomment if using stereoscopic 3D

myargc = argc;
myargv = argv;
H2_Main();

#ifdef _3DS
gfxExit();
#endif

exit(0);
return 0;
}

Expand Down Expand Up @@ -164,8 +168,13 @@ void I_Init(void)
===============
*/

void mus_exit();
void mix_exit();
void S_ShutDown(void)
{
mus_exit();
mix_exit();
printf("sound shutdown complete\n");
#if 0
extern int tsm_ID;
if (tsm_ID != -1)
Expand Down Expand Up @@ -243,10 +252,7 @@ void I_Quit(void)
I_Shutdown();

printf("\nHexen: Beyond Heretic\n");
#ifdef _3DS
gfxExit();
#endif
exit(0);
exit(1);
}

/*
Expand Down Expand Up @@ -603,6 +609,9 @@ void keyboard_input();

void DS_Controls(void) {
touchPosition touch;
circlePosition nubPos = { 0, 0 };
circlePosition cstickPos = { 0, 0 };
int dx, dy;

scanKeys(); // Do DS input housekeeping
u32 keys = keysDown();
Expand Down Expand Up @@ -641,7 +650,6 @@ void DS_Controls(void) {

if (keysHeld() & KEY_TOUCH) // this is only for x axis
{
int dx, dy;
event_t event;

touchRead(&g_currentTouch);// = touchReadXY();
Expand All @@ -655,14 +663,50 @@ void DS_Controls(void) {
event.type = ev_mouse;
//event.data1 = I_SDLtoDoomMouseState(Event->motion.state);
event.data1 = 0;
event.data2 = dx << 5;// ((touch.px - 128) / 3) << 5;
//event.data3 = (-(touch.py - 96) / 8) << 5;
event.data3 = 0;// dy << 4;// (0) << 5;
event.data2 = (dx << 3) * (mouseSensitivity + 5) / 10;
event.data3 = (dy >> 1) * (mouseSensitivity + 5) / 10;
H2_PostEvent(&event);

g_lastTouch.px = (g_lastTouch.px + g_currentTouch.px) / 2;
g_lastTouch.py = (g_lastTouch.py + g_currentTouch.py) / 2;
}
irrstCstickRead(&nubPos);
if (abs(nubPos.dx) > 20 || abs(nubPos.dy) > 20) {
event_t ev;
dx = 0;
dy = 0;
if (abs(nubPos.dx) > 20) {
dx = (nubPos.dx) * (nubSensitivity + 5) / 10;
}
if (abs(nubPos.dy) > 20) {
dy = -(nubPos.dy) * (nubSensitivity + 5) / 10;
}

ev.type = ev_nub;
ev.data1 = 0;
ev.data2 = dx;
ev.data3 = dy;
H2_PostEvent(&ev);
}

circleRead(&cstickPos);
if (abs(cstickPos.dx) > 20 || abs(cstickPos.dy) > 20) {
event_t ev;
dx = 0;
dy = 0;
if (abs(cstickPos.dx) > 20) {
dx = (cstickPos.dx >> 2) * (cstickSensitivity + 5) / 10;
}
if (abs(cstickPos.dy) > 20) {
dy = (cstickPos.dy >> 2) * (cstickSensitivity + 5) / 10;
}

ev.type = ev_cstick;
ev.data1 = 0;
ev.data2 = dx;
ev.data3 = dy;
H2_PostEvent(&ev);
}
}
#else
void DS_Controls() {
Expand Down
6 changes: 5 additions & 1 deletion include/H2DEF.H
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ typedef enum
ev_keydown,
ev_keyup,
ev_mouse,
ev_joystick
ev_joystick,
ev_nub,
ev_cstick
} evtype_t;

typedef struct
Expand Down Expand Up @@ -842,6 +844,8 @@ extern int scaledviewwidth;
extern int viewheight;

extern int mouseSensitivity;
extern int cstickSensitivity;
extern int nubSensitivity;

extern boolean precache; // if true, load all graphics at level load

Expand Down
30 changes: 27 additions & 3 deletions source/G_GAME.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ boolean mousearray[4];
boolean *mousebuttons = &mousearray[1];
// allow [-1]
int mousex, mousey; // mouse values are used once
int cstickx, csticky;
int nubx, nuby;
int dclicktime, dclickstate, dclicks;
int dclicktime2, dclickstate2, dclicks2;

Expand Down Expand Up @@ -715,10 +717,21 @@ void G_BuildTiccmd (ticcmd_t *cmd)
else
{
cmd->angleturn -= mousex*0x8;
}
forward += mousey;
}

side += cstickx;
forward += csticky;

cmd->angleturn -= nubx * 0x8;
if (nuby) {
look -= (nuby > 0 ? 1 : -1);
}

//forward += mousey;
mousex = mousey = 0;

cstickx = csticky = 0;
nubx = nuby = 0;

if (forward > MaxPlayerMove[pClass])
{
forward = MaxPlayerMove[pClass];
Expand Down Expand Up @@ -831,6 +844,8 @@ void G_DoLoadLevel (void)
memset (gamekeydown, 0, sizeof(gamekeydown));
joyxmove = joyymove = 0;
mousex = mousey = 0;
cstickx = csticky = 0;
nubx = nuby = 0;
sendpause = sendsave = paused = false;
memset (mousebuttons, 0, sizeof(mousebuttons));
memset (joybuttons, 0, sizeof(joybuttons));
Expand Down Expand Up @@ -981,6 +996,15 @@ boolean G_Responder(event_t *ev)
joyymove = ev->data3;
return(true); // eat events

case ev_cstick:
cstickx = ev->data2;
csticky = ev->data3;
return true;

case ev_nub:
nubx = ev->data2;
nuby = ev->data3;
return true;
default:
break;
}
Expand Down
Loading

0 comments on commit 76eccc8

Please sign in to comment.