Tuesday, April 9, 2013

emuclient --config PS3_Battlefield3_McKack.xml --port /dev/ttyUSB0 --type joystick --refresh 4

Sunday, April 7, 2013

Simulate Mouse Clicks on Python



The evdev package provides bindings to parts of the input handling subsystem in Linux. It also happens to include a pythonic interface to uinput.
Example of sending a relative motion event and a left mouse click with evdev:
from evdev import UInput, ecodes as e

capabilities = {
    e.EV_REL : (e.REL_X, e.REL_Y), 
    e.EV_KEY : (e.BTN_LEFT, e.BTN_RIGHT),
}

with UInput(capabilities) as ui:
    ui.write(e.EV_REL, e.REL_X, 10)
    ui.write(e.EV_REL, e.REL_Y, 10)
    ui.write(e.EV_KEY, e.BTN_LEFT, 1)
    ui.syn()

Raspberry Pi linux-headers 3.1.9+


Note by Dean:  I have made some changes from the original post to match my 3.1.9+ environment
by shig » Sun Sep 23, 2012 6:31 am
So, as the standard debian kernel packaging system isn't used (the kernel and module are all in the raspberrypi-bootloader package), and the headers aren't distributed, you will need to download the source tree from the github at https://github.com/raspberrypi/linux/. You won't have to recompile it however.

Here a quick guide. I'm assuming that you already have build-essential/compiler/everything else you need in place anyhow, and just need the kernel specific headers and symbols.

Download the kernel source and unpack it with:
CODE: SELECT ALL
sudo bash
cd /usr/src
git clone --depth 1 git://github.com/raspberrypi/linux.git

Then we'll grab the config from the raspberry pi's running kernel, and get the source tree to prepare itself for module builds:
CODE: SELECT ALL
cd linux
zcat /proc/config.gz > .config
make oldconfig
make modules_prepare

What you will also need to build modules that will actually go into the new kernel is Modules.symvers. Luckily, someone has nicely put it in the raspberrypi/firmware github along with the pre-compiled kernel and firmware binaries, so we can just download the latest one from there:
CODE: SELECT ALL
wget https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers

Then just make symlinks available in /lib/modules/[kernelversion]/ for the stuff you're compiling. Might as well put a symlink in for /usr/src/linux etc as well
CODE: SELECT ALL
KSRC=`pwd`
pushd /lib/modules/`uname -r`
ln -s ${KSRC} source
ln -s ${KSRC} build
popd

pushd /usr/src
ln -s ${KSRC} linux-`uname -r`
ln -s ${KSRC} linux
popd

Apart from the time downloading, the rest should take about 10 minutes or so hopefully, depending on how fast the storage you've got available is. This will also take up about 630MB of space under /usr/src until you clean it up

Hope this helps