ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
keyshift.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
41#if defined(__c128__) || defined(__c64__) || defined(__c64reu__)
42
43extern char DATATYPE_AS_STRING[][16];
44
45/* <usermanual>
46@keyword KEY SHIFT
47
48@english
49
50The ''KEY SHIFT'' function returns the current status of the various
51control keys. These keys such as ''SHIFT'' or ''ALT'' cannot be
52detected using the standard ''INKEY$'' or ''SCANCODE'' functions.
53But you can easily test for any combination of control keys with
54just a single call to the ''KEY SHIFT'' function. The result is a
55bit map with the following meaning:
56
57'''0 -LEFT SHIFT'''
58'''1 - RIGHT SHIFT'''
59'''2 - CAPS LOCK'''
60'''3 - CTRL'''
61'''4 - LEFT ALT'''
62'''5 - RIGHT ALT''
63
64If a bit is set to a one, then the associated button has been held
65down by the user.
66
67Note that not all computers support control keys, nor is it possible
68to have individual pressure detection. Depending on the target,
69some of the bits may not be available, or only under certain
70conditions.
71
72@italian
73
74La funzione ''KEY SHIFT'' restituisce lo stato corrente dei vari
75tasti di controllo. Questi tasti come ''SHIFT'' o ''ALT'' non
76possono essere rilevati utilizzando le funzioni standard
77''INKEY$'' o ''SCANCODE''. Ma puoi facilmente testare qualsiasi
78combinazione di tasti di controllo con una singola chiamata alla
79funzione ''KEY SHIFT''. Il risultato è una bitmap con il seguente
80significato:
81
82'''0 - LEFT SHIFT'''
83'''1 - RIGHT SHIFT'''
84'''2 - CAPS LOCK'''
85'''3 - CTRL'''
86'''4 - LEFT ALT'''
87'''5 - RIGHT ALT''
88
89Se un bit è impostato su uno, il pulsante associato è stato tenuto
90premuto dall'utente. Nota che non tutti i computer supportano i tasti
91di controllo, né è possibile avere il rilevamento della pressione di
92un singolo tasto. A seconda del target, alcuni bit potrebbero non
93essere disponibili o esserlo solo in determinate condizioni.
94
95@syntax = KEY SHIFT
96
97@example CENTER "Press some control keys"
98@example DO
99@example LOCATE 14, 4
100@example PRINT BIN$(KEY SHIFT, 8)
101@example LOOP
102
103@alias KEYSHIFT
104
105</usermanual> */
106
107/* <usermanual>
108@keyword KEYSHIFT
109
110@english
111
112@italian
113
114@syntax = KEYSHIFT
115
116@example CENTER "Press some control keys"
117@example DO
118@example LOCATE 14, 4
119@example PRINT BIN$(KEYSHIFT, 8)
120@example LOOP
121
122@alias KEY SHIFT
123
124</usermanual> */
125
126Variable * keyshift( Environment * _environment ) {
127
128 Variable * result = variable_temporary( _environment, VT_BYTE, "(result of KEYSHIFT)");
129
130 cia_keyshift( _environment, result->realName );
131
132 return result;
133
134}
135
136#endif
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Variable * keyshift(Environment *_environment)
Definition keyshift.c:43
void cia_keyshift(Environment *_environment, char *_shifts)
Definition cia.c:219
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450
char DATATYPE_AS_STRING[][16]