static size_t handle_panel_passthrough(struct avctp *session, uint8_t transaction, uint8_t *code, uint8_t *subunit, uint8_t *operands, size_t operand_count, void *user_data) { struct avctp_passthrough_handler *handler = session->handler; const char *status; int pressed, i; if (*code != AVC_CTYPE_CONTROL || *subunit != AVC_SUBUNIT_PANEL) { *code = AVC_CTYPE_REJECTED; return operand_count; } if (operand_count == 0) goto done; if (operands[0] & 0x80) { status = "released"; pressed = 0; } else { status = "pressed"; pressed = 1; } if (session->key.timer == 0 && handler != NULL) { if (handler->cb(session, operands[0] & 0x7F, pressed, handler->user_data)) goto done; } for (i = 0; key_map[i].name != NULL; i++) { uint8_t key_quirks; if ((operands[0] & 0x7F) != key_map[i].avc) continue; DBG("AV/C: %s %s", key_map[i].name, status); key_quirks = session->key_quirks[key_map[i].avc]; if (key_quirks & QUIRK_NO_RELEASE) { if (!pressed) { DBG("AV/C: Ignoring release"); break; } DBG("AV/C: treating key press as press + release"); send_key(session->uinput, key_map[i].uinput, 1); send_key(session->uinput, key_map[i].uinput, 0); break; } if (pressed) handle_press(session, key_map[i].uinput); else handle_release(session, key_map[i].uinput); break; } if (key_map[i].name == NULL) { DBG("AV/C: unknown button 0x%02X %s", operands[0] & 0x7F, status); *code = AVC_CTYPE_NOT_IMPLEMENTED; return operand_count; } done: *code = AVC_CTYPE_ACCEPTED; return operand_count; }
main (int argc, char *argv[]) #endif { XEvent ev; fd_set fd; int xfd; dd = XOpenDisplay (NULL); if (!dd) return 0; scr_screen = DefaultScreen (dd); scr_depth = DefaultDepth (dd, scr_screen); scr_height = DisplayHeight (dd, scr_screen); scr_width = DisplayWidth (dd, scr_screen); root_win = RootWindow (dd, scr_screen); /* helps us catch windows closing/opening */ XSelectInput (dd, root_win, PropertyChangeMask); XSetErrorHandler ((XErrorHandler) handle_error); XInternAtoms (dd, atom_names, ATOM_COUNT, False, atoms); gui_init (); bzero (&tb, sizeof (struct taskbar)); tb.win = gui_create_taskbar (); xfd = ConnectionNumber (dd); gui_sync (); while (1) { FD_ZERO (&fd); FD_SET (xfd, &fd); select (xfd + 1, &fd, 0, 0, 0); while (XPending (dd)) { XNextEvent (dd, &ev); switch (ev.type) { case ButtonPress: handle_press (ev.xbutton.x, ev.xbutton.y, ev.xbutton.button); break; case DestroyNotify: del_task (ev.xdestroywindow.window); /* fall through */ case Expose: gui_draw_taskbar (); break; case PropertyNotify: handle_propertynotify (ev.xproperty.window, ev.xproperty.atom); break; case FocusIn: handle_focusin (ev.xfocus.window); break; /*default: printf ("unknown evt type: %d\n", ev.type);*/ } } } /*XCloseDisplay (dd); return 0;*/ }