Skip to content

Commit

Permalink
Bugfixes and mod support
Browse files Browse the repository at this point in the history
  • Loading branch information
masterfeizz committed Nov 9, 2015
1 parent be17031 commit 4dd4397
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 75 deletions.
8 changes: 8 additions & 0 deletions source/cl_main.c
Expand Up @@ -35,6 +35,10 @@ cvar_t lookspring = {"lookspring","0", true};
cvar_t lookstrafe = {"lookstrafe","0", true};
cvar_t sensitivity = {"sensitivity","3", true};

#ifdef _3DS
cvar_t csensitivity = {"csensitivity","3", true};
#endif

cvar_t m_pitch = {"m_pitch","0.022", true};
cvar_t m_yaw = {"m_yaw","0.022", true};
cvar_t m_forward = {"m_forward","1", true};
Expand Down Expand Up @@ -739,6 +743,10 @@ void CL_Init (void)
Cvar_RegisterVariable (&lookstrafe);
Cvar_RegisterVariable (&sensitivity);

#ifdef _3DS
Cvar_RegisterVariable (&csensitivity);
#endif

Cvar_RegisterVariable (&m_pitch);
Cvar_RegisterVariable (&m_yaw);
Cvar_RegisterVariable (&m_forward);
Expand Down
4 changes: 4 additions & 0 deletions source/client.h
Expand Up @@ -268,6 +268,10 @@ extern cvar_t m_yaw;
extern cvar_t m_forward;
extern cvar_t m_side;

#ifdef _3DS
extern cvar_t csensitivity;
#endif


#define MAX_TEMP_ENTITIES 64 // lightning bolts, etc
#define MAX_STATIC_ENTITIES 128 // torches, etc
Expand Down
31 changes: 19 additions & 12 deletions source/in_ctr.c
Expand Up @@ -58,24 +58,31 @@ void IN_Move (usercmd_t *cmd)

hidCircleRead(&circlepad);
//CirclePad deadzone to fix ghost movements
if(abs(circlepad.dy) > 15)
cmd->forwardmove += m_forward.value * circlepad.dy * 2; //FIX ME: allow circlepad sensitivity to be changed
if(abs(circlepad.dx) > 15)
cmd->sidemove += m_side.value * circlepad.dx * 2; //FIX ME: allow player to choose between strafing or turning
if(abs(circlepad.dy) > 15){
cmd->forwardmove += m_forward.value * circlepad.dy * 2;
}
if(abs(circlepad.dx) > 15){
if((in_strafe.state & 1) || (lookstrafe.value))
cmd->sidemove += m_side.value * circlepad.dx * 2;
else
cl.viewangles[YAW] -= m_side.value * circlepad.dx * 0.03;
}

//cStick is only available on N3DS... Until libctru implements support for circlePad Pro
if(isN3DS){

hidCstickRead(&cstick);
cstick.dx = abs(cstick.dx) < 10 ? 0 : cstick.dx * sensitivity.value * 0.01;
cstick.dy = abs(cstick.dy) < 15 ? 0 : cstick.dy * sensitivity.value * 0.01;

if(m_pitch.value < 0)
cstick.dy = -cstick.dy;

cstick.dx = abs(cstick.dx) < 10 ? 0 : cstick.dx * csensitivity.value * 0.01;
cstick.dy = abs(cstick.dy) < 10 ? 0 : cstick.dy * csensitivity.value * 0.01;

cl.viewangles[YAW] -= cstick.dx;
if(in_mlook.state & 1){
cl.viewangles[PITCH] -= cstick.dy;
}
cl.viewangles[PITCH] -= cstick.dy;
}

//If mouselook enabled, stop camera from centering
if(in_mlook.state & 1)
V_StopPitchDrift ();
V_StopPitchDrift ();

}
33 changes: 33 additions & 0 deletions source/menu.c
Expand Up @@ -1091,6 +1091,16 @@ void M_AdjustSliders (int dir)
sensitivity.value = 11;
Cvar_SetValue ("sensitivity", sensitivity.value);
break;
#ifdef _3DS
case 6: // mouse speed
csensitivity.value += dir * 0.5;
if (csensitivity.value < 1)
csensitivity.value = 1;
if (csensitivity.value > 11)
csensitivity.value = 11;
Cvar_SetValue ("csensitivity", csensitivity.value);
break;
#else
case 6: // music volume
#ifdef _WIN32
bgmvolume.value += dir * 1.0;
Expand All @@ -1103,6 +1113,7 @@ void M_AdjustSliders (int dir)
bgmvolume.value = 1;
Cvar_SetValue ("bgmvolume", bgmvolume.value);
break;
#endif
case 7: // sfx volume
volume.value += dir * 0.1;
if (volume.value < 0)
Expand Down Expand Up @@ -1196,28 +1207,50 @@ void M_Options_Draw (void)
r = (1.0 - v_gamma.value) / 0.5;
M_DrawSlider (220, 64, r);

#ifdef _3DS
M_Print (16, 72, " Touch Sensitivity");
#else
M_Print (16, 72, " Mouse Speed");
#endif
r = (sensitivity.value - 1)/10;
M_DrawSlider (220, 72, r);

#ifdef _3DS

M_Print (16, 80, " C Sensitivity");
r = (csensitivity.value - 1)/10;
M_DrawSlider (220, 80, r);

#else

M_Print (16, 80, " CD Music Volume");
r = bgmvolume.value;
M_DrawSlider (220, 80, r);

#endif

M_Print (16, 88, " Sound Volume");
r = volume.value;
M_DrawSlider (220, 88, r);

M_Print (16, 96, " Always Run");
M_DrawCheckbox (220, 96, cl_forwardspeed.value > 200);

#ifdef _3DS
M_Print (16, 104, " Invert C-Button");
#else
M_Print (16, 104, " Invert Mouse");
#endif
M_DrawCheckbox (220, 104, m_pitch.value < 0);

M_Print (16, 112, " Lookspring");
M_DrawCheckbox (220, 112, lookspring.value);

#ifdef _3DS
M_Print (16, 120, " CirclePad Strafe");
#else
M_Print (16, 120, " Lookstrafe");
#endif
M_DrawCheckbox (220, 120, lookstrafe.value);

if (vid_menudrawfn)
Expand Down
30 changes: 19 additions & 11 deletions source/net_udpctr.c
Expand Up @@ -82,16 +82,20 @@ int UDP_Init (void)
if (COM_CheckParm ("-noudp"))
return -1;

SOC_buffer = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);
if(SOC_buffer == NULL)
{
Sys_Error("Failed to allocate SOC_Buffer\n");
}
ret = SOC_Initialize(SOC_buffer, SOC_BUFFERSIZE);
if(SOC_buffer == NULL)
{
Sys_Error("SOC_Initialize failed\n");
}
SOC_buffer = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);

if(SOC_buffer == NULL)
{
Sys_Error("Failed to allocate SOC_Buffer\n");
}
ret = SOC_Initialize(SOC_buffer, SOC_BUFFERSIZE);

if(ret != 0)
{

free(SOC_buffer);
return -1;
}
myAddr = gethostid();

// if the quake hostname isn't set, set it to the machine name
Expand All @@ -101,7 +105,11 @@ int UDP_Init (void)
}

if ((net_controlsocket = UDP_OpenSocket (5000)) == -1) //Passing 0 causes function to fail on 3DS
Sys_Error("UDP_Init: Unable to open control socket\n");
{
SOC_Shutdown();
free(SOC_buffer);
return -1;
}

((struct sockaddr_in *)&broadcastaddr)->sin_family = AF_INET;
((struct sockaddr_in *)&broadcastaddr)->sin_addr.s_addr = INADDR_BROADCAST;
Expand Down
85 changes: 34 additions & 51 deletions source/sys_ctr.c
Expand Up @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "errno.h"

#include <3ds.h>
#include <dirent.h>
#include "ctr.h"
#include "touch_ctr.h"

Expand Down Expand Up @@ -219,77 +220,47 @@ void Sys_Sleep (void)
{
}

void CTR_KeyDown(u32 keys){
void CTR_SetKeys(u32 keys, u32 state){
if( keys & KEY_SELECT)
Key_Event(K_ESCAPE, true);
Key_Event(K_ESCAPE, state);
if( keys & KEY_START)
Key_Event(K_ENTER, true);
Key_Event(K_ENTER, state);
if( keys & KEY_DUP)
Key_Event(K_UPARROW, true);
Key_Event(K_UPARROW, state);
if( keys & KEY_DDOWN)
Key_Event(K_DOWNARROW, true);
Key_Event(K_DOWNARROW, state);
if( keys & KEY_DLEFT)
Key_Event(K_LEFTARROW, true);
Key_Event(K_LEFTARROW, state);
if( keys & KEY_DRIGHT)
Key_Event(K_RIGHTARROW, true);
Key_Event(K_RIGHTARROW, state);
if( keys & KEY_Y)
Key_Event('y', true);
Key_Event('y', state);
if( keys & KEY_X)
Key_Event('x', true);
Key_Event('x', state);
if( keys & KEY_B)
Key_Event('b', true);
Key_Event('b', state);
if( keys & KEY_A)
Key_Event('a', true);
Key_Event('a', state);
if( keys & KEY_L)
Key_Event('l', true);
Key_Event('l', state);
if( keys & KEY_R)
Key_Event('r', true);
Key_Event('r', state);
if( keys & KEY_ZL)
Key_Event('k', true);
Key_Event('k', state);
if( keys & KEY_ZR)
Key_Event('t', true);
Key_Event('t', state);
}

void CTR_KeyUp(u32 keys){
if( keys & KEY_SELECT)
Key_Event(K_ESCAPE, false);
if( keys & KEY_START)
Key_Event(K_ENTER, false);
if( keys & KEY_DUP)
Key_Event(K_UPARROW, false);
if( keys & KEY_DDOWN)
Key_Event(K_DOWNARROW, false);
if( keys & KEY_DLEFT)
Key_Event(K_LEFTARROW, false);
if( keys & KEY_DRIGHT)
Key_Event(K_RIGHTARROW, false);
if( keys & KEY_Y)
Key_Event('y', false);
if( keys & KEY_X)
Key_Event('x', false);
if( keys & KEY_B)
Key_Event('b', false);
if( keys & KEY_A)
Key_Event('a', false);
if( keys & KEY_L)
Key_Event('l', false);
if( keys & KEY_R)
Key_Event('r', false);
if( keys & KEY_ZL)
Key_Event('k', false);
if( keys & KEY_ZR)
Key_Event('t', false);
}

void Sys_SendKeyEvents (void)
{
hidScanInput();
u32 kDown = hidKeysDown();
u32 kUp = hidKeysUp();
if(kDown)
CTR_KeyDown(kDown);
CTR_SetKeys(kDown, true);
if(kUp)
CTR_KeyUp(kUp);
CTR_SetKeys(kUp, false);

Touch_Update();
}
Expand All @@ -308,7 +279,7 @@ int main (int argc, char **argv)
{
float time, oldtime;

APT_CheckNew3DS(NULL, &isN3DS);
APT_CheckNew3DS(&isN3DS);
if(isN3DS)
osSetSpeedupEnable(true);

Expand All @@ -318,13 +289,25 @@ int main (int argc, char **argv)
gfxSetDoubleBuffering(GFX_BOTTOM, false);
gfxSet3D(false);
consoleInit(GFX_BOTTOM, NULL);

char *qargv[3];
int qargc = 1;

qargv[0] = "";

if(strlen(argv[1]) != 0){
qargv[1] = "-game";
qargv[2] = argv[1];
qargc += 2;
}

static quakeparms_t parms;

parms.memsize = 16*1024*1024;
parms.memsize = 24*1024*1024;
parms.membase = malloc (parms.memsize);
parms.basedir = ".";

COM_InitArgv (argc, argv);
COM_InitArgv (qargc, qargv);

parms.argc = com_argc;
parms.argv = com_argv;
Expand All @@ -334,7 +317,7 @@ int main (int argc, char **argv)
Touch_DrawOverlay();
//Sys_Init();
oldtime = Sys_FloatTime() -0.1;
while (1)
while (aptMainLoop())
{
time = Sys_FloatTime();
Host_Frame (time - oldtime);
Expand Down
2 changes: 1 addition & 1 deletion source/touch_ctr.c
Expand Up @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//Keyboard is currently laid out on a 14*4 grid of 20px*20px boxes for lazy implementation
char keymap[14 * 6] = {
K_ESCAPE , K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_F10, K_F11, K_F12, 0,
'`' , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '+', K_BACKSPACE,
'`' , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', K_BACKSPACE,
K_TAB, 'q' , 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '|',
0, 'a' , 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', K_ENTER, K_ENTER,
K_SHIFT, 'z' , 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, K_UPARROW, 0,
Expand Down
5 changes: 5 additions & 0 deletions tf.xml
@@ -0,0 +1,5 @@
<shortcut>
<name>Team Fortress</name>
<executable>/3ds/ctrQuake/ctrQuake.3dsx</executable>
<arg>fortress</arg>
</shortcut>

0 comments on commit 4dd4397

Please sign in to comment.