Hello There,
I've written a very little piece of python code that uses
William R Sowerbutts's rudimentary (his own words) python
interface to the powermate device.
BE WARNED!! This hack will crash your pymol session when you type
"quit" to terminate your pymol session. this wouldn't be a problem if
it didn't leave python threads floating around...Anyone knows a workaround?
The safest way to quit is to "CTRL-C" the prompt that started pymol.
This a first announcement. /dev/input/event* is indeed the future...
Cheers,
Zac
HOWTO:
1) put the python interface (powermate.py) in ${PYMOL_PATH}/modules
http://www.sowerbutts.com/powermate/powermate.py
2) put the code below in your $HOME/.pymolrc.py
3) tweak the line that says CONFIGURE to match your setup
#
# code below starts here
#
def powermate_reader(): # thread for reading powermate dial
import sys
from pymol import cmd
from powermate import PowerMate
dial_down = 0
pm1 = PowerMate('/dev/input/event1') #CONFIGURE
while 1:
event = pm1.WaitForEvent(1)
if event == None:
continue
sec,usec,type,code,value = event
if code == 256:
dial_down = not dial_down
continue
if dial_down:
cmd.turn('x',value)
else:
cmd.turn('y',value)
pm = threading.Thread(target=powermate_reader)
print 'PowerMate'
pm.setDaemon(1)
pm.start()