Advertisement
Guest User

egalaxpatch-mod

a guest
May 18th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.62 KB | None | 0 0
  1. From: http://code.google.com/p/andrei-development/downloads/detail?name=eGalax_patch_for_XBMC_12.tar.gz
  2.  
  3. --- a/xbmc/input/MouseStat.h    2013-01-29 16:20:27.000000000 +0200
  4. +++ b/xbmc/input/MouseStat.h    2013-02-24 10:47:27.570767079 +0200
  5. @@ -123,7 +123,7 @@
  6.       */
  7.      BUTTON_ACTION Update(unsigned int time, int x, int y, bool down);
  8.    private:
  9. -    static const unsigned int click_confines = 5;        ///< number of pixels that the pointer may move while the button is down to trigger a click
  10. +    static const unsigned int click_confines = 7;        ///< number of pixels that the pointer may move while the button is down to trigger a click
  11.      static const unsigned int short_click_time = 1000;   ///< time for mouse down/up to trigger a short click rather than a long click
  12.      static const unsigned int double_click_time = 500;   ///< time for mouse down following a short click to trigger a double click
  13.  
  14. --- a/xbmc/input/linux/LinuxInputDevices.cpp    2013-01-29 16:20:27.000000000 +0200
  15. +++ b/xbmc/input/linux/LinuxInputDevices.cpp    2013-02-24 11:29:57.655929879 +0200
  16. @@ -317,6 +317,13 @@
  17.  
  18.  static char remoteStatus = 0xFF; // paired, battery OK
  19.  
  20. +/* [touchscreens] calibration values */
  21. +static int calib_x_d = 1280;
  22. +static float calib_x_fact = -1.0f;
  23. +static int calib_y_d = 720;
  24. +static float calib_y_fact = -1.0f;
  25. +static int swap_axes = 0;
  26. +
  27.  CLinuxInputDevice::CLinuxInputDevice(const std::string fileName, int index)
  28.  {
  29.    m_fd = -1;
  30. @@ -502,6 +509,13 @@
  31.  {
  32.    int code = levt.code;
  33.  
  34. +  /* [touchscreens] when PRESS or RELEASE action occurs
  35. +  if(levt.code == BTN_TOUCH)
  36. +  {
  37. +    m_mouseX = g_graphicsContext.GetWidth() + 1;
  38. +    m_mouseY = g_graphicsContext.GetHeight() + 1;
  39. +  } */
  40. +
  41.    /* map touchscreen and smartpad events to button mouse */
  42.    if (code == BTN_TOUCH || code == BTN_TOOL_FINGER)
  43.      code = BTN_MOUSE;
  44. @@ -645,11 +659,17 @@
  45.    switch (levt.code)
  46.    {
  47.    case ABS_X:
  48. -    m_mouseX = levt.value;
  49. +    if(swap_axes)
  50. +      m_mouseY = g_graphicsContext.GetHeight() - (int)(((float)levt.value) * (calib_y_fact)) - calib_y_d;
  51. +    else
  52. +      m_mouseX = g_graphicsContext.GetWidth() - (int)(((float)levt.value) * (calib_x_fact)) - calib_x_d;
  53.      break;
  54.  
  55.    case ABS_Y:
  56. -    m_mouseY = levt.value;
  57. +    if(swap_axes)
  58. +      m_mouseX = g_graphicsContext.GetWidth() - (int)(((float)levt.value) * (calib_x_fact)) - calib_x_d;
  59. +    else
  60. +      m_mouseY = g_graphicsContext.GetHeight() - (int)(((float)levt.value) * (calib_y_fact)) - calib_y_d;
  61.      break;
  62.    
  63.    case ABS_MISC:
  64. @@ -840,6 +860,8 @@
  65.    unsigned long evbit[NBITS(EV_CNT)];
  66.    unsigned long keybit[NBITS(KEY_CNT)];
  67.  
  68. +  FILE *c_fp = NULL;
  69. +
  70.    /* get device name */
  71.    bzero(m_deviceName, sizeof(m_deviceName));
  72.    ioctl(fd, EVIOCGNAME(sizeof(m_deviceName)-1), m_deviceName);
  73. @@ -854,6 +876,25 @@
  74.    }
  75.    CLog::Log(LOGINFO, "opened device '%s' (file name %s), m_bSkipNonKeyEvents %d\n", m_deviceName, m_fileName.c_str(), m_bSkipNonKeyEvents);
  76.  
  77. +  /* [touchscreens] read calibration values(this should be changed to an XML file) */
  78. +  if(strstr(m_deviceName, "eGalax") || strstr(m_deviceName, "Touch"))
  79. +  {
  80. +      c_fp = fopen("/usr/share/eGalaxCalibration/touchscreen_axes_calib", "r");
  81. +      if (c_fp)
  82. +      {
  83. +        fscanf(c_fp, "calib_x_d=%d;calib_x_fact=%f;calib_y_d=%d;calib_y_fact=%f;swap_axes=%d;\n",
  84. +            &calib_x_d,
  85. +            &calib_x_fact,
  86. +            &calib_y_d,
  87. +            &calib_y_fact,
  88. +            &swap_axes
  89. +        );
  90. +
  91. +        /* close the file */
  92. +        fclose(c_fp);
  93. +      }
  94. +  }
  95. +  
  96.    /* get event type bits */
  97.    ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement