2 * \file tpl_drv_joystick
\r
3 * \brief Joystick Driver Interface Definitions
\r
4 * \author John Hodge (thePowersGang)
\r
6 * \section dirs VFS Layout
\r
7 * Joystick drivers define a single VFS node, that acts as a fixed size file.
\r
8 * Reads from this file return the current state, writes are ignored.
\r
10 * \section File Structure
\r
11 * The device file must begin with a valid sJoystick_FileHeader structure.
\r
12 * The file header is followed by \a NAxies instances of sJoystick_Axis, one
\r
14 * This is followed by \a NButtons boolean values (represented using \a Uint8),
\r
15 * each representing the state of a single button (where 0 is unpressed,
\r
16 * 0xFF is fully depressed - intermediate values are valid in the case of
\r
17 * variable-pressure buttons)
\r
19 #ifndef _TPL_JOYSTICK_H
\r
20 #define _TPL_JOYSTICK_H
\r
22 #include <tpl_drv_common.h>
\r
25 * \enum eTplJoystick_IOCtl
\r
26 * \brief Common Joystick IOCtl Calls
\r
27 * \extends eTplDrv_IOCtl
\r
29 enum eTplJoystick_IOCtl {
\r
31 * ioctl(..., tJoystickCallback *Callback)
\r
32 * \brief Sets the callback
\r
33 * \note Can be called from kernel mode only
\r
35 * Sets the callback that is called when a event occurs (button or axis
\r
36 * change). This function pointer must be in kernel mode (although,
\r
37 * kernel->user or kernel->ring3driver abstraction functions can be used)
\r
39 JOY_IOCTL_SETCALLBACK = 4,
\r
42 * ioctl(..., int *Argument)
\r
43 * \brief Set the argument passed as the first parameter to the callback
\r
44 * \note Kernel mode only
\r
46 JOY_IOCTL_SETCALLBACKARG,
\r
49 * ioctl(..., tJoystickNumValue *)
\r
50 * \brief Set maximum value for sJoystick_Axis.CurState
\r
51 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
53 JOY_IOCTL_GETSETAXISLIMIT,
\r
56 * ioctl(..., tJoystickNumValue *)
\r
57 * \brief Set the value of sJoystick_Axis.CurState
\r
58 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
60 JOY_IOCTL_GETSETAXISPOSITION,
\r
63 * ioctl(..., tJoystickNumValue *)
\r
64 * \brief Set axis flags
\r
65 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
66 * \todo Define flag values
\r
68 JOY_IOCTL_GETSETAXISFLAGS,
\r
71 * ioctl(..., tJoystickNumValue *)
\r
72 * \brief Set Button Flags
\r
73 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
74 * \todo Define flag values
\r
76 JOY_IOCTL_GETSETBUTTONFLAGS,
\r
79 #define DRV_JOY_IOCTLNAMES "set_callback", "set_callback_arg", "getset_axis_limit", "getset_axis_position", \
\r
80 "getset_axis_flags", "getset_button_flags"
\r
83 typedef struct sJoystick_NumValue tJoystick_NumValue;
\r
84 typedef struct sJoystick_FileHeader tJoystick_FileHeader;
\r
85 typedef struct sJoystick_Axis tJoystick_Axis;
\r
88 * \brief Number/Value pair for joystick IOCtls
\r
90 struct sJoystick_NumValue
\r
92 int Num; //!< Axis/Button number
\r
93 int Value; //!< Value (see IOCtl defs for meaning)
\r
97 * \brief Callback type for JOY_IOCTL_SETCALLBACK
\r
98 * \param Ident Ident value passed to JOY_IOCTL_SETCALLBACK
\r
101 typedef void (*tJoystick_Callback)(int Ident, int bIsAxis, int Num, int Delta);
\r
104 * \struct sJoystick_FileHeader
\r
106 struct sJoystick_FileHeader
\r
108 Uint16 NAxies; //!< Number of Axies
\r
109 Uint16 NButtons; //!< Number of buttons
\r
113 * \brief Axis Definition in file data
\r
115 * Describes the current state of an axis on the joystick.
\r
116 * \a MinValue and \a MaxValue describe the valid range for \a CurValue
\r
117 * While \a CurState is between zero and the current limit set by the
\r
118 * JOY_IOCTL_GETSETAXISLIMIT IOCtl.
\r
120 struct sJoystick_Axis
\r
122 Sint16 MinValue; //!< Minumum value for \a CurValue
\r
123 Sint16 MaxValue; //!< Maximum value for \a CurValue
\r
124 Sint16 CurValue; //!< Current value (joystick position)
\r
125 Uint16 CurState; //!< Current state (cursor position)
\r