Saves axes behaviours on the config file.

This commit is contained in:
Johnny on Flame 2013-01-25 17:27:38 -02:00 committed by Bill Currie
parent 4f92bceb4f
commit 637d751aa7
3 changed files with 36 additions and 2 deletions

View file

@ -29,6 +29,7 @@
#define __QF_joystick_h_ #define __QF_joystick_h_
#include <QF/qtypes.h> #include <QF/qtypes.h>
#include "QF/quakeio.h"
#define JOY_MAX_AXES 8 #define JOY_MAX_AXES 8
#define JOY_MAX_BUTTONS 18 #define JOY_MAX_BUTTONS 18
@ -147,4 +148,7 @@ int JOY_GetOption_i (const char *c);
const char * JOY_GetDest_c (int i); const char * JOY_GetDest_c (int i);
int JOY_GetDest_i (const char *c); int JOY_GetDest_i (const char *c);
void Joy_WriteBindings (QFile *f);
#endif // __QF_joystick_h_ #endif // __QF_joystick_h_

View file

@ -264,8 +264,22 @@ in_joy_f (void)
{ {
int i, ax, c = Cmd_Argc(); int i, ax, c = Cmd_Argc();
if (c < 3) { if (c == 2) {
ax = strtol(Cmd_Argv(1), NULL ,0);
Sys_Printf ("<=====> AXIS %i <=====>\n", ax);
Sys_Printf ("amp: %f\n", joy_axes[ax].amp);
Sys_Printf ("pre_amp: %f\n", joy_axes[ax].pre_amp);
Sys_Printf ("deadzone: %i\n", joy_axes[ax].deadzone);
Sys_Printf ("offset: %f\n", joy_axes[ax].offset);
Sys_Printf ("type: %s\n", JOY_GetDest_c(joy_axes[ax].dest));
Sys_Printf ("<====================>\n");
}
else if (c < 4) {
Sys_Printf ("in_joy <axis#> [<var> <value>]* : Configures the joystick behaviour\n"); Sys_Printf ("in_joy <axis#> [<var> <value>]* : Configures the joystick behaviour\n");
return;
} }
ax = strtol(Cmd_Argv(1), NULL ,0); ax = strtol(Cmd_Argv(1), NULL ,0);
@ -278,7 +292,6 @@ in_joy_f (void)
switch (var) { switch (var) {
case js_amp: case js_amp:
joy_axes[ax].amp = strtof (Cmd_Argv(i++), NULL); joy_axes[ax].amp = strtof (Cmd_Argv(i++), NULL);
Sys_Printf("Set axis %i's amp to %f\n", ax, joy_axes[ax].amp);
break; break;
case js_pre_amp: case js_pre_amp:
joy_axes[ax].pre_amp = strtof (Cmd_Argv(i++), NULL); joy_axes[ax].pre_amp = strtof (Cmd_Argv(i++), NULL);
@ -293,6 +306,8 @@ in_joy_f (void)
joy_axes[ax].dest = JOY_GetDest_i (Cmd_Argv(i++)); joy_axes[ax].dest = JOY_GetDest_i (Cmd_Argv(i++));
joy_axes[ax].axis = strtol (Cmd_Argv(i++), NULL, 10); joy_axes[ax].axis = strtol (Cmd_Argv(i++), NULL, 10);
break; break;
case js_axis_button:
break;
default: default:
Sys_Printf ("Unknown option %s.\n", Cmd_Argv(i-1)); Sys_Printf ("Unknown option %s.\n", Cmd_Argv(i-1));
break; break;
@ -315,6 +330,19 @@ JOY_Init_Cvars (void)
Cmd_AddCommand("in_joy", in_joy_f, "Configures the joystick behaviour"); Cmd_AddCommand("in_joy", in_joy_f, "Configures the joystick behaviour");
} }
void
Joy_WriteBindings (QFile *f)
{
int i;
for (i=0;i<JOY_MAX_AXES;i++)
{
Qprintf(f, "in_joy %i amp %f pre_amp %f deadzone %i offset %f type %s %i\n",
i, joy_axes[i].amp, joy_axes[i].pre_amp, joy_axes[i].deadzone,
joy_axes[i].offset, JOY_GetDest_c (joy_axes[i].dest), joy_axes[i].axis);
}
}
VISIBLE void VISIBLE void
JOY_Shutdown (void) JOY_Shutdown (void)
{ {

View file

@ -35,6 +35,7 @@
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/draw.h" #include "QF/draw.h"
#include "QF/input.h" #include "QF/input.h"
#include "QF/joystick.h"
#include "QF/keys.h" #include "QF/keys.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/qfplist.h" #include "QF/qfplist.h"
@ -113,6 +114,7 @@ CL_WriteConfiguration (void)
Key_WriteBindings (f); Key_WriteBindings (f);
Cvar_WriteVariables (f); Cvar_WriteVariables (f);
Joy_WriteBindings (f);
Qclose (f); Qclose (f);
} }