1 // input.cxx -- handle user input from various sources.
3 // Written by David Megginson, started May 2001.
5 // Copyright (C) 2001 David Megginson, david@megginson.com
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.
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.
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.
31 #include <simgear/compiler.h>
40 #include <simgear/compiler.h>
42 #include <simgear/constants.h>
43 #include <simgear/debug/logstream.hxx>
44 #include <simgear/props/props.hxx>
46 #include <Aircraft/aircraft.hxx>
47 #include <Autopilot/xmlauto.hxx>
48 #include <Cockpit/hud.hxx>
49 #include <Cockpit/panel.hxx>
50 #include <Cockpit/panel_io.hxx>
52 #include <Model/panelnode.hxx>
54 #include <Main/globals.hxx>
55 #include <Main/fg_props.hxx>
59 SG_USING_STD(ifstream);
63 void mouseClickHandler(int button, int updown, int x, int y);
64 void mouseMotionHandler(int x, int y);
65 void keyHandler(int key, int keymod, int mousex, int mousey);
68 ////////////////////////////////////////////////////////////////////////
70 ////////////////////////////////////////////////////////////////////////
72 static FGInput * default_input = 0;
76 ////////////////////////////////////////////////////////////////////////
77 // Implementation of FGBinding.
78 ////////////////////////////////////////////////////////////////////////
80 FGBinding::FGBinding ()
82 _arg(new SGPropertyNode),
87 FGBinding::FGBinding (const SGPropertyNode * node)
96 FGBinding::read (const SGPropertyNode * node)
98 const SGPropertyNode * conditionNode = node->getChild("condition");
99 if (conditionNode != 0)
100 setCondition(sgReadCondition(globals->get_props(), conditionNode));
102 _command_name = node->getStringValue("command", "");
103 if (_command_name.empty()) {
104 SG_LOG(SG_INPUT, SG_WARN, "No command supplied for binding.");
109 _arg = new SGPropertyNode;
111 copyProperties(node, _arg); // FIXME: don't use whole node!!!
115 FGBinding::fire () const
119 _command = globals->get_commands()->getCommand(_command_name);
121 SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding");
122 } else if (!(*_command)(_arg)) {
123 SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
130 FGBinding::fire (double offset, double max) const
133 _arg->setDoubleValue("offset", offset/max);
139 FGBinding::fire (double setting) const
142 // A value is automatically added to
144 if (_setting == 0) // save the setting node for efficiency
145 _setting = _arg->getChild("setting", 0, true);
146 _setting->setDoubleValue(setting);
153 ////////////////////////////////////////////////////////////////////////
154 // Implementation of FGInput.
155 ////////////////////////////////////////////////////////////////////////
160 if (default_input == 0)
161 default_input = this;
166 if (default_input == this)
177 fgRegisterKeyHandler(keyHandler);
178 fgRegisterMouseClickHandler(mouseClickHandler);
179 fgRegisterMouseMotionHandler(mouseMotionHandler);
183 FGInput::update (double dt)
186 _update_joystick(dt);
203 FGInput::is_suspended () const
209 FGInput::makeDefault (bool status)
212 default_input = this;
213 else if (default_input == this)
218 FGInput::doKey (int k, int modifiers, int x, int y)
221 if (k < 0 || k >= MAX_KEYS) {
222 SG_LOG(SG_INPUT, SG_WARN, "Key value " << k << " out of range");
226 button &b = _key_bindings[k];
229 if (modifiers&KEYMOD_RELEASED == 0) {
230 SG_LOG( SG_INPUT, SG_DEBUG, "User pressed key " << k
231 << " with modifiers " << modifiers );
232 if (!b.last_state || b.is_repeatable) {
233 const binding_list_t &bindings =
234 _find_key_bindings(k, modifiers);
235 int max = bindings.size();
237 for (int i = 0; i < max; i++)
245 SG_LOG(SG_INPUT, SG_DEBUG, "User released key " << k
246 << " with modifiers " << modifiers);
248 const binding_list_t &bindings =
249 _find_key_bindings(k, modifiers);
250 int max = bindings.size();
252 for (int i = 0; i < max; i++)
261 FGInput::doMouseClick (int b, int updown, int x, int y)
263 int modifiers = fgGetKeyModifiers();
265 mouse &m = _mouse_bindings[0];
266 mouse_mode &mode = m.modes[m.current_mode];
268 // Let the property manager know.
269 if (b >= 0 && b < MAX_MOUSE_BUTTONS)
270 m.mouse_button_nodes[b]->setBoolValue(updown == MOUSE_BUTTON_DOWN);
272 // Pass on to PUI and the panel if
273 // requested, and return if one of
274 // them consumes the event.
275 if (mode.pass_through) {
276 if (puMouse(b, updown, x, y))
278 else if ((globals->get_current_panel() != 0) &&
279 globals->get_current_panel()->getVisibility() &&
280 globals->get_current_panel()->doMouseAction(b, updown, x, y))
282 else if (fgHandle3DPanelMouseEvent(b, updown, x, y))
286 // OK, PUI and the panel didn't want the click
287 if (b >= MAX_MOUSE_BUTTONS) {
288 SG_LOG(SG_INPUT, SG_ALERT, "Mouse button " << b
289 << " where only " << MAX_MOUSE_BUTTONS << " expected");
293 _update_button(m.modes[m.current_mode].buttons[b], modifiers, 0 != updown, x, y);
297 FGInput::doMouseMotion (int x, int y)
299 // Don't call fgGetKeyModifiers() here, until we are using a
300 // toolkit that supports getting the mods from outside a key
301 // callback. Glut doesn't.
302 int modifiers = KEYMOD_NONE;
304 int xsize = fgGetInt("/sim/startup/xsize", 800);
305 int ysize = fgGetInt("/sim/startup/ysize", 600);
306 mouse &m = _mouse_bindings[0];
307 if (m.current_mode < 0 || m.current_mode >= m.nModes)
309 mouse_mode &mode = m.modes[m.current_mode];
311 // Pass on to PUI if requested, and return
312 // if PUI consumed the event.
313 if (mode.pass_through && puMouse(x, y))
316 // OK, PUI didn't want the event,
317 // so we can play with it.
320 for (unsigned int i = 0; i < mode.x_bindings[modifiers].size(); i++)
321 mode.x_bindings[modifiers][i]->fire(double(delta), double(xsize));
325 for (unsigned int i = 0; i < mode.y_bindings[modifiers].size(); i++)
326 mode.y_bindings[modifiers][i]->fire(double(delta), double(ysize));
329 // Constrain the mouse if requested
330 if (mode.constrained) {
331 bool need_warp = false;
335 } else if (x >= (xsize-1)) {
343 } else if (y >= (ysize-1)) {
356 FGInput::_init_keyboard ()
358 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing key bindings");
359 SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
360 if (key_nodes == 0) {
361 SG_LOG(SG_INPUT, SG_WARN, "No key bindings (/input/keyboard)!!");
362 key_nodes = fgGetNode("/input/keyboard", true);
365 vector<SGPropertyNode_ptr> keys = key_nodes->getChildren("key");
366 for (unsigned int i = 0; i < keys.size(); i++) {
367 int index = keys[i]->getIndex();
368 SG_LOG(SG_INPUT, SG_DEBUG, "Binding key " << index);
370 _key_bindings[index].bindings->clear();
371 _key_bindings[index].is_repeatable = keys[i]->getBoolValue("repeatable");
372 _read_bindings(keys[i], _key_bindings[index].bindings, KEYMOD_NONE);
378 FGInput::_init_joystick ()
380 // TODO: zero the old bindings first.
381 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing joystick bindings");
382 SGPropertyNode * js_nodes = fgGetNode("/input/joysticks");
384 SG_LOG(SG_INPUT, SG_WARN, "No joystick bindings (/input/joysticks)!!");
385 js_nodes = fgGetNode("/input/joysticks", true);
388 for (int i = 0; i < MAX_JOYSTICKS; i++) {
389 SGPropertyNode_ptr js_node = js_nodes->getChild("js", i);
391 SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for joystick " << i);
392 js_node = js_nodes->getChild("js", i, true);
394 jsJoystick * js = new jsJoystick(i);
395 _joystick_bindings[i].js = js;
396 if (js->notWorking()) {
397 SG_LOG(SG_INPUT, SG_DEBUG, "Joystick " << i << " not found");
400 bool found_js = false;
401 const char * name = js->getName();
402 SG_LOG(SG_INPUT, SG_INFO, "Looking for bindings for joystick \""
404 vector<SGPropertyNode_ptr> nodes = js_nodes->getChildren("js-named");
405 for (unsigned int i = 0; i < nodes.size(); i++) {
406 SGPropertyNode_ptr node = nodes[i];
407 vector<SGPropertyNode_ptr> name_nodes = node->getChildren("name");
408 for (unsigned int j = 0; j < name_nodes.size(); j++) {
409 const char * js_name = name_nodes[j]->getStringValue();
410 SG_LOG(SG_INPUT, SG_INFO, " Trying \"" << js_name << '"');
411 if (!strcmp(js_name, name)) {
412 SG_LOG(SG_INPUT, SG_INFO, " Found bindings");
424 joyGetDevCaps( i, &jsCaps, sizeof(jsCaps) );
425 int nbuttons = jsCaps.wNumButtons;
426 if (nbuttons > MAX_JOYSTICK_BUTTONS) nbuttons = MAX_JOYSTICK_BUTTONS;
428 int nbuttons = MAX_JOYSTICK_BUTTONS;
431 int naxes = js->getNumAxes();
432 if (naxes > MAX_JOYSTICK_AXES) naxes = MAX_JOYSTICK_AXES;
433 _joystick_bindings[i].naxes = naxes;
434 _joystick_bindings[i].nbuttons = nbuttons;
436 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing joystick " << i);
438 // Set up range arrays
439 float minRange[MAX_JOYSTICK_AXES];
440 float maxRange[MAX_JOYSTICK_AXES];
441 float center[MAX_JOYSTICK_AXES];
443 // Initialize with default values
444 js->getMinRange(minRange);
445 js->getMaxRange(maxRange);
446 js->getCenter(center);
448 // Allocate axes and buttons
449 _joystick_bindings[i].axes = new axis[naxes];
450 _joystick_bindings[i].buttons = new button[nbuttons];
454 // Initialize the axes.
457 for (j = 0; j < naxes; j++) {
458 const SGPropertyNode * axis_node = js_node->getChild("axis", j);
459 if (axis_node == 0) {
460 SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for axis " << j);
461 axis_node = js_node->getChild("axis", j, true);
464 axis &a = _joystick_bindings[i].axes[j];
466 js->setDeadBand(j, axis_node->getDoubleValue("dead-band", 0.0));
468 a.tolerance = axis_node->getDoubleValue("tolerance", 0.002);
469 minRange[j] = axis_node->getDoubleValue("min-range", minRange[j]);
470 maxRange[j] = axis_node->getDoubleValue("max-range", maxRange[j]);
471 center[j] = axis_node->getDoubleValue("center", center[j]);
473 _read_bindings(axis_node, a.bindings, KEYMOD_NONE);
475 // Initialize the virtual axis buttons.
476 _init_button(axis_node->getChild("low"), a.low, "low");
477 a.low_threshold = axis_node->getDoubleValue("low-threshold", -0.9);
479 _init_button(axis_node->getChild("high"), a.high, "high");
480 a.high_threshold = axis_node->getDoubleValue("high-threshold", 0.9);
481 a.interval_sec = axis_node->getDoubleValue("interval-sec",0.0);
486 // Initialize the buttons.
489 for (j = 0; j < nbuttons; j++) {
490 sprintf(buf, "%d", j);
491 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << j);
492 _init_button(js_node->getChild("button", j),
493 _joystick_bindings[i].buttons[j],
496 // get interval-sec property
497 button &b = _joystick_bindings[i].buttons[j];
498 const SGPropertyNode * button_node = js_node->getChild("button", j);
499 if (button_node != 0) {
500 b.interval_sec = button_node->getDoubleValue("interval-sec",0.0);
505 js->setMinRange(minRange);
506 js->setMaxRange(maxRange);
507 js->setCenter(center);
512 // Map of all known cursor names
513 // This used to contain all the Glut cursors, but those are
514 // not defined by other toolkits. It now supports only the cursor
515 // images we actually use, in the interest of portability. Someday,
516 // it would be cool to write an OpenGL cursor renderer, with the
517 // cursors defined as textures referenced in the property tree. This
518 // list could then be eliminated. -Andy
523 } mouse_cursor_map[] = {
524 { "none", MOUSE_CURSOR_NONE },
525 { "inherit", MOUSE_CURSOR_POINTER },
526 { "wait", MOUSE_CURSOR_WAIT },
527 { "crosshair", MOUSE_CURSOR_CROSSHAIR },
528 { "left-right", MOUSE_CURSOR_LEFTRIGHT },
533 FGInput::_init_mouse ()
535 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing mouse bindings");
537 SGPropertyNode * mouse_nodes = fgGetNode("/input/mice");
538 if (mouse_nodes == 0) {
539 SG_LOG(SG_INPUT, SG_WARN, "No mouse bindings (/input/mice)!!");
540 mouse_nodes = fgGetNode("/input/mice", true);
544 for (int i = 0; i < MAX_MICE; i++) {
545 SGPropertyNode * mouse_node = mouse_nodes->getChild("mouse", i, true);
546 mouse &m = _mouse_bindings[i];
548 // Grab node pointers
550 sprintf(buf, "/devices/status/mice/mouse[%d]/mode", i);
551 m.mode_node = fgGetNode(buf);
552 if (m.mode_node == NULL) {
553 m.mode_node = fgGetNode(buf, true);
554 m.mode_node->setIntValue(0);
556 for (j = 0; j < MAX_MOUSE_BUTTONS; j++) {
557 sprintf(buf, "/devices/status/mice/mouse[%d]/button[%d]", i, j);
558 m.mouse_button_nodes[j] = fgGetNode(buf, true);
559 m.mouse_button_nodes[j]->setBoolValue(false);
562 // Read all the modes
563 m.nModes = mouse_node->getIntValue("mode-count", 1);
564 m.modes = new mouse_mode[m.nModes];
566 for (int j = 0; j < m.nModes; j++) {
569 // Read the mouse cursor for this mode
570 SGPropertyNode * mode_node = mouse_node->getChild("mode", j, true);
571 const char * cursor_name =
572 mode_node->getStringValue("cursor", "inherit");
573 m.modes[j].cursor = MOUSE_CURSOR_POINTER;
574 for (k = 0; mouse_cursor_map[k].name != 0; k++) {
575 if (!strcmp(mouse_cursor_map[k].name, cursor_name)) {
576 m.modes[j].cursor = mouse_cursor_map[k].cursor;
581 // Read other properties for this mode
582 m.modes[j].constrained = mode_node->getBoolValue("constrained", false);
583 m.modes[j].pass_through = mode_node->getBoolValue("pass-through", false);
585 // Read the button bindings for this mode
586 m.modes[j].buttons = new button[MAX_MOUSE_BUTTONS];
588 for (k = 0; k < MAX_MOUSE_BUTTONS; k++) {
589 sprintf(buf, "mouse button %d", k);
590 SG_LOG(SG_INPUT, SG_DEBUG, "Initializing mouse button " << k);
591 _init_button(mode_node->getChild("button", k),
592 m.modes[j].buttons[k],
596 // Read the axis bindings for this mode
597 _read_bindings(mode_node->getChild("x-axis", 0, true),
598 m.modes[j].x_bindings,
600 _read_bindings(mode_node->getChild("y-axis", 0, true),
601 m.modes[j].y_bindings,
609 FGInput::_init_button (const SGPropertyNode * node,
614 SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for button " << name);
616 b.is_repeatable = node->getBoolValue("repeatable", b.is_repeatable);
618 // Get the bindings for the button
619 _read_bindings(node, b.bindings, KEYMOD_NONE);
625 FGInput::_update_keyboard ()
632 FGInput::_update_joystick (double dt)
634 int modifiers = KEYMOD_NONE; // FIXME: any way to get the real ones?
636 // float js_val, diff;
637 float axis_values[MAX_JOYSTICK_AXES];
642 for ( i = 0; i < MAX_JOYSTICKS; i++) {
644 jsJoystick * js = _joystick_bindings[i].js;
645 if (js == 0 || js->notWorking())
648 js->read(&buttons, axis_values);
651 // Fire bindings for the axes.
652 for ( j = 0; j < _joystick_bindings[i].naxes; j++) {
653 axis &a = _joystick_bindings[i].axes[j];
655 // Do nothing if the axis position
656 // is unchanged; only a change in
657 // position fires the bindings.
658 if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
659 // SG_LOG(SG_INPUT, SG_DEBUG, "Axis " << j << " has moved");
661 a.last_value = axis_values[j];
662 // SG_LOG(SG_INPUT, SG_DEBUG, "There are "
663 // << a.bindings[modifiers].size() << " bindings");
664 for (unsigned int k = 0; k < a.bindings[modifiers].size(); k++)
665 a.bindings[modifiers][k]->fire(axis_values[j]);
668 // do we have to emulate axis buttons?
670 if(a.last_dt >= a.interval_sec) {
671 if (a.low.bindings[modifiers].size())
672 _update_button(_joystick_bindings[i].axes[j].low,
674 axis_values[j] < a.low_threshold,
677 if (a.high.bindings[modifiers].size())
678 _update_button(_joystick_bindings[i].axes[j].high,
680 axis_values[j] > a.high_threshold,
682 a.last_dt -= a.interval_sec;
686 // Fire bindings for the buttons.
687 for (j = 0; j < _joystick_bindings[i].nbuttons; j++) {
688 button &b = _joystick_bindings[i].buttons[j];
690 if(b.last_dt >= b.interval_sec) {
691 _update_button(_joystick_bindings[i].buttons[j],
693 (buttons & (1 << j)) > 0,
695 b.last_dt -= b.interval_sec;
702 FGInput::_update_mouse ()
704 mouse &m = _mouse_bindings[0];
705 int mode = m.mode_node->getIntValue();
706 if (mode != m.current_mode) {
707 m.current_mode = mode;
708 if (mode >= 0 && mode < m.nModes) {
709 fgSetMouseCursor(m.modes[mode].cursor);
710 m.x = fgGetInt("/sim/startup/xsize", 800) / 2;
711 m.y = fgGetInt("/sim/startup/ysize", 600) / 2;
712 fgWarpMouse(m.x, m.y);
714 SG_LOG(SG_INPUT, SG_DEBUG, "Mouse mode " << mode << " out of range");
715 fgSetMouseCursor(MOUSE_CURSOR_POINTER);
721 FGInput::_update_button (button &b, int modifiers, bool pressed,
725 // The press event may be repeated.
726 if (!b.last_state || b.is_repeatable) {
727 SG_LOG( SG_INPUT, SG_DEBUG, "Button has been pressed" );
728 for (unsigned int k = 0; k < b.bindings[modifiers].size(); k++)
729 b.bindings[modifiers][k]->fire(x, y);
732 // The release event is never repeated.
734 SG_LOG( SG_INPUT, SG_DEBUG, "Button has been released" );
735 for (unsigned int k = 0; k < b.bindings[modifiers|KEYMOD_RELEASED].size(); k++)
736 b.bindings[modifiers|KEYMOD_RELEASED][k]->fire(x, y);
740 b.last_state = pressed;
745 FGInput::_read_bindings (const SGPropertyNode * node,
746 binding_list_t * binding_list,
749 SG_LOG(SG_INPUT, SG_DEBUG, "Reading all bindings");
750 vector<SGPropertyNode_ptr> bindings = node->getChildren("binding");
751 for (unsigned int i = 0; i < bindings.size(); i++) {
752 SG_LOG(SG_INPUT, SG_DEBUG, "Reading binding "
753 << bindings[i]->getStringValue("command"));
754 binding_list[modifiers].push_back(new FGBinding(bindings[i]));
757 // Read nested bindings for modifiers
758 if (node->getChild("mod-up") != 0)
759 _read_bindings(node->getChild("mod-up"), binding_list,
760 modifiers|KEYMOD_RELEASED);
762 if (node->getChild("mod-shift") != 0)
763 _read_bindings(node->getChild("mod-shift"), binding_list,
764 modifiers|KEYMOD_SHIFT);
766 if (node->getChild("mod-ctrl") != 0)
767 _read_bindings(node->getChild("mod-ctrl"), binding_list,
768 modifiers|KEYMOD_CTRL);
770 if (node->getChild("mod-alt") != 0)
771 _read_bindings(node->getChild("mod-alt"), binding_list,
772 modifiers|KEYMOD_ALT);
776 const vector<FGBinding *> &
777 FGInput::_find_key_bindings (unsigned int k, int modifiers)
779 unsigned char kc = (unsigned char)k;
780 button &b = _key_bindings[k];
782 // Try it straight, first.
783 if (b.bindings[modifiers].size() > 0)
784 return b.bindings[modifiers];
786 // Alt-Gr is CTRL+ALT
787 else if (modifiers&(KEYMOD_CTRL|KEYMOD_ALT))
788 return _find_key_bindings(k, modifiers&~(KEYMOD_CTRL|KEYMOD_ALT));
790 // Try removing the control modifier
792 else if ((modifiers&KEYMOD_CTRL) && iscntrl(kc))
793 return _find_key_bindings(k, modifiers&~KEYMOD_CTRL);
795 // Try removing shift modifier
796 // for upper case or any punctuation
797 // (since different keyboards will
798 // shift different punctuation types)
799 else if ((modifiers&KEYMOD_SHIFT) && (isupper(kc) || ispunct(kc)))
800 return _find_key_bindings(k, modifiers&~KEYMOD_SHIFT);
802 // Try removing alt modifier for
803 // high-bit characters.
804 else if ((modifiers&KEYMOD_ALT) && k >= 128 && k < 256)
805 return _find_key_bindings(k, modifiers&~KEYMOD_ALT);
807 // Give up and return the empty vector.
809 return b.bindings[modifiers];
814 ////////////////////////////////////////////////////////////////////////
815 // Implementation of FGInput::button.
816 ////////////////////////////////////////////////////////////////////////
818 FGInput::button::button ()
819 : is_repeatable(false),
824 FGInput::button::~button ()
826 // FIXME: memory leak
827 // for (int i = 0; i < KEYMOD_MAX; i++)
828 // for (int j = 0; i < bindings[i].size(); j++)
829 // delete bindings[i][j];
834 ////////////////////////////////////////////////////////////////////////
835 // Implementation of FGInput::axis.
836 ////////////////////////////////////////////////////////////////////////
838 FGInput::axis::axis ()
839 : last_value(9999999),
846 FGInput::axis::~axis ()
848 // for (int i = 0; i < KEYMOD_MAX; i++)
849 // for (int j = 0; i < bindings[i].size(); j++)
850 // delete bindings[i][j];
855 ////////////////////////////////////////////////////////////////////////
856 // Implementation of FGInput::joystick.
857 ////////////////////////////////////////////////////////////////////////
859 FGInput::joystick::joystick ()
863 FGInput::joystick::~joystick ()
872 ////////////////////////////////////////////////////////////////////////
873 // Implementation of FGInput::mouse_mode
874 ////////////////////////////////////////////////////////////////////////
876 FGInput::mouse_mode::mouse_mode ()
877 : cursor(MOUSE_CURSOR_POINTER),
884 FGInput::mouse_mode::~mouse_mode ()
886 // FIXME: memory leak
887 // for (int i = 0; i < KEYMOD_MAX; i++) {
889 // for (j = 0; i < x_bindings[i].size(); j++)
890 // delete bindings[i][j];
891 // for (j = 0; j < y_bindings[i].size(); j++)
892 // delete bindings[i][j];
899 ////////////////////////////////////////////////////////////////////////
900 // Implementation of FGInput::mouse
901 ////////////////////////////////////////////////////////////////////////
903 FGInput::mouse::mouse ()
912 FGInput::mouse::~mouse ()
917 ////////////////////////////////////////////////////////////////////////
918 // Implementation of OS callbacks.
919 ////////////////////////////////////////////////////////////////////////
921 void keyHandler(int key, int keymod, int mousex, int mousey)
923 if((keymod & KEYMOD_RELEASED) == 0)
924 if(puKeyboard(key, PU_DOWN))
928 default_input->doKey(key, keymod, mousex, mousey);
931 void mouseClickHandler(int button, int updown, int x, int y)
934 default_input->doMouseClick(button, updown, x, y);
937 void mouseMotionHandler(int x, int y)
939 if (default_input != 0)
940 default_input->doMouseMotion(x, y);