static struct libusb_transfer *noct_read_xfer;
static bool noct_read_pending;
+char noct_rotary_touched[10];
+char noct_button_pressed[16];
static void noct_read_done(struct libusb_transfer *xfer)
{
if (arg < 0x80)
{
DBG("Noct: Slider value = %d", arg);
+ notify_rotary(9, arg);
continue;
}
break;
{
int state = !!arg;
DBG("Noct: Center touch = %d", state);
+ noct_rotary_touched[8] = state;
+ notify_touch(8, state);
continue;
}
break;
{
int state = !!arg;
DBG("Noct: Slider touch = %d", state);
+ noct_rotary_touched[9] = state;
+ notify_touch(9, state);
continue;
}
break;
int r = cmd - 0x60;
int state = !!arg;
DBG("Noct: Rotary %d touch = %d", r, state);
+ noct_rotary_touched[r] = state;
+ notify_touch(r, state);
continue;
}
break;
int b = cmd - 0x70;
int state = !!arg;
DBG("Noct: Button %d = %d", b, state);
+ noct_button_pressed[b] = state;
notify_button(b, state);
continue;
}
noct_read_pending = 1;
}
-static byte noct_button_state[16];
+static byte noct_button_light[16];
static byte noct_ring_mode[8]; // RING_MODE_xxx
static byte noct_ring_val[9];
-static uns noct_dirty_button;
-static uns noct_dirty_ring_mode;
-static uns noct_dirty_ring_val;
+static uint noct_dirty_button;
+static uint noct_dirty_ring_mode;
+static uint noct_dirty_ring_val;
static struct libusb_transfer *noct_write_xfer;
static bool noct_write_pending;
noct_sched_write();
}
-static void noct_do_write(uns cmd, uns arg)
+static void noct_do_write(uint cmd, uint arg)
{
DBG("USB: Submitting write %02x %02x", cmd, arg);
ASSERT(!noct_write_pending);
static void noct_sched_write(void)
{
- if (noct_write_pending)
+ if (!usb_dev || noct_write_pending)
return;
if (noct_dirty_button)
{
int i = bit_ffs(noct_dirty_button);
noct_dirty_button ^= 1U << i;
- noct_do_write(0x70 + i, noct_button_state[i]);
+ noct_do_write(0x70 + i, noct_button_light[i]);
}
else if (noct_dirty_ring_mode)
{
{
ASSERT(button >= 0 && button < 16);
ASSERT(val == 0 || val == 1);
- if (noct_button_state[button] != val)
+ if (noct_button_light[button] != val)
{
- noct_button_state[button] = val;
+ noct_button_light[button] = val;
noct_dirty_button |= 1U << button;
noct_sched_write();
}
noct_write_xfer = libusb_alloc_transfer(0);
libusb_fill_interrupt_transfer(noct_write_xfer, usb_dev, 0x02, xmalloc(8), 0, noct_write_done, NULL, 1000);
+ bzero(noct_button_pressed, sizeof(noct_button_pressed));
+ bzero(noct_rotary_touched, sizeof(noct_rotary_touched));
noct_dirty_button = 0xffff;
noct_dirty_ring_mode = 0xff;
noct_dirty_ring_val = 0x1ff;