c = e.key.keysym.sym;
if (config_tst_d(CONFIG_KEY_FORWARD, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 0);
else if (config_tst_d(CONFIG_KEY_BACKWARD, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 0);
else if (config_tst_d(CONFIG_KEY_LEFT, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 0);
else if (config_tst_d(CONFIG_KEY_RIGHT, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 0);
else switch (c)
{
if (pad[0] && !pad[1]) st_stick(X, -JOY_MAX);
else if (pad[1] && !pad[0]) st_stick(X, +JOY_MAX);
- else st_stick(X, 1);
+ else st_stick(X, 0);
if (pad[2] && !pad[3]) st_stick(Y, -JOY_MAX);
else if (pad[3] && !pad[2]) st_stick(Y, +JOY_MAX);
- else st_stick(Y, 1);
+ else st_stick(Y, 0);
}
else d = st_buttn(b, s);
}
int shared_point_basic(int id, int x, int y)
{
- /* Pulse, activate and return the active id (if changed) */
+ int jd;
- int jd = gui_point(id, x, y);
-
- if (jd)
+ if ((jd = gui_point(id, x, y)))
gui_pulse(jd, 1.2f);
return jd;
int shared_stick_basic(int id, int a, int v)
{
- /* Pulse, activate and return the active id (if changed) */
-
- int jd = 0;
+ int jd;
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- jd = gui_stick(id, v, 0);
- else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- jd = gui_stick(id, 0, v);
- if (jd)
+ if ((jd = gui_stick(id, a, v)))
gui_pulse(jd, 1.2f);
return jd;
static void start_stick(int id, int a, int v)
{
- int x = (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a)) ? v : 0;
- int y = (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a)) ? v : 0;
-
- start_over(gui_stick(id, x, y), 1);
+ start_over(gui_stick(id, a, v), 1);
}
static int start_keybd(int c, int d)
c = e.key.keysym.sym;
- /* gui_stick needs a non-null value, so we use 1 instead of 0. */
-
if (config_tst_d(CONFIG_KEY_FORWARD, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 0);
else if (config_tst_d(CONFIG_KEY_BACKWARD, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_Y), 0);
else if (config_tst_d(CONFIG_KEY_LEFT, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 0);
else if (config_tst_d(CONFIG_KEY_RIGHT, c))
- st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 1);
+ st_stick(config_get_d(CONFIG_JOYSTICK_AXIS_X), 0);
else switch (c)
{
static int shared_stick_basic(int id, int a, int v)
{
- int jd = 0;
-
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- jd = gui_stick(id, v, 0);
- else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- jd = gui_stick(id, 0, v);
+ int jd;
- if (jd)
+ if ((jd = gui_stick(id, a, v)))
gui_pulse(jd, 1.2f);
return jd;
static void stroke_stick(int id, int a, int v)
{
- if (v == 1) /* See 'loop' in main.c */
- v = 0;
-
if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
stroke_rotate = (6 * v) / JOY_MAX;
else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
static void conf_stick(int id, int a, int v)
{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
+ gui_pulse(gui_stick(id, a, v), 1.2f);
}
static int conf_click(int b, int d)
yflag = 0;
}
-int gui_stick(int id, int x, int y)
+int gui_stick(int id, int a, int v)
{
int jd = 0;
/* Find a new active widget in the direction of joystick motion. */
- if (x && -JOY_MID <= x && x <= +JOY_MID)
- xflag = 1;
- else if (x < -JOY_MID && xflag && (jd = gui_wrap_L(id, active)))
- xflag = 0;
- else if (x > +JOY_MID && xflag && (jd = gui_wrap_R(id, active)))
- xflag = 0;
-
- if (y && -JOY_MID <= y && y <= +JOY_MID)
- yflag = 1;
- else if (y < -JOY_MID && yflag && (jd = gui_wrap_U(id, active)))
- yflag = 0;
- else if (y > +JOY_MID && yflag && (jd = gui_wrap_D(id, active)))
- yflag = 0;
+ if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
+ {
+ if (-JOY_MID <= v && v <= +JOY_MID)
+ xflag = 1;
+ else if (v < -JOY_MID && xflag && (jd = gui_wrap_L(id, active)))
+ xflag = 0;
+ else if (v > +JOY_MID && xflag && (jd = gui_wrap_R(id, active)))
+ xflag = 0;
+ }
+ else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
+ {
+ if (-JOY_MID <= v && v <= +JOY_MID)
+ yflag = 1;
+ else if (v < -JOY_MID && yflag && (jd = gui_wrap_U(id, active)))
+ yflag = 0;
+ else if (v > +JOY_MID && yflag && (jd = gui_wrap_D(id, active)))
+ yflag = 0;
+ }
/* If the active widget has changed, return the new active id. */
static void resol_stick(int id, int a, int v)
{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
+ gui_pulse(gui_stick(id, a, v), 1.2f);
}
static int resol_click(int b, int d)