/shark/trunk/drivers/input/include/drivers/shark_keyb26.h |
---|
0,0 → 1,168 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/** |
------------ |
CVS : $Id: shark_keyb26.h,v 1.1 2004-03-22 14:48:15 mauro Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2004-03-22 14:48:15 $ |
------------ |
**/ |
/* |
* Copyright (C) 2000 Giuseppe Lipari |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Project: HARTIK 3.0 */ |
/* Description: Hard Real TIme Kernel for 8086 compatible */ |
/* Author: Giuseppe Lipari */ |
/* Start date : 19/6/96 */ |
/* CVS $Id: shark_keyb26.h,v 1.1 2004-03-22 14:48:15 mauro Exp $ */ |
/* File: Keyb.H */ |
/* Revision: 1.4b */ |
/* Last update : 22/3/99 */ |
/* (MG) */ |
/* -- added keyb_enable() & keyb_disable() */ |
/* -- changed keyb_init() definition */ |
#ifndef __KEYB_H__ |
#define __KEYB_H__ |
#include <kernel/const.h> |
#include <kernel/model.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "keycode.h" |
typedef struct { |
BYTE useAltGr; |
char keyMap [TABLE_KEY_SIZE]; |
char keyShiftMap[TABLE_KEY_SIZE]; |
char keyAltGrMap[TABLE_KEY_SIZE]; |
} KEYB_MAP; |
extern KEYB_MAP keyMaps[]; |
#define KEYMAP_US 0 |
#define KEYMAP_IT 1 |
/* Key Status */ |
#define KEY_RELEASED 0 |
#define KEY_PRESSED 1 |
#define KEY_REPEATED 2 |
/* Ascii Codes */ |
#define BACKSPACE 0x08 |
#define ENTER 0x0d |
#define DELETE 0x18 |
#define ESC 0x1b |
#define TAB 0x09 |
/* Flag Codes */ |
#define ALTR_BIT 0x01 |
#define ALTL_BIT 0x02 |
#define CNTR_BIT 0x04 |
#define CNTL_BIT 0x08 |
#define SHFL_BIT 0x10 |
#define SHFR_BIT 0x20 |
#define SCAN_BIT 0x40 |
typedef struct { |
BYTE ascii; |
BYTE scan; |
BYTE flag; |
BYTE status; |
} KEY_EVT; |
#define isRepeated(k) (k.status == KEY_REPEATED) |
#define isReleased(k) (k.status == KEY_RELEASED) |
#define isScanCode(k) (k.flag & SCAN_BIT) |
#define isLeftShift(k) (k.flag & SHFL_BIT) |
#define isRightShift(k) (k.flag & SHFR_BIT) |
#define isLeftCtrl(k) (k.flag & CNTL_BIT) |
#define isRightCtrl(k) (k.flag & CNTR_BIT) |
#define isLeftAlt(k) (k.flag & ALTL_BIT) |
#define isRightAlt(k) (k.flag & ALTR_BIT) |
#define keyb_getchar() keyb_getch(BLOCK) |
typedef struct keyb_parms { |
TASK_MODEL *tm; |
unsigned char keymap; |
void (*ctrlcfunc)(KEY_EVT *k); |
} KEYB_PARMS; |
#define KEYB_DEFAULT ((unsigned long)(-1)) /*+ used for default params +*/ |
#define BASE_KEYB {(TASK_MODEL *)KEYB_DEFAULT, \ |
(unsigned char)KEYB_DEFAULT, \ |
(void *)KEYB_DEFAULT} |
#define keyb_default_parm(m) (m).tm = (TASK_MODEL *) KEYB_DEFAULT, \ |
(m).keymap = (unsigned char) KEYB_DEFAULT, \ |
(m).ctrlcfunc = (void *) KEYB_DEFAULT |
#define keyb_def_map(s,m) (s).keymap=(m) |
#define keyb_def_ctrlC(s,f) (s).ctrlcfunc=(f) |
#define keyb_def_task(s,m) (s).tm=(TASK_MODEL *)(m) |
int KEYB26_init(KEYB_PARMS *s); |
int KEYB26_close(void); |
BYTE keyb_getch(BYTE wait); |
int keyb_getcode(KEY_EVT *k, BYTE wait); |
void keyb_hook(KEY_EVT k, void (*f)(KEY_EVT *k), unsigned char l); |
int keyb_enable(void); |
int keyb_disable(void); |
int keyb_end(void); |
int keyb_set_map(unsigned char m); |
int keyb_get_map(void); |
#ifdef __cplusplus |
}; |
#endif |
#endif |
/shark/trunk/drivers/input/include/drivers/shark_spk26.h |
---|
0,0 → 1,50 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Glue Layer Header Linux Input Driver*/ |
#ifndef __SHARK_SPK26_H__ |
#define __SHARK_SPK26_H__ |
int SPEAK26_init(void); |
int SPEAK26_close(void); |
void speaker_sound(unsigned int hz, unsigned int ticks); |
void speaker_mute(void); |
#endif |
/shark/trunk/drivers/input/include/drivers/shark_input26.h |
---|
0,0 → 1,53 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Glue Layer Header Linux Input Driver*/ |
#ifndef __SHARK_INPUT26_H__ |
#define __SHARK_INPUT26_H__ |
int JOY26_init(void); |
int JOY26_close(void); |
int INPUT26_init(void); |
int INPUT26_close(void); |
int EVBUG26_init(void); |
int EVBUG26_close(void); |
#endif |
/shark/trunk/drivers/input/include/drivers/keycode.h |
---|
0,0 → 1,163 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#ifndef __KEYCODE_H__ |
#define __KEYCODE_H__ |
#define NUM_OF_KEY 0x90 /* Till the end */ |
#define TABLE_KEY_SIZE 0x3A /* Till KEY_SPC */ |
#define KEY_ESC 0x01 |
#define KEY_1 0x02 |
#define KEY_2 0x03 |
#define KEY_3 0x04 |
#define KEY_4 0x05 |
#define KEY_5 0x06 |
#define KEY_6 0x07 |
#define KEY_7 0x08 |
#define KEY_8 0x09 |
#define KEY_9 0x0A |
#define KEY_0 0x0B |
#define KEY_SUB 0x0C |
#define KEY_PLUS 0x0D |
#define KEY_BKS 0x0E |
#define KEY_TAB 0x0F |
#define KEY_Q 0x10 |
#define KEY_W 0x11 |
#define KEY_E 0x12 |
#define KEY_R 0x13 |
#define KEY_T 0x14 |
#define KEY_Y 0x15 |
#define KEY_U 0x16 |
#define KEY_I 0x17 |
#define KEY_O 0x18 |
#define KEY_P 0x19 |
#define KEY_BRL 0x1A |
#define KEY_BRR 0x1B |
#define KEY_ENT 0x1C |
#define KEY_CTRLL 0x1D |
#define KEY_A 0x1E |
#define KEY_S 0x1F |
#define KEY_D 0x20 |
#define KEY_F 0x21 |
#define KEY_G 0x22 |
#define KEY_H 0x23 |
#define KEY_J 0x24 |
#define KEY_K 0x25 |
#define KEY_L 0x26 |
#define KEY_COL 0x27 |
#define KEY_API 0x28 |
#define KEY_TIL 0x29 |
#define KEY_SHL 0x2A |
#define KEY_BSL 0x2B |
#define KEY_Z 0x2C |
#define KEY_X 0x2D |
#define KEY_C 0x2E |
#define KEY_V 0x2F |
#define KEY_B 0x30 |
#define KEY_N 0x31 |
#define KEY_M 0x32 |
#define KEY_LT 0x33 |
#define KEY_GT 0x34 |
#define KEY_SLH 0x35 |
#define KEY_SHR 0x36 |
#define PAD_AST 0x37 |
#define KEY_ALTL 0x38 |
#define KEY_SPC 0x39 |
#define KEY_CPSLOCK 0x3A |
#define KEY_F1 0x3B |
#define KEY_F2 0x3C |
#define KEY_F3 0x3D |
#define KEY_F4 0x3E |
#define KEY_F5 0x3F |
#define KEY_F6 0x40 |
#define KEY_F7 0x41 |
#define KEY_F8 0x42 |
#define KEY_F9 0x43 |
#define KEY_F10 0x44 |
#define PAD_NUMLOCK 0x45 |
#define EXT_SCRLOCK 0x46 |
#define PAD_HOME 0x47 |
#define PAD_UP 0x48 |
#define PAD_PGUP 0x49 |
#define PAD_SUB 0x4A |
#define PAD_LEFT 0x4B |
#define PAD_5 0x4C |
#define PAD_RIGHT 0x4D |
#define PAD_PLUS 0x4E |
#define PAD_END 0x4F |
#define PAD_DOWN 0x50 |
#define PAD_PGDW 0x51 |
#define PAD_INS 0x52 |
#define PAD_DEL 0x53 |
#define KEY_MACRO 0x56 /* ?!? */ |
#define KEY_F11 0x57 |
#define KEY_F12 0x58 |
#define PAD_ENT 0x60 |
#define KEY_CTRLR 0x61 |
#define PAD_SLH 0x62 |
#define EXT_PTRSC 0x63 |
#define KEY_ALTR 0x64 |
#define EXT_HOME 0x66 |
#define EXT_UP 0x67 |
#define EXT_PGUP 0x68 |
#define EXT_LEFT 0x69 |
#define EXT_RIGHT 0x6A |
#define EXT_END 0x6B |
#define EXT_DOWN 0x6C |
#define EXT_PGDW 0x6D |
#define EXT_INS 0x6E |
#define EXT_DEL 0x6F |
#define PWR_POWER 0x74 |
#define EXT_PAUSE 0x77 |
#define WIN_L 0x7D |
#define WIN_R 0x7E |
#define WIN_APPS 0x7F |
#define PWR_SLEEP 0x8E |
#define PWR_WAKE 0x8F |
#endif /* __KEYCODE_H__ */ |
/shark/trunk/drivers/input/include/drivers/shark_mouse26.h |
---|
0,0 → 1,70 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Glue Layer Header Linux Input Driver*/ |
#ifndef __SHARK_MOUSE26_H__ |
#define __SHARK_MOUSE26_H__ |
/* mouse buttons constant */ |
#define MOUSE_RBUTT 1 |
#define MOUSE_CBUTT 2 |
#define MOUSE_LBUTT 4 |
/* the mouse event struct */ |
typedef struct { |
int x, y, z; /* mouse position */ |
int dx, dy, dz; /* distance covered by mouse */ |
int buttons; /* buttons flags */ |
} MOUSE_EVT; |
/* macros to test mouse buttons */ |
#define isLeftButton(m) ((m).buttons & MOUSE_LBUTT) |
#define isRightButton(m) ((m).buttons & MOUSE_RBUTT) |
#define isCentralButton(m) ((m).buttons & MOUSE_CBUTT) |
/* user mouse handler */ |
typedef void (*MOUSE_HANDLER)(MOUSE_EVT*); |
int MOUSE26_init(void); |
int MOUSE26_close(void); |
#endif |
/shark/trunk/drivers/input/shark/shark_keymap.c |
---|
0,0 → 1,115 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <muro.marinoi@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#include <kernel/kern.h> |
#include "../include/drivers/shark_keyb26.h" |
extern BYTE useAltGr; |
extern char keyTable [TABLE_KEY_SIZE]; |
extern char keyShiftTable[TABLE_KEY_SIZE]; |
extern char keyAltGrTable[TABLE_KEY_SIZE]; |
static unsigned char actualMap; |
static KEYB_MAP keyMaps[] = { |
/* US International Map */ |
{ FALSE, |
/* Plain Map */ |
{ 0x00, 0x1b, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2d, 0x3d, 0x7f, 0x09, |
0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6f, 0x70, 0x5b, 0x5d, 0x0d, 0x00, 0x61, 0x73, |
0x64, 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0x3b, 0x27, 0x60, 0x00, 0x5c, 0x7a, 0x78, 0x63, 0x76, |
0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x2f, 0x00, 0x2a, 0x00, 0x20}, |
/* Shift Map */ |
{ 0x00, 0x1b, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5e, 0x26, 0x2a, 0x28, 0x29, 0x5f, 0x2b, 0x7f, 0x09, |
0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4f, 0x50, 0x7b, 0x7d, 0x0d, 0x00, 0x41, 0x53, |
0x44, 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x3a, 0x22, 0x7e, 0x00, 0x7c, 0x5a, 0x58, 0x43, 0x56, |
0x42, 0x4e, 0x4d, 0x3c, 0x3e, 0x3f, 0x00, 0x2a, 0x00, 0x20}, |
/* AltGr Map */ |
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
}, |
/* Italian Map */ |
{ TRUE, |
/* Plain Map */ |
{ 0x00, 0x1b, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x27, 0xec, 0x7f, 0x09, |
0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6f, 0x70, 0xe7, 0x2b, 0x0d, 0x00, 0x61, 0x73, |
0x64, 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0xf2, 0xe0, 0x5c, 0x00, 0xf8, 0x7a, 0x78, 0x63, 0x76, |
0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x2d, 0x00, 0x2a, 0x00, 0x20}, |
/* Shift Map */ |
{ 0x00, 0x1b, 0x21, 0x22, 0x9c, 0x24, 0x25, 0x26, 0x2f, 0x28, 0x29, 0x3d, 0x3f, 0x5e, 0x7f, 0x09, |
0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4f, 0x50, 0xe9, 0x2a, 0x0d, 0x00, 0x41, 0x53, |
0x44, 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0xe7, 0xb0, 0x7c, 0x00, 0xa7, 0x5a, 0x58, 0x43, 0x56, |
0x42, 0x4e, 0x4d, 0x3b, 0x3a, 0x5f, 0x00, 0x2a, 0x00, 0x20}, |
/* AltGr Map */ |
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x7d, 0x7e, 0x60, 0xed, 0x00, 0x00, |
0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6f, 0x70, 0x5b, 0x5d, 0x0d, 0x00, 0x61, 0x73, |
0x64, 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0x40, 0x23, 0x00, 0x00, 0xfa, 0x7a, 0x78, 0x63, 0x76, |
0x62, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x20} |
} |
}; |
#define NUM_OF_MAPS (sizeof keyMaps / sizeof keyMaps[0]) |
int keyb_get_map(void) |
{ |
return actualMap; |
} |
int keyb_set_map(unsigned char m) |
{ |
register int i = 0; |
/* If keyMaps[m] not available then set US */ |
if (m >= NUM_OF_MAPS) |
actualMap = KEYMAP_US; |
else |
actualMap = m; |
useAltGr = keyMaps[i].useAltGr; |
for (i=0; i < TABLE_KEY_SIZE; i++) { |
keyTable[i] = keyMaps[actualMap].keyMap[i]; |
keyShiftTable[i] = keyMaps[actualMap].keyShiftMap[i]; |
} |
if (useAltGr) |
for (i=0; i < TABLE_KEY_SIZE; i++) |
keyAltGrTable[i] = keyMaps[actualMap].keyAltGrMap[i]; |
return actualMap; |
} |
/shark/trunk/drivers/input/shark/shark_mouse.c |
---|
0,0 → 1,114 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#define __MOUSE_DEBUG__ |
#include <kernel/kern.h> |
#include "../include/drivers/shark_input26.h" |
#include "../include/drivers/shark_mouse26.h" |
/* Devices */ |
extern int psmouse_init(void); |
extern int psmouse_exit(void); |
/* Handlers */ |
extern int mouse_init(void); |
extern void mouse_exit(void); |
extern int input_installed; |
/* Mouse driver currently installed */ |
static int mouse_installed = FALSE; |
/*static PID mouse_pid = NIL;*/ |
/* |
* Start mouseProc Task |
*/ |
void shark_mouse_task(void) |
{ |
//task_activate(mousebpid); |
} |
/* Init the Linux Speaker Driver */ |
int MOUSE26_init(void) |
{ |
int status = 0; |
if (mouse_installed == TRUE) return 0; |
if (input_installed == FALSE) { |
status = INPUT26_init(); |
if (status) { |
printk(KERN_ERR "shark_mouse.c: Unable to open Input SubSystem.\n"); |
return -1; |
} |
} |
status = psmouse_init(); |
if (status) { |
printk(KERN_ERR "shark_mouse.c: PsMouse_Init return: %d\n", status); |
return -1; |
} |
status = mouse_init(); |
if (status) { |
printk(KERN_ERR "shark_mouse.c: Mouse_Init return: %d\n", status); |
return -1; |
} |
mouse_installed = TRUE; |
return status; |
} |
int MOUSE26_close() |
{ |
if (!mouse_installed) |
return -1; |
mouse_exit(); |
psmouse_exit(); |
mouse_installed = FALSE; |
return 0; |
} |
/shark/trunk/drivers/input/shark/shark_keyb.c |
---|
0,0 → 1,568 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@gandalf.sssup.it> |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
//#define __KEYB_DEBUG__ |
#include <kernel/kern.h> |
#include <signal.h> |
#include <modules/hartport.h> |
#include "../include/drivers/shark_input26.h" |
#include "../include/drivers/shark_keyb26.h" |
/* Devices */ |
extern int atkbd_init(void); |
extern int atkbd_exit(void); |
/* Handlers */ |
extern int kbd_init(void); |
extern int kbd_exit(void); |
extern int kbd_enable(void); |
extern int kbd_disable(void); |
/* Functions */ |
extern int kbd_get(unsigned int *data, BYTE access); |
extern void kbd_setleds(unsigned int led); |
extern int kbd_rate(unsigned int *delay, unsigned int *period); |
extern void kbd_mksound(unsigned int hz, unsigned int ticks); |
extern int input_installed; |
/* |
* The following tables contains the ascii code corresponding to the |
* scan codes, with shift & no shift... |
*/ |
char keyTable [TABLE_KEY_SIZE]; |
char keyShiftTable[TABLE_KEY_SIZE]; |
char keyAltGrTable[TABLE_KEY_SIZE]; |
BYTE useAltGr = FALSE; |
/* Status variables */ |
static BYTE shift = FALSE; |
static BYTE ctrl = FALSE; |
static BYTE alt = FALSE; |
static BYTE altgr = FALSE; |
static BYTE capslock = FALSE; |
static BYTE numlock = TRUE; |
static BYTE scrolllock = FALSE; |
/* Keyboard Flags (if shift, alt or control are pressed...); */ |
static BYTE keyFlag = 0x00; |
static BYTE status; |
/* Keyboard driver currently installed */ |
static int keyb_installed = FALSE; |
#define MAX_KEY_EXC 50 |
static struct keyexctable |
{ |
KEY_EVT evt; |
void (*func) (KEY_EVT * k); |
unsigned char lock; |
} keyExcTable[MAX_KEY_EXC]; |
static int lastExc; |
/* Communication port between the extern process & the user */ |
static PORT pkeyPort, ukeyPort; |
/* keyboard task PID */ |
static PID keybpid; |
/* |
* Start keyProc Task |
*/ |
void shark_kbd_task(void) |
{ |
task_activate(keybpid); |
} |
/* |
* This function get a scan code, return an ascii code and set |
* the status vars in order to handle the special keys of the AT keyboard |
*/ |
WORD scanCode(unsigned int c, int d) |
{ |
//printk("scanCode: c (%x) - d (%d)\n", c, d); |
/* KEY_EVT status setting */ |
status = d; |
switch (c) { |
/* CapsLock pressed*/ |
case KEY_CPSLOCK: |
if (d == KEY_PRESSED) { |
capslock = capslock ? FALSE : TRUE; |
/* light the caps lock led */ |
kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
} |
return 0; |
/* NumLock pressed */ |
case PAD_NUMLOCK: |
if (d == KEY_PRESSED) { |
numlock = numlock ? FALSE : TRUE; |
/* light the num lock led */ |
kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
} |
return 0; |
/* ScrollLock pressed*/ |
case EXT_SCRLOCK: |
if (d == KEY_PRESSED) { |
scrolllock = scrolllock ? FALSE : TRUE; |
/* light the scroll lock led */ |
kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
} |
return 0; |
/* Shift pressed or released */ |
case KEY_SHL: |
if (d) { |
shift = TRUE; |
if (c == KEY_SHL) |
keyFlag |= SHFL_BIT; |
} else { |
keyFlag &= (!SHFL_BIT); |
if (!(keyFlag & SHFR_BIT)) |
shift = FALSE; |
} |
return 0; |
/* Shift pressed or released */ |
case KEY_SHR: |
if (d) { |
shift = TRUE; |
if (c == KEY_SHR) |
keyFlag |= SHFR_BIT; |
} else { |
keyFlag &= (!SHFR_BIT); |
if (!(keyFlag & SHFL_BIT)) |
shift = FALSE; |
} |
return 0; |
/* Control pressed or released */ |
case KEY_CTRLL: |
if (d) { |
ctrl = TRUE; |
keyFlag |= CNTL_BIT; |
} else { |
keyFlag &= (!CNTL_BIT); |
if (!(keyFlag & CNTR_BIT)) |
ctrl = FALSE; |
} |
return 0; |
/* Control pressed or released */ |
case KEY_CTRLR: |
if (d) { |
ctrl = TRUE; |
keyFlag |= CNTR_BIT; |
} else { |
keyFlag &= (!CNTR_BIT); |
if (!(keyFlag & CNTL_BIT)) |
ctrl = FALSE; |
} |
return 0; |
/* Alt Left pressed */ |
case KEY_ALTL: |
if (d) { |
alt = TRUE; |
keyFlag |= ALTL_BIT; |
} else { |
alt = FALSE; |
keyFlag &= (!ALTL_BIT); |
} |
return 0; |
/* Alt Right (AltGr) pressed */ |
case KEY_ALTR: |
if (d) { |
altgr = TRUE; |
keyFlag |= ALTR_BIT; |
} else { |
altgr = FALSE; |
keyFlag &= (!ALTR_BIT); |
if ((!useAltGr) && (!(keyFlag & ALTL_BIT))) |
alt = FALSE; |
} |
return 0; |
/* Delete */ |
case EXT_DEL: |
return DELETE; |
case PAD_DEL: |
if (numlock || shift) |
return 0x18; |
else |
break; |
/* Pad Enter */ |
case PAD_ENT: |
return 0x0d; |
/* Pad Add */ |
case PAD_PLUS: |
return 0x2b; |
/* Pad Sub */ |
case PAD_SUB: |
return 0x2d; |
/* Pad Slash */ |
case PAD_SLH: |
return 0x2f; |
/* Numbers & simbols */ |
case KEY_1: case KEY_2: case KEY_3: case KEY_4: case KEY_5: |
case KEY_6: case KEY_7: case KEY_8: case KEY_9: case KEY_0: |
case KEY_SUB: case KEY_PLUS: case KEY_BRL: case KEY_BRR: |
case KEY_COL: case KEY_API: case KEY_TIL: case KEY_BSL: |
case KEY_LT: case KEY_GT: case KEY_SLH: |
/* AlrGR enabled & pressed */ |
if (altgr && useAltGr) { |
return keyAltGrTable[c]; |
} |
/* Control Shift status */ |
if (shift) |
return keyShiftTable[c]; |
else |
return keyTable[c]; |
} |
/* Pad Keys */ |
if (numlock || shift) |
switch (c) { |
case PAD_DEL: |
return 0x18; |
case PAD_INS: |
return 0x30; |
case PAD_END: |
return 0x31; |
case PAD_DOWN: |
return 0x32; |
case PAD_PGDW: |
return 0x33; |
case PAD_RIGHT: |
return 0x34; |
case PAD_5: |
return 0x35; |
case PAD_LEFT: |
return 0x36; |
case PAD_HOME: |
return 0x37; |
case PAD_UP: |
return 0x38; |
case PAD_PGUP: |
return 0x39; |
} |
/* Characters keys */ |
if (((c >= KEY_Q) && (c <= KEY_P)) || |
((c >= KEY_A) && (c <= KEY_L)) || |
((c >= KEY_Z) && (c <= KEY_M))) { |
/* AlrGR enabled & pressed */ |
if (altgr && useAltGr) { |
return keyAltGrTable[c]; |
} |
/* Control CapsLock & Shift status */ |
if (capslock) { |
if (shift) |
return keyTable[c]; |
else |
return keyShiftTable[c]; |
} else { |
if (shift) |
return keyShiftTable[c]; |
else |
return keyTable[c]; |
} |
} |
/* Remaining keys */ |
if (c < TABLE_KEY_SIZE) |
/* Left 'low' keys (Esc, BackSpace, Space, ...) */ |
return keyTable[c]; |
else |
/* Default - Return as keycode */ |
return (0xff00 | c); |
} |
TASK keyProc(void) |
{ |
WORD code; |
BYTE found; |
KEY_EVT dt; |
int i, res; |
unsigned int dato; |
while (1) { |
res = kbd_get(&dato, NON_BLOCK); |
if (res >= 0) { |
code = scanCode(dato, res); |
if (code != 0) { |
if (code & 0xff00) |
/* It's a scan code, set the right bit */ |
dt.flag = (keyFlag | SCAN_BIT); |
else |
/* Simply send the keyFlag status */ |
dt.flag = keyFlag; |
dt.status = status; |
dt.ascii = (BYTE) (code & 0x00FF); |
dt.scan = dato; |
#ifdef __KEYB_DEBUG__ |
printk("shark_keyb.c: KEY_EVT ( %2x - %c - %2x - %1d)\n", dt.scan, dt.ascii, dt.flag, dt.status); |
#endif |
found = FALSE; |
for (i = 0; i < lastExc; i++) |
if ((keyExcTable[i].evt.scan == dt.scan) && (keyExcTable[i].evt.flag == dt.flag) && (keyExcTable[i].evt.status == dt.status)) { |
#ifdef __KEYB_DEBUG__ |
printk("shark_keyb.c: Key_Hook ( %2x - %2x - %1d) -> ( %2x - %2x - %1d)\n", dt.scan, dt.flag, dt.status, keyExcTable[i].evt.scan, keyExcTable[i].evt.flag, keyExcTable[i].evt.status); |
#endif |
keyExcTable[i].func(&dt); |
if (keyExcTable[i].lock == TRUE) |
found = TRUE; |
} |
/* when the port is full, data is lost */ |
if (!found) |
port_send(pkeyPort, (BYTE *) (&dt), NON_BLOCK); |
} |
} |
task_endcycle(); |
} |
} |
/* default function called on ctrl-c */ |
void default_ctrlChandler(KEY_EVT * k) { |
set_active_page(0); |
set_visual_page(0); |
cputs("Ctrl-C pressed!\n"); |
sys_end(); |
//exit(1); |
} |
/**** Start User Functions ****/ |
/* Function that returns the ascii code */ |
BYTE keyb_getch(BYTE wait) |
{ |
KEY_EVT c; |
BYTE fl; |
fl = port_receive (ukeyPort, &c, wait); |
if (fl && !isScanCode(c) && !isReleased(c)) |
return (c.ascii); |
else |
return 0; |
} |
/* |
* Function that returns a structure containing the flags status, the ascii |
* code, and the scan code |
*/ |
int keyb_getcode(KEY_EVT * k, BYTE wait) |
{ |
return (port_receive (ukeyPort, (BYTE *) (k), wait)); |
} |
void keyb_hook(KEY_EVT k, void (*f) (KEY_EVT * k), unsigned char l) |
{ |
if (lastExc >= MAX_KEY_EXC) |
return; |
keyExcTable[lastExc].evt = k; |
keyExcTable[lastExc].func = f; |
keyExcTable[lastExc++].lock = l; |
return; |
} |
/* MG: this function disable the keyboard */ |
int keyb_disable(void) |
{ |
kbd_disable(); |
return 0; |
} |
/* MG: this function enable the keyboard */ |
int keyb_enable(void) |
{ |
kbd_enable(); |
return 0; |
} |
/**** End Functions ****/ |
int KEYB26_init(KEYB_PARMS *s) |
{ |
KEYB_PARMS kparms = BASE_KEYB; |
WORD i; |
int status = 0; |
SOFT_TASK_MODEL base_m; |
TASK_MODEL *m; |
if (keyb_installed == TRUE) return 0; |
/* if a NULL is passed */ |
if (s == NULL) |
s = &kparms; |
for (i = 0; i < TABLE_KEY_SIZE; i++) { |
keyTable[i] = 0; |
keyShiftTable[i] = 0; |
keyAltGrTable[i] = 0; |
} |
/* keymap */ |
if (s->keymap == (unsigned char)KEYB_DEFAULT) s->keymap = KEYMAP_US; |
keyb_set_map(s->keymap); |
/* MG: changed RECEIVE to STREAM port - added a failure test */ |
pkeyPort = port_create ("KeybPort", 3, 20, STREAM, WRITE); |
if (pkeyPort == -1) |
return -2; |
ukeyPort = port_connect ("KeybPort", 3, STREAM, READ); |
if (ukeyPort == -1) { |
port_delete (pkeyPort); |
return -3; |
} |
/* remove all key pressed handlers */ |
lastExc = 0; |
/* and add a ctrl-c handler if requested */ |
if (s->ctrlcfunc == (void *) KEYB_DEFAULT) |
s->ctrlcfunc = (void *) default_ctrlChandler; |
if (s->ctrlcfunc != NULL) { |
KEY_EVT emerg; |
emerg.ascii = 'c'; |
emerg.scan = KEY_C; |
emerg.flag = CNTL_BIT; |
keyb_hook (emerg, s->ctrlcfunc, TRUE); |
emerg.flag = CNTR_BIT; |
keyb_hook (emerg, s->ctrlcfunc, TRUE); |
} |
/* keyb task */ |
if (s->tm == (TASK_MODEL *) KEYB_DEFAULT) { |
soft_task_default_model (base_m); |
soft_task_def_wcet (base_m, 2000); |
soft_task_def_met (base_m, 800); |
soft_task_def_period (base_m, 25000); |
soft_task_def_system (base_m); |
soft_task_def_nokill (base_m); |
soft_task_def_aperiodic (base_m); |
m = (TASK_MODEL *) & base_m; |
} else |
m = s->tm; |
#ifdef __KEYB_DEBUG__ |
//printk(KERN_DEBUG "keyb task: %li %li %li %li\n", (long)s->pclass, (long)APERIODIC, (long)s->dline, (long)s->wcet); |
#endif |
keybpid = task_create ("KeyTask", keyProc, m, NULL); |
if (keybpid == -1) { |
port_delete (pkeyPort); |
port_delete (ukeyPort); |
return -1; |
} |
if (input_installed == FALSE) |
if (INPUT26_init()) { |
#ifdef __KEYB_DEBUG__ |
printk(KERN_ERR "shark_keyb.c: Unable to open Input SubSystem.\n"); |
#endif |
port_delete (pkeyPort); |
port_delete (ukeyPort); |
return -1; |
} |
status = atkbd_init(); |
if (status) { |
#ifdef __KEYB_DEBUG__ |
printk(KERN_ERR "shark_keyb.c: AtKbd_Init return: %d\n", status); |
#endif |
port_delete (pkeyPort); |
port_delete (ukeyPort); |
return -1; |
} |
status = kbd_init(); |
if (status) { |
#ifdef __KEYB_DEBUG__ |
printk(KERN_ERR "shark_keyb.c: Kbd_Init return: %d\n", status); |
#endif |
port_delete (pkeyPort); |
port_delete (ukeyPort); |
return -1; |
} |
kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
kbd_enable(); |
keyb_installed = TRUE; |
return status; |
} |
/* |
* KEYB module cleanup |
* (must be called if it's needed to re-call keyb_init() with other parameters) |
* -1 -> ERROR |
*/ |
int KEYB26_close(void) |
{ |
int free; |
SYS_FLAGS f; |
if (!keyb_installed) |
return -1; |
kbd_disable(); |
kbd_exit(); |
atkbd_exit(); |
f = kern_fsave(); |
free = (proc_table[keybpid].status == FREE); |
kern_frestore(f); |
#ifdef __KEYB_DEBUG__ |
printk(KERN_DEBUG "shark_keyb.c: KeyTask is %s.\n", free ? "killed" : "alive"); |
#endif |
if (free) |
task_kill (keybpid); |
/*port_delete (pkeyPort); |
port_delete (ukeyPort);*/ |
keyb_installed = FALSE; |
return 0; |
} |
/shark/trunk/drivers/input/shark/shark_spk.c |
---|
0,0 → 1,103 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see the web pages for full authors list) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#define __MOUSE_DEBUG__ 1 |
#include <kernel/kern.h> |
#include "../include/drivers/shark_input26.h" |
#include "../include/drivers/shark_spk26.h" |
/* Devices */ |
extern int pcspkr_init(void); |
extern int pcspkr_exit(void); |
/* Handlers */ |
extern int speaker_init(void); |
extern void speaker_exit(void); |
/* Functions */ |
extern void spk_mksound(unsigned int hz, unsigned int ticks); |
extern void spk_nosound(unsigned long ignored); |
extern int input_installed; |
/* User Functions */ |
void speaker_sound(unsigned int hz, unsigned int ticks) |
{ |
spk_mksound(hz, ticks); |
} |
void speaker_mute(void) |
{ |
spk_nosound(0); |
} |
/* Init the Linux Speaker Driver */ |
int SPEAK26_init() |
{ |
int ret; |
if (input_installed == FALSE) |
if (INPUT26_init()) { |
printk(KERN_ERR "Unable to open Input SubSystem.\n"); |
return -1; |
} |
ret = pcspkr_init(); |
if (ret) { |
printk(KERN_ERR "PcSpkr_Init return: %d\n", ret); |
return -1; |
} |
ret = speaker_init(); |
if (ret) { |
printk(KERN_ERR "Speaker_Init return: %d\n", ret); |
return -1; |
} |
return 0; |
} |
int SPEAK26_close() |
{ |
speaker_exit(); |
pcspkr_exit(); |
return 0; |
} |
/shark/trunk/drivers/input/shark/shark_input.c |
---|
0,0 → 1,165 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Mauro Marinoni <mauro.marinoni@unipv.it> |
* |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#include <kernel/func.h> |
/* System */ |
extern int input_init(void); |
extern int input_exit(void); |
extern int serio_init(void); |
extern int serio_exit(void); |
/* Controllers */ |
extern int i8042_init(void); |
extern int i8042_exit(void); |
/*extern int serport_init(void); |
extern int serport_exit(void);*/ |
/* Devices */ |
/*extern int ns558_init(void); |
extern int ns558_exit(void); |
extern int analog_init(void); |
extern int analog_exit(void); |
extern int joydump_init(void); |
extern int joydump_exit(void);*/ |
/* Handlers */ |
extern int evbug_init(void); |
extern int evbug_exit(void); |
int input_installed = FALSE; |
/* Init the Linux Input Layer */ |
int INPUT26_init() { |
int ret; |
if (input_installed == TRUE) return 0; |
ret = input_init(); |
if (ret) { |
printk(KERN_ERR "Input_Init return: %d\n", ret); |
return -1; |
} |
ret = serio_init(); |
if (ret) { |
printk(KERN_ERR "Serio_Init return: %d\n", ret); |
return -1; |
} |
ret = i8042_init(); |
if (ret) { |
printk(KERN_ERR "i8042_Init return: %d\n", ret); |
return -1; |
} |
/* TODO |
ret = serport_init(); |
if (ret) { |
printk(KERN_ERR "SerPort_Init return: %d\n", ret); |
return -1; |
} */ |
input_installed = TRUE; |
return ret; |
} |
int INPUT26_close() { |
if (input_installed == TRUE) { |
i8042_exit(); |
serio_exit(); |
input_exit(); |
return 0; |
} else |
return -1; |
} |
/* Init the Linux Joystick Driver */ |
/*int JOY26_init() { |
int ret; |
if (input_installed == FALSE) |
if (INPUT26_init()) { |
printk(KERN_ERR "Unable to open Input SubSystem.\n"); |
return -1; |
} |
ret = ns558_init(); |
if (ret) { |
printk(KERN_ERR "Gameport_Init return: %d\n", ret); |
return -1; |
} |
//ret = analog_init(); |
ret = joydump_init(); |
if (ret) { |
printk(KERN_ERR "Joystick_Init return: %d\n", ret); |
return -1; |
} |
return 0; |
} |
int JOY26_close() { |
//analog_exit(); |
joydump_exit(); |
ns558_exit(); |
return 0; |
}*/ |
int EVBUG26_init() { |
evbug_init(); |
return 0; |
} |
int EVBUG26_close() { |
evbug_exit(); |
return 0; |
} |
/shark/trunk/drivers/input/handler/keyboard.c |
---|
0,0 → 1,319 |
/* |
* $Id: keyboard.c,v 1.1 2004-03-22 14:48:15 mauro Exp $ |
* |
* Copyright (c) 1999-2001 Vojtech Pavlik |
*/ |
/* |
* Input driver event debug module - dumps all events into syslog |
*/ |
/* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
#include <linuxcomp.h> |
#include <linux/slab.h> |
#include <linux/module.h> |
#include <linux/input.h> |
#include <linux/init.h> |
#include <linux/device.h> |
#include <linux/kbd_kern.h> |
#include <linux/kbd_diacr.h> |
//#define DEBUG_KBD |
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
MODULE_DESCRIPTION("Input driver event debug module"); |
MODULE_LICENSE("GPL"); |
extern void shark_kbd_task(void); |
/* Buffer Ssize */ |
#define KEYB_BUFFERSIZE 256 |
/* Buffer Mask ( i=(i+1)&MASK is better than i=(i+1)%SIZE ) */ |
#define KEYB_BUFFERMASK 0xff |
/* Circular Buffer */ |
static struct keyb_event { |
unsigned int keycode; |
int down; |
} kbuffer[KEYB_BUFFERSIZE]; |
/* |
* Buffer Pointers |
* data is inserted to khead |
* data is kept from ktail+1 |
* (khead point to ktail+1 when buffer is empty) |
*/ |
static unsigned ktail, khead; |
static char kbd_name[] = "kbd"; |
static struct input_handler kbd_handler; |
static unsigned char ledstate = 0xff; /* undefined */ |
/* |
* Start / Stop Keyboard |
*/ |
int kbd_enable(void) |
{ |
struct list_head *node; |
list_for_each(node,&kbd_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
struct input_dev *dev = handle->dev; |
if (test_bit(EV_REP, dev->evbit)) { |
input_event(dev, EV_PWR, 1, 0); |
} |
} |
return 0; |
} |
int kbd_disable(void) |
{ |
struct list_head *node; |
list_for_each(node,&kbd_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
struct input_dev *dev = handle->dev; |
if (test_bit(EV_REP, dev->evbit)) { |
input_event(dev, EV_PWR, 0, 0); |
} |
} |
return 0; |
} |
/* |
* Get data from the keyboard (primary port) |
* |
* it's follow the port_receive() semantic |
*/ |
int kbd_get(unsigned int *data, BYTE access) |
{ |
if ( ((ktail+1) & KEYB_BUFFERMASK) == ((khead) & KEYB_BUFFERMASK) ) |
return -1; |
ktail = (ktail+1) & KEYB_BUFFERMASK; |
*data = kbuffer[ktail].keycode; |
return kbuffer[ktail].down; |
} |
/* |
* Making beeps and bells. |
*/ |
static void kbd_nosound(unsigned long ignored) |
{ |
struct list_head * node; |
list_for_each(node,&kbd_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
if (test_bit(EV_SND, handle->dev->evbit)) { |
if (test_bit(SND_TONE, handle->dev->sndbit)) |
input_event(handle->dev, EV_SND, SND_TONE, 0); |
if (test_bit(SND_BELL, handle->dev->sndbit)) |
input_event(handle->dev, EV_SND, SND_BELL, 0); |
} |
} |
} |
static struct timer_list kd_mksound_timer = |
TIMER_INITIALIZER(kbd_nosound, 0, 0); |
void kbd_mksound(unsigned int hz, unsigned int ticks) |
{ |
struct list_head * node; |
del_timer(&kd_mksound_timer); |
if (hz) { |
list_for_each_prev(node,&kbd_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
if (test_bit(EV_SND, handle->dev->evbit)) { |
if (test_bit(SND_TONE, handle->dev->sndbit)) { |
input_event(handle->dev, EV_SND, SND_TONE, hz); |
break; |
} |
if (test_bit(SND_BELL, handle->dev->sndbit)) { |
input_event(handle->dev, EV_SND, SND_BELL, 1); |
break; |
} |
} |
} |
if (ticks) |
mod_timer(&kd_mksound_timer, jiffies26 + ticks); |
} else |
kbd_nosound(0); |
} |
/* |
* Setting the keyboard rate. |
*/ |
//int kbd_rate(struct kbd_repeat *rep) |
int kbd_rate(unsigned int *delay, unsigned int *period) |
{ |
struct list_head *node; |
unsigned int d = 0; |
unsigned int p = 0; |
list_for_each(node,&kbd_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
struct input_dev *dev = handle->dev; |
if (test_bit(EV_REP, dev->evbit)) { |
if (*delay > 0) |
input_event(dev, EV_REP, REP_DELAY, *delay); |
if (*period > 0) |
input_event(dev, EV_REP, REP_PERIOD, *period); |
d = dev->rep[REP_DELAY]; |
p = dev->rep[REP_PERIOD]; |
} |
} |
*delay = d; |
*period = p; |
return 0; |
} |
/* |
* This allows a keyboard to pick the LED state. |
*/ |
void kbd_refresh_leds(void) |
{ |
struct list_head * node; |
unsigned char leds = ledstate; |
list_for_each(node,&kbd_handler.h_list) { |
struct input_handle * handle = to_handle_h(node); |
input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); |
input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); |
input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04)); |
input_sync(handle->dev); |
} |
} |
void kbd_setleds(unsigned int led) |
{ |
ledstate = led; |
kbd_refresh_leds(); |
} |
static void kbd_event(struct input_handle *handle, unsigned int type, unsigned int keycode, int down) |
{ |
if (type != EV_KEY) |
return; |
#ifdef DEBUG_KBD |
printk(KERN_DEBUG "keyboard.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, keycode, down); |
#endif |
if (ktail != khead) { |
kbuffer[khead].keycode = keycode; |
kbuffer[khead].down = down; |
khead = (khead+1) & KEYB_BUFFERMASK; |
} |
shark_kbd_task(); |
} |
static struct input_handle *kbd_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
{ |
struct input_handle *handle; |
int i; |
for (i = KEY_RESERVED; i < BTN_MISC; i++) |
if (test_bit(i, dev->keybit)) break; |
if ((i == BTN_MISC) && !test_bit(EV_SND, dev->evbit)) |
return NULL; |
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
return NULL; |
memset(handle, 0, sizeof(struct input_handle)); |
handle->dev = dev; |
handle->handler = handler; |
handle->name = kbd_name; |
input_open_device(handle); |
#ifdef DEBUG_KBD |
printk(KERN_DEBUG "keyboard.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); |
#endif |
return handle; |
} |
static void kbd_disconnect(struct input_handle *handle) |
{ |
#ifdef DEBUG_KBD |
printk(KERN_DEBUG "keyboard.c: Disconnected device: %s\n", handle->dev->phys); |
#endif |
input_close_device(handle); |
kfree(handle); |
} |
static struct input_device_id kbd_ids[] = { |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
.evbit = { BIT(EV_KEY) }, |
}, |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
.evbit = { BIT(EV_SND) }, |
}, |
{ }, /* Terminating entry */ |
}; |
MODULE_DEVICE_TABLE(input, kbd_ids); |
static struct input_handler kbd_handler = { |
.event = kbd_event, |
.connect = kbd_connect, |
.disconnect = kbd_disconnect, |
.name = "kbd", |
.id_table = kbd_ids, |
}; |
int __init kbd_init(void) |
{ |
/* Initialize Buffer Variables */ |
khead=1; |
ktail=0; |
input_register_handler(&kbd_handler); |
return 0; |
} |
void __exit kbd_exit(void) |
{ |
input_unregister_handler(&kbd_handler); |
} |
module_init(kbd_init); |
module_exit(kbd_exit); |
/shark/trunk/drivers/input/handler/evbug.c |
---|
0,0 → 1,101 |
/* |
* $Id: evbug.c,v 1.1 2004-03-22 14:48:14 mauro Exp $ |
* |
* Copyright (c) 1999-2001 Vojtech Pavlik |
*/ |
/* |
* Input driver event debug module - dumps all events into syslog |
*/ |
/* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
#include <linuxcomp.h> |
#include <linux/slab.h> |
#include <linux/module.h> |
#include <linux/input.h> |
#include <linux/init.h> |
#include <linux/device.h> |
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
MODULE_DESCRIPTION("Input driver event debug module"); |
MODULE_LICENSE("GPL"); |
static char evbug_name[] = "evbug"; |
static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
{ |
printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value); |
} |
static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
{ |
struct input_handle *handle; |
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
return NULL; |
memset(handle, 0, sizeof(struct input_handle)); |
handle->dev = dev; |
handle->handler = handler; |
handle->name = evbug_name; |
input_open_device(handle); |
printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); |
return handle; |
} |
static void evbug_disconnect(struct input_handle *handle) |
{ |
printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys); |
input_close_device(handle); |
kfree(handle); |
} |
static struct input_device_id evbug_ids[] = { |
{ .driver_info = 1 }, /* Matches all devices */ |
{ }, /* Terminating zero entry */ |
}; |
MODULE_DEVICE_TABLE(input, evbug_ids); |
static struct input_handler evbug_handler = { |
.event = evbug_event, |
.connect = evbug_connect, |
.disconnect = evbug_disconnect, |
.name = "evbug", |
.id_table = evbug_ids, |
}; |
int __init evbug_init(void) |
{ |
input_register_handler(&evbug_handler); |
return 0; |
} |
void __exit evbug_exit(void) |
{ |
input_unregister_handler(&evbug_handler); |
} |
module_init(evbug_init); |
module_exit(evbug_exit); |
/shark/trunk/drivers/input/handler/mouse.c |
---|
0,0 → 1,304 |
/* |
* $Id: mouse.c,v 1.1 2004-03-22 14:48:15 mauro Exp $ |
* |
* Copyright (c) 1999-2001 Vojtech Pavlik |
*/ |
/* |
* Input driver event debug module - dumps all events into syslog |
*/ |
/* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
*/ |
#include <linuxcomp.h> |
#include <linux/slab.h> |
#include <linux/module.h> |
#include <linux/input.h> |
#include <linux/init.h> |
#include <linux/device.h> |
#define DEBUG_MOUSE |
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
MODULE_DESCRIPTION("Input driver event debug module"); |
MODULE_LICENSE("GPL"); |
extern void shark_mouse_task(void); |
#ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_X |
#define CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024 |
#endif |
#ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_Y |
#define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768 |
#endif |
static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X; |
static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y; |
/* Buffer Ssize */ |
#define MOUSE_BUFFERSIZE 256 |
/* Buffer Mask ( i=(i+1)&MASK is better than i=(i+1)%SIZE ) */ |
#define MOUSE_BUFFERMASK 0xff |
/* Circular Buffer */ |
static struct mouse_event { |
unsigned long buttons; |
int dx, dy, dz; |
} mbuffer[MOUSE_BUFFERSIZE]; |
/* |
* Buffer Pointers |
* data is inserted to mhead |
* data is kept from mtail+1 |
* (mhead point to mtail+1 when buffer is empty) |
*/ |
static unsigned mtail, mhead; |
static char mouse_name[] = "mouse"; |
struct mouse_list { |
int dx, dy, dz, oldx, oldy; |
signed char ps2[6]; |
unsigned long buttons; |
/*unsigned char ready, buffer, bufsiz; |
unsigned char mode, imexseq, impsseq;*/ |
int finger; |
}; |
static struct mouse_list m_list; |
static struct mouse_list *list = &m_list; |
/* |
* Get data from the mouse |
* |
* it's follow the port_receive() semantic |
*/ |
int mouse_get(int *dx, int *dy, int *dz, unsigned long *buttons) |
{ |
if ( ((mtail+1) & MOUSE_BUFFERMASK) == ((mhead) & MOUSE_BUFFERMASK) ) |
return -1; |
mtail = (mtail+1) & MOUSE_BUFFERMASK; |
*dx = mbuffer[mtail].dx; |
*dy = mbuffer[mtail].dy; |
*dz = mbuffer[mtail].dx; |
*buttons = mbuffer[mtail].buttons; |
return 0; |
} |
static void mouse_abs_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
{ |
int size; |
/* Ignore joysticks */ |
if (test_bit(BTN_TRIGGER, handle->dev->keybit)) |
return; |
/* Handle touchpad data */ |
if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) { |
if (list->finger && list->finger < 3) |
list->finger++; |
switch (code) { |
case ABS_X: |
if (list->finger == 3) |
list->dx += (value - list->oldx) / 8; |
list->oldx = value; |
return; |
case ABS_Y: |
if (list->finger == 3) |
list->dy -= (value - list->oldy) / 8; |
list->oldy = value; |
return; |
} |
return; |
} |
/* Handle tablet data */ |
switch (code) { |
case ABS_X: |
size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X]; |
if (size == 0) size = xres; |
list->dx += (value * xres - list->oldx) / size; |
list->oldx += list->dx * size; |
return; |
case ABS_Y: |
size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y]; |
if (size == 0) size = yres; |
list->dy -= (value * yres - list->oldy) / size; |
list->oldy -= list->dy * size; |
return; |
} |
} |
static void mouse_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
{ |
int index; |
#ifdef DEBUG_MOUSE |
printk(KERN_DEBUG "mouse.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value); |
#endif |
switch (type) { |
case EV_ABS: |
mouse_abs_event(handle, type, code, value); |
break; |
case EV_REL: |
switch (code) { |
case REL_X: list->dx += value; break; |
case REL_Y: list->dy -= value; break; |
case REL_WHEEL: list->dz -= value; break; |
} |
break; |
case EV_KEY: |
switch (code) { |
case BTN_TOUCH: /* Handle touchpad data */ |
if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) { |
list->finger = value; |
return; |
} |
case BTN_0: |
case BTN_FORWARD: |
case BTN_LEFT: index = 0; break; |
case BTN_4: |
case BTN_EXTRA: index = 4; break; |
case BTN_STYLUS: |
case BTN_1: |
case BTN_RIGHT: index = 1; break; |
case BTN_3: |
case BTN_BACK: |
case BTN_SIDE: index = 3; break; |
case BTN_2: |
case BTN_STYLUS2: |
case BTN_MIDDLE: index = 2; break; |
default: return; |
} |
switch (value) { |
case 0: clear_bit(index, &list->buttons); break; |
case 1: set_bit(index, &list->buttons); break; |
case 2: return; |
} |
break; |
case EV_SYN: |
switch (code) { |
case SYN_REPORT: |
if (mtail != mhead) { |
mbuffer[mhead].buttons = list->buttons; |
mbuffer[mhead].dx = list->dx; |
mbuffer[mhead].dy = list->dy; |
mbuffer[mhead].dz = list->dz; |
mhead = (mhead+1) & MOUSE_BUFFERMASK; |
list->dx = list->dx = list->dx = 0; |
} |
shark_mouse_task(); |
break; |
} |
} |
} |
static struct input_handle *mouse_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
{ |
struct input_handle *handle; |
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
return NULL; |
memset(handle, 0, sizeof(struct input_handle)); |
handle->dev = dev; |
handle->handler = handler; |
handle->name = mouse_name; |
input_open_device(handle); |
#ifdef DEBUG_MOUSE |
printk(KERN_DEBUG "mouse.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); |
#endif |
return handle; |
} |
static void mouse_disconnect(struct input_handle *handle) |
{ |
#ifdef DEBUG_MOUSE |
printk(KERN_DEBUG "mouse.c: Disconnected device: %s\n", handle->dev->phys); |
#endif |
input_close_device(handle); |
kfree(handle); |
} |
/*static struct input_device_id mouse_ids[] = { |
{ .driver_info = 1 }, // Matches all devices |
{ }, // Terminating zero entry |
};*/ |
static struct input_device_id mouse_ids[] = { |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_RELBIT, |
.evbit = { BIT(EV_KEY) | BIT(EV_REL) }, |
.keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) }, |
.relbit = { BIT(REL_X) | BIT(REL_Y) }, |
}, // A mouse like device, at least one button, two relative axes |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_RELBIT, |
.evbit = { BIT(EV_KEY) | BIT(EV_REL) }, |
.relbit = { BIT(REL_WHEEL) }, |
}, // A separate scrollwheel |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, |
.evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, |
.keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, |
.absbit = { BIT(ABS_X) | BIT(ABS_Y) }, |
}, // A tablet like device, at least touch detection, two absolute axes |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, |
.evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, |
.keybit = { [LONG(BTN_TOOL_FINGER)] = BIT(BTN_TOOL_FINGER) }, |
.absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_TOOL_WIDTH) }, |
}, // A touchpad |
{ }, // Terminating entry |
}; |
MODULE_DEVICE_TABLE(input, mouse_ids); |
static struct input_handler mouse_handler = { |
.event = mouse_event, |
.connect = mouse_connect, |
.disconnect = mouse_disconnect, |
.name = "mouse", |
.id_table = mouse_ids, |
}; |
int __init mouse_init(void) |
{ |
input_register_handler(&mouse_handler); |
return 0; |
} |
void __exit mouse_exit(void) |
{ |
input_unregister_handler(&mouse_handler); |
} |
module_init(mouse_init); |
module_exit(mouse_exit); |
/shark/trunk/drivers/input/handler/speaker.c |
---|
0,0 → 1,171 |
/* |
* $Id: speaker.c,v 1.1 2004-03-22 14:48:15 mauro Exp $ |
* |
* Copyright (c) 1999-2001 Vojtech Pavlik |
*/ |
/* |
* Input driver event debug module - dumps all events into syslog |
*/ |
/* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
#include <linuxcomp.h> |
#include <linux/slab.h> |
#include <linux/module.h> |
#include <linux/input.h> |
#include <linux/init.h> |
#include <linux/device.h> |
//#define DEBUG_SPK |
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
MODULE_DESCRIPTION("Input driver event debug module"); |
MODULE_LICENSE("GPL"); |
static char speaker_name[] = "speaker"; |
static struct input_handler speaker_handler; |
/* |
* Making beeps and bells. |
*/ |
void spk_nosound(unsigned long ignored) |
{ |
struct list_head * node; |
list_for_each(node,&speaker_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
if (test_bit(EV_SND, handle->dev->evbit)) { |
if (test_bit(SND_TONE, handle->dev->sndbit)) |
input_event(handle->dev, EV_SND, SND_TONE, 0); |
if (test_bit(SND_BELL, handle->dev->sndbit)) |
input_event(handle->dev, EV_SND, SND_BELL, 0); |
} |
} |
} |
static struct timer_list spk_mksound_timer = |
TIMER_INITIALIZER(spk_nosound, 0, 0); |
void spk_mksound(unsigned int hz, unsigned int ticks) |
{ |
struct list_head * node; |
del_timer(&spk_mksound_timer); |
if (hz) { |
list_for_each_prev(node,&speaker_handler.h_list) { |
struct input_handle *handle = to_handle_h(node); |
if (test_bit(EV_SND, handle->dev->evbit)) { |
if (test_bit(SND_TONE, handle->dev->sndbit)) { |
input_event(handle->dev, EV_SND, SND_TONE, hz); |
break; |
} |
if (test_bit(SND_BELL, handle->dev->sndbit)) { |
input_event(handle->dev, EV_SND, SND_BELL, 1); |
break; |
} |
} |
} |
if (ticks) |
mod_timer(&spk_mksound_timer, jiffies26 + ticks); |
} else |
spk_nosound(0); |
} |
static void speaker_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
{ |
if (type != EV_SND) |
return; |
#ifdef DEBUG_SPK |
printk(KERN_DEBUG "speaker.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value); |
#endif |
} |
static struct input_handle *speaker_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
{ |
struct input_handle *handle; |
if (!test_bit(EV_SND, dev->evbit)) |
return NULL; |
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
return NULL; |
memset(handle, 0, sizeof(struct input_handle)); |
handle->dev = dev; |
handle->handler = handler; |
handle->name = speaker_name; |
input_open_device(handle); |
#ifdef DEBUG_SPK |
printk(KERN_DEBUG "speaker.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); |
#endif |
return handle; |
} |
static void speaker_disconnect(struct input_handle *handle) |
{ |
#ifdef DEBUG_SPK |
printk(KERN_DEBUG "speaker.c: Disconnected device: %s\n", handle->dev->phys); |
#endif |
input_close_device(handle); |
kfree(handle); |
} |
static struct input_device_id speaker_ids[] = { |
{ .driver_info = 1 }, // Matches all devices |
{ }, // Terminating zero entry |
}; |
/*static struct input_device_id speaker_ids[] = { |
{ |
.flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
.evbit = { BIT(EV_SND) }, |
}, |
{ }, // Terminating entry |
};*/ |
MODULE_DEVICE_TABLE(input, speaker_ids); |
static struct input_handler speaker_handler = { |
.event = speaker_event, |
.connect = speaker_connect, |
.disconnect = speaker_disconnect, |
.name = "speaker", |
.id_table = speaker_ids, |
}; |
int __init speaker_init(void) |
{ |
input_register_handler(&speaker_handler); |
return 0; |
} |
void __exit speaker_exit(void) |
{ |
input_unregister_handler(&speaker_handler); |
} |
module_init(speaker_init); |
module_exit(speaker_exit); |