This example updates the shift state for a loaded keyboard table.

#include <stdio.h>
#include <unikbd.h>

int main(void) {

   KHAND          kbdhandle;
   KBDNAME       *kbd_name;
   ULONG          mode     =  0;

   USHIFTSTATE    Uss      = {0};/* indicates no shift keys, toggle keys,
                                    dead keys, or layer keys are pressed.
                                  */
   VSCAN          v_scan;
   BYTE           makebreak;
   APIRET         rc;

   /***************************************************/
   /* Create a keyboard handle for US keyboard layout */
   /***************************************************/

   kbd_name = (UniChar*)L"us";

   rc = UniCreateKeyboard( &kbdhandle, kbd_name, mode );

   if ( rc != ULS_SUCCESS ) {
      printf("UniCreateKeyboard error: return code = %u\n", rc );
      return 1;
   }

   Uss.Shift      = KBD_LEFTSHIFT   /* indicate left shift          */
   Uss.Effective  = KBD_SHIFT;      /* effective shift state        */
   v_scan         = 0x61;           /* scan code for a              */
   makebreak      = KEYEV_MAKE;     /* indicate key is pressed down */

   rc = UniUpdateShiftState( kbdhandle, &Uss, v_scan, makebreak );

   if ( rc != ULS_SUCCESS ) {
      printf("UniUpdateShiftState error: return code = %u\n", rc );
      return 1;
   }

   return ULS_SUCCESS;

}


[Back: UniUpdateShiftState - Remarks]
[Next: UniUpdateShiftState - Topics]