New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual device #41

Merged
merged 122 commits into from Oct 2, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+22 −0
Diff settings

Always

Just for now

Viewing a subset of changes. View all

jam: implement encoder events

All inputs from the Jam now handled, but the device info still
needs to be exposed.

Signed-off-by: Harry van Haaren <harryhaaren@gmail.com>
  • Loading branch information...
harryhaaren committed Oct 1, 2017
commit f9f8aa012a733a05c0e84bdf5bacb367048d3fe0
@@ -278,6 +278,8 @@ struct ni_maschine_jam_t {
/* current state of the lights, only flush on dirty */
uint8_t lights_dirty;
uint8_t encoder;
uint8_t lights_interface;
uint8_t lights[NI_MASCHINE_JAM_LED_COUNT*2];
@@ -407,6 +409,7 @@ void ni_machine_jam_usb_read_cb(struct ctlra_dev_t *base, uint32_t endpoint,
//ni_maschine_jam_light_flush(base, 1);
break;
}
case 17: {
static uint8_t old[17];
int i = 17;
@@ -503,6 +506,25 @@ void ni_machine_jam_usb_read_cb(struct ctlra_dev_t *base, uint32_t endpoint,
#endif
}
}
/* encoder */
uint8_t encoder_now = (data[1] & 0xf);
if(dev->encoder != encoder_now) {
int dir = ctlra_dev_encoder_wrap_16(encoder_now,
dev->encoder);
dev->encoder = encoder_now;
struct ctlra_event_t event = {
.type = CTLRA_EVENT_ENCODER,
.encoder = {
.id = 0,
},
};
event.encoder.delta = dir;
struct ctlra_event_t *e = {&event};
dev->base.event_func(&dev->base, 1, &e,
dev->base.event_func_userdata);
}
} /* case 17 */
} /* switch */
}
ProTip! Use n and p to navigate between commits in a pull request.