From 24a812c0b623d04c63365fef4fefb2b96dc503c7 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 27 Mar 2002 23:45:11 +0000 Subject: [PATCH] Created a new /devices property subtree to hold input device status (currently just the mouse, but later the joystick and keyboard as well). Publish mouse button status to the property tree. --- src/Input/input.cxx | 17 ++++++++++++++++- src/Input/input.hxx | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 59afa540c..7bd23cf8a 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -359,6 +359,10 @@ FGInput::doMouseClick (int b, int updown, int x, int y) mouse &m = _mouse_bindings[0]; mouse_mode &mode = m.modes[m.current_mode]; + // Let the property manager know. + if (b >= 0 && b < MAX_MOUSE_BUTTONS) + m.mouse_button_nodes[b]->setBoolValue(updown == GLUT_DOWN); + // Pass on to PUI and the panel if // requested, and return if one of // them consumes the event. @@ -611,6 +615,17 @@ FGInput::_init_mouse () SGPropertyNode * mouse_node = mouse_nodes->getChild("mouse", i, true); mouse &m = _mouse_bindings[i]; + // Grab node pointers + char buf[64]; + sprintf(buf, "/devices/status/mice/mouse[%d]/mode", i); + m.mode_node = fgGetNode(buf, true); + m.mode_node->setIntValue(0); + for (j = 0; j < MAX_MOUSE_BUTTONS; j++) { + sprintf(buf, "/devices/status/mice/mouse[%d]/button[%d]", i, j); + m.mouse_button_nodes[j] = fgGetNode(buf, true); + m.mouse_button_nodes[j]->setBoolValue(false); + } + // Read all the modes m.nModes = mouse_node->getIntValue("mode-count", 1); m.modes = new mouse_mode[m.nModes]; @@ -745,7 +760,7 @@ void FGInput::_update_mouse () { mouse &m = _mouse_bindings[0]; - int mode = fgGetInt("/input/mice/mouse[0]/mode"); + int mode = m.mode_node->getIntValue(); if (mode != m.current_mode) { m.current_mode = mode; if (mode >= 0 && mode < m.nModes) { diff --git a/src/Input/input.hxx b/src/Input/input.hxx index 4a28edc96..4b9144f08 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -317,6 +317,8 @@ private: virtual ~mouse (); int x; int y; + SGPropertyNode * mode_node; + SGPropertyNode * mouse_button_nodes[MAX_MOUSE_BUTTONS]; int nModes; int current_mode; mouse_mode * modes;