Fix uinput python code.
This commit is contained in:
parent
1695c30330
commit
a0c79ee086
17
py/create.py
17
py/create.py
|
@ -1,11 +1,12 @@
|
||||||
import cinput, linux_uinput, ctypes, fcntl
|
import cinput, linux_uinput, ctypes, fcntl, os
|
||||||
|
|
||||||
|
|
||||||
def open_uinput():
|
def open_uinput():
|
||||||
try:
|
try:
|
||||||
f = open('/dev/uinput', 'w+')
|
f = os.open('/dev/uinput', os.O_WRONLY | os.O_NONBLOCK)
|
||||||
except IOError:
|
except IOError:
|
||||||
try:
|
try:
|
||||||
f = open('/dev/input/uinput', 'w+')
|
f = os.open('/dev/input/uinput', os.O_WRONLY | os.O_NONBLOCK)
|
||||||
except IOError:
|
except IOError:
|
||||||
print 'FAIL MUCH?'
|
print 'FAIL MUCH?'
|
||||||
return None
|
return None
|
||||||
|
@ -27,24 +28,18 @@ def create_device(specs):
|
||||||
handle_specs(f, specs)
|
handle_specs(f, specs)
|
||||||
|
|
||||||
# Allocate other info
|
# Allocate other info
|
||||||
# TODO:
|
|
||||||
# * Make sure the uidev structure is correct
|
|
||||||
# * Make sure that we are setting the values in the structure
|
|
||||||
# * Make sure the value is properly written to 'f'
|
|
||||||
uidev = linux_uinput.uinput_user_dev()
|
uidev = linux_uinput.uinput_user_dev()
|
||||||
|
|
||||||
uidev.name = 'key2joy'
|
uidev.name = 'key2joy:0'
|
||||||
uidev._id.bustype = 0x03 # BUS_USB (TODO)
|
uidev._id.bustype = 0x03 # BUS_USB (TODO)
|
||||||
uidev._id.vendor = 0x42
|
uidev._id.vendor = 0x42
|
||||||
uidev._id.product = 0xbebe
|
uidev._id.product = 0xbebe
|
||||||
uidev._id.version = 1
|
uidev._id.version = 1
|
||||||
|
|
||||||
|
|
||||||
buf = buffer(uidev)[:]
|
buf = buffer(uidev)[:]
|
||||||
print repr(buf)
|
|
||||||
|
|
||||||
# Write dev info
|
# Write dev info
|
||||||
f.write(buf)
|
os.write(f, buf)
|
||||||
|
|
||||||
print 'ioctl:', fcntl.ioctl(f, linux_uinput.UI_DEV_CREATE)
|
print 'ioctl:', fcntl.ioctl(f, linux_uinput.UI_DEV_CREATE)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue