Add an analog joystick driver. Initial checkin is only a little more of a clone of the discrete joystick driver and is as-of-yet untested

This commit is contained in:
Gregory Nutt
2014-11-28 19:59:27 -06:00
parent 36ac0d2cf4
commit 2b8fe6709b
5 changed files with 940 additions and 12 deletions
+18
View File
@@ -340,3 +340,21 @@ config DJOYSTICK_NPOLLWAITERS
depends on !DISABLE_POLL
endif # DJOYSTICK
config AJOYSTICK
bool "Analog Joystick"
default n
---help---
Enable standard analog joystick upper half driver. An analog
joystick refers to a joystick that provides position data as an
integer value that might have been obtained through DACs.
Discrete button inputs are also supported.
if AJOYSTICK
config AJOYSTICK_NPOLLWAITERS
int "Max Number of Poll Waiters"
default 2
depends on !DISABLE_POLL
endif # AJOYSTICK
+4
View File
@@ -75,6 +75,10 @@ ifeq ($(CONFIG_DJOYSTICK),y)
CSRCS += djoystick.c
endif
ifeq ($(CONFIG_AJOYSTICK),y)
CSRCS += ajoystick.c
endif
# Include input device driver build support
DEPPATH += --dep-path input
File diff suppressed because it is too large Load Diff
+12 -2
View File
@@ -340,7 +340,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
ivdbg("Report events: %02x\n", fds->revents);
illvdbg("Report events: %02x\n", fds->revents);
sem_post(fds->sem);
}
}
@@ -550,6 +550,16 @@ static ssize_t djoy_read(FAR struct file *filep, FAR char *buffer,
DEBUGASSERT(inode->i_private);
priv = (FAR struct djoy_upperhalf_s *)inode->i_private;
/* Make sure that the buffer is sufficiently large to hold at least one
* complete sample.
*/
if (len < sizeof(djoy_buttonset_t))
{
ivdbg("ERROR: buffer too small: %lu\n", (unsigned long)len);
return -EINVAL;
}
/* Get exclusive access to the driver structure */
ret = djoy_takesem(&priv->du_exclsem);
@@ -568,7 +578,7 @@ static ssize_t djoy_read(FAR struct file *filep, FAR char *buffer,
ret = sizeof(djoy_buttonset_t);
djoy_givesem(&priv->du_exclsem);
return ret;
return (ssize_t)ret;
}
/****************************************************************************