Near-Complete Joystick spec
[tpg/acess2.git] / Kernel / include / tpl_drv_joystick.h
1 /**\r
2  * \file tpl_drv_joystick\r
3  * \brief Joystick Driver Interface Definitions\r
4  * \author John Hodge (thePowersGang)\r
5  * \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
9  *\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
13  * for each axis.\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
18  */\r
19 #ifndef _TPL_JOYSTICK_H\r
20 #define _TPL_JOYSTICK_H\r
21 \r
22 #include <tpl_drv_common.h>\r
23 \r
24 /**\r
25  * \enum eTplJoystick_IOCtl\r
26  * \brief Common Joystick IOCtl Calls\r
27  * \extends eTplDrv_IOCtl\r
28  */\r
29 enum eTplJoystick_IOCtl {\r
30         /**\r
31          * ioctl(..., struct{int Ident;tKeybardCallback *Callback})\r
32          * \brief Sets the callback\r
33          * \note Can be called from kernel mode only\r
34          *\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
38          */\r
39         JOY_IOCTL_SETCALLBACK = 4,\r
40 \r
41         /**\r
42          * ioctl(..., struct{int AxisNum;int Value})\r
43          * \brief Set maximum value for sJoystick_Axis.CurState\r
44          * \note If \a Value is equal to -1 (all bits set), the value is not changed\r
45          */\r
46         JOY_IOCTL_GETSETAXISLIMIT,\r
47         \r
48         /**\r
49          * ioctl(..., struct{int AxisNum;int Value})\r
50          * \brief Set axis flags\r
51          * \note If \a Value is equal to -1 (all bits set), the value is not changed\r
52          */\r
53         JOY_IOCTL_GETSETAXISFLAGS,\r
54 \r
55         /**\r
56          * ioctl(..., struct{int ButtonNum;int Value})\r
57          * \brief Set Button Flags\r
58          * \note If \a Value is equal to -1 (all bits set), the value is not changed\r
59          */\r
60         JOY_IOCTL_GETSETBUTTONFLAGS,\r
61 };\r
62 \r
63 /**\r
64  * \brief Callback type for JOY_IOCTL_SETCALLBACK\r
65  * \param Ident Ident value passed to JOY_IOCTL_SETCALLBACK\r
66  * \r
67  */\r
68 typedef void (*tJoystickCallback)(int Ident, int bIsAxis, int Num, int Delta);\r
69 \r
70 /**\r
71  * \struct sJoystick_FileHeader\r
72  */\r
73 struct sJoystick_FileHeader\r
74 {\r
75         Uint16  NAxies; //!< Number of Axies\r
76         Uint16  NButtons;       //!< Number of buttons\r
77 };\r
78 \r
79 /**\r
80  * \brief Axis Definition\r
81  *\r
82  * Describes the current state of an axis on the joystick.\r
83  * \a MinValue and \a MaxValue describe the valid range for \a CurValue\r
84  * While \a CurState is between zero and the current limit set by the\r
85  * JOY_IOCTL_GETSETAXISLIMIT IOCtl.\r
86  */\r
87 struct sJoystick_Axis\r
88 {\r
89         Sint16  MinValue;       //!< Minumum value for \a CurValue\r
90         Sint16  MaxValue;       //!< Maximum value for \a MaxValue\r
91         Sint16  CurValue;       //!< Current value (joystick position)\r
92         Uint16  CurState;       //!< Current state (cursor position)\r
93 };\r
94 \r
95 #endif\r

UCC git Repository :: git.ucc.asn.au