Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 69380
b: refs/heads/master
c: 9a402b6
h: refs/heads/master
v: v3
  • Loading branch information
Andrew McNabb authored and Dmitry Torokhov committed Oct 11, 2007
1 parent 48b4762 commit 9f08004
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f493018ebc3f94d64e12bc848db0906700bf73a2
refs/heads/master: 9a402b649d9c4f5ac17c1368702c9f51219c484b
56 changes: 47 additions & 9 deletions trunk/drivers/macintosh/adbhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@

MODULE_AUTHOR("Franz Sirl <Franz.Sirl-kernel@lauterbach.com>");

static int restore_capslock_events;
module_param(restore_capslock_events, int, 0644);
MODULE_PARM_DESC(restore_capslock_events,
"Produce keypress events for capslock on both keyup and keydown.");

#define KEYB_KEYREG 0 /* register # for key up/down data */
#define KEYB_LEDREG 2 /* register # for leds on ADB keyboard */
#define MOUSE_DATAREG 0 /* reg# for movement/button codes from mouse */
Expand Down Expand Up @@ -217,6 +222,8 @@ struct adbhid {
#define FLAG_FN_KEY_PRESSED 0x00000001
#define FLAG_POWER_FROM_FN 0x00000002
#define FLAG_EMU_FWDEL_DOWN 0x00000004
#define FLAG_CAPSLOCK_TRANSLATE 0x00000008
#define FLAG_CAPSLOCK_DOWN 0x00000010

static struct adbhid *adbhid[16];

Expand Down Expand Up @@ -272,19 +279,50 @@ adbhid_keyboard_input(unsigned char *data, int nb, int apoll)
}

static void
adbhid_input_keycode(int id, int keycode, int repeat)
adbhid_input_keycode(int id, int scancode, int repeat)
{
struct adbhid *ahid = adbhid[id];
int up_flag;

up_flag = (keycode & 0x80);
keycode &= 0x7f;
int keycode, up_flag;

keycode = scancode & 0x7f;
up_flag = scancode & 0x80;

if (restore_capslock_events) {
if (keycode == ADB_KEY_CAPSLOCK && !up_flag) {
/* Key pressed, turning on the CapsLock LED.
* The next 0xff will be interpreted as a release. */
ahid->flags |= FLAG_CAPSLOCK_TRANSLATE
| FLAG_CAPSLOCK_DOWN;
} else if (scancode == 0xff) {
/* Scancode 0xff usually signifies that the capslock
* key was either pressed or released. */
if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) {
keycode = ADB_KEY_CAPSLOCK;
if (ahid->flags & FLAG_CAPSLOCK_DOWN) {
/* Key released */
up_flag = 1;
ahid->flags &= ~FLAG_CAPSLOCK_DOWN;
} else {
/* Key pressed */
up_flag = 0;
ahid->flags &= ~FLAG_CAPSLOCK_TRANSLATE;
}
} else {
printk(KERN_INFO "Spurious caps lock event "
"(scancode 0xff).");
}
}
}

switch (keycode) {
case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */
input_report_key(ahid->input, KEY_CAPSLOCK, 1);
input_report_key(ahid->input, KEY_CAPSLOCK, 0);
input_sync(ahid->input);
case ADB_KEY_CAPSLOCK:
if (!restore_capslock_events) {
/* Generate down/up events for CapsLock everytime. */
input_report_key(ahid->input, KEY_CAPSLOCK, 1);
input_sync(ahid->input);
input_report_key(ahid->input, KEY_CAPSLOCK, 0);
input_sync(ahid->input);
}
return;
#ifdef CONFIG_PPC_PMAC
case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs remapping */
Expand Down

0 comments on commit 9f08004

Please sign in to comment.