]> icculus.org git repositories - btb/d2x.git/blob - unused/win95/iforce.c
use the orientation parameter of g3_draw_bitmap
[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
16 #define _WIN32
17 #define WIN95
18 #define WIN32_LEAN_AND_MEAN
19
20 #include <windows.h>
21 #include <mmsystem.h>
22
23 #include "joy.h"
24 #include "tactile.h"
25 #include "mono.h"
26 #include "winapp.h"
27 #include "iforce.h"
28
29 static JoystickRecord   iForceCaps;
30 static int                                      iForceInit=FALSE;
31
32
33 #define WIN_TACTILE_ON
34
35 //      ----------------------------------------------------------------------------
36
37 #ifdef WIN_TACTILE_ON
38
39 extern Bool _cdecl InitStick(JoystickRecord*);
40
41 int IForce_Init(int port)
42 {
43         Bool result;
44
45         if (iForceInit) return 1;
46
47         if (port < 1 || port > 4) return 0;
48
49         SetJoystickPort(port);  
50         result = InitStick(&iForceCaps);
51         if (!result) {
52                 logentry( "IFORCE: Initialization failed!.\n");
53                 return 0;
54         }
55         
56         if (!EnableForces()) {
57                 logentry("IFORCE: Unable to enable forces.\n");
58                 return 0;
59         }
60
61         ClearForces();
62
63         iForceInit = TRUE;
64
65         logentry("IFORCE: Initialization complete.\n");
66
67         return 1;
68 }
69
70
71 int IForce_Close()
72 {
73         int i = 0;
74
75         if (!iForceInit) return 1;
76
77         while (i < 5) {
78                 CloseStick();
79                 i++;
80         }
81         return 1;
82 }       
83
84
85 int IForce_GetCaps(IForce_Caps *caps)
86 {
87         if (!iForceInit) return 0;
88
89         if (iForceCaps.PositionAxes >= 2) {
90                 caps->axes_mask = JOY_1_X_AXIS;
91                 caps->axes_mask &= JOY_1_Y_AXIS;
92         }
93         if (iForceCaps.PositionAxes == 4) {
94                 caps->axes_mask &= JOY_1_POV;
95                 caps->has_pov = 1;
96         }
97         return 1;
98 }               
99
100
101 void IForce_ReadRawValues(int *axis)
102 {
103         JOYINFOEX       joy;
104
105         if (!iForceInit) return;
106         
107         memset(&joy, 0, sizeof(joy));
108         joy.dwSize = sizeof(joy);
109         joy.dwFlags = JOY_RETURNALL | JOY_USEDEADZONE;
110         joyGetPosEx(JOYSTICKID1, &joy);
111
112         axis[0] = joy.dwXpos;
113         axis[1] = joy.dwYpos;
114         axis[2] = joy.dwZpos;
115         axis[4] = joy.dwRpos;
116         axis[5] = joy.dwUpos;
117         axis[6] = joy.dwVpos;
118         axis[3] = joy.dwPOV;
119 }
120
121 #endif