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