home *** CD-ROM | disk | FTP | other *** search
- /*
- ------------------ Distribution and Copyright -----------------
- --
- -- This software is copyright by the CENA/DGAC/FRANCE
- -- All rights reserved.
- --
- -- No part of the material protected by this copyright notice
- -- may be reproduced or utilized for commercial use in any form
- -- without written permission of the copyright owner.
- --
- -- It may be reproduced or utilized for R&D use in Non Profit
- -- Organization
- --
- ---------------------------------------------------------------
-
-
- ------------------ Disclaimer ---------------------------------
- --
- -- This software and its documentation are provided "AS IS" and
- -- without any expressed or implied warranties whatsoever.
- -- No warranties as to performance, merchantability, or fitness
- -- for a particular purpose exist.
- --
- -- Because of the diversity of conditions and hardware under
- -- which this software may be used, no warranty of fitness for
- -- a particular purpose is offered. The user is advised to
- -- test the software thoroughly before relying on it. The user
- -- must assume the entire risk and liability of using this
- -- software.
- --
- -- In no event shall any person or organization of people be
- -- held responsible for any direct, indirect, consequential
- -- or inconsequential damages or lost profits.
- --
- -------------------END-PROLOGUE--------------------------------
- */
-
-
-
-
- /*****************************************************************************
- *****************************************************************************
- ** **
- ** D E M O D E S R O U T I N E S K B D $ **
- ** **
- ******* Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne ********
- *****************************************************************************/
-
-
-
-
- /*
- * Titre: DEMO DES ROUTINES KBD$
- *
- * Sujet: Single keypress under VMS.
- *
- * Version: 1.0-00
- *
- * Description: Programme de demonstration des routines kbd$.
- *
- * Ce programme de demonstration met en oeuvre la fonction
- * kbd$read_keystroke permettant d'attendre une action au
- * clavier et renvoyant la sequence ANSI correspondant a la
- * touche actionnee.
- *
- * Lorsque le tampon est plein, l'utilisateur est prevenu
- * par un beep sonore emit par le sous-programme d'IT.
- *
- * Afin de pouvoir recuperer les codes emis par CTRL/C,
- * CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
- * necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
- * /NOTTSYNC".
- *
- * Pour utiliser kbd$read_keystroke, vous devez appeler au
- * prealable la fonction kbd$open_keyboard et terminer par
- * kbd$close_keyboard.
- * La routine kbd$open_keyboard permet, entre autres, de ne
- * creer la zone tampon que si l'on desire reellement utiliser
- * kbd$read_keystroke.
- *
- * Langage: C ANSI
- *
- * Fichier: DEMO_KBD$ROUTINES.C
- *
- * Environnement: Machine cible: VAX
- * Systeme d'exploitation: VAX/VMS Version 5.4-3
- * Compilateur: VAX C Version 3.2-044
- *
- * Auteur: Martin VICENTE (DGAC/CENA/SID)
- *
- * E-mail: vicente@cenaath.cena.dgac.fr
- *
- * Mail: C.E.N.A.
- * Div. Support Informatique & Developpement
- * Orly Sud 205
- * 94 542 ORLY AEROGARE CEDEX, FRANCE
- *
- * Creation: 23/05/92
- *
- * Modification: 26/05/92
- *
- */
-
-
-
-
- #include <stdio.h>
- #include <lib$routines.h>
- #include "kbd$routines.h"
-
-
- const float second = 1.0;
-
- static void perform();
-
-
- main()
- {
- char yes;
- int i;
- kbd$t_ansi_sequence key;
-
-
- perform(kbd$open_keyboard());
-
- (void) printf("Press a key.\n");
-
- do {
- (void) kbd$key_pressed(&yes);
- } while (!yes);
-
- (void) printf("Five loop...\n");
-
- for (i = 0; i < 5; i++) {
- (void) printf("Programme principal (loop): %d\n", i);
- (void) lib$wait(&second);
- }
-
- (void) printf("Five readkey...\n");
-
- for (i = 0; i < 5; i++) {
- (void) printf("Programme principal (SMG code): ");
- perform(kbd$read_keystroke(&key));
- (void) printf("%d\n", kbd$cvt_ansi_smg(&key));
- }
-
- (void) printf("Five loop...\n");
-
- for (i = 0; i < 5; i++) {
- (void) printf("Programme principal (loop): %d\n", i);
- (void) lib$wait(&second);
- }
-
- (void) printf("Flush keyboard.\n");
-
- perform(kbd$flush_keyboard());
-
- (void) printf("Five loop...\n");
-
- for (i = 0; i < 5; i++) {
- (void) printf("Programme principal (loop): %d\n", i);
- (void) lib$wait(&second);
- }
-
- (void) printf("End\n");
-
- perform(kbd$close_keyboard());
- }
-
-
- static void perform(unsigned cond_value)
- {
- if (!(cond_value & 1)) (void) lib$stop(cond_value);
- }
-