00001 // Filename: mouseAndKeyboard.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 MOUSEANDKEYBOARD_H 00020 #define MOUSEANDKEYBOARD_H 00021 00022 #include "pandabase.h" 00023 00024 #include "dataNode.h" 00025 #include "buttonEventList.h" 00026 #include "linmath_events.h" 00027 #include "pointerTo.h" 00028 #include "graphicsWindow.h" 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : MouseAndKeyboard 00032 // Description : Reads the mouse and/or keyboard data sent from a 00033 // GraphicsWindow, and transmits it down the data graph. 00034 // 00035 // The mouse and keyboard devices are bundled together 00036 // into one device here, because they interrelate so 00037 // much. A mouse might be constrained by the holding 00038 // down of the shift key, for instance, or the clicking 00039 // of the mouse button might be handled in much the same 00040 // way as a keyboard key. 00041 // 00042 // Mouse data is sent down the data graph as an x,y 00043 // position as well as the set of buttons currently 00044 // being held down; keyboard data is sent down as a set 00045 // of keypress events in an EventDataTransition. To 00046 // throw these events to the system, you must attach an 00047 // EventThrower to the MouseAndKeyboard object; 00048 // otherwise, the events will be discarded. 00049 //////////////////////////////////////////////////////////////////// 00050 class EXPCL_PANDA MouseAndKeyboard : public DataNode { 00051 PUBLISHED: 00052 MouseAndKeyboard(GraphicsWindow *window, int device, const string &name); 00053 void set_source(GraphicsWindow *window, int device); 00054 00055 protected: 00056 // Inherited from DataNode 00057 virtual void do_transmit_data(const DataNodeTransmit &input, 00058 DataNodeTransmit &output); 00059 00060 private: 00061 // outputs 00062 int _pixel_xy_output; 00063 int _xy_output; 00064 int _button_events_output; 00065 00066 PT(EventStoreVec2) _pixel_xy; 00067 PT(EventStoreVec2) _xy; 00068 PT(ButtonEventList) _button_events; 00069 00070 PT(GraphicsWindow) _window; 00071 int _device; 00072 00073 public: 00074 static TypeHandle get_class_type() { 00075 return _type_handle; 00076 } 00077 static void init_type() { 00078 DataNode::init_type(); 00079 register_type(_type_handle, "MouseAndKeyboard", 00080 DataNode::get_class_type()); 00081 } 00082 virtual TypeHandle get_type() const { 00083 return get_class_type(); 00084 } 00085 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00086 00087 private: 00088 static TypeHandle _type_handle; 00089 }; 00090 00091 #endif