aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-08-17 01:46:06 +0200
committercbdev <cb@cbcdn.com>2019-08-17 01:46:06 +0200
commit4863711ee2dac065151f5c9ab5508eb479b25b72 (patch)
tree6b793035231bb9dd490d3ec2fe1ad2db94d0f931 /backends
parent3adaad2a46cddaa4c79bda022c55f4eef7c3f5af (diff)
downloadmidimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.tar.gz
midimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.tar.bz2
midimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.zip
Implement evdev relative axis output (Fixes #20)
Diffstat (limited to 'backends')
-rw-r--r--backends/evdev.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/backends/evdev.c b/backends/evdev.c
index bd2098d..b19cda8 100644
--- a/backends/evdev.c
+++ b/backends/evdev.c
@@ -445,7 +445,7 @@ static int evdev_start(){
static int evdev_set(instance* inst, size_t num, channel** c, channel_value* v) {
#ifndef EVDEV_NO_UINPUT
- size_t evt = 0;
+ size_t evt = 0, axis = 0;
evdev_instance_data* data = (evdev_instance_data*) inst->impl;
evdev_channel_ident ident = {
.label = 0
@@ -467,7 +467,20 @@ static int evdev_set(instance* inst, size_t num, channel** c, channel_value* v)
switch(ident.fields.type){
case EV_REL:
- value = (v[evt].normalised < 0.5) ? -1 : ((v[evt].normalised > 0.5) ? 1 : 0);
+ for(axis = 0; axis < data->relative_axes; axis++){
+ if(data->relative_axis[axis].code == ident.fields.code){
+ value = (v[evt].normalised * data->relative_axis[axis].max) - data->relative_axis[axis].current;
+ data->relative_axis[axis].current = v[evt].normalised * data->relative_axis[axis].max;
+
+ if(data->relative_axis[axis].inverted){
+ value *= -1;
+ }
+ break;
+ }
+ }
+ if(axis == data->relative_axes){
+ value = (v[evt].normalised < 0.5) ? -1 : ((v[evt].normalised > 0.5) ? 1 : 0);
+ }
break;
case EV_ABS:
range = libevdev_get_abs_maximum(data->output_proto, ident.fields.code) - libevdev_get_abs_minimum(data->output_proto, ident.fields.code);