' *************************************************
' These are functions to let you use the CKBD
' program by Pascal Fellerich in GfA Basic.
' Like ICFS, this is a TSR system enhancer your
' programs can use, setup or shutdown using a function
' dispatcher. When it's cookie is found, so is the
' address of this dispatcher. All you need to do is
' call on it, using the C: command.
'
' Theo Ros, 06/02/97
' *************************************************
'
DEFWRD "a-z"
OPTION BASE 0
DEFLIST 4
'
@print_ckbd_info
EDIT
'
> PROCEDURE print_ckbd_info                               ! example routine
  LOCAL ckbd%,struct%,ckbd$,status
  CLS
  ckbd%=@ckbd_identify(ckbd$)
  IF ckbd%>0
    PRINT ckbd$                 ! name and version
    PRINT
    PRINT "EXTKEY  is ";        ! default=ON
    IF @ckbd_extkey(ckbd%,-1)
      PRINT "ON"
    ELSE
      PRINT "OFF"
    ENDIF
    ' -----------------------------------------------------------------'
    status=@ckbd_compose(ckbd%,-1)
    PRINT "COMPOSE is ";        ! default=ON/Dec mode/Order Indifferent
    IF BTST(status,0)
      PRINT "ON  (";
      IF BTST(status,1)
        PRINT "Multichar /";
      ELSE
        PRINT "Dec mode/ ";
      ENDIF
      IF BTST(status,2)
        PRINT "Order Sensitive)"
      ELSE
        PRINT "Order Indifferent)"
      ENDIF
    ELSE
      PRINT "OFF"
    ENDIF
    ' -----------------------------------------------------------------'
    PRINT "ALT_NNN is ";        ! default=ON
    IF @ckbd_alt_nnn(ckbd%,-1)
      PRINT "ON"
    ELSE
      PRINT "OFF"
    ENDIF
    ' -----------------------------------------------------------------'
    PRINT "DEADKEY is ";        ! default=ON / "`'^|~
    IF @ckbd_deadkey(ckbd%,-1,ckbd$)
      PRINT "ON  (";ckbd$;")"
    ELSE
      PRINT "OFF"
    ENDIF
    ' -----------------------------------------------------------------'
    struct%=@ckbd_ckeytbl(ckbd%,-1,-1,-1,-1)
    PRINT "Used keyboard tables : ";CHAR{LONG{struct%+16}}
    PRINT "UNshifted chars at   : ";LONG{struct%}
    PRINT "SHIFTED chars at     : ";LONG{struct%+4}
    PRINT "CAPS-LOCKED chars at : ";LONG{struct%+8}
    PRINT "COMPOSE structure at : ";LONG{struct%+12}
    struct%=LONG{struct%+12}    ! pointer to compose struct
    PRINT "--> 1st keys at      : ";LONG{struct%}
    PRINT "--> 2nd keys at      : ";LONG{struct%+4}
    PRINT "--> composed chars at: ";LONG{struct%+8}
    PRINT "--> flags at         : ";LONG{struct%+12}
    ' -----------------------------------------------------------------'
    DIM ckbd_mspeed(8)          ! if empty get at the vars using
    '                               CARD{struct%+nn}
    struct%=@ckbd_mouse(ckbd%,-1,ckbd_mspeed())
    PRINT "MOUSE SPEEDER is ";
    IF BTST(ckbd_mspeed(0),0)
      PRINT "ON"
      PRINT "--> Buttons L/R are ";
      IF BTST(ckbd_mspeed(0),2)
        PRINT "SWAPPED"
      ELSE
        PRINT "NORMAL"
      ENDIF
      ' Polynomial factors like B‚zier curve: begin/end/magnetic1/magnetic2
      PRINT "--> Speeder factors: ";ckbd_mspeed(1);", ";ckbd_mspeed(4);
      PRINT ", ";ckbd_mspeed(3);", ";ckbd_mspeed(2)
      PRINT "--> Rotation is ";ckbd_mspeed(5);" degrees"
      PRINT "--> X:Y ratio is 1:";ckbd_mspeed(6)/256
      PRINT "--> Mouse resolution is  ";ckbd_mspeed(7);" dpi"
      PRINT "--> Screen resolution is ";ckbd_mspeed(8);" dpi"
    ELSE
      PRINT "OFF"
    ENDIF
  ELSE
    PRINT "No Composed Characters KeyBoard Driver installed.."
  ENDIF
  PRINT
  PRINT "Press a key"
  ~INP(2)
RETURN
> FUNCTION cookie_find(id$)
LOCAL c_ptr%,cname%,c_val%
c_ptr%=LPEEK(&H5A0)
IF OR(c_ptr%=0,ODD(c_ptr%))
  RETURN 0                    ! error: cookiejar does not exist
ELSE
  REPEAT
    cname%=LPEEK(c_ptr%)
    c_val%=LPEEK(c_ptr%+4)
    EXIT IF cname%=0          ! end of list
    ADD c_ptr%,8
  UNTIL MKL$(cname%)=id$      ! cookie found
  IF cname%
    RETURN c_val%             ! return its value
  ENDIF
  RETURN -1                   ! jar exists; cookie not found
ENDIF
ENDFUNC
'
> FUNCTION ckbd_identify(VAR id$)                         ! 0
' function returns the address of the
' CKBD function-dispatcher or zero if
' ckbd was not installed. The parameter
' ckbd$ will be filled with the identifier
' string (or will be empty if no driver
' was found in the system)
'
$F%
LOCAL driver%
CLR id$
driver%=@cookie_find("CKBD")
IF AND(driver%>0,EVEN(driver%))
id$=CHAR{C:driver%(0)}      ! IDENTIFY
RETURN driver%              ! --> 'CKBD Deluxe v1.5 by Pascal Fellerich'
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_extkey(driver%,mode)                      ! 1
' function returns last EXTKEY-status
' mode:      -1 --> inquire status, don't change
'             0 --> switch OFF
'             1 --> switch ON
'
$F&
IF driver%>0
IF OR(mode<-1,mode>1)       ! if inproperly set, use INQUIRE
mode=-1
ENDIF
RETURN CARD(C:driver%(1,mode))              ! EXTKEY
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_compose(driver%,mode)                     ! 2
' function returns last COMPOSE-status
' mode:      -1 --> inquire status, don't change
'             else bitmap:  bit 0:    0 --> switch OFF
'                                     1 --> switch ON
'                           bit 1:    0 --> DEC mode
'                                     1 --> MULTICHAR mode
'                           bit 2:    0 --> order sensitive OFF
'                                     1 --> order sensitive ON
$F&
IF driver%>0
IF OR(mode<-1,mode>1)       ! if inproperly set, use INQUIRE
mode=-1
ENDIF
RETURN (C:driver%(2,mode) AND &X111)        ! COMPOSE
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_alt_nnn(driver%,mode)                     ! 3
' function returns last ALT_NUMKEYS-status
' mode:      -1 --> inquire status, don't change
'             0 --> switch OFF
'             1 --> switch ON
'
$F&
IF driver%>0
IF OR(mode<-1,mode>1)       ! if inproperly set, use INQUIRE
mode=-1
ENDIF
RETURN CARD(C:driver%(3,mode))              ! ALT_NNN
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_ckeytbl(driver%,unsh%,shft%,caps%,comp%)  ! 4
' function works similar to BIOS Keytabl()
' and returns a pointer to a structure
' (XKEYTAB) of pointers:
'     unsh%  points to UNshifted character buffer (128 bytes)
'     shft%  points to SHIFTED character buffer (128 bytes)
'     caps%  points to CAPS-LOCKED character buffer (128 bytes)
'     comp%  points to another structure (COMPTAB):
'               primary%      ! key first pressed
'               secundary%    ! key pressed after first
'               composed%     ! character to build from them
'               flags%        ! dunno
' when on entry any of these parameters are set to <=0,
' the function INQUIRES this table; otherwise the CKBD
' program copies the table this parameter points to into
' its memory and uses it.
'
$F%
IF driver%>0
IF OR(unsh%<1,ODD(unsh%))   ! make sure parameters are ok
unsh%=-1
ENDIF
IF OR(shft%<1,ODD(shft%))
shft%=-1
ENDIF
IF OR(caps%<1,ODD(caps%))
caps%=-1
ENDIF
IF OR(comp%<1,ODD(comp%))
comp%=-1
ENDIF
RETURN C:driver%(4,L:unsh%,L:shft%,L:caps%,L:comp%)
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_cbioskeys(driver%,mode)                   ! 5
' function returns last used keytables and
' switches between system and loaded tables.
' mode:      -1 --> inquire status, don't change
'             else bitmap:  bit 0:    0 --> use default translation tables
'                                     1 --> use loaded translation tables
'                           bit 1:    0 --> don't use compose tables
'                                     1 --> use loaded compose tables
$F&
IF driver%>0
IF OR(mode<-1,mode>3)       ! if inproperly set, use INQUIRE
mode=-1
ENDIF
RETURN (C:driver%(5,mode) AND &X11)         ! CBIOSKEYS
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_deadkey(driver%,mode,VAR deadkey$)        ! 6
' function returns last DEADKEY-status
' mode:      -1 --> inquire status, don't change
'             0 --> switch OFF
'             1 --> switch ON
'             2 --> setup
' deadkey$    will be filled with all possible keys on INQUIRE (-1)
'             or contains the keys to use after SETUP (2)
'
$F&
LOCAL charbuf$
IF driver%>0
IF OR(mode<-1,mode>2)       ! if inproperly set, use INQUIRE
mode=-1
ENDIF
IF mode>1                   ! SETUP?
charbuf$=LEFT$(deadkey$,20)+CHR$(0) ! make sure it's a C-string
ELSE
charbuf$=SPACE$(20)       ! else prepare buffer
ENDIF
mode=CARD(C:driver%(6,mode,L:(V:charbuf$)))       ! DEADKEY
charbuf$=charbuf$+CHR$(0)
deadkey$=CHAR{V:charbuf$}
RETURN mode
ENDIF
RETURN 0
ENDFUNC
> FUNCTION ckbd_mouse(driver%,mode,VAR mspeed())          ! 7
' function returns the address of the currently
' used MSPEEDER setup structure (array of 10 words)
' mode:       -1 --> inquire, don't set
'              0 --> deactivate mouse speeder
'              1 --> activate mouse speeder
'              2 --> install new parameters using mspeed()
' mspeed(0)    bitmap: bit 0    --> speeder OFF (0) or ON (1)
'                      bit 1    --> unused
'                      bit 2    --> swap Left/Right buttons (1) or not (0)
'                      bit 3-16 --> reserved
' mspeed(1)/mspeed(4)   start and finish polynomial factor points
' mspeed(3)/mspeed(2)   in between magnetic polynomial factor points
' mspeed(5)     rotation in degrees
' mspeed(6)     X:Y ratio as 1:mspeed(6)/256
' mspeed(7)     mouse resolution in dpi
' mspeed(8)     screen resolution in dpi
'
LOCAL speed%
IF driver%>0
IF DIM?(mspeed())=>9   ! now, when INQUIRE the array will be filled
speed%=V:mspeed(0)   ! so you can read values directly from array
ELSE                   ! otherwise use CARD{returnval%+offset}
CLR speed%
ENDIF
RETURN C:driver%(7,mode,L:speed%)   ! MOUSE_CFG
ENDIF
RETURN 0
ENDFUNC


Back To ICTARI 45