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