XBOX 360 Wireless controller
#1
Hello XBMC team,

Impressed with the latest developpment of XBMC I just replaced my old XBOX1 with a brand new ASRock Vision 3D. I installed Windows 7 Ultimate and XBMC 10.0. I also installed a XBOX 360 Wireless controller and like some users on this forum I encountered issues with the native support of the controller.

After a few days of research and tweaking I managed to create a joystick.Microsoft.Xbox.360.Wireless.Controller.xml file that simulate pretty closely the old XBOX controller.

Here is the global and FullscreenVideo sections :
Code:
<keymap>
  <global>
    <joystick name="Controller (Xbox 360 Wireless Receiver for Windows)">
      <button id="1">Select</button>                             <!-- A -->
      <button id="2">ParentDir</button>                         <!-- B -->
      <button id="3">FullScreen</button>                        <!-- X -->
      <button id="4">ContextMenu</button>                        <!-- Y -->
      <button id="5">Stop</button>                                <!-- LB -->
      <button id="6">Pause</button>                                <!-- RB -->
      <button id="7">PreviousMenu</button>                        <!-- Back -->
      <button id="8"></button>                                    <!-- Start -->
<!--      <button id="9">Playlist</button>    -->                        <!-- L-Pad Click -->
      <button id="10">XBMC.ActivateWindow(settings)</button>    <!-- R-Pad Click -->
<!--      <hat id="1" position="up">Up</hat>    -->                    <!-- D-Pad Up -->
<!--      <hat id="1" position="down">Down</hat>    -->                <!-- D-Pad Down -->
<!--      <hat id="1" position="right">Right</hat>    -->                <!-- D-Pad Right -->
<!--      <hat id="1" position="left">Left</hat>    -->                <!-- D-Pad Left -->
      <axis limit="-1" id="1"></axis>                            <!-- L-Pad Left -->
      <axis limit="+1" id="1"></axis>                            <!-- L-Pad Right -->
      <axis limit="-1" id="2"></axis>                            <!-- L-Pad Up -->
      <axis limit="+1" id="2"></axis>                            <!-- L-Pad Down -->
      <axis limit="-1" id="3">ScrollDown</axis>                    <!-- RT -->
      <axis limit="+1" id="3">ScrollUp</axis>                    <!-- LT -->
      <axis limit="-1" id="4">VolumeUp</axis>                    <!-- R-Pad Up -->
      <axis limit="+1" id="4">VolumeDown</axis>                    <!-- R-Pad Down -->
      <axis limit="-1" id="5">AnalogSeekBack</axis>                <!-- R-Pad Left -->
      <axis limit="+1" id="5">AnalogSeekForward</axis>            <!-- R-Pad Right -->
    </joystick>

<!-- ... -->

  <FullscreenInfo>
    <joystick name="Controller (Xbox 360 Wireless Receiver for Windows)">
      <button id="2">Close</button>
      <button id="3">CodecInfo</button>
      <button id="6">Close</button>
      <button id="4">OSD</button>
      <axis limit="-1" id="3">AnalogFastForward</axis>
      <axis limit="+1" id="3">AnalogRewind</axis>
    </joystick>
  </FullscreenInfo>

<!-- ... -->

  </global>


The main issue with this configuration file is that it doesn't handle the D-Pad. I could not find a way to have the Jump functions configured to those keys without loosing the DVD menu navigation. In order to have everything work like the old XBOX I had to use Xpadder to configure the D-Pad to simulate the Arrow Keys. So I am using both Xpadder and the native support to make it work perfectly.

So here is my first question: Is it possible to have functions configured to the D-Pad without loosing the DVD navigation ?

My second concern is an issue I noticed again with the Wireless controller. XBMC doesn't handle events from the wirelesss controller if it is not synched before XBMC starts. This is a problem because if you forget to turn on the controller on when booting the HTPC you can find yourself in XBMC without any means to control it. If you only have a wireless X360 controller (without Xpadder to simulate a mouse) the only way out is to reboot the PC.
Is there a workaround for this issue or a fix coming ?

Thank you for your great work, help and comments.
Reply
#2
Since my last post I setup the build environment and started to create my own builds like I used to do with the old XBOX.
I have discovered that the joystick initialization is done only during the boot of XBMC so if another pad is added later on it will not be detected.
I added a few lines of code to solve this problem.

In WinEventsWin32.cpp, CWinEventsWin32::WndProc():
Code:
case WM_DEVICECHANGE:
      newEvent.type = XBMC_SYSWMEVENT;
      newEvent.syswm.msg = (XBMC_SysWMmsg *)WM_DEVICECHANGE;
      m_pEventFunc(newEvent);
      break;

In Application.cpp, CApplication::OnEvent() :
Code:
case XBMC_SYSWMEVENT:
      {
#ifdef HAS_SDL_JOYSTICK
        // Reinit SDL joystick layer otherwise it will not detect new joysticks
        if ((INT_PTR)newEvent.syswm.msg == WM_DEVICECHANGE)
        {
          SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
          SDL_InitSubSystem(SDL_INIT_JOYSTICK);
          g_Joystick.Initialize();
        }
#endif
      }
      break;

This little patch works ok and new joysticks are detected in XBMC. I tested this on my dev machine with a Wired X360 controller.

But there is one thing I am not completely satisfied with here. I think that casting WM_DEVICECHANGE into newEvent.syswm.msg is not the right way to go to discriminate XBMC_SYSWMEVENT. Maybe there is a more elegant way that I overlooked.

Can a developer from the team comment on this ?
Thank you.
Reply
#3
You can try 360eventclient.

http://forum.xbmc.org/showthread.php?tid...ventClient
Reply
#4
You should create a ticket with your patch. The forum is too volatile I think.
For troubleshooting and bug reporting please make sure you read this first (usually it's enough to follow instructions in the second post).
Reply
#5
evil-B Wrote:Since my last post I setup the build environment and started to create my own builds like I used to do with the old XBOX.
I have discovered that the joystick initialization is done only during the boot of XBMC so if another pad is added later on it will not be detected.
I added a few lines of code to solve this problem.

In WinEventsWin32.cpp, CWinEventsWin32::WndProc():
Code:
case WM_DEVICECHANGE:
      newEvent.type = XBMC_SYSWMEVENT;
      newEvent.syswm.msg = (XBMC_SysWMmsg *)WM_DEVICECHANGE;
      m_pEventFunc(newEvent);
      break;

In Application.cpp, CApplication::OnEvent() :
Code:
case XBMC_SYSWMEVENT:
      {
#ifdef HAS_SDL_JOYSTICK
        // Reinit SDL joystick layer otherwise it will not detect new joysticks
        if ((INT_PTR)newEvent.syswm.msg == WM_DEVICECHANGE)
        {
          SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
          SDL_InitSubSystem(SDL_INIT_JOYSTICK);
          g_Joystick.Initialize();
        }
#endif
      }
      break;

This little patch works ok and new joysticks are detected in XBMC. I tested this on my dev machine with a Wired X360 controller.

But there is one thing I am not completely satisfied with here. I think that casting WM_DEVICECHANGE into newEvent.syswm.msg is not the right way to go to discriminate XBMC_SYSWMEVENT. Maybe there is a more elegant way that I overlooked.

Can a developer from the team comment on this ?
Thank you.

Great stuff. Does it work with wireless controller?(i think it should)
Reply
#6
evil-B Wrote:My second concern is an issue I noticed again with the Wireless controller. XBMC doesn't handle events from the wirelesss controller if it is not synched before XBMC starts. This is a problem because if you forget to turn on the controller on when booting the HTPC you can find yourself in XBMC without any means to control it. If you only have a wireless X360 controller (without Xpadder to simulate a mouse) the only way out is to reboot the PC.
Is there a workaround for this issue or a fix coming ?

Thank you for your great work, help and comments.

Thanks will try this.

Does it mean you use this keymap and control xbmc without any eventghost/eventclient running in the background?

As far as the "controller must be on before xbmc start issue" is concerned. I have a very simple workaround to propose. You can use your pad to launch xbmc Smile. I use START key +A combo to launch xbmc on my TV.
Reply
#7
RazorFR Wrote:Thanks will try this.

Does it mean you use this keymap and control xbmc without any eventghost/eventclient running in the background?

As far as the "controller must be on before xbmc start issue" is concerned. I have a very simple workaround to propose. You can use your pad to launch xbmc Smile. I use START key +A combo to launch xbmc on my TV.

What program are you using to launch XBMC with the controller?
Reply

Logout Mark Read Team Forum Stats Members Help
XBOX 360 Wireless controller0