uinput-mapper/configs/touchscreen.py

76 lines
1.5 KiB
Python
Raw Normal View History

2013-05-24 08:17:12 -04:00
from uinputmapper.cinput import *
2013-05-10 11:33:12 -04:00
# Approx
2013-05-10 11:33:12 -04:00
# top left: (300, 3500)
# bottom left: 300, 300)
2013-05-10 11:33:12 -04:00
# top right: (3000, 3700)
# bottom right: (3880, 430)
2013-05-10 11:33:12 -04:00
w = 1920.
h = 1080.
rx1 = 300.
ry1 = 200.
rx2 = 3800.
ry2 = 4000.
2013-05-10 11:33:12 -04:00
def transform_x(x):
x -= rx1
x *= w / (rx2 - rx1)
return int(x)
def transform_y(y):
y = ry2 - y
y -= ry1
2013-05-24 08:17:12 -04:00
y *= h / (rx2 - rx1) # shouldn't the x here be y?
2013-05-10 11:33:12 -04:00
return int(y)
config = {
2013-05-19 07:07:59 -04:00
(0, EV_ABS) : {
ABS_X : {
2013-05-19 07:07:59 -04:00
'type' : (0, EV_ABS),
'code' : ABS_X,
2013-05-24 08:17:12 -04:00
'value' : transform_x,
'prop' : {
'max' : 3000,
'min' : 200,
'flat' : 0,
'fuzz' : 0
}
},
ABS_Y : {
2013-05-19 07:07:59 -04:00
'type' : (0, EV_ABS),
'code' : ABS_Y,
2013-05-24 08:17:12 -04:00
'value' : transform_y,
'prop' : {
'max' : 3000,
'min' : 200,
'flat' : 0,
'fuzz' : 0
}
}
}
}
def config_merge(c):
# XXX: We cannot just use update; as it will override everything in say EV_KEY
for k, v in config.iteritems():
if k in c:
c[k].update(v)
else:
c[k] = v
# Uncomment this to make touch click too
2013-05-24 08:17:12 -04:00
#c[(0, EV_KEY)][BTN_TOUCH] = {
# 'type' : (0, EV_KEY),
# 'code' : BTN_TOUCH,
# 'value' : lambda x: 0
#}