You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.9KB

  1. /* JoystickPlugin
  2. * Copyleft (C) 2002 William Bland <wjb@abstractnonsense.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "JoystickPluginGUI.h"
  19. #include <FL/fl_draw.H>
  20. using namespace std;
  21. JoystickPluginGUI::JoystickPluginGUI(int w, int h,JoystickPlugin *o,const HostInfo *Info) :
  22. SpiralPluginGUI(w,h,o)
  23. {
  24. m_Plugin=o;
  25. Invertx = new Fl_Button(0, 20, 50, 20, "Invert x");
  26. Invertx->type(1);
  27. Invertx->down_box(FL_DOWN_BOX);
  28. Invertx->labelsize(10);
  29. Invertx->callback((Fl_Callback*)cb_Invertx);
  30. Inverty = new Fl_Button(50, 20, 50, 20, "Invert y");
  31. Inverty->type(1);
  32. Inverty->down_box(FL_DOWN_BOX);
  33. Inverty->labelsize(10);
  34. Inverty->callback((Fl_Callback*)cb_Inverty);
  35. Invertz = new Fl_Button(100, 20, 50, 20, "Invert z");
  36. Invertz->type(1);
  37. Invertz->down_box(FL_DOWN_BOX);
  38. Invertz->labelsize(10);
  39. Invertz->callback((Fl_Callback*)cb_Invertz);
  40. valuex = new Fl_Box( 0, 40, 50, 20 );
  41. valuey = new Fl_Box( 50, 40, 50, 20 );
  42. valuez = new Fl_Box( 100, 40, 50, 20 );
  43. end();
  44. }
  45. char xbuffer[20];
  46. char ybuffer[20];
  47. char zbuffer[20];
  48. void JoystickPluginGUI::UpdateValues()
  49. {
  50. snprintf( xbuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 0 ) );
  51. valuex->label( xbuffer );
  52. snprintf( ybuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 1 ) );
  53. valuey->label( ybuffer );
  54. snprintf( zbuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 2 ) );
  55. valuez->label( zbuffer );
  56. Fl::check();
  57. }
  58. void JoystickPluginGUI::draw()
  59. {
  60. SpiralGUIType::draw();
  61. UpdateValues();
  62. }
  63. inline void JoystickPluginGUI::cb_Invert_ix(Fl_Button* o, void* v)
  64. { LowLevelJoystick::Get()->m_invert_axis[0] = o->value(); }
  65. void JoystickPluginGUI::cb_Invertx(Fl_Button* o, void* v)
  66. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_ix(o,v); }
  67. inline void JoystickPluginGUI::cb_Invert_iy(Fl_Button* o, void* v)
  68. { LowLevelJoystick::Get()->m_invert_axis[1] = o->value(); }
  69. void JoystickPluginGUI::cb_Inverty(Fl_Button* o, void* v)
  70. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_iy(o,v); }
  71. inline void JoystickPluginGUI::cb_Invert_iz(Fl_Button* o, void* v)
  72. { LowLevelJoystick::Get()->m_invert_axis[2] = o->value(); }
  73. void JoystickPluginGUI::cb_Invertz(Fl_Button* o, void* v)
  74. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_iz(o,v); }