..:: PCSX2 Forums ::..

Full Version: Analog controls on Linux: The Hacky way
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all! First of all, sorry for my english. I'm not a native speaker.
Some games I really like (like "Marvel Ultimate Alliance" and "God Hand") are only playable if you can use Analog Controls and I don't have a Pad (broken Sad ...). So I modified the ZeroPad plugin so I could use the keyboard as a Analog Control.
Since I did it only for my personal use, the code is very messy and I didn't bother to add these buttons to the configuration file: I just hard-coded them on the plugin.
This was almost a year ago. I kept telling myself I would make it the right way, with a configuration window and all that, and post it here. But I just procrastinate and done nothing. I'm not sure if it's worth the trouble since I don't know if people are going to use it.
So I thought "better this way than nothing to the people out there. If I couldn't program, I would like to have it even in this state".
If a lot of people start using I will do it the proper way and maybe, who knows, it gets merged in the main project.
Here is how to use it:
Download the code here:
http://www.linux.ime.usp.br/~lenin/zeropad.tar.bz2
Put it inside the plugin dir in the pcsx2 dir.
Then do the following commands:
Code:
tar -xvjf zeropad.tar.bz2
cd zeropad
sh build.sh
cp libZeroPAD.so.* ..
(Or just uncompress it, run the build.sh file and copy the result through the file manager)
There you go! Done!
In this version the left analog Control is configured to the directionals arrows and the right to Home, Delete, End, Page Down.
To modify this settings, open the file zeropad.h
In the line 111 you will see something like this:
Code:
#define KEY_PAD_RY_UP            0xff50
#define KEY_PAD_RY_DOWN            0xff57
#define KEY_PAD_LY_UP            0xff52
#define KEY_PAD_LY_DOWN           0xff54
#define KEY_PAD_RX_LEFT            0xffff
#define KEY_PAD_RX_RIGHT        0xff56
#define KEY_PAD_LX_LEFT            0xff51
#define KEY_PAD_LX_RIGHT        0xff53
#define DEF_VALUE          32766

These are the button codes. KEY_PAD_RY_UP is the Up button of the right controller. KEY_PAD_LX_LEFT is the Left button of the left controller, etc.
DEF_VALUE is the strength you press the control. This value (32766) is the maximum. If you want a lighter touch, decrease it.
To discover the key code of some key you can do the following procedure:

Open the file ini/zeropad.ini. Save a copy of it.
Open PCSX2 and put the key you want in some other button.
Compare the new ini/zeropad.ini with the old one and see what changed.
Put the code that changed in the proper location in zeropad.h
Repeat until done

After any change in zeropad.h, don't forget to build and copy again.

Well, that is it. I know it's ugly, that's why I didn't wanted to release it, but as I said, better than nothing.

Any problems, contact me

Farewell
Could be a good feature to have in ZeroPad. I'm not promising anything, but if at some point I hack up a gui for it, I could very well add it to ZeroPad. I'm mainly not promising anything because I'm very easily distractible. Smile

Thanks for sharing the code, in any case...
--Arcum42
First of all thanks for this. I haven't been able to try it yet, but when I get it working I'm sure I'll appreciate it. Anyways, when I try to compile on Ubuntu 8.10 I get the following output:

Code:
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
gcc -DPACKAGE_NAME=\"ZeroPAD\" -DPACKAGE_TARNAME=\"zeropad\" -DPACKAGE_VERSION=\"0.2\" -DPACKAGE_STRING=\"ZeroPAD\ 0.2\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE=\"ZeroPAD\" -DVERSION=\"0.2\" -DNDEBUG=1 -DHAVE_LIBSDL=1 -I. -I./../../common/include     -O2 -fomit-frame-pointer -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/SDL    -MT libZeroPAD_a-zeropad.o -MD -MP -MF .deps/libZeroPAD_a-zeropad.Tpo -c -o libZeroPAD_a-zeropad.o `test -f 'zeropad.cpp' || echo './'`zeropad.cpp
In file included from zeropad.cpp:25:
zeropad.h:44:22: error: PS2Edefs.h: No such file or directory
In file included from zeropad.cpp:25:
zeropad.h:81: error: ‘u8’ does not name a type
zeropad.h:123: error: ‘keyEvent’ does not name a type
zeropad.h:125: error: ‘u16’ does not name a type
zeropad.h:126: error: ‘u32’ does not name a type
zeropad.h:128: error: ‘u32’ was not declared in this scope
zeropad.h:128: error: ‘u32’ was not declared in this scope
zeropad.h:128: error: initializer expression list treated as compound expression
zeropad.h:129: error: ‘s32’ does not name a type
zeropad.h:131: error: ‘u32’ has not been declared
zeropad.h:132: error: ‘u32’ has not been declared
zeropad.cpp:39: error: ‘keyEvent’ does not name a type
zeropad.cpp:41: error: ‘u16’ does not name a type
zeropad.cpp:45: error: ‘PS2E_PAD_VERSION’ was not declared in this scope
zeropad.cpp:50: error: ‘u32’ does not name a type
zeropad.cpp:51: error: ‘u8’ does not name a type
zeropad.cpp:57: error: ‘u8’ does not name a type
zeropad.cpp:59: error: ‘u8’ does not name a type
zeropad.cpp:61: error: ‘u8’ does not name a type
zeropad.cpp:63: error: ‘u8’ does not name a type
zeropad.cpp:65: error: ‘u8’ does not name a type
zeropad.cpp:67: error: ‘u8’ does not name a type
zeropad.cpp:69: error: ‘u8’ does not name a type
zeropad.cpp:71: error: ‘u8’ does not name a type
zeropad.cpp:73: error: ‘u8’ does not name a type
zeropad.cpp:75: error: ‘u8’ does not name a type
zeropad.cpp:90: error: expected constructor, destructor, or type conversion before ‘*’ token
zeropad.cpp:100: error: redefinition of ‘int POV’
zeropad.h:128: error: ‘int POV’ previously defined here
zeropad.cpp:100: error: ‘u32’ was not declared in this scope
zeropad.cpp:100: error: ‘u32’ was not declared in this scope
zeropad.cpp:109: error: ‘u32’ has not been declared
zeropad.cpp: In function ‘void _KeyPress(int, int)’:
zeropad.cpp:115: error: ‘status’ was not declared in this scope
zeropad.cpp:120: error: ‘event’ was not declared in this scope
zeropad.cpp:120: error: ‘KEYPRESS’ was not declared in this scope
zeropad.cpp: At global scope:
zeropad.cpp:124: error: ‘u32’ has not been declared
zeropad.cpp: In function ‘void _KeyRelease(int, int)’:
zeropad.cpp:130: error: ‘status’ was not declared in this scope
zeropad.cpp:135: error: ‘event’ was not declared in this scope
zeropad.cpp:135: error: ‘KEYRELEASE’ was not declared in this scope
zeropad.cpp: At global scope:
zeropad.cpp:186: error: ‘u32’ does not name a type
zeropad.cpp:190: error: expected initializer before ‘PS2EgetLibName’
zeropad.cpp:195: error: ‘u32’ does not name a type
zeropad.cpp:209: error: ‘s32’ does not name a type
zeropad.cpp:245: error: expected initializer before ‘PADshutdown’
zeropad.cpp:529: fatal error: opening dependency file .deps/libZeroPAD_a-zeropad.Tpo: Permission denied
compilation terminated.
make: *** [libZeroPAD_a-zeropad.o] Error 1

Any ideas?
Source of errors is here:

zeropad.h:44:22: error: PS2Edefs.h: No such file or directory

You need to state the exact location. For this you could get last sources from pcsx2 plugin and use makefile.am from it. You need this string: INCLUDES = -I@srcdir@/../../common/include