User:Solar.george

From Openmoko

Jump to: navigation, search

O/P from /dev/input/event4 (Aux Button)

|----- time ------|  |type| |code|  |-value-|
b088 4a43 c952 0000   0001   00a9    00010000
b088 4a43 c988 0000   0000   0000    00000000
b088 4a43 661d 000a   0001   00a9    00000000
b088 4a43 6651 000a   0000   0000    00000000

Event type 0x01 (Keys or Buttons)

from Accelerometer_data_retrieval

  1. int, int, short, short, int

fmt = 'iihhi' # use with struct.unpack

#!/usr/bin/env python
import struct

ev_file = "/dev/input/event4"

#int, int, short, short, int
fmt = 'iihhi'

ev_open = open(ev_file, "rb")

aux = ev_open.read(16)
while aux:
    (time1, time2, ev_type, code, value) = struct.unpack(fmt, aux)
    print [time1,time2,ev_type,code,value]
    aux = ev_open.read(16)

ev_open.close 
Personal tools