Setting up keymapping for XBMC (specifically for PS2 users)

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
crcook84 Offline
Junior Member
Posts: 10
Joined: Feb 2013
Reputation: 0
Post: #1
I've recently aquired a USB adapter for a PS2 controller. After much trial and error, I managed to figure out the key mapping for the controller and how to apply commands so as to make the controller useful in XBMC. First off, the location of my keymap (because I use portable XBMC) is XBMC (base folder) > system > keymaps. Second, it didn't take much effort to plug in the controller and adapter and have Windows install the drivers. However, the Windows drivers are limited. As such, I recommend (if you want to be able to use all the buttons, the D-pad, and both analogs) installing this driver file.

http://www.1file-download.com/File/bijcaeglompg

Third, the analog button on the controller is only capable of enabling/disabling the analog sticks.

Here's the basic controller, keymap layout:
Code:
<keymap>
  <global>
    <joystick name="USB Network Gamepad">

      <altname>PLAYSTATION 2 Controller</altname>
      <altname>PS2 Controller</altname>
      <altname>Sony Computer Entertainment Controller</altname>

      <button id="1">Triangle</button>
      <button id="2">Circle</button>
      <button id="3">X</button>
      <button id="4">Square</button>
      <button id="5">L2</button>
      <button id="6">R2</button>
      <button id="7">L1</button>
      <button id="8">R1</button>
      <button id="9">Select</button>
      <button id="10">Start</button>

      <!-- Left Analog -->
      <axis id="1" limit="-1">Left</axis>
      <axis id="1" limit="+1">Right</axis>
      <axis id="2" limit="-1">Down</axis>
      <axis id="2" limit="+1">Up</axis>
      <button id="11"></button>

      <!-- Right Analog -->
      <axis id="3" limit="-1">Down</axis>
      <axis id="3" limit="+1">Up</axis>
      <axis id="4" limit="-1">(Non-functional)</axis>
      <axis id="4" limit="+1">(Non-functional)</axis>
      <button id="12"></button>

      <!-- D-Pad -->
      <hat id="1" position="up">Up</hat>
      <hat id="1" position="right">Right</hat>
      <hat id="1" position="down">Down</hat>
      <hat id="1" position="left">Left</hat>

    </joystick>
  </global>
</keymap>
As you can see, I've managed to find most of the functions on the controller. Fortunately, there was a PS3 keymap I was able to use for reference.

Where it says "joystick name", you need to find the ID of your controller to be able to use it. For the life of me, I can't figure out how I found mine. However, if you're game, one way it can be identified is by looking in the registry file (regedit) and searching for "oemname". You'll know you're in the right place when you find a directory listing similar to this "Joystick > OEM" and under that you'll find listings similar to this "VID_0079&PID_0006". You'll need to comb through those listings until you find the right "OEMname". My suggestion is jot down all the names you can find, map one of the buttons on your controller "Select", then save the keymap file with each of the different names until the button works with one of them.

There's only 1 control I was unable to, either, identify or utilize: <axis id="4">, which is the left-right axis on the right analog, in either direction. I labeled it non-functional. If anyone can figure out what the ID is, more power to ya. On my device settings, it's called 4(Rz).

The axis controls are very sensitive. I've tried setting the limit from .5 to 5 but it didn't seem to make a difference. Also, I tried adding the negative and positive characters so that the keymap would identify the axis as moving in one direction or another. It didn't help. Also, if you want to use the axis controls, you'll need to add controls for both sides of the axis. Not that you wouldn't add both sides. It just doesn't work if you don't. Ex:

Won't work:
<axis id="1" limit="-1">Left</axis>
<axis id="1" limit="+1"></axis>

Will Work:
<axis id="1" limit="-1">Left</axis>
<axis id="1" limit="+1">Right</axis>

As for programming the buttons, if you've been using your keyboard up till now, I suggest you reference it. I was able to "guess" some of the commands to be able to start keymapping my controller. But, I've started to rely on my keyboard file for some of the more specific controls.

Here's my keymap:
Code:
<keymap>

  <global>
    <joystick name="USB Network Gamepad">
      <altname>PLAYSTATION 2 Controller</altname>
      <altname>PS2 Controller</altname>
      <altname>Sony Computer Entertainment Controller</altname>

      <button id="1"></button>
      <button id="2">Select</button>
      <button id="3">Play</button>
      <button id="4">Stop</button>
      <button id="5"></button>
      <button id="6"></button>
      <button id="7">Back</button>
      <button id="8">Select</button>
      <button id="9"></button>
      <button id="10">ActivateWindow(shutdownmenu)</button>
      <button id="11"></button>
      <button id="12"></button>

      <!-- Left Analog -->
      <axis id="1" limit="-1"></axis>
      <axis id="1" limit="+1"></axis>
      <axis id="2" limit="-1"></axis>
      <axis id="2" limit="+1"></axis>
      <button id="11"></button>

      <!-- Right Analog -->
      <axis id="3" limit="-1"></axis>
      <axis id="3" limit="+1"></axis>
      <axis id="4" limit="-1"></axis>
      <axis id="4" limit="+1"></axis>
      <button id="12"></button>

      <!-- D-Pad -->
      <hat id="1" position="up">Up</hat>
      <hat id="1" position="right">Right</hat>
      <hat id="1" position="down">Down</hat>
      <hat id="1" position="left">Left</hat>

    </joystick>
  </global>

  <FullscreenVideo>
    <joystick name="USB Network Gamepad">
      <hat id="1" position="right">StepForward</hat>
      <hat id="1" position="left">StepBack</hat>
      <button id="1">Info</button>
    </joystick>
  </FullscreenVideo>

</keymap>
(This post was last modified: 2013-07-28 20:00 by crcook84.)
find quote
crcook84 Offline
Junior Member
Posts: 10
Joined: Feb 2013
Reputation: 0
Post: #2
In case anyone doesn't know this, because the keymap file uses the XML format, it works very similarly to the HTML markup language.

Here are some tweaks I made to my final keymap (by the way, the spaces aren't neccessary, it's just less confusing for me):
Code:
<keymap>

  <global>
    <joystick name="USB Network Gamepad">
      ...
      <button id="1">FullScreen</button>
      ...
    </joystick>
  </global>

  <FullscreenVideo>
    <joystick name="USB Network Gamepad">
      <hat id="1" position="left">StepBack</hat>
      <hat id="1" position="right">StepForward</hat>
      <axis id="1" limit="-1">Rewind</axis>
      <axis id="1" limit="+1">FastForward</axis>
    </joystick>
  </FullscreenVideo>

</keymap>
In particular, I have programmed <button id="1"> (the triangle on the PS2) to clear the screen during playback in case you start file browsing and want to go back to your video or accidentally move the mouse. As for full screen video, the <hat> buttons are set to do frame stepping during playback and the <axis>, if you move it gingerly, is actually rather useful for fastforward or rewind.

I'm sure I don't need to say this next part. But, the control configuration set under <FullscreenVideo> needs to stay there if you want your buttons to have multiple configurations depending on what you're doing at any one time. Also, I tried putting the "FullScreen" command under <FullscreenVideo> but it lost half it's function when I did that.
find quote
crcook84 Offline
Junior Member
Posts: 10
Joined: Feb 2013
Reputation: 0
Post: #3
After looking through some log files, I stumbled across the log file I used to find my gamepad ID for XBMC. As for how to find it, enable debugging by going to System > System > Debugging and select "Enable debug logging". (I'd recommend restarting XBMC so that it can cycle through the connected devices.) White text will appear showing you where the debug file will be located. Here's what I found:
Code:
19:54:23 T:4816  NOTICE: CJoystick::EnumJoysticksCallback : Enabled Joystick: USB Network Gamepad
Considering the fact that most gamepads will act like joysticks, it shouldn't be too difficult to find the log line by looking for the word "joystick".
find quote
crcook84 Offline
Junior Member
Posts: 10
Joined: Feb 2013
Reputation: 0
Post: #4
Further evidence of the fact that you can have multiple commands for one button, I have reassigned the "button id's" for 3 and 4 under <global> to "Select" and "Back" and added those same "id's" to the <FullscreenVideo> section, assigning them "Play" and "Stop". I can play and pause with those buttons in full screen while being able to browse through the XBMC menu.

(In case it isn't blatantly obvious: No, the button will not give off both commands at the same time. They are "Select" and "Back" while browsing and "Play" and "Stop" while in full screen playback.)
find quote
Saraya Offline
Junior Member
Posts: 40
Joined: Dec 2013
Reputation: 0
Post: #5
Hi Cook.

Mayo sent me over here to have a look at this, since I mentioned possibly using a PS2 controller for XBMC navigation.
Thanks for taking the time out to post your findings and I will probably make use of it for very specific custom commands.

In the meantime for a more quick start approach to using a controller, I would add that Xpadder is a nice tool that emulates both key strokes and mouse movement/buttons. I use this often on the PC when games do not have native controller support (or fail to recognize the Xbox 360/Rumblepad emulator called 360CE).

I've tested it and it works well with XBMC - as it is just replicating the mouse and keyboard.
Generally I have Dpad or left analog stick as the keyboard up/down/left/right. Right analog is the mouse cursor. R1/R2 buttons serve as the mouse left/right.
Anything else after that will be for custom command, so thanks again.
(This post was last modified: 2013-12-12 16:50 by Saraya.)
find quote
crcook84 Offline
Junior Member
Posts: 10
Joined: Feb 2013
Reputation: 0
Post: #6
(2013-12-12 16:49)Saraya Wrote:  Hi Cook.

Mayo sent me over here to have a look at this, since I mentioned possibly using a PS2 controller for XBMC navigation.
Thanks for taking the time out to post your findings and I will probably make use of it for very specific custom commands.

In the meantime for a more quick start approach to using a controller, I would add that Xpadder is a nice tool that emulates both key strokes and mouse movement/buttons. I use this often on the PC when games do not have native controller support (or fail to recognize the Xbox 360/Rumblepad emulator called 360CE).

I've tested it and it works well with XBMC - as it is just replicating the mouse and keyboard.
Generally I have Dpad or left analog stick as the keyboard up/down/left/right. Right analog is the mouse cursor. R1/R2 buttons serve as the mouse left/right.
Anything else after that will be for custom command, so thanks again.
Thanks for that. I was having a hard time finding any information about how to make a custom keymap file. So, I just made my own. Although, I wondered how popular it would be considering versions of the XBOX controller seems to be more popular because it’s easier to hook up to a PC. On that note, it’s nice to see a fellow PS2 enthusiast.

I, also, use Xpadder. When I first got the controller working, I thought about how I could make it work with racing games. Fortunately, most of my games recognized the controller. Those that didn’t, I found an appropriate Xpadder PS2 image and started mapping all the buttons. What I liked the most was that every button was mappable and the analog button allowed for the axises to be enabled/disabled (you’ll know why from the post).
find quote