11 if(sscanf(values,
"%hu,%hu", &x, &y) != 2){
13 if(sscanf(values,
"%hu", &x) == 1)
15 else if(!strncmp(values,
"off", 3))
22 if((x == 0 || y == 0) && !disable)
25 int left = strlen(stages);
26 int position = 0, field = 0;
28 while(position < left && sscanf(stages + position,
"%2[^,]%n", stagename, &field) == 1){
30 if(sscanf(stagename,
"%hhu", &stagenum) && stagenum <
DPI_COUNT){
34 mode->
dpi.
x[stagenum] = 0;
35 mode->
dpi.
y[stagenum] = 0;
38 mode->
dpi.
x[stagenum] =
x;
39 mode->
dpi.
y[stagenum] =
y;
42 if(stages[position += field] ==
',')
53 if(sscanf(stage,
"%hhu", &stagenum) != 1)
66 if(sscanf(height,
"%hhu", &heightnum) != 1)
78 if(!strcmp(enable,
"on"))
80 if(!strcmp(enable,
"off"))
88 const int BUFFER_LEN = 100;
89 char*
buffer = malloc(BUFFER_LEN);
94 snprintf(buffer + length, BUFFER_LEN - length, length == 0 ?
"%d%n" :
" %d%n", i, &newlen);
98 snprintf(buffer + length, BUFFER_LEN - length,
":off%n", &newlen);
100 snprintf(buffer + length, BUFFER_LEN - length,
":%u,%u%n", dpi->
x[i], dpi->
y[i], &newlen);
113 && !memcmp(lastdpi, newdpi,
sizeof(
dpiset)))
134 uchar data_pkt[
MSG_SIZE] = { 0x07, 0x13, 0x05, 0, newenabled };
144 data_pkt[2] |= newdpi->
current;
162 if (newdpi->
x[i] == lastdpi->
x[i] && newdpi->
y[i] == lastdpi->
y[i])
166 *(
ushort*)(data_pkt + 5) = newdpi->
x[i];
167 *(
ushort*)(data_pkt + 7) = newdpi->
y[i];
178 if (newdpi->
lift != lastdpi->
lift) {
183 if (newdpi->
snap != lastdpi->
snap) {
190 memcpy(lastdpi, newdpi,
sizeof(
dpiset));
199 *(
ushort*)(data_pkt + 5) = dpi->
x[i];
200 *(
ushort*)(data_pkt + 7) = dpi->
y[i];
211 { 0x07, 0x13, 0x05, 1, dpi->
enabled },
212 { 0x07, 0x13, 0x02, 1, dpi->
current },
213 { 0x07, 0x13, 0x03, 1, dpi->
lift },
214 { 0x07, 0x13, 0x04, 1, dpi->
snap, 0x05 }
216 if(!
usbsend(kb, data_pkt[0], 4))
225 { 0x0e, 0x13, 0x05, 1, },
226 { 0x0e, 0x13, 0x02, 1, },
227 { 0x0e, 0x13, 0x03, 1, },
228 { 0x0e, 0x13, 0x04, 1, }
231 for(
int i = 0; i < 4; i++){
232 if(!
usbrecv(kb, data_pkt[i], in_pkt[i]))
234 if(memcmp(in_pkt[i], data_pkt[i], 4)){
245 dpi->
lift = in_pkt[2][4];
248 dpi->
snap = !!in_pkt[3][4];
255 if(!
usbrecv(kb, data_pkt, in_pkt))
257 if(memcmp(in_pkt, data_pkt, 4)){
262 dpi->
x[i] = *(
ushort*)(in_pkt + 5);
263 dpi->
y[i] = *(
ushort*)(in_pkt + 7);
void cmd_dpi(usbdevice *kb, usbmode *mode, int dummy, const char *stages, const char *values)
void cmd_lift(usbdevice *kb, usbmode *mode, int dummy1, int dummy2, const char *height)
int savedpi(usbdevice *kb, dpiset *dpi, lighting *light)
#define ckb_err(fmt, args...)
int updatedpi(usbdevice *kb, int force)
void cmd_snap(usbdevice *kb, usbmode *mode, int dummy1, int dummy2, const char *enable)
void cmd_dpisel(usbdevice *kb, usbmode *mode, int dummy1, int dummy2, const char *stage)
#define usbrecv(kb, out_msg, in_msg)
usbrecv macro is used to wrap _usbrecv() with debugging information (file and lineno) ...
Definitions for using USB interface.
char * printdpi(const dpiset *dpi, const usbdevice *kb)
#define usbsend(kb, messages, count)
usbsend macro is used to wrap _usbsend() with debugging information (file and lineno) ...
int loaddpi(usbdevice *kb, dpiset *dpi, lighting *light)