Lines Matching +full:len +full:- +full:or +full:- +full:define

14  * and/or sell copies of the Software, and to permit persons to whom the
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 #include "chardev/char-serial.h"
38 #define WC_OUTPUT_BUF_MAX_LEN 512
39 #define WC_COMMAND_MAX_LEN 60
41 #define WC_L7(n) ((n) & 127)
42 #define WC_M7(n) (((n) >> 7) & 127)
43 #define WC_H2(n) ((n) >> 14)
45 #define WC_L4(n) ((n) & 15)
46 #define WC_H4(n) (((n) >> 4) & 15)
49 #define WC_MODEL_STRING_LENGTH 18
50 uint8_t WC_MODEL_STRING[WC_MODEL_STRING_LENGTH + 1] = "~#CT-0045R,V1.3-5,";
52 #define WC_CONFIG_STRING_LENGTH 8
55 #define WC_FULL_CONFIG_STRING_LENGTH 61
88 #define TYPE_CHARDEV_WCTABLET "chardev-wctablet"
97 tablet->query_index -= count; in wctablet_shift_input()
98 memmove(tablet->query, tablet->query + count, tablet->query_index); in wctablet_shift_input()
99 tablet->query[tablet->query_index] = 0; in wctablet_shift_input()
104 if (tablet->outlen + count > sizeof(tablet->outbuf)) { in wctablet_queue_output()
108 memcpy(tablet->outbuf + tablet->outlen, buf, count); in wctablet_queue_output()
109 tablet->outlen += count; in wctablet_queue_output()
116 tablet->query_index = 0; in wctablet_reset()
117 tablet->outlen = 0; in wctablet_reset()
119 tablet->send_events = false; in wctablet_reset()
126 if (tablet->line_speed != 9600) { in wctablet_queue_event()
130 int newX = tablet->axis[INPUT_AXIS_X] * 0.1537; in wctablet_queue_event()
131 int nexY = tablet->axis[INPUT_AXIS_Y] * 0.1152; in wctablet_queue_event()
141 if (tablet->btns[INPUT_BUTTON_LEFT]) { in wctablet_queue_event()
155 switch (evt->type) { in wctablet_input_event()
157 move = evt->u.abs.data; in wctablet_input_event()
158 tablet->axis[move->axis] = move->value; in wctablet_input_event()
162 btn = evt->u.btn.data; in wctablet_input_event()
163 tablet->btns[btn->button] = btn->down; in wctablet_input_event()
176 if (tablet->send_events) { in wctablet_input_sync()
191 int len, canWrite; in wctablet_chr_accept_input() local
194 len = canWrite; in wctablet_chr_accept_input()
195 if (len > tablet->outlen) { in wctablet_chr_accept_input()
196 len = tablet->outlen; in wctablet_chr_accept_input()
199 if (len) { in wctablet_chr_accept_input()
200 qemu_chr_be_write(chr, tablet->outbuf, len); in wctablet_chr_accept_input()
201 tablet->outlen -= len; in wctablet_chr_accept_input()
202 if (tablet->outlen) { in wctablet_chr_accept_input()
203 memmove(tablet->outbuf, tablet->outbuf + len, tablet->outlen); in wctablet_chr_accept_input()
209 const uint8_t *buf, int len) in wctablet_chr_write() argument
215 if (tablet->line_speed != 9600) { in wctablet_chr_write()
216 return len; in wctablet_chr_write()
218 for (i = 0; i < len && tablet->query_index < sizeof(tablet->query) - 1; i++) { in wctablet_chr_write()
219 tablet->query[tablet->query_index++] = buf[i]; in wctablet_chr_write()
221 tablet->query[tablet->query_index] = 0; in wctablet_chr_write()
223 while (tablet->query_index > 0 && (tablet->query[0] == '@' || in wctablet_chr_write()
224 tablet->query[0] == '\r' || in wctablet_chr_write()
225 tablet->query[0] == '\n')) { in wctablet_chr_write()
228 if (!tablet->query_index) { in wctablet_chr_write()
229 return len; in wctablet_chr_write()
232 if (strncmp((char *)tablet->query, "~#", 2) == 0) { in wctablet_chr_write()
238 return len; in wctablet_chr_write()
242 pos = strchr((char *)tablet->query, '\r'); in wctablet_chr_write()
244 pos = strchr((char *)tablet->query, '\n'); in wctablet_chr_write()
247 return len; in wctablet_chr_write()
249 clen = pos - (char *)tablet->query; in wctablet_chr_write()
252 if (strncmp((char *)tablet->query, "RE", 2) == 0 && in wctablet_chr_write()
259 } else if (strncmp((char *)tablet->query, "ST", 2) == 0 && in wctablet_chr_write()
263 tablet->send_events = true; in wctablet_chr_write()
266 } else if (strncmp((char *)tablet->query, "SP", 2) == 0 && in wctablet_chr_write()
270 tablet->send_events = false; in wctablet_chr_write()
272 } else if (strncmp((char *)tablet->query, "TS", 2) == 0 && in wctablet_chr_write()
274 unsigned int input = tablet->query[2]; in wctablet_chr_write()
289 tablet->query[clen] = 0; /* terminate line for printing */ in wctablet_chr_write()
290 trace_wct_cmd_other((char *)tablet->query); in wctablet_chr_write()
295 return len; in wctablet_chr_write()
306 if (tablet->line_speed != ssp->speed) { in wctablet_chr_ioctl()
307 trace_wct_speed(ssp->speed); in wctablet_chr_ioctl()
309 tablet->line_speed = ssp->speed; in wctablet_chr_ioctl()
313 return -ENOTSUP; in wctablet_chr_ioctl()
322 if (tablet->hs) { in wctablet_chr_finalize()
323 qemu_input_handler_unregister(tablet->hs); in wctablet_chr_finalize()
337 memcpy(tablet->outbuf, WC_FULL_CONFIG_STRING, WC_FULL_CONFIG_STRING_LENGTH); in wctablet_chr_open()
338 tablet->outlen = WC_FULL_CONFIG_STRING_LENGTH; in wctablet_chr_open()
339 tablet->query_index = 0; in wctablet_chr_open()
341 tablet->hs = qemu_input_handler_register((DeviceState *)tablet, in wctablet_chr_open()
349 cc->open = wctablet_chr_open; in wctablet_chr_class_init()
350 cc->chr_write = wctablet_chr_write; in wctablet_chr_class_init()
351 cc->chr_ioctl = wctablet_chr_ioctl; in wctablet_chr_class_init()
352 cc->chr_accept_input = wctablet_chr_accept_input; in wctablet_chr_class_init()