From a7b53bdade367d877dd34ad063762e5c8feecbb0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Jun 2015 18:07:21 +0100 Subject: Fix stuck keys, and turn on debugging --- app/Makefile | 2 +- app/keyboard.c | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Makefile b/app/Makefile index 7c378cf..30debb5 100644 --- a/app/Makefile +++ b/app/Makefile @@ -32,7 +32,7 @@ OBJS = ${CSRCS:%.c=%.o} include ../Makefile.include -CFLAGS+=-Wno-redundant-decls -Wno-unused-parameter #-DDEBUG +CFLAGS+=-Wno-redundant-decls -Wno-unused-parameter -DDEBUG DID=$(shell printf '\#include "id.h"\nID_PRODUCT' | ${CC} -I.. -E - | grep -v ^\# ) diff --git a/app/keyboard.c b/app/keyboard.c index f780ccc..dcbd824 100644 --- a/app/keyboard.c +++ b/app/keyboard.c @@ -128,7 +128,7 @@ keyboard_send (uint8_t modifiers, uint8_t * key_list) }; if (!usb_is_suspended) - usbd_ep_write_packet (usbd_dev, KEYBOARD_EP, buf, sizeof (buf)); + usbd_ep_write_packet (usbd_dev, KEYBOARD_EP, buf, sizeof (buf)); } static uint8_t modifiers; @@ -142,7 +142,7 @@ keyboard_dispatch (int sc, int updown) /*Windows needs the modifiers spliting out, so we do this as per our * descriptor, others need them in the list so we do that as well */ - usb_wakeup_host(); + usb_wakeup_host (); switch (sc) { @@ -166,14 +166,28 @@ keyboard_dispatch (int sc, int updown) if (updown) { + int found = 0; + for (i = 0; i < KEY_LIST_LEN; ++i) { - if ((key_list[i] == 0) || (key_list[i] == sc)) + if (key_list[i] == sc) { - key_list[i] = sc; - break; + found++; } } + + if (!found) + { + for (i = 0; i < KEY_LIST_LEN; ++i) + { + if (!key_list[i]) + { + key_list[i] = sc; + break; + } + } + } + } else { -- cgit v1.2.3