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