[PATCH] Touchscreen support improvement/enhancement (relative mouse coordinates)
#1
Thumbs Up 
Hello,

I tried to use the linuxport with a touchscreen. All works fine when windowed, but not when in fullscreen mode.

I figured it is because the mouse SDL driver reads relative mouse coordinates which doesn't work well with my touchscreen.

Would there be any change to be able to poll the mouse coordinates from the Xorg system? How whould this be implemented? If someone could give me global directions, I can implement it and share it.

Thanks.
Reply
#2
SDL_GetMouseState returns absolute coordinates. You might want to start there first.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Please read and follow the forum rules.
For troubleshooting and bug reporting, please make sure you read this first.


Image
Reply
#3
d4rk Wrote:SDL_GetMouseState returns absolute coordinates. You might want to start there first.

No, that is not what I mean. XBMC uses SDL_GetMouseState already. But the SDL gets its mousedata which it uses to make those absolute coordinates only in a relative way.

Is it not possible to get the pointer position from Xorg? Another way to illustrate this is to log on with VNC on a computer running XBMC. The mouse pointer will not work with IRC (because SDL gets its data directly from the input devices).
Reply
#4
I'm not sure I understand what you're saying, why would you need to get the same absolute coordinates directly from X when SDL provides them?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Please read and follow the forum rules.
For troubleshooting and bug reporting, please make sure you read this first.


Image
Reply
#5
d4rk Wrote:I'm not sure I understand what you're saying, why would you need to get the same absolute coordinates directly from X when SDL provides them?

That is the point, SDL provides them but not correctly, at least not with my touchscreen.
Reply
#6
I've got it partially working now, using XQueryPointer. In fullscreen mode normally VNC mouse did not work, normal mouse did work and touchscreen worked but not well because of SDL not doing it well.

Now in fullscreen the mouse works on VNC (so it recognises where the X pointer is), but now the normal input doesnt work. I suspect SDL redirects the input to itself and not to the X server. Any idea how to fix this?
Reply
#7
Lightbulb 
Ok, I resolved the problem myself now. Because it worked in windowed mode, I just made sure it was allways windowed. Then I used Devilspie (a window config program for GNOME) to make XBMC fullscreen. (Just removes windows decorations, etc.)

Also, XBMC lacks a way of right clicking for touchscreens, so I just hacked it a bit, so that when you click in the upper bar (y <= 30), it is a right click. I edited this in SDLMouse so it works everywhere, but it may not be the most elegant way.

For those interested, this is the SVN diff:

Code:
Index: guilib/GraphicContext.cpp
===================================================================
--- guilib/GraphicContext.cpp    (revision 10668)
+++ guilib/GraphicContext.cpp    (working copy)
@@ -391,6 +391,7 @@

void CGraphicContext::SetFullScreenVideo(bool bOnOff)
{
+  bOnOff = false;
   Lock();
   m_bFullScreenVideo = bOnOff;
   SetFullScreenViewWindow(m_Resolution);
@@ -583,7 +584,7 @@
     CLog::Log(LOGERROR, "The screen resolution requested is not valid, resetting to a valid mode");
     res = g_videoConfig.GetSafeMode();
   }
-  if (res>=DESKTOP)
+  if (res>DESKTOP)
   {
     g_advancedSettings.m_fullScreen = 1;
     m_bFullScreenRoot = true;
Index: guilib/common/SDLMouse.cpp
===================================================================
--- guilib/common/SDLMouse.cpp    (revision 10668)
+++ guilib/common/SDLMouse.cpp    (working copy)
@@ -46,8 +46,8 @@
   }

   // Fill in the public members
-  state.button[MOUSE_LEFT_BUTTON] = (mouseState & SDL_BUTTON(1)) == SDL_BUTTON(1);
-  state.button[MOUSE_RIGHT_BUTTON] = (mouseState & SDL_BUTTON(3)) == SDL_BUTTON(3);
+  state.button[MOUSE_LEFT_BUTTON] = ((mouseState & SDL_BUTTON(1)) == SDL_BUTTON(1)) && (state.y > 30);
+  state.button[MOUSE_RIGHT_BUTTON] = ((mouseState & SDL_BUTTON(3)) == SDL_BUTTON(3)) || (state.y <= 30 && (mouseState & SDL_BUTTON(1)) == SDL_BUTTON(1) );
   state.button[MOUSE_MIDDLE_BUTTON] = (mouseState & SDL_BUTTON(2)) == SDL_BUTTON(2);
   state.button[MOUSE_EXTRA_BUTTON1] = (mouseState & SDL_BUTTON(4)) == SDL_BUTTON(4);
   state.button[MOUSE_EXTRA_BUTTON2] = (mouseState & SDL_BUTTON(5)) == SDL_BUTTON(5);
Reply
#8
An updated patch of this submitted to our tracking system (trac) would be more than welcomed:
http://wiki.xbmc.org/?title=HOW-TO_submit_a_patch
http://trac.xbmc.org
http://wiki.xbmc.org/?title=Appendix_D:_...ment_Notes

Wink
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply

Logout Mark Read Team Forum Stats Members Help
[PATCH] Touchscreen support improvement/enhancement (relative mouse coordinates)0