Subversion Repositories group.electronics

Rev

Rev 178 | Rev 187 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 178 Rev 180
Line 97... Line 97...
97
            this.addControl(new Switch2Pos(new CommandDCS("NMSP_STEERPT_BTN"), 21));
97
            this.addControl(new Switch2Pos(new CommandDCS("NMSP_STEERPT_BTN"), 21));
98
            this.addControl(new Switch2Pos(new CommandDCS("NMSP_ABLE_STOW"), 22, true));
98
            this.addControl(new Switch2Pos(new CommandDCS("NMSP_ABLE_STOW"), 22, true));
99
 
99
 
100
 
100
 
101
            // Joystick 
101
            // Joystick 
-
 
102
            Switch3Pos joySwitch = new Switch3Pos(null, 0, 1);
-
 
103
 
-
 
104
            Dictionary<uint, Command> joyx = new Dictionary<uint, Command>();
-
 
105
            joyx.Add(0, new CommandVJSAxis(1, HID_USAGES.HID_USAGE_X));
-
 
106
            this.addControl(new Potentiometer(new CommandIf(joySwitch, joyx), 1));
-
 
107
 
-
 
108
            Dictionary<uint, Command> joyy = new Dictionary<uint, Command>();
-
 
109
            joyy.Add(0, new CommandVJSAxis(1, HID_USAGES.HID_USAGE_Y));
-
 
110
            this.addControl(new Potentiometer(new CommandIf(joySwitch, joyy), 0));
-
 
111
 
102
            this.addControl(new Potentiometer(new CommandVJSAxis(0, HID_USAGES.HID_USAGE_X), 0));     // X 0x00 - 0x8000
112
            //this.addControl(new Potentiometer(new CommandVJSAxis(1, HID_USAGES.HID_USAGE_Y), 0));     // X 0x00 - 0x8000
103
            this.addControl(new Potentiometer(new CommandVJSAxis(0, HID_USAGES.HID_USAGE_Y), 0));     // Y 0x00 - 0x8000
113
            //this.addControl(new Potentiometer(new CommandVJSAxis(1, HID_USAGES.HID_USAGE_X), 1));     // Y 0x00 - 0x8000
104
            this.addControl(new Switch2Pos(new CommandMouseButton(CommandMouseButton.MB_LEFT), 32));
114
            this.addControl(new Switch2Pos(new CommandMouseButton(CommandMouseButton.MB_LEFT), 32));
105
 
115
 
106
            // Enable the mcp23017
116
            // Enable the mcp23017
107
            mcp.WriteGpio(3, 0);
117
            mcp.WriteGpio(3, 0);
108
            Utils.delayms(50);
118
            Utils.delayms(50);
Line 125... Line 135...
125
            this.addLed(new Led(0, 0, 0x1110, 0x8000, 15));    // NMSP_STEERPT_LED
135
            this.addLed(new Led(0, 0, 0x1110, 0x8000, 15));    // NMSP_STEERPT_LED
126
            this.addLed(new Led(0, 2, 0x1112, 0x0008, 3));     // NMSP_TCN_LED
136
            this.addLed(new Led(0, 2, 0x1112, 0x0008, 3));     // NMSP_TCN_LED
127
            this.addLed(new Led(0, 7, 0x11bc, 0x0002, 1));     // NMSP_UHF_LED
137
            this.addLed(new Led(0, 7, 0x11bc, 0x0002, 1));     // NMSP_UHF_LED
128
 
138
 
129
            //this.addLed(new Led(0, 6, 0x1012, 0x0800, 11));     // MASTER_CAUTION
139
            //this.addLed(new Led(0, 6, 0x1012, 0x0800, 11));     // MASTER_CAUTION
-
 
140
            // Center the vjoy axis
-
 
141
            Globals.vjoy.SetAxis(0x4000, 1, HID_USAGES.HID_USAGE_X);
-
 
142
            Globals.vjoy.SetAxis(0x4000, 1, HID_USAGES.HID_USAGE_Y);
-
 
143
 
130
            data.axis[0].mapsize = 0x8000;
144
            data.axis[0].mapsize = 0x8000;
131
            data.axis[1].mapsize = 0x8000;
145
            data.axis[1].mapsize = 0x8000;
-
 
146
            data.axis[0].thres = 4;
-
 
147
            data.axis[1].thres = 4;
-
 
148
 
132
            this.Refresh();
149
            this.Refresh();
133
            data.prev = data.buttons;
150
            data.prev = data.buttons;
134
            data.axis[0].prev = data.axis[0].value;
151
            data.axis[0].prev = data.axis[0].value;
135
            data.axis[1].prev = data.axis[1].value;
152
            data.axis[1].prev = data.axis[1].value;
136
            data.changed = false;
153
            data.changed = false;
Line 151... Line 168...
151
 
168
 
152
            rslt = chips[0].GetIO(out bytes);
169
            rslt = chips[0].GetIO(out bytes);
153
            data.buttons |= (UInt64)bytes[0] << 8;
170
            data.buttons |= (UInt64)bytes[0] << 8;
154
            data.buttons |= (UInt64)bytes[1];
171
            data.buttons |= (UInt64)bytes[1];
155
 
172
 
156
            data.axis[0].value = mcp.ReadADC(0);
173
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
157
            data.axis[1].value = mcp.ReadADC(1);
174
            data.axis[1].value = mcp.ReadADC(1); // X Axis
158
 
175
 
159
 
176
 
160
            if (data.buttons != data.prev)
177
            if (data.buttons != data.prev
-
 
178
                || (data.axis[0].prev != data.axis[0].value)
-
 
179
                || (data.axis[1].prev != data.axis[1].value))
161
                data.changed = true;
180
                data.changed = true;
162
            else
181
            else
163
                data.changed = false;
182
                data.changed = false;
164
 
183
 
165
            byte tmpShadow = this.ledShadow;
184
            byte tmpShadow = this.ledShadow;
Line 174... Line 193...
174
 
193
 
175
            return rslt;
194
            return rslt;
176
        }
195
        }
177
 
196
 
178
        public override int Input() {
197
        public override int Input() {
179
            //Console.WriteLine(input.curr.ToString("X"));
198
            //Console.WriteLine(data.buttons.ToString("X"));
180
            foreach (Control control in this.controls) {
199
            foreach (Control control in this.controls) {
181
                control.data = this.data;
200
                control.data = this.data;
182
                control.Tick();
201
                control.Tick();
183
            }
202
            }
-
 
203
            
184
            data.changed = false;
204
            data.axis[0].prev = data.axis[0].value;
185
 
-
 
-
 
205
            data.axis[1].prev = data.axis[1].value;
186
            data.prev = data.buttons;
206
            data.prev = data.buttons;
-
 
207
            data.changed = false;
187
            return 1;
208
            return 1;
188
        }
209
        }
189
    }
210
    }
190
}
211
}