mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
add MouseSubregion
This commit is contained in:
parent
e66a0faba0
commit
0560375cbb
@ -37,10 +37,12 @@ MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) :
|
|||||||
_device(device)
|
_device(device)
|
||||||
{
|
{
|
||||||
_pixel_xy_output = define_output("pixel_xy", EventStoreVec2::get_class_type());
|
_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());
|
_xy_output = define_output("xy", EventStoreVec2::get_class_type());
|
||||||
_button_events_output = define_output("button_events", ButtonEventList::get_class_type());
|
_button_events_output = define_output("button_events", ButtonEventList::get_class_type());
|
||||||
|
|
||||||
_pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f));
|
_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));
|
_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f));
|
||||||
_button_events = new ButtonEventList;
|
_button_events = new ButtonEventList;
|
||||||
}
|
}
|
||||||
@ -83,6 +85,14 @@ do_transmit_data(const DataNodeTransmit &, DataNodeTransmit &output) {
|
|||||||
output.set_data(_button_events_output, EventParameter(_button_events));
|
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)) {
|
if (_window->has_pointer(_device)) {
|
||||||
const MouseData &mdata = _window->get_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));
|
_pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos));
|
||||||
output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
|
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].
|
// Normalize pixel motion to range [-1,1].
|
||||||
float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f;
|
float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f;
|
||||||
float yf = 1.0f - (float)(2 * mdata._ypos) / (float)h;
|
float yf = 1.0f - (float)(2 * mdata._ypos) / (float)h;
|
||||||
|
@ -60,10 +60,12 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// outputs
|
// outputs
|
||||||
int _pixel_xy_output;
|
int _pixel_xy_output;
|
||||||
|
int _pixel_size_output;
|
||||||
int _xy_output;
|
int _xy_output;
|
||||||
int _button_events_output;
|
int _button_events_output;
|
||||||
|
|
||||||
PT(EventStoreVec2) _pixel_xy;
|
PT(EventStoreVec2) _pixel_xy;
|
||||||
|
PT(EventStoreVec2) _pixel_size;
|
||||||
PT(EventStoreVec2) _xy;
|
PT(EventStoreVec2) _xy;
|
||||||
PT(ButtonEventList) _button_events;
|
PT(ButtonEventList) _button_events;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user