Panda3D
|
00001 // Filename: virtualMouse.h 00002 // Created by: drose (12Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef VIRTUALMOUSE_H 00016 #define VIRTUALMOUSE_H 00017 00018 #include "pandabase.h" 00019 #include "dataNode.h" 00020 #include "buttonHandle.h" 00021 #include "buttonEvent.h" 00022 #include "pointerTo.h" 00023 #include "luse.h" 00024 #include "linmath_events.h" 00025 #include "buttonEventList.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : VirtualMouse 00029 // Description : Poses as a MouseAndKeyboard object in the datagraph, 00030 // but accepts input from user calls, rather than 00031 // reading the actual mouse and keyboard from an input 00032 // device. The user can write high-level code to put 00033 // the mouse wherever he/she wants, and to insert 00034 // keypresses on demand. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode { 00037 PUBLISHED: 00038 VirtualMouse(const string &name); 00039 00040 void set_mouse_pos(int x, int y); 00041 void set_window_size(int width, int height); 00042 void set_mouse_on(bool flag); 00043 00044 void press_button(ButtonHandle button); 00045 void release_button(ButtonHandle button); 00046 00047 private: 00048 int _mouse_x, _mouse_y; 00049 int _win_width, _win_height; 00050 bool _mouse_on; 00051 00052 protected: 00053 // Inherited from DataNode 00054 virtual void do_transmit_data(DataGraphTraverser *trav, 00055 const DataNodeTransmit &input, 00056 DataNodeTransmit &output); 00057 00058 private: 00059 // outputs 00060 int _pixel_xy_output; 00061 int _pixel_size_output; 00062 int _xy_output; 00063 int _button_events_output; 00064 00065 PT(EventStoreVec2) _pixel_xy; 00066 PT(EventStoreVec2) _pixel_size; 00067 PT(EventStoreVec2) _xy; 00068 PT(ButtonEventList) _button_events; 00069 PT(ButtonEventList) _next_button_events; 00070 00071 public: 00072 static TypeHandle get_class_type() { 00073 return _type_handle; 00074 } 00075 static void init_type() { 00076 DataNode::init_type(); 00077 register_type(_type_handle, "VirtualMouse", 00078 DataNode::get_class_type()); 00079 } 00080 virtual TypeHandle get_type() const { 00081 return get_class_type(); 00082 } 00083 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00084 00085 private: 00086 static TypeHandle _type_handle; 00087 }; 00088 00089 #endif 00090