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.

menukey.cxx 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright 2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
  2. * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
  3. *
  4. * This 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 software 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 software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22. #include <string.h>
  23. #include <FL/Fl.H>
  24. // FLTK can pull in the X11 headers on some systems
  25. #ifndef XK_VoidSymbol
  26. #define XK_MISCELLANY
  27. #include <rfb/keysymdef.h>
  28. #endif
  29. #include "menukey.h"
  30. #include "parameters.h"
  31. static const MenuKeySymbol menuSymbols[] = {
  32. {"F1", FL_F + 1, 0x3b, XK_F1},
  33. {"F2", FL_F + 2, 0x3c, XK_F2},
  34. {"F3", FL_F + 3, 0x3d, XK_F3},
  35. {"F4", FL_F + 4, 0x3e, XK_F4},
  36. {"F5", FL_F + 5, 0x3f, XK_F5},
  37. {"F6", FL_F + 6, 0x40, XK_F6},
  38. {"F7", FL_F + 7, 0x41, XK_F7},
  39. {"F8", FL_F + 8, 0x42, XK_F8},
  40. {"F9", FL_F + 9, 0x43, XK_F9},
  41. {"F10", FL_F + 10, 0x44, XK_F10},
  42. {"F11", FL_F + 11, 0x57, XK_F11},
  43. {"F12", FL_F + 12, 0x58, XK_F12},
  44. {"Pause", FL_Pause, 0xc6, XK_Pause},
  45. {"Scroll_Lock", FL_Scroll_Lock, 0x46, XK_Scroll_Lock},
  46. {"Escape", FL_Escape, 0x01, XK_Escape},
  47. {"Insert", FL_Insert, 0xd2, XK_Insert},
  48. {"Delete", FL_Delete, 0xd3, XK_Delete},
  49. {"Home", FL_Home, 0xc7, XK_Home},
  50. {"Page_Up", FL_Page_Up, 0xc9, XK_Page_Up},
  51. {"Page_Down", FL_Page_Down, 0xd1, XK_Page_Down},
  52. };
  53. int getMenuKeySymbolCount()
  54. {
  55. return sizeof(menuSymbols)/sizeof(menuSymbols[0]);
  56. }
  57. const MenuKeySymbol* getMenuKeySymbols()
  58. {
  59. return menuSymbols;
  60. }
  61. void getMenuKey(int *fltkcode, int *keycode, uint32_t *keysym)
  62. {
  63. const char *menuKeyStr;
  64. menuKeyStr = menuKey;
  65. for(int i = 0; i < getMenuKeySymbolCount(); i++) {
  66. if (!strcmp(menuSymbols[i].name, menuKeyStr)) {
  67. *fltkcode = menuSymbols[i].fltkcode;
  68. *keycode = menuSymbols[i].keycode;
  69. *keysym = menuSymbols[i].keysym;
  70. return;
  71. }
  72. }
  73. *fltkcode = 0;
  74. *keycode = 0;
  75. *keysym = 0;
  76. }