]> icculus.org git repositories - btb/d2x.git/blob - unused/win95/iforce.c
This commit was generated by cvs2svn to compensate for changes in r5,
[btb/d2x.git] / unused / win95 / iforce.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: iforce.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
17 #pragma on (unreferenced)
18
19
20 #define _WIN32
21 #define WIN95
22 #define WIN32_LEAN_AND_MEAN
23
24 #include <windows.h>
25 #include <mmsystem.h>
26
27 #include "joy.h"
28 #include "tactile.h"
29 #include "mono.h"
30 #include "winapp.h"
31 #include "iforce.h"
32
33 static JoystickRecord   iForceCaps;
34 static int                                      iForceInit=FALSE;
35
36
37 #define WIN_TACTILE_ON
38
39 //      ----------------------------------------------------------------------------
40
41 #ifdef WIN_TACTILE_ON
42
43 extern Bool _cdecl InitStick(JoystickRecord*);
44
45 int IForce_Init(int port)
46 {
47         Bool result;
48
49         if (iForceInit) return 1;
50
51         if (port < 1 || port > 4) return 0;
52
53         SetJoystickPort(port);  
54         result = InitStick(&iForceCaps);
55         if (!result) {
56                 logentry( "IFORCE: Initialization failed!.\n");
57                 return 0;
58         }
59         
60         if (!EnableForces()) {
61                 logentry("IFORCE: Unable to enable forces.\n");
62                 return 0;
63         }
64
65         ClearForces();
66
67         iForceInit = TRUE;
68
69         logentry("IFORCE: Initialization complete.\n");
70
71         return 1;
72 }
73
74
75 int IForce_Close()
76 {
77         int i = 0;
78
79         if (!iForceInit) return 1;
80
81         while (i < 5) {
82                 CloseStick();
83                 i++;
84         }
85         return 1;
86 }       
87
88
89 int IForce_GetCaps(IForce_Caps *caps)
90 {
91         if (!iForceInit) return 0;
92
93         if (iForceCaps.PositionAxes >= 2) {
94                 caps->axes_mask = JOY_1_X_AXIS;
95                 caps->axes_mask &= JOY_1_Y_AXIS;
96         }
97         if (iForceCaps.PositionAxes == 4) {
98                 caps->axes_mask &= JOY_1_POV;
99                 caps->has_pov = 1;
100         }
101         return 1;
102 }               
103
104
105 void IForce_ReadRawValues(int *axis)
106 {
107         JOYINFOEX       joy;
108
109         if (!iForceInit) return;
110         
111         memset(&joy, 0, sizeof(joy));
112         joy.dwSize = sizeof(joy);
113         joy.dwFlags = JOY_RETURNALL | JOY_USEDEADZONE;
114         joyGetPosEx(JOYSTICKID1, &joy);
115
116         axis[0] = joy.dwXpos;
117         axis[1] = joy.dwYpos;
118         axis[2] = joy.dwZpos;
119         axis[4] = joy.dwRpos;
120         axis[5] = joy.dwUpos;
121         axis[6] = joy.dwVpos;
122         axis[3] = joy.dwPOV;
123 }
124
125 #endif