Home | History | Annotate | Download | only in xf86-input-keyboard
sun-kb-autodetect.patch revision 724
      1 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
      2 # Use subject to license terms.
      3 #
      4 # Permission is hereby granted, free of charge, to any person obtaining a
      5 # copy of this software and associated documentation files (the
      6 # "Software"), to deal in the Software without restriction, including
      7 # without limitation the rights to use, copy, modify, merge, publish,
      8 # distribute, and/or sell copies of the Software, and to permit persons
      9 # to whom the Software is furnished to do so, provided that the above
     10 # copyright notice(s) and this permission notice appear in all copies of
     11 # the Software and that both the above copyright notice(s) and this
     12 # permission notice appear in supporting documentation.
     13 # 
     14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
     17 # OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     18 # HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
     19 # INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
     20 # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
     21 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
     22 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     23 # 
     24 # Except as contained in this notice, the name of a copyright holder
     25 # shall not be used in advertising or otherwise to promote the sale, use
     26 # or other dealings in this Software without prior written authorization
     27 # of the copyright holder.
     28 
     29 
     30 diff -urp -x '*~' -x '*.orig' src/Makefile.am src/Makefile.am
     31 --- src/Makefile.am	2009-01-07 08:47:02.000000000 -0800
     32 +++ src/Makefile.am	2009-01-11 17:49:44.006395000 -0800
     33 @@ -28,7 +28,7 @@ BSD_SRCS = bsd_KbdMap.c bsd_kbd.c bsd_kb
     34  HURD_SRCS = hurd_kbd.c at_scancode.c
     35  LINUX_SRCS = lnx_KbdMap.c lnx_kbd.c lnx_kbd.h at_scancode.c
     36  SCO_SRCS = sco_KbdMap.c sco_kbd.c sco_kbd.h
     37 -SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c
     38 +SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c sun_xkbtable.c sun_xkbtable.h
     39  
     40  if BSD
     41  kbd_drv_la_SOURCES += $(BSD_SRCS)
     42 diff -urp -x '*~' -x '*.orig' src/sun_kbd.c src/sun_kbd.c
     43 --- src/sun_kbd.c	2009-01-07 08:35:10.000000000 -0800
     44 +++ src/sun_kbd.c	2009-01-11 17:49:44.007550000 -0800
     45 @@ -64,6 +64,10 @@
     46  #include <sys/vuid_event.h>
     47  #include <sys/kbd.h>
     48  
     49 +#ifdef XKB
     50 +# include "sun_xkbtable.h"
     51 +#endif
     52 +
     53  static void
     54  sunKbdSetLeds(InputInfoPtr pInfo, int leds)
     55  {
     56 @@ -98,6 +104,13 @@ sunKbdGetLeds(InputInfoPtr pInfo)
     57  static int
     58  KbdInit(InputInfoPtr pInfo, int what)
     59  {
     60 +    /* Does nothing now - sunKbdInit called from OpenKeyboard instead */
     61 +    return Success;
     62 +}
     63 +
     64 +static int
     65 +sunKbdInit(InputInfoPtr pInfo)
     66 +{
     67      KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
     68      sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
     69      pointer options = pInfo->options;
     70 @@ -155,6 +168,7 @@ KbdInit(InputInfoPtr pInfo, int what)
     71      xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", pInfo->name, klayout);
     72  
     73      priv->ktype 	= ktype;
     74 +    priv->klayout 	= klayout;
     75      priv->oleds 	= sunKbdGetLeds(pInfo);
     76  
     77      return Success;
     78 @@ -403,6 +417,61 @@ OpenKeyboard(InputInfoPtr pInfo)
     79      if (pInfo->fd == -1) {
     80  	return FALSE;
     81      } else {
     82 +	if (sunKbdInit(pInfo) != Success) {
     83 +	    close(pInfo->fd);
     84 +	    pInfo->fd = -1;
     85 +	    return FALSE;
     86 +	}
     87 +#ifdef XKB
     88 +	else {
     89 +	    /* Probe keyboard settings if not specified in configuration */
     90 +	    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
     91 +	    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
     92 +	    char *xkbkeymap = NULL, *xkbmodel = NULL, *xkblayout = NULL;
     93 +	    int i, found;
     94 +	    
     95 +	    const char *kbdDefaults[] = {
     96 +		"Protocol",         "standard",
     97 +		"AutoRepeat",       "500 30",
     98 +		"XkbRules",         "xorg",
     99 +		"XkbModel",         "pc105",
    100 +		"XkbLayout",        "us",
    101 +		"Panix106",         "off",
    102 +		"CustomKeycodes",   "off",
    103 +		NULL, NULL, 	    /* leave room to add XkbKeymap if needed */
    104 +		NULL 		    /* list terminator */
    105 +	    };
    106 +	    
    107 +	    sun_find_xkbnames(priv->ktype, priv->klayout,
    108 +			      &xkbkeymap, &xkbmodel, &xkblayout);
    109 +
    110 +#define SetXkbDefaults(OPTION, VALUE) \
    111 +	if (VALUE != NULL) { \
    112 +	    for (i = 0, found = 0; kbdDefaults[i] != NULL; i += 2) { \
    113 +		if (strcmp(kbdDefaults[i], OPTION) == 0) { \
    114 +		    kbdDefaults[i+1] = VALUE; found++; \
    115 +		    xf86Msg(X_PROBED, "%s: %s = %s\n", pInfo->name, \
    116 +			    OPTION, VALUE); \
    117 +		    break; \
    118 +		} \
    119 +	    } \
    120 +	}
    121 +	    
    122 +#define AddXkbDefaults(OPTION, VALUE) \
    123 +	if (VALUE != NULL) { \
    124 +	    for (i = 0; kbdDefaults[i] != NULL; i += 2) \
    125 +	    { /* skip to end */ ; } \
    126 +	    kbdDefaults[i++] = OPTION; \
    127 +	    kbdDefaults[i++] = VALUE; \
    128 +	}
    129 +
    130 +	    SetXkbDefaults("XkbModel", xkbmodel);
    131 +	    SetXkbDefaults("XkbLayout", xkblayout);
    132 +	    AddXkbDefaults("XkbKeymap", xkbkeymap);
    133 +
    134 +	    xf86CollectInputOptions(pInfo, kbdDefaults, NULL);
    135 +	}
    136 +#endif
    137  	pInfo->read_input = ReadInput;
    138  	return TRUE;
    139      }
    140 diff -urp -x '*~' -x '*.orig' src/sun_kbd.h src/sun_kbd.h
    141 --- src/sun_kbd.h	2009-01-07 08:35:10.000000000 -0800
    142 +++ src/sun_kbd.h	2009-01-11 17:49:44.016628000 -0800
    143 @@ -31,6 +31,7 @@
    144  
    145  typedef struct {
    146      int 		ktype;		/* Keyboard type from KIOCTYPE */
    147 +    int 		klayout;	/* Keyboard layout from KIOCLAYOUT */
    148      Bool		kbdActive;	/* Have we set kbd modes for X? */
    149      int 		otranslation;	/* Original translation mode */
    150      int 		odirect;	/* Original "direct" mode setting */
    151