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.

91 lines
3.0KB

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