The known parts of the struct can be accessed by name. Why did I use this? Because now it is possible to fill the complete structure using a memcpy to a PS3Data* and then be able to access all requested attributes both by name and by byte offset. This way we can use PS3_data.Circle instead of (PS3_data.data&0x02) This makes it possible to map a number of bool's to a BYTE. The variable PS3_data.LAnalogX shares the same memory location with PS3_data.data. This makes it possible to let multiple variables be positioned on the same physical memory location. So you can map two structs to the same location, without the need to give this struct a name.
Instead of PS3_ we can simply use PS3_data.LAnalogX.Ī second feature is the abilty to use the struct in a union. This makes it possible to 'group' a set of variables, while not needing to add the struct name in the variable name. Three of the features used are nameless struct, nameless union and data width settings: One nice thing about C is the ability to let the compiler help in splitting up a raw data structure. Digital and analog values.įor demo purposes I also made a ' Format' method, which make a output string, to show in the dialog of the current state of the controller. This thread will contiuosly fill a struct of type PS3_data.
#PS3 CONTROLLER BUTTONS PS3#
When a PS3 controller is connected the ' ThreadPS3' is created. When the application is started it will register for device-connection events. Some info I found was mad for accessing a USB temperature device from Cyprus Using the HID class eases the job of writing USB device drivers.įor a big explanation on the USB-HID calls, look at the last link. Some info I found was using delphi SixAxis on Windows. (Tested under Windows XP and Windows Vista).
#PS3 CONTROLLER BUTTONS DRIVER#
The PS3 controller does get recognized by Windows, but before the controller reacts on our request, the following driver should be installed. I made a variable for all buttons, so even the combined bits in a BYTE are mapped to a 'bool'. The biggest trick is the mapping of the received data-block to a nice and easy struct. But it does provide the eager programmer a way to communicate with a PS3 controller. This is not yet a complete highly re-usable library.