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