===============================================================================================================================
Release 0.8
===============================================================================================================================
- fixed the remapping issues where the controller seemed buggy when it was enabled
- added custom and native driver input mode
- added VSH/In-Game menu
- added wireless DS3/DS4 support (needs usb BT adapter)
- added game compatibility modes (fixes GTAV & RDR)
- added multiple remap settings
- added user configurable settings file (xpad_settings.txt)
- added user configurable controller delay which sets response time of controller
- added auto game detection and attach to game proc
- added disconnect/reset all ports option
- added screenshot option

All Supported controllers:
  Xbox S-type (untested)
  Xbox 360 (wired & wireless)
  Xbox One (wired)
  PS3 Controllers (wired & wireless)
  PS4 Controllers (wired & wireless)

Only the official Xbox 360 controller (VID: 0x45e PID: 0x028e), Xbox 360 receiver (0x45e, 0x0719), and Xbox One controller (0x45e, 0x02d1) are hardcoded.
You will need to edit plugins/ps3xpad/xpad_devices.txt for other devices.
Note: Not all third party Xbox controllers may work with this plugin.

===============================================================================================================================
Compatibility Chart:
===============================================================================================================================
Custom Driver Mode       | CEX | DEX | Notes
------------------------------------------------------------------
Wired 360, One           |  X  |  X  |
Wireless 360             |  X  |  X  | Needs usb Xbox 360 wireless adapter
Wired DS3, DS4           |  X  |  X  |
Wireless DS3, DS4        |  X  |  X  | Needs usb bluetooth adapter
VSH Menu                 |  X  |  X  |
In-Game Menu             |     |  X  | Needs DEX Eboot for game
Rumble Support           |     |  X  | Needs DEX Eboot for game
Button Remapping         |  X  |  X  |
Game compatibility modes |     |  X  | Needs DEX Eboot for game
------------------------------------------------------------------
Native Driver Mode       | CEX | DEX | Notes
------------------------------------------------------------------
Wired 360, One           |     |     |
Wireless 360             |     |     |
Wired DS3, DS4           |  X  |  X  |
Wireless DS3, DS4        |  X  |  X  |
VSH Menu                 |  X  |  X  |
In-Game Menu             |     |  X  | Needs DEX Eboot for game
Rumble Support           |     |  X  | Needs DEX Eboot for game. Only for DS3 controllers
Button Remapping         |     |  X  | Needs DEX Eboot for game
Game compatibility modes |     |  X  | Needs DEX Eboot for game

===============================================================================================================================
Installation
===============================================================================================================================
Pre-reqs:
1. You will need custom firmware with Cobra enabled. (Most newer CFWs have this)

2. (Optional for rumble support) DEX kernel & convert your game's EBOOT.BIN to debug EBOOT.BIN.
There are mulltiple ways of doing this such as using TrueAncestor SELF Resigner
Note: Some games such as GTAIV will have more than one .BIN file. You will need to convert all .BIN files to debug

===============================================================================================================================
Method 1: Running XPAD with PRX Loader or Cobra boot_plugins + Button Combo
===============================================================================================================================
This method will run XPAD first in VSH and then switch to a game after it has booted.
If you do not wish to use rumble, you may skip steps 5 to 7.

1. Copy the plugins folder to /dev_hdd0/. You should have the directory /dev_hdd0/plugins/ps3xpad/ with xpad_vsh.sprx, xpad_game.sprx and xpad_devices.txt in it.
Note: If you use gameDATA utility, you will need to transfer the folder before and after you enable gameDATA.

2. Add this line to plugins.txt if you're using PRX Loader or to boot_plugins.txt if you're using Cobra:
  /dev_hdd0/plugins/ps3xpad/xpad_vsh.sprx

3. Either reboot your PS3 or run PRX Loader to run the xpad plugin under VSH.
You should be able to see the "XPAD Loaded (VSH)" message and your Xbox controller connected.
If you're using an Xbox One controller, hold down the Xbox button to make it connect.
If you're using a wireless Xbox 360 controller, you may need to sync your controller to the receiver.

4. Start your game and wait until it has fully booted.

5. Press (START+SELECT+R3). You should see a message displaying "XPAD Loaded (GAME)".

6. Wait a few seconds and your Xbox controller should be reconnected.
If you're using a wireless controller, read the notes below on how to properly resync the controller using a button combo.

7. You should now be able to play your game with rumble enabled.

Note for running the game plugin: While a game is running, the VSH plugin will run in the background and check every 10 seconds for when the game has exited.
                                  Once a game has exited, control will be back to the VSH plugin.

===============================================================================================================================
Method 2: Using webMAN-MOD Plugin
===============================================================================================================================
1. Follow steps 1 and 2 of method 1.

2. Download the latest webMAN-MOD plugin.
Be sure to select webman_server_rebug_cobra_ps3mapi.sprx if you're using Rebug CFW or webman_server_ps3mapi.sprx if you're using another CFW.
I will use webman_server_rebug_cobra_ps3mapi.sprx as an example.

3. Copy webman_server_rebug_cobra_ps3mapi.sprx to /dev_hdd0/plugins/

4. Add this line to plugins.txt if you're using PRX Loader or to boot_plugins.txt if you're using Cobra:
  /dev_hdd0/plugins/webman_server_rebug_cobra_ps3mapi.sprx

5. Either reboot your PS3 or run PRX Loader to run webMAN-MOD.

6. Start your game and wait until it has fully booted.

7. Log on to webMAN with your browser using your PS3's IP address as the URL and click on the PS3MAPI tab.

8. Scroll down to the Game Plugins section and select your game's process. Usually it will have the name EBOOT in it. Click on Set

9. You will get a page with all your game's plugins loaded. Go to the first free slot and enter /dev_hdd0/plugins/ps3xpad/xpad_game.sprx. Click on Load.

10. Wait a few seconds and your Xbox controller should be connected.
Note: If you're using a wireless controller, you will need to re-sync using a button combo.
      Do this by pressing (START+BACK+DPAD DOWN) and then holding the XBOX button for a couple seconds.
      Your wireless controller should then reconnect.

11. You should now be able to play your game with rumble enabled.

===============================================================================================================================
Controller Not Being Recognized In Game
===============================================================================================================================
Most games work without needing anything special but if you have trouble getting your controller recognized in game, try the following steps in order.

1. Try reassigning your controller to different slots.
You can do this by holding down the Xbox button or PS button and going to Controller Settings.

2. Attach XPAD plugin to game process by following the methods described above.

3. Enable compatibility mode by pressing (START+SELECT+DPAD_UP).
Note: Compatibility mode installs hooks to the game and therefore a debug EBOOT.BIN of the game is needed.
      Compatibility mode only allows one controller to be used and must be assigned to port 1.

Games tested that need compatibility mode on:
  Red Dead Redemption (XPAD plugin needs to be attached to VSH)
  Grand Theft Auto V (XPAD plugin needs to be attached to VSH)
  Soul Calibur IV
  Soul Calibur V

===============================================================================================================================
Xbox 360 Wireless Controller Notes:
===============================================================================================================================
You may connect up to 4 wireless controllers with a single receiver.
If you're using a wireless controller, you will need to re-sync using a button combo each time you swith from VSH to GAME or from GAME to VSH.
Do this by pressing (START+SELECT+DPAD_DOWN) and then holding the XBOX button for a couple seconds. Your wireless controller should then reconnect.

===============================================================================================================================
Playstation DualShock 4 Controller Notes:
===============================================================================================================================
The DualShock 4 controller driver enables rumble and sixaxis support. It also increases compatibility of some games over the official driver.
DS4 sixaxis sensors were about 4 times more sensitive than DS3s. I had to reduce it's sensitivity to make PS3 games compatible with the sixaxis.
DS4 controller PID/VIDs are not hardcoded. You will need to have them in xpad_devices.txt. This gives the option to switch between official/unofficial driver when using the xpad plugin.

===============================================================================================================================
Bluetooth Adapter Notes:
===============================================================================================================================
The driver is based on the USB host shield for Arduino. It should work for most generic adapters although I have only tested with one adapter.
A maximum of 4 controllers may be connected to a single adapter at a time.

To connect a DualShock 4 controller, first we need to set the internal bluetooth address of the controller.
You only need to do this the first time you connect the controller to the bluetooth adapter. There are two ways of doing this but I will show one way.

1. Connect your DualShock 4 through USB.
2. Start up your PS3 with the XPAD plugin loaded.
3. Press (START+SELECT+SQUARE) to open the VSH menu.
4. Go down and enter the bluetooth options menu.
5. Go down and select the "Set DS4 internal BT address" option.
6. You can now disconnect the DS4 controller and should connect wirelessly to the adapter.

===============================================================================================================================
Native Mode Notes:
===============================================================================================================================
I only recommend using native mode if you want to connect your controller wirelessly and do not have a BT adapter.
This mode also emulates pressure sensitivity and therefore games that did not work with DS4 controllers should work in this mode.
The requirements for using native mode is you need CFW with DEX kernel and your game Eboots must be converted to debug.

Here's a quick guide for connecting a DualShock 4 controller and playing a game with it.

1. Modify xpad_settings.txt and change "XPAD_MODE = 0" to "XPAD_MODE = 1"
2. Start up your PS3 with XPAD plugin loaded.
3. Connect your DS4 controller to the PS3 wirelessly like normal.
4. In the PS3 XMB, go to Settings, scroll down to Accessory Settings, select Reassign Controllers, and set the controller to port 7.
5. Start up your game and wait until it has loaded completely.
6. Press (START+SELECT+R3) to load the plugin into game proc.
7. You should now be able to play your game with the option of remapping and emulated pressure sensitivity.

===============================================================================================================================
Controller button combo summary:
===============================================================================================================================
(START+SELECT+SQUARE) Open VSH/GAME Menu
(START+SELECT+TRIANGLE) Take screenshot (Only works in XMB if VSH plugin is loaded or In-Game if game plugin is loaded)
(START+SELECT+CIRCLE) Save current XPAD settings
(START+SELECT+DPAD_UP) Enable compatibility mode
(START+SELECT+DPAD_DOWN) Disconnects Xbox 360 wireless controller from receiver. Allows wireless controllers to be resynced
(START+SELECT+DPAD_RIGHT) Enable/disable button remapping
(START+SELECT+DPAD_LEFT) Disable controller LED light
(START+SELECT+L1) Decrease controller response delay
(START+SELECT+R1) Increase controller response delay
(START+SELECT+R3) Switches XPAD plugin from VSH proc to GAME proc
(START+SELECT+L3) Unloads XPAD plugin

