From 0560375cbb52e6cfba3f81471a2530bb922b3bc7 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 13 May 2005 22:03:42 +0000 Subject: [PATCH] add MouseSubregion --- panda/src/device/mouseAndKeyboard.cxx | 14 ++++++++++---- panda/src/device/mouseAndKeyboard.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/panda/src/device/mouseAndKeyboard.cxx b/panda/src/device/mouseAndKeyboard.cxx index 4ba14c9c1d..975ae9a645 100644 --- a/panda/src/device/mouseAndKeyboard.cxx +++ b/panda/src/device/mouseAndKeyboard.cxx @@ -37,10 +37,12 @@ MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : _device(device) { _pixel_xy_output = define_output("pixel_xy", EventStoreVec2::get_class_type()); + _pixel_size_output = define_output("pixel_size", EventStoreVec2::get_class_type()); _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_size = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); _button_events = new ButtonEventList; } @@ -83,6 +85,14 @@ do_transmit_data(const DataNodeTransmit &, DataNodeTransmit &output) { output.set_data(_button_events_output, EventParameter(_button_events)); } + // Get the window size. + WindowProperties properties = _window->get_properties(); + int w = properties.get_x_size(); + int h = properties.get_y_size(); + + _pixel_size->set_value(LPoint2f(w, h)); + output.set_data(_pixel_size_output, EventParameter(_pixel_size)); + if (_window->has_pointer(_device)) { const MouseData &mdata = _window->get_pointer(_device); @@ -91,10 +101,6 @@ do_transmit_data(const DataNodeTransmit &, DataNodeTransmit &output) { _pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); - WindowProperties properties = _window->get_properties(); - int w = properties.get_x_size(); - int h = properties.get_y_size(); - // Normalize pixel motion to range [-1,1]. float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f; float yf = 1.0f - (float)(2 * mdata._ypos) / (float)h; diff --git a/panda/src/device/mouseAndKeyboard.h b/panda/src/device/mouseAndKeyboard.h index 0aaa62fdc6..21363d2087 100644 --- a/panda/src/device/mouseAndKeyboard.h +++ b/panda/src/device/mouseAndKeyboard.h @@ -60,10 +60,12 @@ protected: private: // outputs int _pixel_xy_output; + int _pixel_size_output; int _xy_output; int _button_events_output; PT(EventStoreVec2) _pixel_xy; + PT(EventStoreVec2) _pixel_size; PT(EventStoreVec2) _xy; PT(ButtonEventList) _button_events;