aboutsummaryrefslogtreecommitdiffhomepage
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
parent3adaad2a46cddaa4c79bda022c55f4eef7c3f5af (diff)
downloadmidimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.tar.gz
midimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.tar.bz2
midimonster-4863711ee2dac065151f5c9ab5508eb479b25b72.zip
Implement evdev relative axis output (Fixes #20)
-rw-r--r--README.md2
-rw-r--r--backends/evdev.c17
2 files changed, 16 insertions, 3 deletions
diff --git a/README.md b/README.md
index 3e9bb88..ff6e9cb 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ on any other (or the same) supported protocol, for example to:
* Use an OSC app as a simple lighting controller via ArtNet or sACN
* Visualize ArtNet data using OSC tools
* Control lighting fixtures or DAWs using gamepad controllers, trackballs, etc ([Example configuration](configs/evdev.conf))
-* Play games or type using MIDI controllers
+* Play games, type, or control your mouse using MIDI controllers ([Example configuration](configs/midi-mouse.cfg))
[![Build Status](https://travis-ci.com/cbdevnet/midimonster.svg?branch=master)](https://travis-ci.com/cbdevnet/midimonster) [![Coverity Scan Build Status](https://scan.coverity.com/projects/15168/badge.svg)](https://scan.coverity.com/projects/15168)
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);