Kodi Community Forum
Xbox 360 Controller EventClient - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: Xbox 360 Controller EventClient (/showthread.php?tid=40186)

Pages: 1 2 3


Xbox 360 Controller EventClient - frain - 2008-11-10

I wrote an EventClient in C++ for the Xbox 360 Controller for Windows. I've tested it in Windows Vista 32bit. From trac:

"This patch adds the C++ code for an Xbox 360 Controller EventClient for Windows (using XINPUT). A new project is added to the XBMC VSE2008 solution from which the EventClient can be compiled. The EventClient has no user interface - it simply sends the data received from the first connected controller to XBMC listening on localhost (using the "XG" [Xbox gamepad] device map). At the moment, I do not have time to add further features, so I'm submitting the patch as the basic functionality is working correctly."


I would be interested in seeing the code - jhsrennie - 2008-11-11

Can you post a link to the ticket? I've been struggling to get an eventclient to work and I would be very interested to see your code.

Thanks,

John Rennie


- frain - 2008-11-11

Here's the link to the trac ticket: http://trac.xbmc.org/ticket/5299

To write an EventClient in C++, you use the class CXBMCClient defined in xbmcclient.h. The SendButton method is used to send button presses to XBMC. Be sure to have a look at xbmcclient.h - there you find which flags the SendButton method supports.

That's it in a nutshell. Have a look at the code, it's rather self-explanatory.


Thanks - jhsrennie - 2008-11-12

The problem I had was working out what to send. For example I worked out that you have to OR the keycode with 0xF000 by trial and error. Also my example doesn't work unless I include BTN_QUEUE in the flags, but I can't find a description of what this flag means or why it might be necessary. I notice your code does not use it.

John Rennie


- frain - 2008-11-12

I solved the problem of knowing which strings to send for which buttons by looking at ButtonTranslator.cpp - in the Translate*String functions you can find the names used for the buttons/keys.

I don't know about the BTN_QUEUE flag, though - my code appears to work without it.


- WiSo - 2008-11-13

Unfortunately I can't test this due to a missing x360 controller but I'm happy that someone tried the event client method. It would be nice if we could get more event clients also for other remotes and together with topfs we might add missing pieces to the event server.


- jhsrennie - 2008-11-13

Having to run separate processes is always going to be clunky. The event server is neat, but I don't think it's ideal for supporting things like IR remotes. I can see a role for controlling XBMC remotely from a different PC, but I doubt this would be a common requirement.

The best solution would be to support event hooks in a dll. This is pretty standard practice in Windows, though I don't know how easy it would be to do cross platform without an untidy maze of #ifdefs.

JR


- Awen - 2008-11-24

@jhsrennie: could you be more specific ? On a low scaled htpc, i can evaluate how task switching may be painful, fe while decoding some hd video... but on a reasonably modern box, i'm pretty confident about multitasking a bunch(3-4) of spinning tasks, and still having good response-time... Is the hd decoding, the worst case situation you're afraid of ?
Awen


- ultrabrutal - 2008-11-24

Would it be possible to get it to work on the old Xbox provided you add the wireless receiver via USB available for the pc?


- bb10 - 2009-01-06

Can't get this patch applied with tortoiseSVN, it doesn't like line 486 for some reason...


- frain - 2009-01-06

ultrabrutal Wrote:Would it be possible to get it to work on the old Xbox provided you add the wireless receiver via USB available for the pc?

I do not know this, but my guess would be: no. You would need to ask someone who is more familiar with the Xbox port of XBMC than me to know for sure, though.

bb10 Wrote:Can't get this patch applied with tortoiseSVN, it doesn't like line 486 for some reason...

Well, the patch should apply cleanly to the SVN version from two months ago, when I submitted it Smile

I'll have a look at problem as soon as I can and report back.


- bb10 - 2009-01-07

frain Wrote:Well, the patch should apply cleanly to the SVN version from two months ago, when I submitted it Smile

I'll have a look at problem as soon as I can and report back.

Well, to be honest, I tried it 2 months ago and tortoiseSVN didn't like it back then either. I just ignored it as I thought it would be added to SVN anyway.

Last night I thought I would try it again, and it failed. I decided to patch it manually.

I encountered a few problems like the unknown location of xbmcclient.h, so I tried to add it to the headerfiles. That didn't work so I copied it to the xbox360evenclient folder and it compiled (with BuildSetup.bat), but only the eventclient and no XBMC. Tongue

Thanks for the reply though, I'll wait for an updated patch. Smile


- ultrabrutal - 2009-01-10

frain Wrote:I do not know this, but my guess would be: no.

Well the XBMC xbox version has the event server built in, so basicly adding a USB receiver to my server and two Xbmc 360 wireless remotes, should make it possible to access these two Xboxes? You see I have 3 xboxes and only one working logitech controller left Sad The two Xboxes are close enough for my PC server to be able to work with the USB receiver I think.


- frain - 2009-01-17

ultrabrutal Wrote:Well the XBMC xbox version has the event server built in, so basicly adding a USB receiver to my server and two Xbmc 360 wireless remotes, should make it possible to access these two Xboxes? You see I have 3 xboxes and only one working logitech controller left Sad The two Xboxes are close enough for my PC server to be able to work with the USB receiver I think.

Ah, I think I misread your original question. To clarify: I believe it will be impossible to use the XBox360 Controller by connecting the USB receiver directly to the XBox.

On the other hand, using the XBox360 Controller together with the EventClient on Windows and telling the EventClient to send events to the XBMC instance running on the XBox should work! I think this is what you were referring to anyways, I'm sorry that I misunderstood your post!

In any case, I haven't been able to work on updating the patch yet. I hope to be able to do some work on it either this or the next weekend. Sorry about the delay!


- frain - 2009-01-18

bb10 Wrote:Thanks for the reply though, I'll wait for an updated patch. Smile

I posted an updated diff to http://trac.xbmc.org/ticket/5299. The diff should now apply cleanly to the SVN version (this time, I checked out a fresh copy and verified this fact).