2 * \file api_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 _API_DRV_JOYSTICK_H
\r
20 #define _API_DRV_JOYSTICK_H
\r
22 #include <api_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(..., tJoystick_Callback *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 * Axis events depend on the axis limit, if non-zero, the callback fires
\r
40 * if the cursor position changes. Otherwise it fires when the axis value
\r
41 * (cursor accelleration) changes.
\r
43 JOY_IOCTL_SETCALLBACK = 4,
\r
46 * ioctl(..., int *Argument)
\r
47 * \brief Set the argument passed as the first parameter to the callback
\r
48 * \note Kernel mode only
\r
50 JOY_IOCTL_SETCALLBACKARG,
\r
53 * ioctl(..., tJoystickNumValue *)
\r
54 * \brief Set maximum value for sJoystick_Axis.CurState
\r
55 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
57 JOY_IOCTL_GETSETAXISLIMIT,
\r
60 * ioctl(..., tJoystickNumValue *)
\r
61 * \brief Set the value of sJoystick_Axis.CurState
\r
62 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
64 JOY_IOCTL_GETSETAXISPOSITION,
\r
67 * ioctl(..., tJoystickNumValue *)
\r
68 * \brief Set axis flags
\r
69 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
70 * \todo Define flag values
\r
72 JOY_IOCTL_GETSETAXISFLAGS,
\r
75 * ioctl(..., tJoystickNumValue *)
\r
76 * \brief Set Button Flags
\r
77 * \note If \a Value is equal to -1 (all bits set), the value is not changed
\r
78 * \todo Define flag values
\r
80 JOY_IOCTL_GETSETBUTTONFLAGS,
\r
83 #define DRV_JOY_IOCTLNAMES "set_callback", "set_callback_arg", "getset_axis_limit", "getset_axis_position", \
\r
84 "getset_axis_flags", "getset_button_flags"
\r
87 typedef struct sJoystick_NumValue tJoystick_NumValue;
\r
88 typedef struct sJoystick_FileHeader tJoystick_FileHeader;
\r
89 typedef struct sJoystick_Axis tJoystick_Axis;
\r
92 * \brief Number/Value pair for joystick IOCtls
\r
94 struct sJoystick_NumValue
\r
96 int Num; //!< Axis/Button number
\r
97 int Value; //!< Value (see IOCtl defs for meaning)
\r
101 * \brief Callback type for JOY_IOCTL_SETCALLBACK
\r
102 * \param Ident Ident value passed to JOY_IOCTL_SETCALLBACK
\r
105 typedef void (*tJoystick_Callback)(int Ident, int bIsAxis, int Num, int Delta);
\r
108 * \struct sJoystick_FileHeader
\r
110 struct sJoystick_FileHeader
\r
112 Uint16 NAxies; //!< Number of Axies
\r
113 Uint16 NButtons; //!< Number of buttons
\r
117 * \brief Axis Definition in file data
\r
119 * Describes the current state of an axis on the joystick.
\r
120 * \a CursorPos is between zero and the current limit set by the
\r
121 * JOY_IOCTL_GETSETAXISLIMIT IOCtl, while \a CurValue indicates the
\r
122 * current position of the joystick axis. This is defined to be between
\r
123 * \a MinValue and \a MaxValue.
\r
125 struct sJoystick_Axis
\r
127 Sint16 MinValue; //!< Minumum value for \a CurValue
\r
128 Sint16 MaxValue; //!< Maximum value for \a CurValue
\r
129 Sint16 CurValue; //!< Current value (joystick position)
\r
130 Uint16 CursorPos; //!< Current state (cursor position)
\r
133 #define JOY_INFOSTRUCT(_naxies, _nbuttons) struct { \
\r
134 Uint16 NAxies, NButtons;\
\r
135 tJoystick_Axis Axies[_naxies];\
\r
136 Uint16 Buttons[_nbuttons];\
\r