..:: PCSX2 Forums ::..

Full Version: XInput Wrapper for DS3 and Play.com USB Dual DS2 Controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
(05-02-2014, 11:15 PM)roninx Wrote: [ -> ]What driver version are you using?

USB\VID_0A12&PID_0001. Is this what you are asking? Is on the list.

Is a generic Bluetooth USB dongle 2.0.
(05-02-2014, 11:33 PM)Danat Wrote: [ -> ]No. Aren't L3 and R3 buttons ? I need pressure sensitive triggers that would work like pedals. Mapping R2 to R3 would just make it a button, no ?
Just in case - I need to use analog sticks as well for that game (left stick to look around and right stick to steer the wheel).

But anyways, I've just managed to modify the source code so that R2 maps to another joystick's R2 (the Reserved one) and now I can use both triggers without sacrificing anything. It is at moments like these it feels good to be a programmer Wink.

If someone needs this stuff I made, I can post some code samples that need to be inserted in original source.

Yea I know L3 and R3 are buttons. I thought it would have been better than nothing. Please post the samples of the changes you made. I'm sure it'll help others. In fact, I'm having trouble with JoyToKey because it doesn't recognize the L2 and R2 triggers. Maybe your modifications could solve my problem. Although I don't see a Game Controller icon in my Control Panel.

edit: nevermind the Xbox 360 Controller icon is in Devices and Printers but I still only see one icon.




(05-02-2014, 11:42 PM)CarloxTheBoy Wrote: [ -> ]USB\VID_0A12&PID_0001. Is this what you are asking? Is on the list.

Is a generic Bluetooth USB dongle 2.0.

No I mean what SCP driver are you using? Did you install 1.2.0.160 and then update with 1.2.2.175?
Quote:Please post the samples of the changes you made. I'm sure it'll help others.
I've opened the sln file in VS2010. Then I did this...

ScpControl_2010/UsbHub.cs
Code:
public partial class UsbHub : ScpHub
    {
        public static UsbDevice[] GlobalDevice = null;

        protected UsbDevice[] Device = new UsbDevice[4];                

        public UsbHub()
        {
            InitializeComponent();

            if (GlobalDevice == null)
                GlobalDevice = Device;
        }
Explanation: added a static variable that will hold reference to all 4 usb devices. I do that because otherwise I can't reach that array where I need it.

ScpControl_2010/ScpUtil.cs
Code:
public class Ds3InputHelper
    {
        public static byte GetAxisValue(byte[] Input, Ds3Axis Axis)
        {
            return Input[(UInt32)Axis];
        }

        public static void SetAxisValue(byte[] Input, Ds3Axis Axis, byte Value)
        {
            Input[(UInt32)Axis] = Value;
        }

        public static Ds3Button GetButtons(byte[] Input)
        {
            return (Ds3Button)((Input[10] << 0) | (Input[11] << 8) | (Input[12] << 16) | (Input[13] << 24));
        }

        public static void SetButtons(byte[] Input, Ds3Button Buttons)
        {
            Input[10] = (byte)(Buttons);
            Input[11] = (byte)((int)Buttons >> 8);
            Input[12] = (byte)((int)Buttons >> 16);
            Input[13] = (byte)((int)Buttons >> 24);            
        }
    }
Explanation: Added a helper class so that I can easily modify button/trigger states.

ScpControl_2010/UsbDevice.cs
Code:
protected virtual void Publish()
        {
            m_ReportArgs.Report[0] = m_ControllerId;
            m_ReportArgs.Report[1] = (Byte) m_State;

            Ds3Button Buttons = Ds3InputHelper.GetButtons(m_ReportArgs.Report);
            byte R2Value = Ds3InputHelper.GetAxisValue(m_ReportArgs.Report, Ds3Axis.R2);

            Ds3InputHelper.SetButtons(m_ReportArgs.Report, Buttons & ~Ds3Button.R2);
            Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.R2, 0);

            if (Report != null) Report(this, m_ReportArgs);

            foreach (UsbDevice device in UsbHub.GlobalDevice)
            {
                if (device.State == DsState.Reserved)
                {
                    m_ReportArgs.Report[0] = device.m_ControllerId;
                    m_ReportArgs.Report[1] = (Byte)m_State;

                    Ds3InputHelper.SetButtons(m_ReportArgs.Report, Buttons & Ds3Button.R2);
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.L2, 0);                    
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.R2, R2Value);
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.LX, 0);
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.LY, 0);
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.RX, 0);
                    Ds3InputHelper.SetAxisValue(m_ReportArgs.Report, Ds3Axis.RY, 0);

                    if (Report != null) Report(this, m_ReportArgs);

                    break;
                }
            }          
        }
Explanation: Modified Publish() method so that when R2 is pressed, it's value and button state are set to zero for real joystick and then the actual value is used for the second joystick. Note that I also zero all irrelevant axis values for the second joystick.

Oh and by the way in order to have two XBOX gamepads in Control Panel -> Game Controllers I needed to unplug my DS3 controller and plug it in again. When it is unplugged, the xbox gamepad icon remains, but when I plug the controller back in, the second icon appears. Once you stop/restart the ScpService service, you need to repeat this procedure again (plug DS3, unplug, plug)
Just in case - I'm using Windows XP SP3.
EDIT: Fixed some bugs in my third code sample.
EDIT: Fixed another bug in third code sample. Things look stable now.

I've attached the binary and source files of this mod. The package also contains some explanations on how to use.
(05-02-2014, 11:43 PM)roninx Wrote: [ -> ]No I mean what SCP driver are you using? Did you install 1.2.0.160 and then update with 1.2.2.175?

I have installed 1.2.0.160, but i don't updated to 1.2.2.175. I gonna update this now.

EDIT: I uninstalled 1.2.0.160, updated to 1.2.2.175 and reinstalled SCP Server with force install. bluetooth still not working.
I am also currently having a problem with my DS3 over bluetooth. It works fine plugged in, but no long works over my bluetooth connection (it stopped for no reason). When I remove the USB plug, SCP Monitor displays it as BTH 00000000 None. I don't know why this suddenly stopped working, and why nothing seems to fix it. I uninstalled the drivers from the wrapper, as well as all of the bluetooth drivers for my dongle and any drivers installed by Windows 8 for my controller. Short of a disc wipe, I don't know what else I could possibly remove.
(05-03-2014, 12:14 AM)CarloxTheBoy Wrote: [ -> ]I have installed 1.2.0.160, but i don't updated to 1.2.2.175. I gonna update this now.

EDIT: I uninstalled 1.2.0.160, updated to 1.2.2.175 and reinstalled SCP Server with force install. bluetooth still not working.


I don't know what else to think of. I had the same problem as you before, with my DS3 controller not working through bluetooth. I uninstalled SCP drivers, then plugged in my usb bluetooth controller, connected my DS3 controller through usb, then force installed SCP driver 1.2.0.160, and then updated with latest drivers and it worked.

After you install the SCP drivers do you see all 5 entries in the Install Summary like in the screenshot: http://forums.pcsx2.net/attachment.php?aid=47326
(05-03-2014, 12:08 AM)Danat Wrote: [ -> ]I've opened the sln file in VS2010. Then I did this...

Thanks for the code. Unfortunately I don't have VS2010 so I can't open the .sln file. Maybe the author can incorporate this into the next update.
(05-01-2014, 03:54 PM)jesalvein Wrote: [ -> ]why would we. after dozens of users using it without reporting any problem, it's easy to guess it's a false positive

I do not intend to sound sarcastic but isn't that the very definition of a trojan? Just being concerned about my computer security that's all.
@MCZ: from your report link -

- 1 positive [TrendMicro-HouseCall]
- 37 negative [TrendMicro, Malwarebytes, McAfee, Symantec, etc ...]

Tends to suggest a false positive?
(05-02-2014, 11:43 PM)roninx Wrote: [ -> ]In fact, I'm having trouble with JoyToKey because it doesn't recognize the L2 and R2 triggers. Maybe your modifications could solve my problem. Although I don't see a Game Controller icon in my Control Panel.

To get the triggers R2 and L2 working in JoytoKey without mapping the triggers to buttons is easy, first go to the JoytoKey preferences and make sure "Use Axes other than X and Y" is checked, then go back to the joystick profile and:
Axes3(<0) is R2
Axes3(>0) is L2

best regards,
- dink
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510