add MouseSubregion

This commit is contained in:
David Rose 2005-05-13 22:03:42 +00:00
parent e66a0faba0
commit 0560375cbb
2 changed files with 12 additions and 4 deletions

View File

@ -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;

View File

@ -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;