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.

87 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. JoystickPluginGUI::JoystickPluginGUI(int w, int h,JoystickPlugin *o,const HostInfo *Info) :
  21. SpiralPluginGUI(w,h,o)
  22. {
  23. m_Plugin=o;
  24. Invertx = new Fl_Button(0, 20, 50, 20, "Invert x");
  25. Invertx->type(1);
  26. Invertx->down_box(FL_DOWN_BOX);
  27. Invertx->labelsize(10);
  28. Invertx->callback((Fl_Callback*)cb_Invertx);
  29. Inverty = new Fl_Button(50, 20, 50, 20, "Invert y");
  30. Inverty->type(1);
  31. Inverty->down_box(FL_DOWN_BOX);
  32. Inverty->labelsize(10);
  33. Inverty->callback((Fl_Callback*)cb_Inverty);
  34. Invertz = new Fl_Button(100, 20, 50, 20, "Invert z");
  35. Invertz->type(1);
  36. Invertz->down_box(FL_DOWN_BOX);
  37. Invertz->labelsize(10);
  38. Invertz->callback((Fl_Callback*)cb_Invertz);
  39. valuex = new Fl_Box( 0, 40, 50, 20 );
  40. valuey = new Fl_Box( 50, 40, 50, 20 );
  41. valuez = new Fl_Box( 100, 40, 50, 20 );
  42. end();
  43. }
  44. char xbuffer[20];
  45. char ybuffer[20];
  46. char zbuffer[20];
  47. void JoystickPluginGUI::UpdateValues()
  48. {
  49. snprintf( xbuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 0 ) );
  50. valuex->label( xbuffer );
  51. snprintf( ybuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 1 ) );
  52. valuey->label( ybuffer );
  53. snprintf( zbuffer, 20, "%.3f", LowLevelJoystick::Get()->GetJoystickAxis( 2 ) );
  54. valuez->label( zbuffer );
  55. Fl::check();
  56. }
  57. void JoystickPluginGUI::draw()
  58. {
  59. SpiralGUIType::draw();
  60. UpdateValues();
  61. }
  62. inline void JoystickPluginGUI::cb_Invert_ix(Fl_Button* o, void* v)
  63. { LowLevelJoystick::Get()->m_invert_axis[0] = o->value(); }
  64. void JoystickPluginGUI::cb_Invertx(Fl_Button* o, void* v)
  65. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_ix(o,v); }
  66. inline void JoystickPluginGUI::cb_Invert_iy(Fl_Button* o, void* v)
  67. { LowLevelJoystick::Get()->m_invert_axis[1] = o->value(); }
  68. void JoystickPluginGUI::cb_Inverty(Fl_Button* o, void* v)
  69. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_iy(o,v); }
  70. inline void JoystickPluginGUI::cb_Invert_iz(Fl_Button* o, void* v)
  71. { LowLevelJoystick::Get()->m_invert_axis[2] = o->value(); }
  72. void JoystickPluginGUI::cb_Invertz(Fl_Button* o, void* v)
  73. { ((JoystickPluginGUI*)(o->parent()))->cb_Invert_iz(o,v); }