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 PT(GraphicsWindow) get_source_window() const; 00053 int get_source_device() const; 00054 00055 protected: 00056 // Inherited from DataNode 00057 virtual void do_transmit_data(DataGraphTraverser *trav, 00058 const DataNodeTransmit &input, 00059 DataNodeTransmit &output); 00060 00061 private: 00062 // outputs 00063 int _pixel_xy_output; 00064 int _pixel_size_output; 00065 int _xy_output; 00066 int _button_events_output; 00067 int _pointer_events_output; 00068 00069 PT(EventStoreVec2) _pixel_xy; 00070 PT(EventStoreVec2) _pixel_size; 00071 PT(EventStoreVec2) _xy; 00072 PT(ButtonEventList) _button_events; 00073 00074 PT(GraphicsWindow) _window; 00075 int _device; 00076 00077 public: 00078 static TypeHandle get_class_type() { 00079 return _type_handle; 00080 } 00081 static void init_type() { 00082 DataNode::init_type(); 00083 register_type(_type_handle, "MouseAndKeyboard", 00084 DataNode::get_class_type()); 00085 } 00086 virtual TypeHandle get_type() const { 00087 return get_class_type(); 00088 } 00089 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00090 00091 private: 00092 static TypeHandle _type_handle; 00093 }; 00094 00095 #endif