
In the
last article I talked about the module exclusively for the EE mode. In this chapter I will talk about a rather complicated, difficult to understand, but giving many possibilities module
This module is recommended to be used for games where only one joystick is used.
There is multitap support, but I will not talk about it for this module.
There is a special library libpad2. The library uses the Emotion Engine (EE) and Input Output Processor (IOP) coprocessor.
')
To use it, at the moment, it is possible only for conventional digital controllers, DualShock and DualShock 2.
Libraries for connecting EE: “libdbc.a” and “libpad2.a”. Header files: “libdbc.h” and “libpad2.h”.
Modules for IOP connection: “sio2man.irx” (version 2.4 or higher), “sio2d.irx”, “dbcman.irx”, controller driver modules (***. Irx).
IOP modules are loaded using the sceSifLoadModule () function after loading the EE application.
Modules use virtual sockets.
The following modules are used to connect controller drivers:
Module name | Digital controller | Dualshock | Dualshock 2 |
ds1u.irx | Supports | Supports | DualShock emulation |
ds2u.irx | Supports | Supports | Supports |
dgco.irx | Supports | Digital controller emulation | Digital controller emulation |
ds1o.irx | Not compatible | Supports | DualShock emulation |
ds2o.irx | Not compatible | Not compatible | Supports |
Drivers switch automatically when certain controllers are connected.
Also, the number of loaded drivers must match the number of controllers used.
How to do it?
Each controller has its own driver.
For controller 1, there are: ds1u_s1.irx, ds2u_s1.irx, dgco_s1.irx, ds1o_s1.irx, ds2o_s1.irx.
For controller 2: ds1u_d.irx, ds2u_d.irx, dgco_d.irx, ds1o_d.irx, ds2o_d.irx.
Use a second controller is not desirable.
Module procedures
sceSifLoadModule () is used to load sio2man.irx, sio2d.irx and dbcman.irx in the same sequence.
sceDbcInit () and scePad2Init () are used to initialize libdbc and libpad2.
scePad2CreateSocket () - used to create a socket for working with the controller. The first parameter is the port number (or NULL for the first controller) and the second is a 64 byte profile through which data will be transmitted.
scePad2ButtonProfile () - reads data from the socket and passes to the buffer. Parameters are socket and buffer.
scePad2Read () - reads button data. Parameters are the same.
scePad2GetState () - checks the state of the controller. Parameters are the same.
scePad2DeleteSocket () - deletes a socket. The parameter is the socket number.
scePad2End () and sceDbcEnd () - terminate the work of libpad2 and libdbc, respectively.
The simplest program code will look like this:
<br>main(){<br> int socket_number;<br> unsigned char rdata[32];<br> unsigned char profile[10];<br> u_long128 pad_buff[SCE_PAD2_DMA_BUFFER_MAX]__attribute__((aligned(64)));<br> sceDbcInit();<br> scePad2Init();<br> socket_number = scePad2CreateSocket( NULL, pad_buff );<br> while (1) {<br> scePad2ButtonProfile( socket_number, profile );<br> scePad2Read( socket_number, rdata );<br> // <br> }<br> scePad2DeleteSocket( socket_number );<br> scePad2End();<br> sceDbcEnd();<br>}<br> <br> * This source code was highlighted with Source Code Highlighter .
Controller profiles
The profile shows the features of the controllers, i.e. all information about the connected controller, which buttons are present and the number.
Each bit of the profile describes an individual controller feature. If the controller has the required capability, then the bit will be set to 1 and 0 - for lack of support.
The profile is 4 bytes of information that Sony wanted to expand in the future.
Byte | Bit | Button | Number of bits allocated |
0 | 0 | Select | one |
one | L3 (pressing the left stick) | one |
2 | R3 (click on the right stick) | one |
3 | Start | one |
four | Up arrow | one |
five | Right arrow | one |
6 | Arrow to down | one |
7 | Left arrow | one |
one | eight | L2 | one |
9 | R2 | one |
ten | L1 | one |
eleven | R1 | one |
12 | Triangle | one |
13 | A circle | one |
14 | X | one |
15 | Square | one |
2 | sixteen | Analog mode: Right stick translated X | eight |
17 | Analog mode: Right stick translated by Y | eight |
18 | Analog mode: Left stick translated X | eight |
nineteen | Analog mode: Left stick translated by Y | eight |
20 | Analog mode: Right arrow | eight |
21 | Analog mode: Left arrow | eight |
22 | Analog mode: Up arrow | eight |
23 | Analog mode: Arrow to down | eight |
3 | 24 | Analog mode: Triangle | eight |
25 | Analog mode: A circle | eight |
26 | Analog mode: Cross | eight |
27 | Analog mode: Square | eight |
28 | Analog mode: L1 | eight |
29 | Analog mode: R1 | eight |
thirty | Analog mode: L2 | eight |
31 | Analog mode: R2 | eight |
Analog mode implies sensitivity.
For a digital controller, all analogs, R3 and L3 will be zero. Therefore, the profile for him will look like this:
Byte | Bit | Button | Number of bits allocated |
0 | 0 | Select | one |
one | Start | one |
2 | Up arrow | one |
3 | Right arrow | one |
four | Arrow to down | one |
five | Left arrow | one |
6 | L2 | one |
7 | R2 | one |
one | eight | L1 | one |
9 | R1 | one |
ten | Triangle | one |
eleven | A circle | one |
12 | X | one |
13 | Square | one |
14 | -Pusto- | one |
15 | -Pusto- | one |
Cases
It may happen that the user turns off the digital controller and connects the analog one.
The driver will switch automatically. And you can incorrectly process the data.
In case the controller is disabled, the scePad2GetState () function will return scePad2StateNoLink. If the controller is connected back after this, the scePad2GetState () function will return scePad2StateStable. It is advisable to call the scePad2GetState () function to check the disconnection before each frame.
At the end.
This type of information on the controller buttons is suitable for both modes.
Monitor the controllers must constantly.
On this about the controllers only the library of vibration remains, but I will tell you later, i.e. in the end.
PS : I think that's enough for today.