void ActivePickCallbacks::init( int b, const osgGA::GUIEventAdapter* ea )
{
// Get the list of hit callbacks. Take the first callback that
void ActivePickCallbacks::init( int b, const osgGA::GUIEventAdapter* ea )
{
// Get the list of hit callbacks. Take the first callback that
// The nearest one is the first one and the deepest
// (the most specialized one in the scenegraph) is the first.
std::vector<SGSceneryPick> pickList;
// The nearest one is the first one and the deepest
// (the most specialized one in the scenegraph) is the first.
std::vector<SGSceneryPick> pickList;
std::vector<SGSceneryPick>::const_iterator i;
for (i = pickList.begin(); i != pickList.end(); ++i) {
if (i->callback->buttonPressed(b, i->info)) {
std::vector<SGSceneryPick>::const_iterator i;
for (i = pickList.begin(); i != pickList.end(); ++i) {
if (i->callback->buttonPressed(b, i->info)) {
xSizeNode(fgGetNode("/sim/startup/xsize", false ) ),
ySizeNode(fgGetNode("/sim/startup/ysize", false ) ),
xAccelNode(fgGetNode("/devices/status/mice/mouse/accel-x", true ) ),
xSizeNode(fgGetNode("/sim/startup/xsize", false ) ),
ySizeNode(fgGetNode("/sim/startup/ysize", false ) ),
xAccelNode(fgGetNode("/devices/status/mice/mouse/accel-x", true ) ),
buf << "/devices/status/mice/mouse["<< i << "]/button[" << j << "]";
m.mouse_button_nodes[j] = fgGetNode(buf.str().c_str(), true);
m.mouse_button_nodes[j]->setBoolValue(false);
buf << "/devices/status/mice/mouse["<< i << "]/button[" << j << "]";
m.mouse_button_nodes[j] = fgGetNode(buf.str().c_str(), true);
m.mouse_button_nodes[j]->setBoolValue(false);
buf << "mouse button " << k;
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing mouse button " << k);
m.modes[j].buttons[k].init( mode_node->getChild("button", k), buf.str(), module );
buf << "mouse button " << k;
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing mouse button " << k);
m.modes[j].buttons[k].init( mode_node->getChild("button", k), buf.str(), module );
m.x = (xSizeNode ? xSizeNode->getIntValue() : 800) / 2;
m.y = (ySizeNode ? ySizeNode->getIntValue() : 600) / 2;
fgWarpMouse(m.x, m.y);
m.x = (xSizeNode ? xSizeNode->getIntValue() : 800) / 2;
m.y = (ySizeNode ? ySizeNode->getIntValue() : 600) / 2;
fgWarpMouse(m.x, m.y);
} else {
SG_LOG(SG_INPUT, SG_DEBUG, "Mouse mode " << mode << " out of range");
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
} else {
SG_LOG(SG_INPUT, SG_DEBUG, "Mouse mode " << mode << " out of range");
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
// OK, PUI didn't want the event,
// so we can play with it.
// OK, PUI didn't want the event,
// so we can play with it.
- if (x != m.x) {
- int delta = x - m.x;
- xAccelNode->setIntValue( delta );
- for (unsigned int i = 0; i < mode.x_bindings[modifiers].size(); i++)
- mode.x_bindings[modifiers][i]->fire(double(delta), double(xsize));
- }
- if (y != m.y) {
- int delta = y - m.y;
- yAccelNode->setIntValue( -delta );
- for (unsigned int i = 0; i < mode.y_bindings[modifiers].size(); i++)
- mode.y_bindings[modifiers][i]->fire(double(delta), double(ysize));
+ if (x != m.x) {
+ int delta = x - m.x;
+ xAccelNode->setIntValue( delta );
+ for (unsigned int i = 0; i < mode.x_bindings[modifiers].size(); i++)
+ mode.x_bindings[modifiers][i]->fire(double(delta), double(xsize));
+ }
+ if (y != m.y) {
+ int delta = y - m.y;
+ yAccelNode->setIntValue( -delta );
+ for (unsigned int i = 0; i < mode.y_bindings[modifiers].size(); i++)
+ mode.y_bindings[modifiers][i]->fire(double(delta), double(ysize));
+ }
+ {
+ fgWarpMouse(new_x, new_y);
+ haveWarped = true;
+ SG_LOG(SG_INPUT, SG_DEBUG, "Mouse warp: " << x << ", " << y << " => " << new_x << ", " << new_y);
+ }