summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/drivers/input/djoystick.c23
-rw-r--r--nuttx/include/nuttx/input/djoystick.h9
2 files changed, 22 insertions, 10 deletions
diff --git a/nuttx/drivers/input/djoystick.c b/nuttx/drivers/input/djoystick.c
index dea01d160..05342c29a 100644
--- a/nuttx/drivers/input/djoystick.c
+++ b/nuttx/drivers/input/djoystick.c
@@ -190,7 +190,8 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
{
FAR const struct djoy_lowerhalf_s *lower = priv->du_lower;
FAR struct djoy_open_s *opriv;
- djoy_buttonset_t intmask;
+ djoy_buttonset_t press;
+ djoy_buttonset_t release;
irqstate_t flags;
#ifndef CONFIG_DISABLE_POLL
int i;
@@ -207,7 +208,9 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
/* Visit each opened reference to the device */
- intmask = 0;
+ press = 0;
+ release = 0;
+
for (opriv = priv->du_open; opriv; opriv = opriv->do_flink)
{
#ifndef CONFIG_DISABLE_POLL
@@ -219,8 +222,8 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
{
/* Yes.. OR in the poll event buttons */
- intmask |= (opriv->do_pollevents.dp_press |
- opriv->do_pollevents.dp_release);
+ press |= opriv->do_pollevents.dp_press;
+ release |= opriv->do_pollevents.dp_release;
break;
}
}
@@ -229,24 +232,26 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
#ifndef CONFIG_DISABLE_SIGNALS
/* OR in the signal events */
- intmask |= (opriv->do_notify.dn_press | opriv->do_notify.dn_release);
+ press |= opriv->do_notify.dn_press;
+ release |= opriv->do_notify.dn_release;
#endif
}
/* Enable/disable button interrupts */
DEBUGASSERT(lower->dl_enable);
- if (intmask != 0)
+ if (press != 0 || release != 0)
{
/* Enable interrupts with the new button set */
- lower->dl_enable(lower, intmask, (djoy_interrupt_t)djoy_interrupt, priv);
+ lower->dl_enable(lower, press, release,
+ (djoy_interrupt_t)djoy_interrupt, priv);
}
else
{
/* Disable further interrupts */
- lower->dl_enable(lower, 0, NULL, NULL);
+ lower->dl_enable(lower, 0, 0, NULL, NULL);
}
irqrestore(flags);
@@ -812,7 +817,7 @@ int djoy_register(FAR const char *devname,
/* Make sure that all djoystick interrupts are disabled */
DEBUGASSERT(lower->dl_enable);
- lower->dl_enable(lower, (djoy_buttonset_t)0, NULL, NULL);
+ lower->dl_enable(lower, 0, 0, NULL, NULL);
/* Initialize the new djoystick driver instance */
diff --git a/nuttx/include/nuttx/input/djoystick.h b/nuttx/include/nuttx/input/djoystick.h
index c973936b7..ca1273dc2 100644
--- a/nuttx/include/nuttx/input/djoystick.h
+++ b/nuttx/include/nuttx/input/djoystick.h
@@ -82,6 +82,13 @@
#define DJOY_BUTTON_3 (1 << 7) /* Bit 7: True = Button 4 pressed */
#define DJOY_BUTTONS_ALL 0xff /* The set of all buttons */
+/* Typical usage */
+
+#define DJOY_BUTTON_SELECT DJOY_BUTTON_1
+#define DJOY_BUTTON_FIRE DJOY_BUTTON_2
+#define DJOY_BUTTON_JUMP DJOY_BUTTON_3
+#define DJOY_BUTTON_RUN DJOY_BUTTON_4
+
/* IOCTL commands
*
* Discrete joystick drivers do not support the character driver write() or
@@ -185,7 +192,7 @@ struct djoy_lowerhalf_s
*/
CODE void (*dl_enable)(FAR const struct djoy_lowerhalf_s *lower,
- djoy_buttonset_t buttons,
+ djoy_buttonset_t press, djoy_buttonset_t release,
djoy_interrupt_t handler, FAR void *arg);
};