You are not logged in.

#1 2011-02-07 16:13:42

ahel
Member
Registered: 2010-07-19
Posts: 20

removed hal; how could i use accellerometers used by halevt before?

i have an Intel Classmate and when it is in tablet mode, thanks to its accellerometers, it was used to turn by this halevt configuration:

<?xml version="1.0" encoding="UTF-8"?>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
<halevt:Device match="hal.button.type = tablet_mode">
    <halevt:Property name="hal.button.state.value">
        <halevt:Action value="true" exec="/usr/bin/cellwriter &amp;" />
    <halevt:Action value="true" exec="python2 /usr/local/bin/accel.py &gt;&gt; /dev/null 2&gt;&amp;1 &amp;" />
    <halevt:Action value="false" exec="ps ax | grep accel.py | grep -v grep | awk '{print (/^V/ ? $0 : $1)}' | xargs kill &gt;&gt; /dev/null 2&gt;&amp;1; /usr/local/bin/rotate.sh normal" />
    <halevt:Action value="false" exec="ps ax | grep cellwriter | grep -v grep | awk '{print (/^V/ ? $0 : $1)}' | xargs kill &gt;&gt; /dev/null 2&gt;&amp;1;" />
    </halevt:Property>
</halevt:Device>
<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/computer_logicaldev_input_1">
    <halevt:Condition name="ButtonPressed" value="brightness-down" exec="/usr/local/bin/cmpc-brn-down.sh" />
</halevt:Device>
<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/computer_logicaldev_input_1">
    <halevt:Condition name="ButtonPressed" value="brightness-up" exec="/usr/local/bin/cmpc-brn-up.sh" />
</halevt:Device>
</halevt:Configuration>

and by this accel.py script

#!/usr/bin/python
##########################################################################
#
# accel.py - Handling accelerometer events of an Intel Classmate Netbook
#
# Copyright (C) 2010  Kay Hannay <klinux@hannay.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################

import pygame
from pygame import joystick
from pygame import event
from pygame.locals import *
import sys
import os

rotate_script= "/usr/local/bin/rotate.sh"

def rotate(orientation):
    print "Rotate " + orientation
    os.system(rotate_script + ' ' + orientation)
    return orientation

pygame.init()
joystick.init()
num_dev = joystick.get_count()
accel = None
i = 0
while (i < num_dev):
    accel = joystick.Joystick(i)
    try:
        accel.init()
    except pygame.error:
        print "Error initializing accelerator!"
        sys.exit(1)
    i = i + 1
    #print "Device:  " + accel.get_name()
    #print "Buttons: " + str(accel.get_numbuttons())
    #print "Axes:    " + str(accel.get_numaxes())
    #print "Hats:    " + str(accel.get_numhats())
    #print "Balls:   " + str(accel.get_numballs())
    if(accel.get_numaxes() == 3):
        break

if(accel == None):
    print "No accelerator device found. Exiting..."
    sys.exit(1)

orientation = rotate("inverted") #"normal"
while True:
    for ev in event.get():
        #print "Event: " + str(event.type)
        if(ev.type == QUIT):
            joystick.quit()
            pygame.quit()
            sys.exit(0)

        if(ev.type == JOYAXISMOTION):
            axis_x = accel.get_axis(0)
            axis_y = accel.get_axis(1)
            axis_z = accel.get_axis(2)
            #print "X " + str(axis_x) + ", Y " + str(axis_y) + ", Z " + str(axis_z)
            if((axis_x > 0.3) and (orientation != "left")):
                #print "X " + str(axis_x) + ", Y " + str(axis_y) + ", Z " + str(axis_z)
                orientation=rotate("left")
            elif((axis_x < -0.4) and (orientation != "right")):
                #print "X " + str(axis_x) + ", Y " + str(axis_y) + ", Z " + str(axis_z)
                orientation=rotate("right")
            elif((axis_x < 0.3) and (axis_x > -0.2) and (axis_y < -0.1) and (orientation != "normal")):
                #print "X " + str(axis_x) + ", Y " + str(axis_y) + ", Z " + str(axis_z)
                orientation=rotate("normal")
            elif((axis_x < 0.3) and (axis_x > -0.2) and (axis_y > 0.3) and (orientation != "inverted")):
                #print "X " + str(axis_x) + ", Y " + str(axis_y) + ", Z " + str(axis_z)
                orientation=rotate("inverted")

but now without hal & halevt, what can i do?
can anyone be of some help?
because i can't really managed to solve this issue.
thank you all


religion is like a penis.
It's fine to have one.
It's fine to be proud of it.
But please don't whip it out in public and start waving it around and please don't try to shove it down my childrens' throats.

Offline

#2 2011-02-07 16:54:10

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: removed hal; how could i use accellerometers used by halevt before?

Uhmm... is "reinstall hal and halevt" too obvious?

Offline

#3 2011-02-07 20:06:38

ahel
Member
Registered: 2010-07-19
Posts: 20

Re: removed hal; how could i use accellerometers used by halevt before?

tomk wrote:

Uhmm... is "reinstall hal and halevt" too obvious?

I'd the same idea..


religion is like a penis.
It's fine to have one.
It's fine to be proud of it.
But please don't whip it out in public and start waving it around and please don't try to shove it down my childrens' throats.

Offline

Board footer

Powered by FluxBB