Added possibility to inject input events to tty
M include/Makefile A include/minix/input.h M include/minix/com.h M drivers/tty/keyboard.c M drivers/tty/tty.c M drivers/tty/tty.h M include/minix/syslib.h M lib/libsys/Makefile A lib/libsys/input.c
This commit is contained in:
parent
4ee146c00a
commit
c22564335f
9 changed files with 132 additions and 44 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
#include <minix/callnr.h>
|
#include <minix/callnr.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
|
#include <minix/input.h>
|
||||||
#include <minix/keymap.h>
|
#include <minix/keymap.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
#include "kernel/const.h"
|
#include "kernel/const.h"
|
||||||
|
@ -74,6 +75,12 @@ PRIVATE int aux_irq_hook_id = -1;
|
||||||
|
|
||||||
#define CONSOLE 0 /* line number for console */
|
#define CONSOLE 0 /* line number for console */
|
||||||
#define KB_IN_BYTES 32 /* size of keyboard input buffer */
|
#define KB_IN_BYTES 32 /* size of keyboard input buffer */
|
||||||
|
|
||||||
|
PRIVATE char injbuf[KB_IN_BYTES];
|
||||||
|
PRIVATE char *injhead = injbuf;
|
||||||
|
PRIVATE char *injtail = injbuf;
|
||||||
|
PRIVATE int injcount;
|
||||||
|
|
||||||
PRIVATE char ibuf[KB_IN_BYTES]; /* input buffer */
|
PRIVATE char ibuf[KB_IN_BYTES]; /* input buffer */
|
||||||
PRIVATE char *ihead = ibuf; /* next free spot in input buffer */
|
PRIVATE char *ihead = ibuf; /* next free spot in input buffer */
|
||||||
PRIVATE char *itail = ibuf; /* scan code to return to TTY */
|
PRIVATE char *itail = ibuf; /* scan code to return to TTY */
|
||||||
|
@ -558,6 +565,31 @@ message *m_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PUBLIC void do_kb_inject(message *msg)
|
||||||
|
{
|
||||||
|
unsigned char scode;
|
||||||
|
/* only handle keyboard events */
|
||||||
|
if (msg->INPUT_TYPE == INPUT_EV_KEY) {
|
||||||
|
scode = msg->INPUT_CODE;
|
||||||
|
|
||||||
|
/* is it a KEY RELEASE? */
|
||||||
|
if (msg->INPUT_VALUE == 0) {
|
||||||
|
scode |= KEY_RELEASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (injcount < KB_IN_BYTES) {
|
||||||
|
*injhead++ = scode;
|
||||||
|
if (injhead == injbuf + KB_IN_BYTES) injhead = injbuf;
|
||||||
|
injcount++;
|
||||||
|
tty_table[ccurrent].tty_events = 1;
|
||||||
|
if (tty_table[ccurrent].tty_select_ops & SEL_RD) {
|
||||||
|
select_retry(&tty_table[ccurrent]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* kb_read *
|
* kb_read *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -570,22 +602,32 @@ int try;
|
||||||
int scode;
|
int scode;
|
||||||
unsigned ch;
|
unsigned ch;
|
||||||
|
|
||||||
tp = &tty_table[ccurrent]; /* always use the current console */
|
/* always use the current console */
|
||||||
|
tp = &tty_table[ccurrent];
|
||||||
|
|
||||||
if (try) {
|
if (try) {
|
||||||
if (icount > 0) return 1;
|
if (icount > 0) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (icount > 0) {
|
while (icount > 0 || injcount > 0) {
|
||||||
scode = *itail++; /* take one key scan code */
|
if (injcount > 0) {
|
||||||
|
/* take one key scan code */
|
||||||
|
scode = *injtail++;
|
||||||
|
if (injtail == injbuf + KB_IN_BYTES) injtail = injbuf;
|
||||||
|
injcount--;
|
||||||
|
} else {
|
||||||
|
/* take one key scan code */
|
||||||
|
scode = *itail++;
|
||||||
if (itail == ibuf + KB_IN_BYTES) itail = ibuf;
|
if (itail == ibuf + KB_IN_BYTES) itail = ibuf;
|
||||||
icount--;
|
icount--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Function keys are being used for debug dumps (if enabled). */
|
/* Function keys are being used for debug dumps (if enabled). */
|
||||||
if (debug_fkeys && func_key(scode)) continue;
|
if (debug_fkeys && func_key(scode)) continue;
|
||||||
|
|
||||||
/* Perform make/break processing. */
|
/* Perform make/break processing. */
|
||||||
|
|
||||||
ch = make_break(scode);
|
ch = make_break(scode);
|
||||||
|
|
||||||
if (ch <= 0xFF) {
|
if (ch <= 0xFF) {
|
||||||
|
|
|
@ -232,6 +232,9 @@ PUBLIC int main(void)
|
||||||
case FKEY_CONTROL: /* (un)register a fkey observer */
|
case FKEY_CONTROL: /* (un)register a fkey observer */
|
||||||
do_fkey_ctl(&tty_mess);
|
do_fkey_ctl(&tty_mess);
|
||||||
continue;
|
continue;
|
||||||
|
case INPUT_EVENT:
|
||||||
|
do_kb_inject(&tty_mess);
|
||||||
|
continue;
|
||||||
default: /* should be a driver request */
|
default: /* should be a driver request */
|
||||||
; /* do nothing; end switch */
|
; /* do nothing; end switch */
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,6 +180,7 @@ _PROTOTYPE( int kbd_loadmap, (message *m, int safe) );
|
||||||
_PROTOTYPE( void do_fkey_ctl, (message *m) );
|
_PROTOTYPE( void do_fkey_ctl, (message *m) );
|
||||||
_PROTOTYPE( void kbd_interrupt, (message *m) );
|
_PROTOTYPE( void kbd_interrupt, (message *m) );
|
||||||
_PROTOTYPE( void do_kbd, (message *m) );
|
_PROTOTYPE( void do_kbd, (message *m) );
|
||||||
|
_PROTOTYPE( void do_kb_inject, (message *m) );
|
||||||
_PROTOTYPE( void do_kbdaux, (message *m) );
|
_PROTOTYPE( void do_kbdaux, (message *m) );
|
||||||
_PROTOTYPE( int kbd_status, (message *m_ptr) );
|
_PROTOTYPE( int kbd_status, (message *m_ptr) );
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
|
||||||
minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \
|
minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \
|
||||||
minix/u64.h minix/vfsif.h minix/vm.h minix/vtreefs.h minix/gcov.h \
|
minix/u64.h minix/vfsif.h minix/vm.h minix/vtreefs.h minix/gcov.h \
|
||||||
minix/compiler.h minix/compiler-ack.h minix/sha2.h minix/sha1.h minix/md5.h \
|
minix/compiler.h minix/compiler-ack.h minix/sha2.h minix/sha1.h minix/md5.h \
|
||||||
minix/audio_fw.h minix/hash.h
|
minix/audio_fw.h minix/hash.h minix/input.h
|
||||||
INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h
|
INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h
|
||||||
INCS+= net/gen/arp_io.h net/gen/dhcp.h net/gen/ether.h \
|
INCS+= net/gen/arp_io.h net/gen/dhcp.h net/gen/ether.h \
|
||||||
net/gen/eth_hdr.h net/gen/eth_io.h net/gen/icmp.h \
|
net/gen/eth_hdr.h net/gen/eth_io.h net/gen/icmp.h \
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* 0xE00 - 0xEFF Common system messages (e.g. system signals)
|
* 0xE00 - 0xEFF Common system messages (e.g. system signals)
|
||||||
* 0xF00 - 0xFFF Scheduling messages
|
* 0xF00 - 0xFFF Scheduling messages
|
||||||
* 0x1000 - 0x10FF Notify messages
|
* 0x1000 - 0x10FF Notify messages
|
||||||
|
* 0x1300 - 0x13FF TTY Input
|
||||||
*
|
*
|
||||||
* Zero and negative values are widely used for OK and error responses.
|
* Zero and negative values are widely used for OK and error responses.
|
||||||
*/
|
*/
|
||||||
|
@ -1172,6 +1173,18 @@
|
||||||
/* SCHEDULING_INHERIT is like SCHEDULING_START, but without _QUANTUM field */
|
/* SCHEDULING_INHERIT is like SCHEDULING_START, but without _QUANTUM field */
|
||||||
#define SCHEDULING_INHERIT (SCHEDULING_BASE+5)
|
#define SCHEDULING_INHERIT (SCHEDULING_BASE+5)
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* TTY INPUT INJECTION *
|
||||||
|
*===========================================================================*/
|
||||||
|
|
||||||
|
#define INPUT_BASE 0x1300
|
||||||
|
|
||||||
|
#define INPUT_EVENT (INPUT_BASE + 0)
|
||||||
|
|
||||||
|
# define INPUT_TYPE m4_l1
|
||||||
|
# define INPUT_CODE m4_l2
|
||||||
|
# define INPUT_VALUE m4_l3
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* _MINIX_COM_H */
|
/* _MINIX_COM_H */
|
||||||
|
|
8
include/minix/input.h
Normal file
8
include/minix/input.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _MINIX_INPUT_H
|
||||||
|
#define _MINIX_INPUT_H
|
||||||
|
|
||||||
|
#define INPUT_EV_KEY 0x1
|
||||||
|
#define INPUT_EV_REL 0x2
|
||||||
|
#define INPUT_EV_ABS 0x3
|
||||||
|
|
||||||
|
#endif
|
|
@ -268,5 +268,8 @@ _PROTOTYPE( int sys_profbuf, (void *ctl_ptr, void *mem_ptr) );
|
||||||
_PROTOTYPE( int sys_getmcontext, (endpoint_t proc, mcontext_t *mcp) );
|
_PROTOTYPE( int sys_getmcontext, (endpoint_t proc, mcontext_t *mcp) );
|
||||||
_PROTOTYPE( int sys_setmcontext, (endpoint_t proc, mcontext_t *mcp) );
|
_PROTOTYPE( int sys_setmcontext, (endpoint_t proc, mcontext_t *mcp) );
|
||||||
|
|
||||||
|
/* input */
|
||||||
|
_PROTOTYPE( int tty_input_inject, (int type, int code, int val) );
|
||||||
|
|
||||||
#endif /* _SYSLIB_H */
|
#endif /* _SYSLIB_H */
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,24 @@ LIB= sys
|
||||||
SRCS= \
|
SRCS= \
|
||||||
alloc_util.c \
|
alloc_util.c \
|
||||||
assert.c \
|
assert.c \
|
||||||
|
asynsend.c \
|
||||||
|
ds.c \
|
||||||
|
env_get_prm.c \
|
||||||
|
env_panic.c \
|
||||||
|
env_parse.c \
|
||||||
|
env_prefix.c \
|
||||||
|
fkey_ctl.c \
|
||||||
|
gcov.c \
|
||||||
|
get_randomness.c \
|
||||||
|
getidle.c \
|
||||||
getsysinfo.c \
|
getsysinfo.c \
|
||||||
|
getuptime.c \
|
||||||
|
getuptime2.c \
|
||||||
|
input.c \
|
||||||
kernel_call.c \
|
kernel_call.c \
|
||||||
|
kprintf.c \
|
||||||
|
kputc.c \
|
||||||
|
kputs.c \
|
||||||
panic.c \
|
panic.c \
|
||||||
pci_attr_r16.c \
|
pci_attr_r16.c \
|
||||||
pci_attr_r32.c \
|
pci_attr_r32.c \
|
||||||
|
@ -27,6 +43,8 @@ SRCS= \
|
||||||
pci_reserve.c \
|
pci_reserve.c \
|
||||||
pci_set_acl.c \
|
pci_set_acl.c \
|
||||||
pci_slot_name.c \
|
pci_slot_name.c \
|
||||||
|
profile.c \
|
||||||
|
profile_extern.c \
|
||||||
safecopies.c \
|
safecopies.c \
|
||||||
sched_start.c \
|
sched_start.c \
|
||||||
sched_stop.c \
|
sched_stop.c \
|
||||||
|
@ -36,9 +54,11 @@ SRCS= \
|
||||||
sef_liveupdate.c \
|
sef_liveupdate.c \
|
||||||
sef_ping.c \
|
sef_ping.c \
|
||||||
sef_signal.c \
|
sef_signal.c \
|
||||||
|
ser_putc.c \
|
||||||
|
spin.c \
|
||||||
|
stacktrace.c \
|
||||||
sys_abort.c \
|
sys_abort.c \
|
||||||
sys_clear.c \
|
sys_clear.c \
|
||||||
sys_mcontext.c \
|
|
||||||
sys_cprof.c \
|
sys_cprof.c \
|
||||||
sys_endsig.c \
|
sys_endsig.c \
|
||||||
sys_eniop.c \
|
sys_eniop.c \
|
||||||
|
@ -47,37 +67,38 @@ SRCS= \
|
||||||
sys_fork.c \
|
sys_fork.c \
|
||||||
sys_getinfo.c \
|
sys_getinfo.c \
|
||||||
sys_getsig.c \
|
sys_getsig.c \
|
||||||
|
sys_hz.c \
|
||||||
sys_in.c \
|
sys_in.c \
|
||||||
sys_int86.c \
|
sys_int86.c \
|
||||||
sys_irqctl.c \
|
sys_irqctl.c \
|
||||||
sys_kill.c \
|
sys_kill.c \
|
||||||
|
sys_mcontext.c \
|
||||||
sys_memset.c \
|
sys_memset.c \
|
||||||
sys_newmap.c \
|
sys_newmap.c \
|
||||||
sys_out.c \
|
sys_out.c \
|
||||||
sys_physcopy.c \
|
sys_physcopy.c \
|
||||||
|
sys_privctl.c \
|
||||||
|
sys_profbuf.c \
|
||||||
sys_readbios.c \
|
sys_readbios.c \
|
||||||
sys_runctl.c \
|
sys_runctl.c \
|
||||||
sys_update.c \
|
|
||||||
sys_safecopy.c \
|
sys_safecopy.c \
|
||||||
sys_safemap.c \
|
sys_safemap.c \
|
||||||
sys_sysctl.c \
|
sys_schedctl.c \
|
||||||
sys_vsafecopy.c \
|
sys_schedule.c \
|
||||||
sys_profbuf.c \
|
|
||||||
sys_sdevio.c \
|
sys_sdevio.c \
|
||||||
sys_segctl.c \
|
sys_segctl.c \
|
||||||
sys_setalarm.c \
|
sys_setalarm.c \
|
||||||
|
sys_setgrant.c \
|
||||||
sys_sigreturn.c \
|
sys_sigreturn.c \
|
||||||
sys_sigsend.c \
|
sys_sigsend.c \
|
||||||
sys_privctl.c \
|
|
||||||
sys_setgrant.c \
|
|
||||||
sys_sprof.c \
|
sys_sprof.c \
|
||||||
sys_stime.c \
|
|
||||||
sys_schedule.c \
|
|
||||||
sys_schedctl.c \
|
|
||||||
sys_statectl.c \
|
sys_statectl.c \
|
||||||
|
sys_stime.c \
|
||||||
|
sys_sysctl.c \
|
||||||
sys_times.c \
|
sys_times.c \
|
||||||
sys_trace.c \
|
sys_trace.c \
|
||||||
sys_umap.c \
|
sys_umap.c \
|
||||||
|
sys_update.c \
|
||||||
sys_vinb.c \
|
sys_vinb.c \
|
||||||
sys_vinl.c \
|
sys_vinl.c \
|
||||||
sys_vinw.c \
|
sys_vinw.c \
|
||||||
|
@ -86,44 +107,24 @@ SRCS= \
|
||||||
sys_voutb.c \
|
sys_voutb.c \
|
||||||
sys_voutl.c \
|
sys_voutl.c \
|
||||||
sys_voutw.c \
|
sys_voutw.c \
|
||||||
|
sys_vsafecopy.c \
|
||||||
sys_vtimer.c \
|
sys_vtimer.c \
|
||||||
taskcall.c \
|
taskcall.c \
|
||||||
ds.c \
|
tickdelay.c \
|
||||||
|
timers.c \
|
||||||
|
timing.c \
|
||||||
|
tsc_util.c \
|
||||||
vm_brk.c \
|
vm_brk.c \
|
||||||
vm_exec_newmem.c \
|
vm_exec_newmem.c \
|
||||||
vm_exit.c \
|
vm_exit.c \
|
||||||
vm_notify_sig.c \
|
|
||||||
vm_fork.c \
|
vm_fork.c \
|
||||||
vm_info.c \
|
vm_info.c \
|
||||||
vm_map_phys.c \
|
vm_map_phys.c \
|
||||||
vm_umap.c \
|
vm_notify_sig.c \
|
||||||
vm_push_sig.c \
|
vm_push_sig.c \
|
||||||
|
vm_umap.c \
|
||||||
vm_yield_get_block.c \
|
vm_yield_get_block.c \
|
||||||
asynsend.c \
|
|
||||||
kprintf.c \
|
|
||||||
kputc.c \
|
|
||||||
kputs.c \
|
|
||||||
tickdelay.c \
|
|
||||||
get_randomness.c \
|
|
||||||
getidle.c \
|
|
||||||
getuptime.c \
|
|
||||||
getuptime2.c \
|
|
||||||
env_get_prm.c \
|
|
||||||
env_parse.c \
|
|
||||||
env_panic.c \
|
|
||||||
env_prefix.c \
|
|
||||||
fkey_ctl.c \
|
|
||||||
tsc_util.c \
|
|
||||||
ser_putc.c \
|
|
||||||
stacktrace.c \
|
|
||||||
sys_hz.c \
|
|
||||||
timing.c \
|
|
||||||
profile_extern.c \
|
|
||||||
profile.c \
|
|
||||||
vprintf.c \
|
vprintf.c \
|
||||||
timers.c \
|
|
||||||
spin.c \
|
|
||||||
gcov.c
|
|
||||||
|
|
||||||
CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR}
|
CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR}
|
||||||
|
|
||||||
|
|
17
lib/libsys/input.c
Normal file
17
lib/libsys/input.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include "syslib.h"
|
||||||
|
#include <minix/sysutil.h>
|
||||||
|
/*****************************************************************************
|
||||||
|
* tty_inject_event *
|
||||||
|
*****************************************************************************/
|
||||||
|
PUBLIC int tty_inject_event(type, code, val)
|
||||||
|
int type;
|
||||||
|
int code;
|
||||||
|
int val;
|
||||||
|
{
|
||||||
|
message msg;
|
||||||
|
msg.INPUT_TYPE = type;
|
||||||
|
msg.INPUT_CODE = code;
|
||||||
|
msg.INPUT_VALUE = val;
|
||||||
|
|
||||||
|
return send(TTY_PROC_NR, &msg);
|
||||||
|
}
|
Loading…
Reference in a new issue