]> git.sur5r.net Git - cc65/blob - include/joystick.h
New joystick API
[cc65] / include / joystick.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                joystick.h                                 */
4 /*                                                                           */
5 /*               Read the joystick on systems that support it                */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2002 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _JOYSTICK_H
37 #define _JOYSTICK_H
38
39
40
41 /*****************************************************************************/
42 /*                                  Definitions                              */
43 /*****************************************************************************/
44
45
46
47 /* Error codes */
48 #define JOY_ERR_OK              0       /* No error */
49 #define JOY_ERR_NO_DRIVER       1       /* No driver available */
50 #define JOY_ERR_CANNOT_LOAD     2       /* Error loading driver */
51 #define JOY_ERR_INV_DRIVER      3       /* Invalid driver */
52 #define JOY_ERR_NO_DEVICE       4       /* Device (hardware) not found */
53
54 /* Argument for the joy_read function */
55 #define JOY_1           0
56 #define JOY_2           1
57
58 /* The following codes are *indices* into the joy_masks array */
59 #define JOY_UP          0
60 #define JOY_DOWN        1
61 #define JOY_LEFT        2
62 #define JOY_RIGHT       3
63 #define JOY_FIRE        4
64
65 /* Array of masks used to check the return value of joy_read for a state */
66 extern const unsigned char joy_masks[8];
67
68
69
70 /* Result codes of the function. The actual code is a bitwise or
71  * of one or more of the following values.
72  */
73 #if 0
74 #if defined(__VIC20__)
75 #  define JOY_UP        0x02
76 #  define JOY_DOWN      0x04
77 #  define JOY_LEFT      0x08
78 #  define JOY_RIGHT     0x80
79 #  define JOY_FIRE      0x10
80 #else
81 #  define JOY_UP        0x01
82 #  define JOY_DOWN      0x02
83 #  define JOY_LEFT      0x04
84 #  define JOY_RIGHT     0x08
85 #  define JOY_FIRE      0x10
86 #endif
87 #endif
88
89
90
91 /*****************************************************************************/
92 /*                                 Functions                                 */
93 /*****************************************************************************/
94
95
96
97 unsigned char __fastcall__ joy_load_driver (const char* driver);
98 /* Load a joystick driver and return an error code */
99
100 unsigned char __fastcall__ joy_unload (void);
101 /* Unload the currently loaded driver. */
102
103 unsigned char __fastcall__ joy_count (void);
104 /* Return the number of joysticks supported by the driver */
105
106 unsigned char __fastcall__ joy_read (unsigned char joystick);
107 /* Read a particular joystick */
108
109
110
111 /* End of joystick.h */
112 #endif
113
114
115