]> git.mxchange.org Git - flightgear.git/blob - src/Input/input.cxx
Added write-all parameter to save command. If set to true, the
[flightgear.git] / src / Input / input.cxx
1 // input.cxx -- handle user input from various sources.
2 //
3 // Written by David Megginson, started May 2001.
4 //
5 // Copyright (C) 2001 David Megginson, david@megginson.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26
27 #ifdef HAVE_WINDOWS_H
28 #  include <windows.h>                     
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #include <math.h>
34 #include <ctype.h>
35
36 #include STL_FSTREAM
37 #include STL_STRING
38 #include <vector>
39
40 #include <GL/glut.h>
41
42 #include <plib/pu.h>
43
44 #include <simgear/compiler.h>
45
46 #include <simgear/constants.h>
47 #include <simgear/debug/logstream.hxx>
48 #include <simgear/misc/props.hxx>
49
50 #include <Aircraft/aircraft.hxx>
51 #include <Autopilot/auto_gui.hxx>
52 #include <Autopilot/newauto.hxx>
53 #include <Cockpit/hud.hxx>
54 #include <Cockpit/panel.hxx>
55 #include <Cockpit/panel_io.hxx>
56 #include <GUI/gui.h>
57
58 #include <Main/globals.hxx>
59 #include <Main/fg_props.hxx>
60
61 #include "input.hxx"
62
63 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
64 SG_USING_STD(ifstream);
65 #endif
66 SG_USING_STD(string);
67 SG_USING_STD(vector);
68
69
70 \f
71 ////////////////////////////////////////////////////////////////////////
72 // Local data structures.
73 ////////////////////////////////////////////////////////////////////////
74
75 \f
76 ////////////////////////////////////////////////////////////////////////
77 // Implementation of FGBinding.
78 ////////////////////////////////////////////////////////////////////////
79
80 FGBinding::FGBinding ()
81   : _command(0),
82     _arg(new SGPropertyNode),
83     _setting(0),
84     _command_state(0)
85 {
86 }
87
88 FGBinding::FGBinding (const SGPropertyNode * node)
89   : _command(0),
90     _arg(new SGPropertyNode),
91     _setting(0),
92     _command_state(0)
93 {
94   read(node);
95 }
96
97 FGBinding::~FGBinding ()
98 {
99 //   delete _arg;                       // Delete the saved arguments
100 //   delete _command_state;     // Delete the saved command state
101 }
102
103 void
104 FGBinding::read (const SGPropertyNode * node)
105 {
106   const SGPropertyNode * conditionNode = node->getChild("condition");
107   if (conditionNode != 0) {
108     cerr << "Adding condition to binding" << endl;
109     setCondition(fgReadCondition(conditionNode));
110   }
111
112   _command_name = node->getStringValue("command", "");
113   if (_command_name == "") {
114     SG_LOG(SG_INPUT, SG_ALERT, "No command supplied for binding.");
115     _command = 0;
116     return;
117   }
118
119   _command = globals->get_commands()->getCommand(_command_name);
120   if (_command == 0) {
121     SG_LOG(SG_INPUT, SG_ALERT, "Command " << _command_name << " is undefined");
122     _arg = 0;
123     return;
124   }
125
126   delete _arg;
127   _arg = new SGPropertyNode;
128   _setting = 0;
129   copyProperties(node, _arg);  // FIXME: don't use whole node!!!
130 }
131
132 void
133 FGBinding::fire () const
134 {
135   if (test()) {
136     if (_command == 0) {
137       SG_LOG(SG_INPUT, SG_ALERT, "No command attached to binding");
138     } else if (!(*_command)(_arg, &_command_state)) {
139       SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
140              << _command_name);
141     }
142   }
143 }
144
145 void
146 FGBinding::fire (double setting) const
147 {
148   if (test()) {
149                                 // A value is automatically added to
150                                 // the args
151     if (_setting == 0)          // save the setting node for efficiency
152       _setting = _arg->getChild("setting", 0, true);
153     _setting->setDoubleValue(setting);
154     fire();
155   }
156 }
157
158
159 \f
160 ////////////////////////////////////////////////////////////////////////
161 // Implementation of FGInput.
162 ////////////////////////////////////////////////////////////////////////
163
164                                 // From main.cxx
165 extern void fgReshape( int width, int height );
166
167 FGInput current_input;
168
169
170 FGInput::FGInput ()
171 {
172   // no op
173 }
174
175 FGInput::~FGInput ()
176 {
177   // no op
178 }
179
180 void
181 FGInput::init ()
182 {
183   _init_keyboard();
184   _init_joystick();
185 }
186
187 void
188 FGInput::bind ()
189 {
190   // no op
191 }
192
193 void
194 FGInput::unbind ()
195 {
196   // no op
197 }
198
199 void 
200 FGInput::update (int dt)
201 {
202   _update_keyboard();
203   _update_joystick();
204 }
205
206 void
207 FGInput::doKey (int k, int modifiers, int x, int y)
208 {
209     // SG_LOG( SG_INPUT, SG_INFO, "User pressed key " << k
210     //         << " with modifiers " << modifiers );
211
212                                 // Sanity check.
213   if (k < 0 || k >= MAX_KEYS) {
214     SG_LOG(SG_INPUT, SG_ALERT, "Key value " << k << " out of range");
215     return;
216   }
217
218   button &b = _key_bindings[k];
219
220                                 // Key pressed.
221   if (modifiers&FG_MOD_UP == 0) {
222     // SG_LOG( SG_INPUT, SG_INFO, "User pressed key " << k
223     //         << " with modifiers " << modifiers );
224     if (!b.last_state || b.is_repeatable) {
225       const binding_list_t &bindings =
226         _find_key_bindings(k, modifiers);
227       int max = bindings.size();
228       if (max > 0) {
229         for (int i = 0; i < max; i++)
230           bindings[i]->fire();
231         return;
232       }
233     }
234   }
235
236                                 // Key released.
237   else {
238     // SG_LOG(SG_INPUT, SG_INFO, "User released key " << k
239     //        << " with modifiers " << modifiers);
240     if (b.last_state) {
241       const binding_list_t &bindings =
242         _find_key_bindings(k, modifiers);
243       int max = bindings.size();
244       if (max > 0) {
245         for (int i = 0; i < max; i++)
246           bindings[i]->fire();
247         return;
248       }
249     }
250   }
251
252
253                                 // Use the old, default actions.
254   // SG_LOG( SG_INPUT, SG_INFO, "(No user binding.)" );
255   if (modifiers&FG_MOD_UP)
256     return;
257
258   // everything after here will be removed sooner or later...
259
260   if (modifiers & FG_MOD_SHIFT) {
261
262         switch (k) {
263         case 72: // H key
264             HUD_brightkey( true );
265             return;
266         case 73: // I key
267             // Minimal Hud
268             fgHUDInit2(&current_aircraft);
269             return;
270         }
271
272
273     } else {
274         SG_LOG( SG_INPUT, SG_DEBUG, "" );
275         switch (k) {
276         case 104: // h key
277             HUD_masterswitch( true );
278             return;
279         case 105: // i key
280             fgHUDInit(&current_aircraft);  // normal HUD
281             return;
282
283 // START SPECIALS
284
285         case 256+GLUT_KEY_F6: // F6 toggles Autopilot target location
286             if ( current_autopilot->get_HeadingMode() !=
287                  FGAutopilot::FG_HEADING_WAYPOINT ) {
288                 current_autopilot->set_HeadingMode(
289                     FGAutopilot::FG_HEADING_WAYPOINT );
290                 current_autopilot->set_HeadingEnabled( true );
291             } else {
292                 current_autopilot->set_HeadingMode(
293                     FGAutopilot::FG_TC_HEADING_LOCK );
294             }
295             return;
296         case 256+GLUT_KEY_F8: {// F8 toggles fog ... off fastest nicest...
297             const string &fog = fgGetString("/sim/rendering/fog");
298             if (fog == "disabled") {
299               fgSetString("/sim/rendering/fog", "fastest");
300               SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=fastest");
301             } else if (fog == "fastest") {
302               fgSetString("/sim/rendering/fog", "nicest");
303               SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=nicest");
304             } else if (fog == "nicest") {
305               fgSetString("/sim/rendering/fog", "disabled");
306               SG_LOG(SG_INPUT, SG_INFO, "Fog disabled");
307             } else {
308               fgSetString("/sim/rendering/fog", "disabled");
309               SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized fog type "
310                      << fog << ", changed to 'disabled'");
311             }
312             return;
313         }
314         case 256+GLUT_KEY_F10: // F10 toggles menu on and off...
315             SG_LOG(SG_INPUT, SG_INFO, "Invoking call back function");
316             guiToggleMenu();
317             return;
318         case 256+GLUT_KEY_F11: // F11 Altitude Dialog.
319             SG_LOG(SG_INPUT, SG_INFO, "Invoking Altitude call back function");
320             NewAltitude( NULL );
321             return;
322         case 256+GLUT_KEY_F12: // F12 Heading Dialog...
323             SG_LOG(SG_INPUT, SG_INFO, "Invoking Heading call back function");
324             NewHeading( NULL );
325             return;
326         }
327
328 // END SPECIALS
329
330     }
331 }
332
333
334 void
335 FGInput::_init_keyboard ()
336 {
337                                 // TODO: zero the old bindings first.
338   SG_LOG(SG_INPUT, SG_INFO, "Initializing key bindings");
339   SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
340   if (key_nodes == 0) {
341     SG_LOG(SG_INPUT, SG_ALERT, "No key bindings (/input/keyboard)!!");
342     return;
343   }
344   
345   vector<SGPropertyNode *> keys = key_nodes->getChildren("key");
346   for (unsigned int i = 0; i < keys.size(); i++) {
347     int index = keys[i]->getIndex();
348     SG_LOG(SG_INPUT, SG_INFO, "Binding key " << index);
349     _key_bindings[index].is_repeatable = keys[i]->getBoolValue("repeatable");
350     _read_bindings(keys[i], _key_bindings[index].bindings, FG_MOD_NONE);
351   }
352 }
353
354
355 void
356 FGInput::_init_joystick ()
357 {
358                                 // TODO: zero the old bindings first.
359   SG_LOG(SG_INPUT, SG_INFO, "Initializing joystick bindings");
360   SGPropertyNode * js_nodes = fgGetNode("/input/joysticks");
361   if (js_nodes == 0) {
362     SG_LOG(SG_INPUT, SG_ALERT, "No joystick bindings (/input/joysticks)!!");
363     return;
364   }
365
366   for (int i = 0; i < MAX_JOYSTICKS; i++) {
367     const SGPropertyNode * js_node = js_nodes->getChild("js", i);
368     if (js_node == 0) {
369       SG_LOG(SG_INPUT, SG_ALERT, "No bindings for joystick " << i);
370       continue;
371     }
372     jsJoystick * js = new jsJoystick(i);
373     _joystick_bindings[i].js = js;
374     if (js->notWorking()) {
375       SG_LOG(SG_INPUT, SG_INFO, "Joystick " << i << " not found");
376       continue;
377     }
378 #ifdef WIN32
379     JOYCAPS jsCaps ;
380     joyGetDevCaps( i, &jsCaps, sizeof(jsCaps) );
381     int nbuttons = jsCaps.wNumButtons;
382     if (nbuttons > MAX_BUTTONS) nbuttons = MAX_BUTTONS;
383 #else
384     int nbuttons = MAX_BUTTONS;
385 #endif
386         
387     int naxes = js->getNumAxes();
388     if (naxes > MAX_AXES) naxes = MAX_AXES;
389     _joystick_bindings[i].naxes = naxes;
390     _joystick_bindings[i].nbuttons = nbuttons;
391
392     SG_LOG(SG_INPUT, SG_INFO, "Initializing joystick " << i);
393
394                                 // Set up range arrays
395     float minRange[MAX_AXES];
396     float maxRange[MAX_AXES];
397     float center[MAX_AXES];
398
399                                 // Initialize with default values
400     js->getMinRange(minRange);
401     js->getMaxRange(maxRange);
402     js->getCenter(center);
403
404                                 // Allocate axes and buttons
405     _joystick_bindings[i].axes = new axis[naxes];
406     _joystick_bindings[i].buttons = new button[nbuttons];
407
408
409     //
410     // Initialize the axes.
411     //
412     int j;
413     for (j = 0; j < naxes; j++) {
414       const SGPropertyNode * axis_node = js_node->getChild("axis", j);
415       if (axis_node == 0) {
416         SG_LOG(SG_INPUT, SG_INFO, "No bindings for axis " << j);
417         continue;
418       }
419       
420       axis &a = _joystick_bindings[i].axes[j];
421
422       js->setDeadBand(j, axis_node->getDoubleValue("dead-band", 0.0));
423
424       a.tolerance = axis_node->getDoubleValue("tolerance", 0.002);
425       minRange[j] = axis_node->getDoubleValue("min-range", minRange[j]);
426       maxRange[j] = axis_node->getDoubleValue("max-range", maxRange[j]);
427       center[j] = axis_node->getDoubleValue("center", center[j]);
428
429       _read_bindings(axis_node, a.bindings, FG_MOD_NONE);
430
431       // Initialize the virtual axis buttons.
432       _init_button(axis_node->getChild("low"), a.low, "low");
433       a.low_threshold = axis_node->getDoubleValue("low-threshold", -0.9);
434       
435       _init_button(axis_node->getChild("high"), a.high, "high");
436       a.high_threshold = axis_node->getDoubleValue("high-threshold", 0.9);
437     }
438
439     //
440     // Initialize the buttons.
441     //
442     char buf[8];
443     for (j = 0; j < nbuttons; j++) {
444       sprintf(buf, "%d", j);
445       SG_LOG(SG_INPUT, SG_INFO, "Initializing button " << j);
446       _init_button(js_node->getChild("button", j),
447                    _joystick_bindings[i].buttons[j],
448                    buf);
449                    
450     }
451
452     js->setMinRange(minRange);
453     js->setMaxRange(maxRange);
454     js->setCenter(center);
455   }
456 }
457
458
459 inline void
460 FGInput::_init_button (const SGPropertyNode * node,
461                        button &b,
462                        const string name)
463 {       
464   if (node == 0)
465     SG_LOG(SG_INPUT, SG_INFO, "No bindings for button " << name);
466   else {
467     b.is_repeatable = node->getBoolValue("repeatable", b.is_repeatable);
468     
469                 // Get the bindings for the button
470     _read_bindings(node, b.bindings, FG_MOD_NONE);
471   }
472 }
473
474
475 void
476 FGInput::_update_keyboard ()
477 {
478   // no-op
479 }
480
481
482 void
483 FGInput::_update_joystick ()
484 {
485   int modifiers = FG_MOD_NONE;  // FIXME: any way to get the real ones?
486   int buttons;
487   // float js_val, diff;
488   float axis_values[MAX_AXES];
489
490   int i;
491   int j;
492
493   for ( i = 0; i < MAX_JOYSTICKS; i++) {
494
495     jsJoystick * js = _joystick_bindings[i].js;
496     if (js == 0 || js->notWorking())
497       continue;
498
499     js->read(&buttons, axis_values);
500
501
502                                 // Fire bindings for the axes.
503     for ( j = 0; j < _joystick_bindings[i].naxes; j++) {
504       axis &a = _joystick_bindings[i].axes[j];
505       
506                                 // Do nothing if the axis position
507                                 // is unchanged; only a change in
508                                 // position fires the bindings.
509       if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
510 //      SG_LOG(SG_INPUT, SG_INFO, "Axis " << j << " has moved");
511         SGPropertyNode node;
512         a.last_value = axis_values[j];
513 //      SG_LOG(SG_INPUT, SG_INFO, "There are "
514 //             << a.bindings[modifiers].size() << " bindings");
515         for (unsigned int k = 0; k < a.bindings[modifiers].size(); k++)
516           a.bindings[modifiers][k]->fire(axis_values[j]);
517       }
518      
519                                 // do we have to emulate axis buttons?
520       if (a.low.bindings[modifiers].size())
521         _update_button(_joystick_bindings[i].axes[j].low,
522                        modifiers,
523                        axis_values[j] < a.low_threshold);
524       
525       if (a.high.bindings[modifiers].size())
526         _update_button(_joystick_bindings[i].axes[j].high,
527                        modifiers,
528                        axis_values[j] > a.high_threshold);
529     }
530
531                                 // Fire bindings for the buttons.
532     for (j = 0; j < _joystick_bindings[i].nbuttons; j++) {
533       _update_button(_joystick_bindings[i].buttons[j],
534                      modifiers,
535                      (buttons & (1 << j)) > 0);
536     }
537   }
538 }
539
540
541 void
542 FGInput::_update_button (button &b, int modifiers, bool pressed)
543 {
544   if (pressed) {
545                                 // The press event may be repeated.
546     if (!b.last_state || b.is_repeatable) {
547       // SG_LOG( SG_INPUT, SG_INFO, "Button has been pressed" );
548       for (unsigned int k = 0; k < b.bindings[modifiers].size(); k++)
549         b.bindings[modifiers][k]->fire();
550     }
551   } else {
552                                 // The release event is never repeated.
553     if (b.last_state) {
554       // SG_LOG( SG_INPUT, SG_INFO, "Button has been released" );
555       for (unsigned int k = 0; k < b.bindings[modifiers|FG_MOD_UP].size(); k++)
556         b.bindings[modifiers|FG_MOD_UP][k]->fire();
557     }
558   }
559           
560   b.last_state = pressed;
561 }  
562
563
564 void
565 FGInput::_read_bindings (const SGPropertyNode * node, 
566                          binding_list_t * binding_list,
567                          int modifiers)
568 {
569   SG_LOG(SG_INPUT, SG_INFO, "Reading all bindings");
570   vector<const SGPropertyNode *> bindings = node->getChildren("binding");
571   for (unsigned int i = 0; i < bindings.size(); i++) {
572     SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
573            << bindings[i]->getStringValue("command"));
574     binding_list[modifiers].push_back(new FGBinding(bindings[i]));
575   }
576
577                                 // Read nested bindings for modifiers
578   if (node->getChild("mod-up") != 0)
579     _read_bindings(node->getChild("mod-up"), binding_list,
580                    modifiers|FG_MOD_UP);
581
582   if (node->getChild("mod-shift") != 0)
583     _read_bindings(node->getChild("mod-shift"), binding_list,
584                    modifiers|FG_MOD_SHIFT);
585
586   if (node->getChild("mod-ctrl") != 0)
587     _read_bindings(node->getChild("mod-ctrl"), binding_list,
588                    modifiers|FG_MOD_CTRL);
589
590   if (node->getChild("mod-alt") != 0)
591     _read_bindings(node->getChild("mod-alt"), binding_list,
592                    modifiers|FG_MOD_ALT);
593 }
594
595
596 const vector<FGBinding *> &
597 FGInput::_find_key_bindings (unsigned int k, int modifiers)
598 {
599   button &b = _key_bindings[k];
600
601                                 // Try it straight, first.
602   if (b.bindings[modifiers].size() > 0)
603     return b.bindings[modifiers];
604
605                                 // Try removing the control modifier
606                                 // for control keys.
607   else if ((modifiers&FG_MOD_CTRL) && iscntrl(k))
608     return _find_key_bindings(k, modifiers&~FG_MOD_CTRL);
609
610                                 // Try removing shift modifier 
611                                 // for upper case or any punctuation
612                                 // (since different keyboards will
613                                 // shift different punctuation types)
614   else if ((modifiers&FG_MOD_SHIFT) && (isupper(k) || ispunct(k)))
615     return _find_key_bindings(k, modifiers&~FG_MOD_SHIFT);
616
617                                 // Try removing alt modifier for
618                                 // high-bit characters.
619   else if ((modifiers&FG_MOD_ALT) && k >= 128 && k < 256)
620     return _find_key_bindings(k, modifiers&~FG_MOD_ALT);
621
622                                 // Give up and return the empty vector.
623   else
624     return b.bindings[modifiers];
625 }
626
627
628 \f
629 ////////////////////////////////////////////////////////////////////////
630 // Implementation of FGInput::button.
631 ////////////////////////////////////////////////////////////////////////
632
633 FGInput::button::button ()
634   : is_repeatable(false),
635     last_state(-1)
636 {
637 }
638
639 FGInput::button::~button ()
640 {
641                                 // FIXME: memory leak
642 //   for (int i = 0; i < FG_MOD_MAX; i++)
643 //     for (int j = 0; i < bindings[i].size(); j++)
644 //       delete bindings[i][j];
645 }
646
647
648 \f
649 ////////////////////////////////////////////////////////////////////////
650 // Implementation of FGInput::axis.
651 ////////////////////////////////////////////////////////////////////////
652
653 FGInput::axis::axis ()
654   : last_value(9999999),
655     tolerance(0.002),
656     low_threshold(-0.9),
657     high_threshold(0.9)
658 {
659 }
660
661 FGInput::axis::~axis ()
662 {
663 //   for (int i = 0; i < FG_MOD_MAX; i++)
664 //     for (int j = 0; i < bindings[i].size(); j++)
665 //       delete bindings[i][j];
666 }
667
668
669 \f
670 ////////////////////////////////////////////////////////////////////////
671 // Implementation of FGInput::joystick.
672 ////////////////////////////////////////////////////////////////////////
673
674 FGInput::joystick::joystick ()
675 {
676 }
677
678 FGInput::joystick::~joystick ()
679 {
680 //   delete js;
681 //   delete[] axes;
682 //   delete[] buttons;
683 }
684
685
686 \f
687 ////////////////////////////////////////////////////////////////////////
688 // Implementation of GLUT callbacks.
689 ////////////////////////////////////////////////////////////////////////
690
691
692 /**
693  * Construct the modifiers.
694  */
695 static inline int get_mods ()
696 {
697   int glut_modifiers = glutGetModifiers();
698   int modifiers = 0;
699
700   if (glut_modifiers & GLUT_ACTIVE_SHIFT)
701     modifiers |= FGInput::FG_MOD_SHIFT;
702   if (glut_modifiers & GLUT_ACTIVE_CTRL)
703     modifiers |= FGInput::FG_MOD_CTRL;
704   if (glut_modifiers & GLUT_ACTIVE_ALT)
705     modifiers |= FGInput::FG_MOD_ALT;
706
707   return modifiers;
708 }
709
710
711 /**
712  * Key-down event handler for Glut.
713  *
714  * <p>Pass the value on to the FGInput module unless PUI wants it.</p>
715  *
716  * @param k The integer value for the key pressed.
717  * @param x (unused)
718  * @param y (unused)
719  */
720 void GLUTkey(unsigned char k, int x, int y)
721 {
722                                 // Give PUI a chance to grab it first.
723   if (!puKeyboard(k, PU_DOWN))
724     current_input.doKey(k, get_mods(), x, y);
725 }
726
727
728 /**
729  * Key-up event handler for GLUT.
730  *
731  * <p>PUI doesn't use this, so always pass it to the input manager.</p>
732  *
733  * @param k The integer value for the key pressed.
734  * @param x (unused)
735  * @param y (unused)
736  */
737 void GLUTkeyup(unsigned char k, int x, int y)
738 {
739   current_input.doKey(k, get_mods()|FGInput::FG_MOD_UP, x, y);
740 }
741
742
743 /**
744  * Special key-down handler for Glut.
745  *
746  * <p>Pass the value on to the FGInput module unless PUI wants it.
747  * The key value will have 256 added to it.</p>
748  *
749  * @param k The integer value for the key pressed (will have 256 added
750  * to it).
751  * @param x (unused)
752  * @param y (unused)
753  */
754 void GLUTspecialkey(int k, int x, int y)
755 {
756                                 // Give PUI a chance to grab it first.
757   if (!puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN))
758     current_input.doKey(k + 256, get_mods(), x, y);
759 }
760
761
762 /**
763  * Special key-up handler for Glut.
764  *
765  * @param k The integer value for the key pressed (will have 256 added
766  * to it).
767  * @param x (unused)
768  * @param y (unused)
769  */
770 void GLUTspecialkeyup(int k, int x, int y)
771 {
772   current_input.doKey(k + 256, get_mods()|FGInput::FG_MOD_UP, x, y);
773 }
774
775 // end of input.cxx