Results 1 to 6 of 6

Thread: [TUTORIAL] PS3 OpenAxis - Read Controller Status from PC - [1/17/2011]

  
  1. #1
    akrutsinger is offline -Hacks Newbie
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default

    *NOTE: I don't have any websites or anything to host pictures so for now they are as attachments on my xda-developers forum post here: http://forum.xda-developers.com/showthread.php?t=918519 If anyone can help me out that would be awesome

    I have began setting up a project page using google project hosting. You can download the source code from here: http://code.google.com/p/openaxis/

    I know its been done already, but as hard as I looked I couldn't find any kind of source code for the ps3sixaxis_en program that lets you use the controller on windows. So I spent the day messing around with USBTrace, GlovePIE, and the controller. So it begins...

    I used GlovePIE (for no particular reason) to find the USB Request Block that gets the status of the controller.



    After I found the URB that gets the controller I used the python script from DIY Kinect Hacking tutorial



    I'm not going to go into detail about how to set everything up (i.e. pyusb, libusb, etc). The DIY Kinect Hacking article is awesome and includes all the preliminary steps.

    So after setting up the script and running it all I had to do was press the buttons and watch the screen and analyze what changed. Here is an example of pressing the start button.



    Here you can also see the joystick X and Y values. when you move a joystick all the way left the X value equals 0 and all the way right it equals 255. Same goes for the Y values. up=0, down=255

    So with the bit of knowledge I learned today I made a few modification to the OpenKinect c# code. All i have it doing is printing some of the buttons to the console window when you press them on the controller.



    I figured that was enough for a proof of concept. I can't attach the source here. It's in my post on xda-developers forum. I used SharpDevelop but visual studio should open the solution fine.


    heres a breakdown of the structures the controller sends to the host

    Code:
    struct CONTROLLER_DATA
    {
    	ushort ????
    	byte DIRECTION_PAD
    	byte BUTTON_PAD
    	byte PS_POWER_BUTTON	//0-depressed; 1-pressed
    	byte ??
    	JOYSTICK_POSITION LEFT_JOYSTICK
    	JOYSTICK_POSITION RIGHT_JOYSTICK
    	ushort
    	ushort
    	ushort
    	ushort	
    	byte BTN_L2_VALUE		//0-depressed; 255-fully pressed
    	byte BTN_R2_VALUE		//0-depressed; 255-fully pressed
    	byte BTN_L1_VALUE		//0-depressed; 255-fully pressed
    	byte BTN_R1_VALUE		//0-depressed; 255-fully pressed
    	ushort
    	ushort
    	ushort
    	byte
    	byte ??	//seems to always be 3
    	byte ??	//seems to always be 239
    	byte ??	//seems to always be 22
    	ushort
    	ushort
    	byte ??	//seems to always be 51
    	byte ??	//seems to always be 60
    	byte ??	//does change. possibly motor?
    	byte ??	//seems to always be 1
    	byte ??	//does change. possibly motor?
    	byte HIT	//Not for sure but appears to be 1 normally, then becomes 2 if the controller is hit
    	byte ROLL	//0-centered; left-positive; right-negative
    	byte ??	//seems to always be 2
    	byte PITCH	//0-centered; up-positive; down-negative
    	byte ??	//seems to always be 1
    	byte Z_AXIS	//Not sure what axis this is. It does change with movement tho
    	byte ?? //seems to always be 1
    	byte ??	//accelerometer perhaps? values are positive when you move controller left and negative when 
    			//you move the controller right
    };
    
    enum DIRECTION_PAD : byte
    {
    	SELECT	= 0x01
    	BTN_L3	= 0x02
    	BTN_R3	= 0x04
    	START	= 0x08
    	UP		= 0x10
    	RIGHT	= 0x20
    	DOWN	= 0x40
    	LEFT	= 0x80
    };
    
    enum BUTTON_PAD : byte
    {
    	LEFT2		= 0x01
    	RIGHT2		= 0x02
    	LEFT1		= 0x04
    	RIGHT1		= 0x08	
    	TRIANGLE	= 0x10
    	CIRCLE		= 0x20
    	CROSS		= 0x40
    	SQUARE		= 0x80	
    };
    
    struct JOYSTICK_POSITION
    {
    	byte X_AXIS		//0-LEFT; 255-RIGHT
    	byte Y_AXIS		//0-UP; 255-DOWN
    };
    References:
    DIY Kinect Hacking Great tutorial
    OpenKinect Edited his code for my pof
    LibUSBDotNet The driver that has to be used with the device


  2. #2
    Fantafaust is offline -Hacks Smarty
    Join Date
    Jan 2011
    Location
    Newport
    Posts
    185
    Rep Power
    9

    Default

    Ah, very good stuff here. I've always had problems with the Ps3 controller on windows, the drivers always want to go and fail.

    Walking through, I see the light. It guides me towards my destiny. Do you not see yours?
    Favorite game: Resident Evil 2, and it damn sure needs a remake, with story fully intact, and environment/characters translated to higher detail. Gameplay mechanics need a rev too.

  3. #3
    akrutsinger is offline -Hacks Newbie
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default

    yeah, I need help with idea on where to take this from here. I'm working an a simple app that will just show you the status of the remote in a window, but I know thats not what people want. Right now I'm kind of lacking the creativity and applicability for this app. I did set up an svn repo at http://code.google.com/p/openaxis/ if anyone is interested.

    IDEAS WELCOME AND ENCOURAGED!!!!

  4. #4
    iJect is offline -Hacks Newbie
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    use it in ps1/ps2 emulators. that requires little work once its installed though. Heres an idea, i dont know if this is possible, but find some way to use it on emulators on iDevices.

  5. #5
    Mr_WoRRieD is offline Gone fishin -Hacks Guru
    Join Date
    Aug 2007
    Posts
    1,691
    Rep Power
    0

    Default

    i don't think akrutsinger still is looking for an solution.

  6. #6
    imported_Toddimyre is offline -Hacks Newbie
    Join Date
    Feb 2011
    Location
    Mississippi
    Posts
    5
    Rep Power
    0

    Default

    I'm not intentionally going to try and steal your thunder here, but while I was looking for a driver to use a PS3 controller on my PC, I found a program called Motion in Joy. The website is http://www.motioninjoy.com/download/ for anyone that's interested. After the somewhat annoying setup process, the PS3 controller will work via USB and Bluetooth (also something I was looking for). The only real bug I found to the program is that it doesn't like to properly load your last used profile. To fix that bug, just change the controller type, set it, change it back, set it again (there's a button at the bottom of the screen to set it). Also, you have to be online to use the program unless you find one of the various "Local Profiles" in their forums. A few final notes, it supposedly works with the 6-axis motion, but I don't have a game that I can really test that feature on. It'll also work really well with Xpadder for those that like to use controllers on your MMOs and whatnot.

    As I said, I'm not trying to steal your thunder, but maybe you can get ahold of the working program (or even the developer) and figure out a better way to implement it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •