DJoystick: Add a new ioctl to get the support joystick discrete signals
This commit is contained in:
parent
27226eba0e
commit
544322edb9
|
@ -584,6 +584,7 @@ static int djoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
FAR struct inode *inode;
|
||||
FAR struct djoy_upperhalf_s *priv;
|
||||
FAR struct djoy_open_s *opriv;
|
||||
FAR const struct djoy_lowerhalf_s *lower;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(filep && filep->f_priv && filep->f_inode);
|
||||
|
@ -606,6 +607,29 @@ static int djoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
ret = -EINVAL;
|
||||
switch (cmd)
|
||||
{
|
||||
/* Command: DJOYIOC_SUPPORTED
|
||||
* Description: Report the set of button events supported by the hardware;
|
||||
* Argument: A pointer to writeable integer value in which to return the
|
||||
* set of supported buttons.
|
||||
* Return: Zero (OK) on success. Minus one will be returned on failure
|
||||
* with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
case DJOYIOC_SUPPORTED:
|
||||
{
|
||||
FAR int *supported = (FAR int *)((uintptr_t)arg);
|
||||
|
||||
if (supported)
|
||||
{
|
||||
lower = priv->du_lower;
|
||||
DEBUGASSERT(lower && lower->dl_supported);
|
||||
|
||||
*supported = (int)lower->dl_supported(lower);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
/* Command: DJOYIOC_POLLEVENTS
|
||||
* Description: Specify the set of button events that can cause a poll()
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#define DJOY_BUTTON_2 (5) /* Bit 5: Button 2 */
|
||||
#define DJOY_BUTTON_3 (6) /* Bit 6: Button 3 */
|
||||
#define DJOY_BUTTON_4 (7) /* Bit 7: Button 4 */
|
||||
#define DJOY_NDISCRETES (8) /* Total number of discrete signals */
|
||||
|
||||
#define DJOY_UP_BIT (1 << DJOY_UP) /* 1:Joystick UP selected */
|
||||
#define DJOY_DOWN_BIT (1 << DJOY_DOWN) /* 1:Joystick DOWN selected */
|
||||
|
@ -112,12 +113,27 @@
|
|||
*
|
||||
* 1) The read() method will always return a single value of size
|
||||
* djoy_buttonset_t represent the current state of the joystick buttons.
|
||||
* read() never blocks.
|
||||
* 2) The poll() method can be used to notify a client if there is a change
|
||||
* in any of the joystick discrete inputs. This feature, of course,
|
||||
* depends upon interrupt GPIO support from the platform.
|
||||
* depends upon interrupt GPIO support from the platform. NOTE: that
|
||||
* semantics of poll() for POLLIN are atypical: The successful poll
|
||||
* means that the data has changed and has nothing to with the
|
||||
* availability of data to be read; data is always available to be
|
||||
* read.
|
||||
* 3) The ioctl() method supports the commands documented below:
|
||||
*/
|
||||
|
||||
/* Command: DJOYIOC_SUPPORTED
|
||||
* Description: Report the set of button events supported by the hardware;
|
||||
* Argument: A pointer to writeable integer value in which to return the
|
||||
* set of supported buttons.
|
||||
* Return: Zero (OK) on success. Minus one will be returned on failure
|
||||
* with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
#define DJOYIOC_SUPPORTED _DJOYIOC(0x0001)
|
||||
|
||||
/* Command: DJOYIOC_POLLEVENTS
|
||||
* Description: Specify the set of button events that can cause a poll()
|
||||
* to awaken. The default is all button depressions and all
|
||||
|
@ -127,7 +143,7 @@
|
|||
* with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
#define DJOYIOC_POLLEVENTS _DJOYIOC(0x0001)
|
||||
#define DJOYIOC_POLLEVENTS _DJOYIOC(0x0002)
|
||||
|
||||
/* Command: DJOYIOC_REGISTER
|
||||
* Description: Register to receive a signal whenever there is a change in
|
||||
|
@ -139,7 +155,7 @@
|
|||
* with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
#define DJOYIOC_REGISTER _DJOYIOC(0x0002)
|
||||
#define DJOYIOC_REGISTER _DJOYIOC(0x0003)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
|
Loading…
Reference in New Issue