normal not to write anything here not related to comics and my drawings, but hey, since I have the blog, then publish this book I've written in a flash, for interest:
Well, this is a small manual to get the most out of your wiimote under linux.
is well known that the Wii Remote works with Bluethoot, so in order to use it, we will have the Bluethoot running on our machine, and of course a Wiimote (the remote).
first thing to do is throw these modules, uinput and evdev to make things work well, I've made a script:
# / bin / bash sudo modprobe
uinput
sudo sudo modprobe evdev mkdir / dev / misc
sudo ln-s / dev / input / uinput / dev / misc / uinput
sudo chmod 666 / dev / misc / uinput
also have to create a link in / dev / misc / uinput to know where the WMD. Depending on your distro the uinput will be / dev / input / or elsewhere in ubuntu at least it's there. Search for it and make a link as I do here.
The second step is to download the library WMD ( http://www.forthewiin.org/ ), which is in python is that going to make life easier. Once downloaded the file ( http://forthewiin.org/WMD/wmd-0.1.2.tar.gz ) is decompressed:
tar-xzvf
wmd-0.1.2.tar.gz
and enter the directory cd
wmd-0.1.2
Once inside, we can launch the script that comes to see that everything works fine: python
WMD.py
have to synchronize the command, pressing 1 and 2 at a time, or the red button is for sync. It will not work first time because he has wearing a mac is not going to be yours and will be the one to look at first, but no problem, just wait until you say, "Now Trying to discover a Wiimote willing, please activate your Wiimote Within 5 seconds. " and then press 1 and 2 at a time, and so find it. We see emerging some graphs, and when you press a button which you can see down and stuff. Once
seen it work, we are ready to use control as a remote control. I'll explain how to use it to manage the mplayer, and I'll just use the buttons, but with the wmd is also very easy to define a function to handle events of the accelerations in three axes, another thing is to find useful. You can also use the mouse with the wiimote, but this does not quite know how it goes. Using
wmd.
The truth is that I'm not sure how it works, I've only played a little in order to use the Wiimote as a remote control, as well as joistick for a game, but I have not gotten further.
To use this library we have to put our script in python in the same directory as the script WMD.py. So we edit our file. Py, adding these headers, which are those that have the WMD.py:
sys.path.append import sys from ('.')
wmd.Common import * from wmd.
CFG Config import from import wmd.UI.UIManager UIManager
wmd.Wiimote.WMManager import from WMManager
wmd.EVDispatcher import from EVDispatcher
wmd.MotionSensing import from MSManager
wmd.Pointer import from POManager
wmd.CommandMapper import from CommandMapper
I also used the years, to make system calls, so should also be put: import os
wii_buttons define a function, for example, that is to be called whenever there is a button event in the controller: def
wii_buttons (buttons):
buttons receives a vector whose first component is the name of the key pressed, and the second event, UP or DOWN
Each time you press a button, we call the system to send a keystroke event. This I do with the command xsendkeycode, which is passed a keycode (you can do with xev) and an event 1 for pressed, 0 for up. Xsendkeycode To command, you must install the lineakd.
if buttons [1] == "DOWN" buttons
if [0] == "A":
os.popen2 (xsendkeycode "+ str (code) +" 1 ")
os.popen2 that does is create a new process with the last call as an argument, as if launched from a terminal .
Once defined all the actions to the buttons, you must write the body of the script:
CFG create an object, you need the EVDispatcher, and
WMManager
cf = CFG
EVDispatcher create an object, by passing the CFG created earlier
EVDispatcher
ev = (cf)
Add the role defined for the buttons EVDispatcher, with constant WM_BT to call our function each occurrence of an event button-press
ev.subscribe (WM_BT, wii_buttons)
create a WMManager, connect, do a setup, and launch the main loop.
WMManager wm = (cf, ev)
wm.connect ()
wm.setup ()
wm.main_loop ()
With this as our script would be ready, and every time we press a button is as pulsars if a keyboard key. With this we could map the multimedia keys, thereby achieving a remote control.
an example, we can handle this mplayer with the Wii Remote (A play-pause, B switch to fullscreen, +, - Up and decrease the volume, 1 to enable, disable osd, 2 enable, disable subtitles):
import os import sys sys.path.append
('.')
wmd.Common
from import * from wmd.Config import
CFG
wmd.UI.UIManager import from UIManager
wmd.Wiimote.WMManager import from WMManager
wmd.EVDispatcher import from EVDispatcher
wmd.MotionSensing import from MSManager
wmd.Pointer import from POManager
wmd.CommandMapper import from CommandMapper
def
wii_buttons (buttons):
code = 65 # spacio
CODEBASE = 41 # f
Codema = 63 # *
codeMinus = 112 # /
CODEH escape
= 9 # 32 # or code1 = code2 =
55 # v
codeU = 98 #
coded arrow down arrow = 104 # 100 #
Codel = left arrow = 102 # coder
right arrow buttons if
[1] == "DOWN" buttons
if [0] == "A":
os.popen2 (xsendkeycode "+ str (code) +" 1 ") elif
buttons [0] ==" B ":
os.popen2 (xsendkeycode" + str (codeBase) + "1") elif
buttons [0] == "+":
os.popen2 (xsendkeycode "+ str (Nicodemus) +" 1 ") elif
buttons [0] == '-':
os.popen2 ("xsendkeycode" + str (codeMinus) + "1") elif
buttons [0] == "H":
os.popen2("xsendkeycode "+str(codeH)+" 1")
elif buttons[0] == "1":
os.popen2("xsendkeycode "+str(code1)+" 1")
elif buttons[0] == "2":
os.popen2("xsendkeycode "+str(code2)+" 1")
elif buttons[0] == "U":
os.popen2("xsendkeycode "+str(codeU)+" 1")
elif buttons[0] == "D":
os.popen2("xsendkeycode "+str(codeD)+" 1")
elif buttons[0] == "L":
os.popen2("xsendkeycode "+str(codeL)+" 1")
elif buttons[0] == "R":
os.popen2("xsendkeycode "+str(codeR)+" 1")
elif buttons[1] == "UP":
if buttons[0] == "A":
os.popen2("xsendkeycode "+str(codeA)+" 0")
elif buttons[0] == "B":
os.popen2("xsendkeycode "+str(codeB)+" 0")
elif buttons[0] == "+":
os.popen2("xsendkeycode "+str(codeMas)+" 0")
elif buttons[0] == "-":
os.popen2("xsendkeycode "+str(codeMinus)+" 0")
elif buttons[0] == "H":
os.popen2("xsendkeycode "+str(codeH)+" 0")
elif buttons[0] == "1":
os.popen2("xsendkeycode "+str(code1)+" 0")
elif buttons[0] == "2":
os.popen2("xsendkeycode "+str(code2)+" 0")
elif buttons[0] == "U":
os.popen2("xsendkeycode "+str(codeU)+" 0")
elif buttons[0] == "D":
os.popen2("xsendkeycode "+str(codeD)+" 0")
elif buttons[0] == "L":
os.popen2("xsendkeycode "+str(codeL)+" 0")
elif buttons[0] == "R":
os.popen2("xsendkeycode "+str(codeR)+" 0")
cf = CFG
ev = EVDispatcher(cf)
ev.subscribe (WM_BT, wii_buttons)
WMManager wm = (cf, ev)
wm.connect ()
wm.setup ()
wm.main_loop ()