Project - PS3 Controller

PS3 Controller

The PS3 Controller like most game controllers have bulk inputs, analog joysticks, triggers and buttons. The unique thing about PS3 controllers is that almost all the buttons can be read either as analog values or digital, directly from the controller. Another feature is the ability to communicate over both USB and Bluetooth. This example implements a PS3 controller driver using raw USB host services with a simple USB connection method. Bluetooth is also supported, via a Bluetooth dongle (Cambridge Silicon Radio (CSR) based).

The rest of the project is found on the wiki http://wiki.tinyclr.com/index.php?title=PS3_Controller

First… I have to tell you that this question is in NO WAY trying to be critical of the code you provided. I realize that alot of your time went into creating it and I am sure it works for you.

I am trying to use your code on a Fez Spider. I have a PS3 controller connected to a USB Host module (Connected at socket 3 (HI)). As a note I have tried 3 different controllers and I receive the same exceptions.

Using C# express 2010 with .NET Micro Framework 4.1 and I have modified your code (Debug.Print() messages) to better show the exceptions I am receiving.

I do NOT expect that you solve my problem. I am only asking (when and IF you have time) if you have any suggestions on where to start looking. My problem is related to using the Rumble button. As far as I know everything else works.

I guess my main question is why would I receive the device disconnect / device connect as shown in the debug messages below.

Gets a bit verbose…

Exceptions received: NOTE: I have added a few Debug.Print messages

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

Initialized
DEVICE CONNECT //A Debug message upon entering DeviceConnectedEvent(USBH_Device device)
PS3 controller was found
Enter ReaderThread() while loop 01/01/2009 01:30:17 //A Debug message upon entering DeviceConnectedEvent(USBH_Device device)
PS3 Controller: 1 - Connected
Enter ReaderThread() while loop 01/01/2009 01:30:17 //A Debug message upon entering ReaderThread() while (true) loop
Enter ReaderThread() while loop 01/01/2009 01:30:17
Enter ReaderThread() while loop 01/01/2009 01:30:17

**Removed a bunch of enter loop messages

Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
PS3 Controller: 1 - Start - Rumble is on
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
Enter ReaderThread() while loop 01/01/2009 01:30:31
PS3 Controller: 1 - RumbleLow
#### Exception System.Exception - 0xffffffff (7) ####
#### Message:
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData [IP: 001c] ####
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 003d] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
====private void ReaderThread()====
====try readPipe.TransferData====
01/01/2009 01:30:31
Exception was thrown: System.Exception
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData
PS3ControllerUSB.PS3Controller::ReaderThread

Enter ReaderThread() while loop 01/01/2009 01:30:31
#### Exception System.Exception - 0xffffffff (7) ####
#### Message:
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData [IP: 001c] ####
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 003d] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
====private void ReaderThread()====
====try readPipe.TransferData====
01/01/2009 01:30:32
Exception was thrown: System.Exception
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData
PS3ControllerUSB.PS3Controller::ReaderThread

Enter ReaderThread() while loop 01/01/2009 01:30:32
DEVICE DISCONNECT //A Debug message upon entering DeviceDisconnectedEvent(USBH_Device device)
#### Exception System.Threading.ThreadAbortException - 0x00000000 (7) ####
#### Message:
#### System.Threading.Thread::Sleep [IP: 0000] ####
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 0029] ####
PS3 Controller: 1 - Disconnected
DEVICE CONNECT
PS3 controller was found
Enter ReaderThread() while loop 01/01/2009 01:30:32
A first chance exception of type ‘System.Threading.ThreadAbortException’ occurred in mscorlib.dll
Enter ReaderThread() while loop 01/01/2009 01:30:32
PS3 Controller: 1 - Connected
Enter ReaderThread() while loop 01/01/2009 01:30:32
Enter ReaderThread() while loop 01/01/2009 01:30:32
Enter ReaderThread() while loop 01/01/2009 01:30:33

**Removed a few of enter loop messages

Enter ReaderThread() while loop 01/01/2009 01:30:33
Enter ReaderThread() while loop 01/01/2009 01:30:33
Enter ReaderThread() while loop 01/01/2009 01:30:33
PS3 Controller: 1 - RumbleOff
Enter ReaderThread() while loop 01/01/2009 01:30:33
Enter ReaderThread() while loop 01/01/2009 01:30:33
Enter ReaderThread() while loop 01/01/2009 01:30:33

Continues in loop forever

I only put the Debug.Print message in the ReaderThread() while loop for this post of the exceptions.
The code acts different (expected with the debug message) in the loop.

With no debug message in the reader thread loop the Rumble goes through the soft/hard rumble, stops, and then gives a short rumble about 10 seconds later.?

Below is the exception WITHOUT the debug message in the reader thread loop

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

Initialized
DEVICE CONNECT
PS3 controller was found
PS3 Controller: 1 - Connected
PS3 Controller: 1 - L1
PS3 Controller: 1 - R1
PS3 Controller: 1 - Start - Rumble is on
PS3 Controller: 1 - RumbleHigh
#### Exception System.Exception - 0xffffffff (7) ####
#### Message:
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData [IP: 001c] ####
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 0026] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
DEVICE DISCONNECT
#### Exception System.Threading.ThreadAbortException - 0x00000000 (7) ####
#### Message:
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData [IP: 001c] ####
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 0026] ####
PS3 Controller: 1 - Disconnected
====private void ReaderThread()====
====try readPipe.TransferData====
01/01/2009 01:09:54
Exception was thrown: System.Exception
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferPipe_Helper
GHIElectronics.NETMF.USBHost.USBH_RawDevice+Pipe::TransferData
PS3ControllerUSB.PS3Controller::ReaderThread

#### Exception System.Threading.ThreadAbortException - 0x00000000 (7) ####
#### Message: 
#### PS3ControllerUSB.PS3Controller::ReaderThread [IP: 008b] ####

A first chance exception of type ‘System.Threading.ThreadAbortException’ occurred in PS3 Controller.exe
DEVICE CONNECT
PS3 controller was found
PS3 Controller: 1 - Connected
PS3 Controller: 1 - RumbleOff

Thanks for any suggestions in advance.

REMEMBER Only if you have the time.

I moved this from wiki but I never used it myself so I am not able to help. Sorry

No need to be sorry. I just had to ask!

Thanks!