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

Always

Just for now

Viewing a subset of changes. View all

wip: buttons info in place and working

  • Loading branch information...
harryhaaren committed Jun 5, 2017
commit d7db8357f6e8d01d4d8de495c0e1f96efe9c2de8
View
@@ -124,7 +124,6 @@ struct ctlra_grid_info_t {
* items such as an LED, or screen.
*/
struct ctlra_item_info_t {
char name[CTLRA_STR_MAX]; /* Human readable name of the item */
uint32_t x; /* location of item on X axis */
uint32_t y; /* location of item on Y axis */
uint32_t w; /* size of item on X axis */
@@ -82,6 +82,15 @@ static const char *ni_kontrol_z1_names_buttons[] = {
#define CONTROL_NAMES_SIZE (CONTROL_NAMES_SLIDERS_SIZE + \
CONTROL_NAMES_BUTTONS_SIZE)
static struct ctlra_item_info_t buttons_info[] = {
{.x = 10, .y = 100, .w = 30, .h = 20},
{.x = 50, .y = 100, .w = 30, .h = 20},
{.x = 80, .y = 100, .w = 30, .h = 20},
{.x =120, .y = 100, .w = 30, .h = 20},
{.x =150, .y = 100, .w = 30, .h = 20},
};
static const struct ni_kontrol_z1_ctlra_t sliders[] = {
/* Left */
{NI_KONTROL_Z1_SLIDER_LEFT_GAIN , 1, UINT32_MAX},
@@ -323,9 +332,8 @@ struct ctlra_dev_info_t ctlra_ni_kontrol_z1_info = {
.device = "Kontrol Z1",
.vendor_id = NI_VENDOR,
.device_id = NI_KONTROL_Z1,
.control_count[CTLRA_EVENT_BUTTON] = BUTTONS_SIZE,
.control_count[CTLRA_EVENT_SLIDER] = SLIDERS_SIZE,
/*
.control_count[CTLRA_EVENT_T_COUNT] = {
},
*/
.control_info[CTLRA_EVENT_BUTTON] = &buttons_info,
};
View
@@ -42,6 +42,7 @@
/** Types of events */
enum ctlra_event_type_t {
/* The order of these events must not be modified */
CTLRA_EVENT_BUTTON = 0,
CTLRA_EVENT_ENCODER,
CTLRA_EVENT_SLIDER,
View
@@ -144,8 +144,17 @@ int main(int argc, char **argv)
id.type = CTLRA_DEV_TYPE_USB_HID;
struct ctlra_dev_info_t *info = ctlra_dev_get_info_by_id(&id);
printf("static info %p\n", info);
if(info != NULL)
printf("static info %s\n", info->device);
if(info != NULL) {
printf("static info %s %s\n buttons = %d\n sliders %d\n",
info->vendor, info->device,
info->control_count[CTLRA_EVENT_BUTTON],
info->control_count[CTLRA_EVENT_SLIDER]);
for(int i = 0; i < info->control_count[CTLRA_EVENT_BUTTON]; i++) {
struct ctlra_item_info_t *item = &info->control_info[CTLRA_EVENT_BUTTON][i];
printf("%d: %d %d\t%d %d\n", i, item->x, item->y,
item->w, item->h);
}
}
struct ctlra_t *ctlra = ctlra_create(NULL);
int num_devs = ctlra_probe(ctlra, accept_dev_func, 0x0);
ProTip! Use n and p to navigate between commits in a pull request.