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.
+66 −1
Diff settings

Always

Just for now

Viewing a subset of changes. View all

mikro mk2: add static device layout info

This commit allows the maschine mikro mk2 to be virtualized,
using the static data as exposed to build up a virtual
representation of the device itself.

Signed-off-by: Harry van Haaren <harryhaaren@gmail.com>
  • Loading branch information...
harryhaaren committed Aug 30, 2017
commit 122d5afa4ded3101b2caad59e15f82dbaa74e47d
View
@@ -36,6 +36,7 @@ CTLRA_DEVICE_DECL(akai_apc);
CTLRA_DEVICE_DECL(avtka);
CTLRA_DEVICE_INFO(ni_kontrol_z1);
CTLRA_DEVICE_INFO(ni_maschine_mikro_mk2);
static const struct ctlra_dev_connect_func_t devices[] = {
{0, 0, 0},
@@ -243,7 +244,8 @@ ctlra_dev_match_usb_hid(struct ctlra_dev_id_t *id)
int vendor = id->usb_hid.vendor_id;
int device = id->usb_hid.device_id;
/* TODO: iter registered static info structs, return if match */
return &CTLRA_DEVICE_INFO_NAME(ni_kontrol_z1);
//return &CTLRA_DEVICE_INFO_NAME(ni_kontrol_z1);
return &CTLRA_DEVICE_INFO_NAME(ni_maschine_mikro_mk2);
}
struct ctlra_dev_info_t *
@@ -131,6 +131,46 @@ static const struct ni_maschine_mikro_mk2_ctlra_t buttons[] = {
};
#define BUTTONS_SIZE (sizeof(buttons) / sizeof(buttons[0]))
#define MIKRO_BTN (CTLRA_ITEM_BUTTON | CTLRA_ITEM_LED_INTENSITY)
static struct ctlra_item_info_t buttons_info[] = {
/* restart -> grid */
{.x = 20, .y = 138, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 45, .y = 138, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 70, .y = 138, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 95, .y = 138, .w = 18, .h = 10, .flags = MIKRO_BTN},
/* play -> shift */
{.x = 20, .y = 156, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 45, .y = 156, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 70, .y = 156, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 95, .y = 156, .w = 18, .h = 10, .flags = MIKRO_BTN},
/* group -> note repeat */
{.x = 20, .y = 107, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 45, .y = 107, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 70, .y = 107, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x = 95, .y = 107, .w = 18, .h = 10, .flags = MIKRO_BTN},
/* encoder press */
{.x = 95, .y = 70, .w = 18, .h = 10, .flags = MIKRO_BTN},
/* F1 -> control */
{.x = 20, .y = 29, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 45, .y = 29, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 70, .y = 29, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 95, .y = 29, .w = 18, .h = 5, .flags = MIKRO_BTN},
/* Nav -> Main */
{.x = 20, .y = 87, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 45, .y = 87, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 70, .y = 87, .w = 18, .h = 5, .flags = MIKRO_BTN},
{.x = 95, .y = 87, .w = 18, .h = 5, .flags = MIKRO_BTN},
/* Scene -> Mute */
{.x =130, .y = 29, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 47, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 66, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 84, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 103, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 121, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 140, .w = 18, .h = 10, .flags = MIKRO_BTN},
{.x =130, .y = 158, .w = 18, .h = 10, .flags = MIKRO_BTN},
};
#define ENCODERS_SIZE (1)
#define CONTROLS_SIZE (BUTTONS_SIZE + ENCODERS_SIZE)
@@ -441,6 +481,7 @@ ctlra_ni_maschine_mikro_mk2_connect(ctlra_event_func event_func,
dev->base.info.vendor_id = NI_VENDOR;
dev->base.info.device_id = NI_MASCHINE_MIKRO_MK2;
dev->base.poll = ni_maschine_mikro_mk2_poll;
dev->base.disconnect = ni_maschine_mikro_mk2_disconnect;
dev->base.light_set = ni_maschine_mikro_mk2_light_set;
@@ -455,3 +496,25 @@ ctlra_ni_maschine_mikro_mk2_connect(ctlra_event_func event_func,
return 0;
}
struct ctlra_dev_info_t ctlra_ni_maschine_mikro_mk2_info = {
.vendor = "Native Instruments",
.device = "Maschine Mikro Mk2",
.vendor_id = NI_VENDOR,
.device_id = NI_MASCHINE_MIKRO_MK2,
.size_x = 320,
.size_y = 195,
.control_count[CTLRA_EVENT_BUTTON] = BUTTONS_SIZE,
.control_count[CTLRA_EVENT_GRID] = 1,
.control_info[CTLRA_EVENT_BUTTON] = &buttons_info,
.grid_info[0] = {
.rgb = 1,
.velocity = 1,
.pressure = 1,
.x = 4,
.y = 4,
},
.get_name = ni_maschine_mikro_mk2_control_get_name,
};
ProTip! Use n and p to navigate between commits in a pull request.