aboutsummaryrefslogtreecommitdiff
path: root/content/Informatique/wiimote.rst
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2014-05-09 14:30:46 +0200
committerSébastien Dailly <sebastien@chimrod.com>2014-05-12 21:19:34 +0200
commitb9e22325bb46e2611a73e54a3f0ade31800d1bd9 (patch)
tree60b8aa46b47ec7fd4b8c8d62821aeef0b22be1a5 /content/Informatique/wiimote.rst
parent23d7fb3e69d06b718a160c3ded763e6e6fbe3240 (diff)
Moved to pelican 3.3
Diffstat (limited to 'content/Informatique/wiimote.rst')
-rw-r--r--content/Informatique/wiimote.rst123
1 files changed, 0 insertions, 123 deletions
diff --git a/content/Informatique/wiimote.rst b/content/Informatique/wiimote.rst
deleted file mode 100644
index eb6641d..0000000
--- a/content/Informatique/wiimote.rst
+++ /dev/null
@@ -1,123 +0,0 @@
-.. -*- mode: rst -*-
-.. -*- coding: utf-8 -*-
-
-Controling the wiimote (I)
-##########################
-
-
-:date: 2009-03-11
-:tags: Programmation, Wiimote, Python
-:slug: controling-the-wiimote-i
-:lang: en
-
-
-Creating the plugin for wminput
--------------------------------
-
-There are a lot of tutorials about how to configure cwiid. I let you follow
-them for getting a functionnal system for your wiimote. You can read the links
-at the end of this article. Be sure your system works well before continuing.
-
-This is a code that we'll use as template for the creation of our driver. Used
-as main, it use pygame for displaying the infrared sources the wiimote can
-detect, but it is also compatible as plugin for wminput ( even if it does
-anything for now ).
-
-You can get it here :
-`wm\_control.py <http://www.chimrod.com/downloads/wiimote/ir_control_0.py>`_
-( This code is licenced under GPL 3+ )
-
-About the code :
-
-.. code-block:: python
-
- import wmplugin
-
-This import does not exist, but is created by wminput when executed. It provide
-the connexion with the wminput core. Just put ( or link ) the script in the
-wminput plugin path ( on my debian this is the /usr/lib/cwiid/plugins/ )
-
-.. code-block:: python
-
- def wmplugin_init(id, wiimote_arg):
- wmplugin.set_rpt_mode(id, cwiid.RPT_IR | cwiid.RPT_BTN)
- return
-
- def wmplugin_info():
- return [],
- [("X", wmplugin.REL | wmplugin.ABS, 1024, 0, 0, 0),
- ("Y", wmplugin.REL | wmplugin.ABS, 768, 0, 0, 0)],
- []
-
-We instanciate the wiimote object here and configure it in the IR mode. The
-name is choosen by wminput if we want to use it as plugin. We define that the
-plugin return the coordonates X and Y in a relative system (
-you can get the signification of all the parameters here : `actions list
-<http://abstrakraft.org/cwiid/browser/trunk/wminput/action_enum.txt>`_)
-
-If we want to define new butons, we just have to name them in the first list,
-the'll be accessible in the configuration file as plugin.[buton\_name] = ACTION
-
-.. code-block:: python
-
- def wmplugin_exec(messages):
- '''Wiimote callback managing method
- Recieves a message list, each element is different, see the libcwiid docs'''
- x = y = 0
-
- for msg in messages:
- if msg[0] == cwiid.MESG_IR:
- x, y = ir_sensor.get_movement(msg)
- return [], (x, y)
-
-Here is the core of our driver. The name is choosen by wminput too, as the
-format value we return. We have in parameter the list of the messages the
-wiimote has sent.
-
-If we have defined buton we need to return their state here. It is a boolean
-saying if the buton is pressed ( True ) or not ( False ).
-
-This method doesn't send any others parameters, and this is a problem when we
-need to store data between two calls ( ie for saving the cursor position ). One
-way for passing throught is to use global variables. But it is unelegant and
-can cause problems if we want to use our code in imports. So we'ill use a list
-as default parameter and let python save it as you can see here :
-
-.. code-block:: python
-
- >>> def meth(a=[]):
- ... a.append(1)
- ... print a
- ...
- >>> meth()
- [1]
- >>> meth()
- [1, 1]
- >>> meth()
- [1, 1, 1]
-
-So the ir\_sensor.get\_movement method is defined with each parameter we
-want to save as an optional list
-
-.. code-block:: python
-
- def get_movement(msg, _old_points=[], _old_position = [0, 0]):
- return 0, 0
-
-The get\_movement method need to return the difference between the old position
-of the cursor and the new one in tuple : (0, 0) mean that the cursor didn't
-move, (-10, 0) mean a deplacement to the left.
-
-For now, the plugin doesn't move the cursor, and doesn't read what the wiimote
-has sent. But you know everything for creating your own plugin for controlling
-your wiimote. You can use all the cwiid method for setting the led, activating
-the differents modes of your wiimote ( IR, Acc, rumble ... ), and define here
-your own actions.
-
-I'll explain the core of the movement analysis in IR mode in the next article.
-
-Links :
- `The cwiid project <http://abstrakraft.org/cwiid/>`_
-
-`Install Cwiid ( Ubuntu Documentation
-) <https://help.ubuntu.com/community/CWiiD>`_