00001 // Copyright (C) 2002 Dominic Letourneau 00002 00003 #ifndef _VIRTUALJOYSTICK_H_ 00004 #define _VIRTUALJOYSTICK_H_ 00005 00006 #include "BufferedNode.h" 00007 #include <pthread.h> 00008 #include <gnome.h> 00009 00010 namespace RobotFlow { 00011 00012 /** 00013 Virtual Joystick is a visual probe that shows a joystick with 2 standard buttons and 2 toggle buttons. 00014 \author Dominic Letourneau 00015 */ 00016 class VirtualJoystick : public FD::BufferedNode { 00017 00018 protected: 00019 00020 ///Flag for the visibility of all the buttons 00021 bool m_buttonsVisible; 00022 ///button 1 state 00023 bool m_button1_on; 00024 ///button 2 state 00025 bool m_button2_on; 00026 ///button 3 state 00027 bool m_toggleButton3_on; 00028 ///button 4 state 00029 bool m_toggleButton4_on; 00030 00031 ///The output vector containing the state of the virtual joystick 00032 int m_outputID; 00033 00034 //GUI widgets 00035 GtkWidget* m_pWindow1; 00036 GtkWidget* m_pVbox2; 00037 GtkWidget* m_pToolbar2; 00038 GnomeCanvas* m_pCanvas; 00039 GnomeCanvasGroup* m_pGroup; 00040 GtkWidget* m_pButton1; 00041 GtkWidget* m_pButton2; 00042 GtkWidget* m_pButton3; 00043 GtkWidget* m_pButton4; 00044 GnomeCanvasItem* m_pBorder; 00045 GnomeCanvasItem* m_pHandle; 00046 00047 public: 00048 00049 /** 00050 Constructor 00051 \param nodeName The name of the node 00052 \param params The parameters passed at construction 00053 */ 00054 VirtualJoystick(std::string nodeName, FD::ParameterSet params); 00055 00056 ///Destructor 00057 virtual ~VirtualJoystick(); 00058 00059 /** 00060 Class specific initialization routine. 00061 Each class will call its subclass specificInitialize() method 00062 */ 00063 virtual void initialize(); 00064 00065 /** 00066 Calculate inherited from BufferedNode 00067 \param output_id the output to calculate 00068 \param count the iteration number 00069 \param out the buffer where to write the result 00070 */ 00071 virtual void calculate(int output_id, int count, FD::Buffer &out); 00072 00073 /** 00074 Catch a GdkEvent on the canvas 00075 \param event The GdkEvent 00076 */ 00077 gint event(GdkEvent *event); 00078 00079 /** 00080 Called when a button changed its status 00081 \param button_id the id of the button 00082 */ 00083 bool change_button_status(int button_id); 00084 00085 }; 00086 00087 }//namespace RobotFlow 00088 #endif