home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / omron / omronUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-29  |  4.4 KB  |  202 lines

  1. /*
  2.  * $XConsortium: omronUtils.c,v 1.1 91/06/29 13:49:07 xguest Exp $
  3.  *
  4.  * Copyright 1991 by OMRON Corporation
  5.  * 
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of OMRON not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  OMRON makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OMRON
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24.  
  25. #include "omron.h"
  26. #include "omronFb.h"
  27.  
  28. int scrw = 0;
  29. int scrh = 0;
  30. char *fb_type = NULL;
  31.  
  32.  
  33. extern    int    atoi();
  34. extern    int    exit();
  35.  
  36. static Bool omronQueryFb();
  37. static void omronQueryVersion();
  38. #ifdef luna2
  39. static void omronQueryKbd();
  40. #endif
  41.  
  42. int
  43. ddxProcessArgument (argc, argv, i)
  44. int argc;
  45. char *argv[];
  46. int i;
  47. {
  48.     extern void UseMsg();
  49.  
  50.     if (strcmp( argv[i], "-scrw") == 0) {
  51.         if (++i >= argc) UseMsg ();
  52.         scrw = atoi(argv[i]);
  53.         return 2;
  54.     }
  55.     if (strcmp( argv[i], "-scrh") == 0) {
  56.         if (++i >= argc) UseMsg ();
  57.         scrh = atoi(argv[i]);
  58.         return 2;
  59.     }
  60.     if (strcmp( argv[i], "-fbtype") == 0) {
  61.         if (++i >= argc) UseMsg ();
  62.         fb_type = argv[i];
  63.         return 2;
  64.     }
  65.     if (strcmp (argv[i], "-queryfb") == 0) {
  66.         omronQueryFb();
  67.         exit(0);
  68.     }
  69. #ifdef luna2
  70.     if (strcmp (argv[i], "-querykbd") == 0) {
  71.         omronQueryKbd();
  72.         exit(0);
  73.     }
  74. #endif
  75.     if (strcmp (argv[i], "-version") == 0) {
  76.         omronQueryVersion();
  77.         exit(0);
  78.     }
  79.     /* Do nothing now */
  80.     return 0;
  81. }
  82.  
  83. static Bool
  84. omronQueryFb()
  85. {
  86.         char *query_type;
  87.         int query_depth;
  88.         int machine_type;
  89.         int plasma = FALSE;
  90.  
  91. #ifdef    uniosu
  92.     if (sys9100(S91MACHTYPE,&machine_type) < 0) {
  93.         Error("sys9100 error.");
  94.     }
  95. #else
  96.     if (sysomron(S91MACHTYPE,&machine_type) < 0) {
  97.         Error("sysomron error.");
  98.     }
  99. #endif
  100.  
  101.     switch(machine_type & MACH_GRAPHIC_BOARD) {
  102.     case MACH_BM : /* we call LUNA */ 
  103.         query_type ="BITMAP";
  104.         break;
  105.  
  106.     case  MACH_PLASMA  : /* LUNA support plasma display */  
  107.         query_type ="PLASMA";
  108.         plasma = TRUE;
  109.         break;
  110.  
  111.     default : 
  112.         ErrorF("Unknown fb type. (0x%x)\n",machine_type);
  113.         return (FALSE);
  114.     }
  115.  
  116.     switch(machine_type & MACH_PLANE){
  117.     case MACH_1_PLANE :
  118.         query_depth = 1;
  119.         break;
  120.  
  121.     case MACH_4_PLANE :
  122.         query_depth = 4;
  123.         break;
  124.  
  125.     case MACH_8_PLANE :
  126.         query_depth = 8;
  127.         break;
  128.  
  129.     default :
  130.         ErrorF("Unknown plane number. (0x%x)\n", machine_type); 
  131.         return (FALSE);
  132.     }
  133.  
  134.         ErrorF(" GRAPHIC  %s\n",query_type);
  135.         if ( plasma ) {
  136.             ErrorF(" SCREEN_WIDTH  %d\n",PLASMA_SCREEN_WIDTH);
  137.             ErrorF(" SCREEN_HEIGHT %d\n",PLASMA_SCREEN_HEIGHT);
  138.         } else {
  139.             ErrorF(" SCREEN_WIDTH  %d\n",SCREEN_WIDTH);
  140.             ErrorF(" SCREEN_HEIGHT %d\n",SCREEN_HEIGHT);
  141.         }
  142.         ErrorF(" SCREEN_DEPTH  %d\n",query_depth);
  143.  
  144.     return (TRUE);
  145. }
  146.  
  147. void
  148. ddxUseMsg()
  149. {
  150.     ErrorF("-scrw #             set screen width  \n");
  151.     ErrorF("-scrh #             set screen height \n");
  152.     ErrorF("-fbtype {DT_BM,DT_BM8,DT_PLASMA,FS_BM} set fb_type \n");
  153.     ErrorF("-queryfb               query framebuffer type \n");
  154. #ifdef luna2
  155.     ErrorF("-querykbd           query keyboard type \n");
  156. #endif
  157.     ErrorF("-version               query server version \n");
  158.  
  159. }
  160.  
  161. static void
  162. omronQueryVersion()
  163. {
  164.     ErrorF("X11R5 OMRON Sample Server.\n");
  165. }
  166.  
  167.  
  168. #ifdef luna2
  169. static    char *omronKbdTypeName[] = {
  170.     "LUNA-II JisJis Keyboard"    /* 0 */
  171.     "LUNA-II Ascii Keyboard"    /* 1 */
  172.     "LUNA-II AsciiJis Keyboard"    /* 2 */
  173.     "LUNA-II Old Keyboard"        /* 3 */
  174.     "LUNA-II Unknown Keyboard"    /* 4 */
  175. };
  176.  
  177. #define    MAX_KEYBOARD    3
  178. #define    ERR_KEYBOARD    4
  179.  
  180. static void
  181. omronQueryKbd()
  182. {
  183.     int keyboardfd;
  184.     int kbd_type;
  185.  
  186.     if((keyboardfd = open("/dev/kbd",O_RDWR,0)) < 0) {
  187.         Error("Can't Open Keyboard");
  188.     } else if( ioctl(keyboardfd,KIOCTYPE,&kbd_type) == -1 ) {
  189.         Error("Can't Get Keyboard Type.\n");
  190.     }
  191.  
  192.     if(kbd_type < 0 || kbd_type > MAX_KEYBOARD) {
  193.         kbd_type = ERR_KEYBOARD;
  194.     }
  195.  
  196.     ErrorF("%s\n", omronKbdTypeName[ kbd_type ]);
  197.  
  198.     close(keyboardfd);
  199. }
  200. #endif
  201.  
  202.