removed TOS dependencies with (some shaky) replacements to make everything compile without TOS headers

This commit is contained in:
Markus Fröschle
2013-04-21 05:13:32 +00:00
parent 9b9caf98e4
commit a822d3f8f5
5 changed files with 881 additions and 819 deletions

View File

@@ -10,7 +10,7 @@
# can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint
# toolchain
COMPILE_ELF=N
COMPILE_ELF=Y
ifeq (Y,$(COMPILE_ELF))
TCPREFIX=m68k-elf-

View File

@@ -26,10 +26,10 @@
#ifndef _USB_H_
#define _USB_H_
#include <mint/osbind.h>
#include <mint/sysvars.h>
#include <stdlib.h>
#include <string.h>
#include <bas_printf.h>
#include "pcixbios.h"
#include "mod_devicetable.h"
#include "pci_ids.h"
@@ -231,6 +231,15 @@ struct usb_device {
int usbnum;
};
/* Structure returned by Iorec() */
typedef struct {
char *ibuf;
short ibufsiz;
volatile short ibufhd;
volatile short ibuftl;
short ibuflow;
short ibufhi;
} _IOREC;
/**********************************************************************
* this is how the lowlevel part communicate with the outer world
*/

File diff suppressed because it is too large Load Diff

View File

@@ -61,7 +61,6 @@ static int usb_kbd_get_hid_desc(struct usb_device *dev);
/* under TOS Repeat keys are build by timer C so infinite (0) or 1000 is a good value */
#define REPEAT_RATE 0 // 40 /* 40msec -> 25cps */
#define MAX_VALUE_LOOKUP 0x90
#define MAX_VALUE_ATARI 0x75
@@ -116,18 +115,18 @@ static union
{
struct
{
unsigned reserved1:3;
unsigned force_alt_shift:1;
unsigned right_shift_host:1;
unsigned left_shift_host:1;
unsigned alt_host:1;
unsigned ctrl_host:1;
unsigned key_forced:1;
unsigned reserved2:3;
unsigned altgr_usb:1;
unsigned shift_usb:1;
unsigned altgr_usb_break:1;
unsigned shift_usb_break:1;
unsigned reserved1 :3;
unsigned force_alt_shift :1;
unsigned right_shift_host :1;
unsigned left_shift_host :1;
unsigned alt_host :1;
unsigned ctrl_host :1;
unsigned key_forced :1;
unsigned reserved2 :3;
unsigned altgr_usb :1;
unsigned shift_usb :1;
unsigned altgr_usb_break :1;
unsigned shift_usb_break :1;
} b;
unsigned short s;
} flags;
@@ -142,7 +141,7 @@ struct usb_hid_descriptor
unsigned char bNumDescriptors;
unsigned char bReportDescriptorType;
unsigned short wDescriptorLength;
} __attribute__ ((packed));
}__attribute__ ((packed));
static struct usb_hid_descriptor usb_kbd_hid_desc;
#endif
@@ -188,7 +187,7 @@ static unsigned char usb_kbd_to_atari_scancode[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x1D, 0x2A, 0x38, 0x56, 0x1D, 0x36, 0x38, 0x57 // virtual codes
};
};
static unsigned char usb_kbd_to_atari_fr_modifier[] =
{
@@ -233,8 +232,7 @@ static unsigned char usb_kbd_to_atari_fr_modifier[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x00, 0x00, 0x00, 0xEA, 0x00, 0x00, 0x00, 0xEA
};
0x00, 0x00, 0x00, 0xEA, 0x00, 0x00, 0x00, 0xEA };
static unsigned char usb_kbd_to_atari_fr_unshift[] =
{
@@ -273,8 +271,7 @@ static unsigned char usb_kbd_to_atari_fr_unshift[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F
};
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F };
static unsigned char usb_kbd_to_atari_fr_shift[] =
{
@@ -315,8 +312,7 @@ static unsigned char usb_kbd_to_atari_fr_shift[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F
};
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F };
static unsigned char usb_kbd_to_atari_fr_altgr[] =
{
@@ -357,8 +353,7 @@ static unsigned char usb_kbd_to_atari_fr_altgr[] =
//VolUp VolDn
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF
};
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF };
static unsigned char usb_kbd_to_atari_de_modifier[] =
{
@@ -403,8 +398,7 @@ static unsigned char usb_kbd_to_atari_de_modifier[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x00, 0x00, 0x00, 0xEA, 0x00, 0x00, 0x00, 0xEA
};
0x00, 0x00, 0x00, 0xEA, 0x00, 0x00, 0x00, 0xEA };
static unsigned char usb_kbd_to_atari_de_unshift[] =
{
@@ -443,8 +437,7 @@ static unsigned char usb_kbd_to_atari_de_unshift[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F
};
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F };
static unsigned char usb_kbd_to_atari_de_shift[] =
{
@@ -485,8 +478,7 @@ static unsigned char usb_kbd_to_atari_de_shift[] =
//VolUp VolDn
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F
};
0x1D, 0x2A, 0x38, 0x0F, 0x1D, 0x36, 0x00, 0x0F };
static unsigned char usb_kbd_to_atari_de_altgr[] =
{
@@ -527,34 +519,33 @@ static unsigned char usb_kbd_to_atari_de_altgr[] =
//VolUp VolDn
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
//LCTRL LSHFT LALT LGUI RCTRL RSHFT RALT RGUI
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF
};
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF };
static COOKIE *get_cookie(long id)
{
COOKIE *p= *(COOKIE **)0x5a0;
while(p)
COOKIE *p = *(COOKIE **) 0x5a0;
while (p)
{
if(p->ident == id)
return(p);
if(!p->ident)
return((COOKIE *)0);
if (p->ident == id)
return (p);
if (!p->ident)
return ((COOKIE *) 0);
p++;
}
return((COOKIE *)0);
return ((COOKIE *) 0);
}
static void *memscan(void *addr, int c, int size)
{
unsigned char *p = (unsigned char *)addr;
while(size)
unsigned char *p = (unsigned char *) addr;
while (size)
{
if(*p == (char)c)
return(void *)p;
if (*p == (char) c)
return (void *) p;
p++;
size--;
}
return(void *)p;
return (void *) p;
}
/* forward declaration */
@@ -564,12 +555,12 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum);
int usb_kbd_deregister(struct usb_device *dev)
{
dev->irq_handle = NULL;
if(new != NULL)
if (new != NULL )
{
usb_free(new);
new = NULL;
}
if(leds != NULL)
if (leds != NULL )
{
usb_free(leds);
leds = NULL;
@@ -582,7 +573,7 @@ int usb_kbd_deregister(struct usb_device *dev)
/* registering the keyboard */
int usb_kbd_register(struct usb_device *dev)
{
if(!kbd_installed && (dev->devnum != -1) && (usb_kbd_probe(dev, 0) == 1))
if (!kbd_installed && (dev->devnum != -1) && (usb_kbd_probe(dev, 0) == 1))
{ /* Ok, we found a keyboard */
USB_KBD_PRINTF("USB KBD found (iorec: 0x%x, USB: %d, devnum: %d)\r\n", iorec, dev->usbnum, dev->devnum);
num_lock = caps_lock = scroll_lock = old_modifier = 0;
@@ -599,17 +590,17 @@ int usb_kbd_register(struct usb_device *dev)
int drv_usb_kbd_init(void)
{
int i, j;
if(kbd_installed)
if (kbd_installed)
return -1;
/* scan all USB Devices */
for(j = 0; j < USB_MAX_BUS; j++)
for (j = 0; j < USB_MAX_BUS; j++)
{
for(i = 0; i < USB_MAX_DEVICE; i++)
for (i = 0; i < USB_MAX_DEVICE; i++)
{
struct usb_device *dev = usb_get_dev_index(i, j); /* get device */
if(dev == NULL)
if (dev == NULL )
break;
if(usb_kbd_register(dev) > 0)
if (usb_kbd_register(dev) > 0)
return 1;
}
}
@@ -628,27 +619,28 @@ int drv_usb_kbd_init(void)
static void usb_kbd_setled(struct usb_device *dev)
{
struct usb_interface_descriptor *iface = &dev->config.if_desc[0];
unsigned char *pleds = (unsigned char *)(((unsigned long)leds + 3) & ~3);
if(scroll_lock != 0)
unsigned char *pleds = (unsigned char *) (((unsigned long) leds + 3) & ~3);
if (scroll_lock != 0)
*pleds = 4;
else
*pleds = 0;
if(caps_lock != 0)
if (caps_lock != 0)
*pleds |= 2;
if(num_lock != 0)
if (num_lock != 0)
*pleds |= 1;
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x200, iface->bInterfaceNumber, pleds, 1, 0);
usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_REPORT,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x200,
iface->bInterfaceNumber, pleds, 1, 0);
}
static void usb_kbd_send_code(unsigned char code)
{
if((iorec != NULL) && (ikbdvec != NULL))
call_ikbdvec(code, iorec, ikbdvec);
if ((iorec != NULL )&& (ikbdvec != NULL))call_ikbdvec(code, iorec, ikbdvec);
}
/* Translate the scancode */
static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int pressed)
/* Translate the scancode */
static int usb_kbd_translate(unsigned char scancode, unsigned char modifier,
int pressed)
{
unsigned char keycode = 0, atari_modifier = 0;
#ifdef CONFIG_USB_INTERRUPT_POLLING
@@ -657,11 +649,11 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
int type = USA;
USB_KBD_PRINTF("USB KBD scancode: 0x%02x, modifier:0x%02x, pressed: %d\r\n", scancode, modifier, pressed);
flags.b.force_alt_shift = 0;
if(scancode > MAX_VALUE_LOOKUP)
if (scancode > MAX_VALUE_LOOKUP)
keycode = 0;
else
{
if(scancode == 0x8A) /* LEFT ALT */
if (scancode == 0x8A) /* LEFT ALT */
keycode = 0x38; /* Alt Atari */
else
{
@@ -671,7 +663,7 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
unsigned char *modifier_table = NULL;
unsigned long lang = USA;
COOKIE *p = get_cookie('_AKP');
if(p != NULL)
if (p != NULL )
lang = (p->v.l >> 8) & 0xFF;
#ifdef USE_COUNTRYCODE
switch(usb_kbd_hid_desc.bCountryCode)
@@ -687,7 +679,7 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
case CC_SWG: lang = SWG; break;
}
#endif
switch(lang)
switch (lang)
{
case FRA:
case SWF:
@@ -709,11 +701,12 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
unshift_table = usb_kbd_to_atari_scancode;
break;
}
if(modifier != old_modifier)
if (modifier != old_modifier)
{
if(((modifier & (1 << LEFT_SHIFT)) != 0) || ((modifier & (1 << RIGHT_SHIFT)) != 0))
if (((modifier & (1 << LEFT_SHIFT)) != 0)
|| ((modifier & (1 << RIGHT_SHIFT)) != 0))
{
if(!flags.b.shift_usb)
if (!flags.b.shift_usb)
{
flags.b.shift_usb = 1;
flags.b.shift_usb_break = 1;
@@ -721,9 +714,9 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
}
else
flags.b.shift_usb = 0;
if((modifier & (1 << RIGHT_ALT)) != 0)
if ((modifier & (1 << RIGHT_ALT)) != 0)
{
if(!flags.b.altgr_usb)
if (!flags.b.altgr_usb)
{
flags.b.altgr_usb = 1;
flags.b.altgr_usb_break = 1;
@@ -733,15 +726,15 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
flags.b.altgr_usb = 0;
old_modifier = modifier;
}
else if(pressed)
else if (pressed)
{
if(!flags.b.altgr_usb)
if (!flags.b.altgr_usb)
flags.b.altgr_usb_break = 0;
if(!flags.b.shift_usb)
if (!flags.b.shift_usb)
flags.b.shift_usb_break = 0;
}
keycode = unshift_table[scancode];
if((modifier & (1 << LEFT_ALT)) == 0)
if ((modifier & (1 << LEFT_ALT)) == 0)
{
/* This modifier table can change host SHIFT & ALT states for each scancode, values
are in hexa : bit 7: 1 for a valid entry
@@ -750,57 +743,58 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
bit 3: ALT, bit 2: SHIFT states for the Shift table
bit 1: ALT, bit 0: SHIFT states for the Unshift table
*/
if(modifier_table != NULL)
if (modifier_table != NULL )
atari_modifier = modifier_table[scancode];
else
atari_modifier = 0;
if((atari_modifier & (1 << 7)) != 0)
if ((atari_modifier & (1 << 7)) != 0)
flags.b.force_alt_shift = 1;
else
atari_modifier = 0;
if(flags.b.altgr_usb_break)
if (flags.b.altgr_usb_break)
{
if(altgr_table[scancode])
if (altgr_table[scancode])
{
keycode = altgr_table[scancode];
if((atari_modifier & (1 << 6)) != 0)
atari_modifier = (atari_modifier >> 4) | (atari_modifier & (1 << 6));
if ((atari_modifier & (1 << 6)) != 0)
atari_modifier = (atari_modifier >> 4)
| (atari_modifier & (1 << 6));
else
atari_modifier >>= 4;
}
}
else if(flags.b.shift_usb_break)
else if (flags.b.shift_usb_break)
{
if(shift_table[scancode])
if (shift_table[scancode])
{
keycode = shift_table[scancode];
if((atari_modifier & (1 << 6)) != 0)
atari_modifier = (atari_modifier >> 2) | (atari_modifier & (1 << 6));
if ((atari_modifier & (1 << 6)) != 0)
atari_modifier = (atari_modifier >> 2)
| (atari_modifier & (1 << 6));
else
atari_modifier >>= 2;
}
}
}
}
}
USB_KBD_PRINTF("USB KBD atari-%s keycode:0x%02x, modifier:0x%02x, flags:0x%04x\r\n", (type == FRA) ? "fr" : (type == FRG) ? "de" : "us", keycode, atari_modifier, flags.s);
if(keycode == 0x1D) /* CTRL */
} USB_KBD_PRINTF("USB KBD atari-%s keycode:0x%02x, modifier:0x%02x, flags:0x%04x\r\n", (type == FRA) ? "fr" : (type == FRG) ? "de" : "us", keycode, atari_modifier, flags.s);
if (keycode == 0x1D) /* CTRL */
{
if(pressed)
if (pressed)
flags.b.ctrl_host = 1;
else
flags.b.ctrl_host = 0;
}
if(keycode == 0x36) /* RSHIFT */
if (keycode == 0x36) /* RSHIFT */
{
if(pressed)
if (pressed)
flags.b.right_shift_host = 1;
else
flags.b.right_shift_host = 0;
}
if(keycode == 0x2A) /* LSHIFT */
if (keycode == 0x2A) /* LSHIFT */
{
if(pressed)
if (pressed)
flags.b.left_shift_host = 1;
else
flags.b.left_shift_host = 0;
@@ -808,84 +802,84 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
#ifdef CONFIG_USB_INTERRUPT_POLLING
level = asm_set_ipl(7); /* mask interrupts for use call_ikbdvec() */
#endif
if(pressed && (flags.b.force_alt_shift))
if (pressed && (flags.b.force_alt_shift))
{
flags.b.key_forced = 1;
if(((atari_modifier & (1 << 6)) != 0) && flags.b.ctrl_host)
if (((atari_modifier & (1 << 6)) != 0) && flags.b.ctrl_host)
usb_kbd_send_code(0x1D); /* CTRL */
if((atari_modifier & (1 << 0)) == 0)
if ((atari_modifier & (1 << 0)) == 0)
{
if(flags.b.left_shift_host)
if (flags.b.left_shift_host)
usb_kbd_send_code(0xAA); /* !LSHIFT */
if(flags.b.right_shift_host)
if (flags.b.right_shift_host)
usb_kbd_send_code(0xB6); /* !RSHIFT */
}
else
{
if(!flags.b.left_shift_host)
if (!flags.b.left_shift_host)
usb_kbd_send_code(0x2A); /* LSHIFT */
if(!flags.b.right_shift_host && (keycode != 0x60)) /* < */
if (!flags.b.right_shift_host && (keycode != 0x60)) /* < */
usb_kbd_send_code(0x36); /* RSHIFT */
}
if((atari_modifier & (1 << 1)) == 0)
if ((atari_modifier & (1 << 1)) == 0)
{
if(flags.b.alt_host)
if (flags.b.alt_host)
usb_kbd_send_code(0xB8); /* !ALT */
}
else
{
if(!flags.b.alt_host)
if (!flags.b.alt_host)
usb_kbd_send_code(0x38); /* ALT */
}
}
if((keycode !=0) && (keycode <= MAX_VALUE_ATARI))
if ((keycode != 0) && (keycode <= MAX_VALUE_ATARI))
usb_kbd_send_code(pressed ? keycode : keycode | 0x80);
if(!pressed && (flags.b.force_alt_shift))
if (!pressed && (flags.b.force_alt_shift))
{
flags.b.key_forced = 0;
if(((atari_modifier & (1 << 6)) != 0) && flags.b.ctrl_host)
if (((atari_modifier & (1 << 6)) != 0) && flags.b.ctrl_host)
usb_kbd_send_code(0x9D); /* !CTRL */
if((atari_modifier & (1 << 0)) == 0)
if ((atari_modifier & (1 << 0)) == 0)
{
if(flags.b.left_shift_host)
if (flags.b.left_shift_host)
usb_kbd_send_code(0x2A); /* LSHIFT */
if(flags.b.right_shift_host)
if (flags.b.right_shift_host)
usb_kbd_send_code(0x36); /* RSHIFT */
}
else
{
if(!flags.b.left_shift_host)
if (!flags.b.left_shift_host)
usb_kbd_send_code(0xAA); /* !LSHIFT */
if(!flags.b.right_shift_host)
if (!flags.b.right_shift_host)
usb_kbd_send_code(0xB6); /* !RSHIFT */
}
if((atari_modifier & (1 << 1)) == 0)
if ((atari_modifier & (1 << 1)) == 0)
{
if(flags.b.alt_host)
if (flags.b.alt_host)
usb_kbd_send_code(0x38); /* ALT */
}
else
{
if(!flags.b.alt_host)
if (!flags.b.alt_host)
usb_kbd_send_code(0xB8); /* !ALT */
}
}
#ifdef CONFIG_USB_INTERRUPT_POLLING
asm_set_ipl(level);
#endif
if(pressed == 1)
if (pressed == 1)
{
if(scancode == NUM_LOCK)
if (scancode == NUM_LOCK)
{
num_lock = ~num_lock;
return 1;
}
if(scancode == CAPS_LOCK)
if (scancode == CAPS_LOCK)
{
caps_lock = ~caps_lock;
return 1;
}
if(scancode == SCROLL_LOCK)
if (scancode == SCROLL_LOCK)
{
scroll_lock = ~scroll_lock;
return 1;
@@ -897,47 +891,55 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
/* Interrupt service routine */
static int usb_kbd_irq(struct usb_device *dev)
{
int i,res;
if((dev->irq_status != 0) || (dev->irq_act_len != 8))
int i, res;
if ((dev->irq_status != 0) || (dev->irq_act_len != 8))
{
USB_KBD_PRINTF("USB KBD error %lX, len %d\r\n",dev->irq_status,dev->irq_act_len);
return 1;
}
res = 0;
for(i = 2; i < 8; i++)
for (i = 2; i < 8; i++)
{
if(old[i] > 3 && memscan(&new[2], old[i], 6) == &new[8])
if (old[i] > 3 && memscan(&new[2], old[i], 6) == &new[8])
{
res |= usb_kbd_translate(old[i], new[0], 0);
old[0] = new[0];
}
if(new[i] > 3 && memscan(&old[2], new[i], 6) == &old[8])
if (new[i] > 3 && memscan(&old[2], new[i], 6) == &old[8])
{
res |= usb_kbd_translate(new[i], new[0], 1);
old[0] = new[0];
}
}
if(new[0] != old[0]) /* modifier change */
if (new[0] != old[0]) /* modifier change */
{
unsigned char modifier_change = new[0] ^ old[0];
if(modifier_change & (1 << LEFT_CNTR))
res |= usb_kbd_translate(0x88, new[0], (new[0] & (1 << LEFT_CNTR)) ? 1 : 0);
if(modifier_change & (1 << LEFT_SHIFT))
res |= usb_kbd_translate(0x89, new[0], (new[0] & (1 << LEFT_SHIFT)) ? 1 : 0);
if(modifier_change & (1 << LEFT_ALT))
res |= usb_kbd_translate(0x8A, new[0], (new[0] & (1 << LEFT_ALT)) ? 1 : 0);
if(modifier_change & (1 << LEFT_GUI))
res |= usb_kbd_translate(0x8B, new[0], (new[0] & (1 << LEFT_GUI)) ? 1 : 0);
if(modifier_change & (1 << RIGHT_CNTR))
res |= usb_kbd_translate(0x8C, new[0], (new[0] & (1 << RIGHT_CNTR)) ? 1 : 0);
if(modifier_change & (1 << RIGHT_SHIFT))
res |= usb_kbd_translate(0x8D, new[0], (new[0] & (1 << RIGHT_SHIFT)) ? 1 : 0);
if(modifier_change & (1 << RIGHT_ALT))
res |= usb_kbd_translate(0x8E, new[0], (new[0] & (1 << RIGHT_ALT)) ? 1 : 0);
if(modifier_change & (1 << RIGHT_GUI))
res |= usb_kbd_translate(0x8F, new[0], (new[0] & (1 << RIGHT_GUI)) ? 1 : 0);
if (modifier_change & (1 << LEFT_CNTR))
res |= usb_kbd_translate(0x88, new[0],
(new[0] & (1 << LEFT_CNTR)) ? 1 : 0);
if (modifier_change & (1 << LEFT_SHIFT))
res |= usb_kbd_translate(0x89, new[0],
(new[0] & (1 << LEFT_SHIFT)) ? 1 : 0);
if (modifier_change & (1 << LEFT_ALT))
res |= usb_kbd_translate(0x8A, new[0],
(new[0] & (1 << LEFT_ALT)) ? 1 : 0);
if (modifier_change & (1 << LEFT_GUI))
res |= usb_kbd_translate(0x8B, new[0],
(new[0] & (1 << LEFT_GUI)) ? 1 : 0);
if (modifier_change & (1 << RIGHT_CNTR))
res |= usb_kbd_translate(0x8C, new[0],
(new[0] & (1 << RIGHT_CNTR)) ? 1 : 0);
if (modifier_change & (1 << RIGHT_SHIFT))
res |= usb_kbd_translate(0x8D, new[0],
(new[0] & (1 << RIGHT_SHIFT)) ? 1 : 0);
if (modifier_change & (1 << RIGHT_ALT))
res |= usb_kbd_translate(0x8E, new[0],
(new[0] & (1 << RIGHT_ALT)) ? 1 : 0);
if (modifier_change & (1 << RIGHT_GUI))
res |= usb_kbd_translate(0x8F, new[0],
(new[0] & (1 << RIGHT_GUI)) ? 1 : 0);
}
if(res == 1)
if (res == 1)
usb_kbd_setled(dev);
memcpy(&old[0], &new[0], 8);
return 1; /* install IRQ Handler again */
@@ -948,34 +950,33 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
{
struct usb_interface_descriptor *iface;
struct usb_endpoint_descriptor *ep;
int pipe,maxp;
if(dev->descriptor.bNumConfigurations != 1)
int pipe, maxp;
if (dev->descriptor.bNumConfigurations != 1)
return 0;
iface = &dev->config.if_desc[ifnum];
if(iface->bInterfaceClass != 3)
if (iface->bInterfaceClass != 3)
return 0;
if(iface->bInterfaceSubClass != 1)
if (iface->bInterfaceSubClass != 1)
return 0;
if(iface->bInterfaceProtocol != 1)
if (iface->bInterfaceProtocol != 1)
return 0;
if(iface->bNumEndpoints != 1)
if (iface->bNumEndpoints != 1)
return 0;
ep = &iface->ep_desc[0];
if(!(ep->bEndpointAddress & 0x80))
if (!(ep->bEndpointAddress & 0x80))
return 0;
if((ep->bmAttributes & 3) != 3)
if ((ep->bmAttributes & 3) != 3)
return 0;
leds = (unsigned char *)usb_malloc(8);
if(leds == NULL)
leds = (unsigned char *) usb_malloc(8);
if (leds == NULL )
return 0;
new = (unsigned char *)usb_malloc(8);
if(new == NULL)
new = (unsigned char *) usb_malloc(8);
if (new == NULL )
{
usb_free(leds);
new = NULL;
return 0;
}
USB_KBD_PRINTF("USB KBD found set protocol...\r\n");
} USB_KBD_PRINTF("USB KBD found set protocol...\r\n");
/* ok, we found a USB Keyboard, install it */
#ifdef USE_COUNTRYCODE
if(usb_kbd_get_hid_desc(dev) < 0)
@@ -1002,12 +1003,14 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
* into the data area.
*/
struct hid_item {
struct hid_item
{
unsigned char format;
unsigned char size;
unsigned char type;
unsigned char tag;
union {
union
{
unsigned char u_8;
char s_8;
unsigned short u_16;
@@ -1015,7 +1018,7 @@ struct hid_item {
unsigned long u_32;
long s_32;
unsigned char *longdata;
} data;
}data;
};
/* HID report item format */
@@ -1322,7 +1325,7 @@ static int usb_kbd_get_hid_desc(struct usb_device *dev)
/*
usb_get_report(dev, 0, 0, 1, &new[0], 8);
*/
*/
#endif /* CONFIG_USB_KEYBOARD */
#endif /* CONFIG_USB_UHCI || CONFIG_USB_OHCI || CONFIG_USB_EHCI */

View File

@@ -12,8 +12,6 @@
*/
#include "config.h"
#include <mint/errno.h>
#include <mint/osbind.h>
#include <string.h>
#include "usb.h"
@@ -182,6 +180,8 @@ static void freeit(MD *m, MPB *mp)
}
}
#define EFAULT -40
int usb_free(void *addr)
{
int level;