Subversion Repositories eduke32

Rev

Rev 8549 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8549 Rev 8550
Line 138... Line 138...
138
    }
138
    }
139
}
139
}
140
140
141
int32_t CONTROL_KeyboardFunctionPressed(int32_t which)
141
int32_t CONTROL_KeyboardFunctionPressed(int32_t which)
142
{
142
{
-
 
143
    if (CONTROL_CheckRange(which) || !CONTROL_Flags[which].used)
143
    int32_t key1 = 0, key2 = 0;
144
        return FALSE;
144
145
145
    if (CONTROL_CheckRange(which)) return FALSE;
146
    int r = 0;
146
-
 
147
    if (!CONTROL_Flags[which].used) return FALSE;
147
    auto &mapped = CONTROL_KeyMapping[which];
148
148
149
    if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED && !CONTROL_KeyBinds[CONTROL_KeyMapping[which].key1].cmdstr)
149
    if (mapped.keyPrimary != KEYUNDEFINED && !CONTROL_KeyBinds[mapped.keyPrimary].cmdstr)
150
        key1 = KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] ? TRUE : FALSE;
150
        r = !!KB_KeyDown[mapped.keyPrimary];
151
151
152
    if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED && !CONTROL_KeyBinds[CONTROL_KeyMapping[which].key2].cmdstr)
152
    if (mapped.keySecondary != KEYUNDEFINED && !CONTROL_KeyBinds[mapped.keySecondary].cmdstr)
153
        key2 = KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] ? TRUE : FALSE;
153
        r |= !!KB_KeyDown[mapped.keySecondary];
154
154
155
    return key1 | key2;
155
    return r;
156
}
156
}
157
157
-
 
158
#if 0
158
void CONTROL_ClearKeyboardFunction(int32_t which)
159
void CONTROL_ClearKeyboardFunction(int32_t which)
159
{
160
{
160
    if (CONTROL_CheckRange(which)) return;
161
    if (CONTROL_CheckRange(which) || !CONTROL_Flags[which].used)
-
 
162
        return;
161
163
162
    if (!CONTROL_Flags[which].used) return;
164
    auto &mapped = CONTROL_KeyMapping[which];
163
165
164
    if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED)
166
    if (mapped.key1 != KEYUNDEFINED)
165
        KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] = 0;
167
        KB_KeyDown[mapped.key1] = 0;
166
168
167
    if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED)
169
    if (mapped.key2 != KEYUNDEFINED)
168
        KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] = 0;
170
        KB_KeyDown[mapped.key2] = 0;
169
}
171
}
-
 
172
#endif
170
173
171
void CONTROL_DefineFlag(int which, int toggle)
174
void CONTROL_DefineFlag(int which, int toggle)
172
{
175
{
173
    if (CONTROL_CheckRange(which)) return;
176
    if (CONTROL_CheckRange(which)) return;
174
177
Line 190... Line 193...
190
193
191
void CONTROL_MapKey(int32_t which, kb_scancode key1, kb_scancode key2)
194
void CONTROL_MapKey(int32_t which, kb_scancode key1, kb_scancode key2)
192
{
195
{
193
    if (CONTROL_CheckRange(which)) return;
196
    if (CONTROL_CheckRange(which)) return;
194
197
195
    CONTROL_KeyMapping[which].key1 = key1 ? key1 : KEYUNDEFINED;
198
    CONTROL_KeyMapping[which].keyPrimary = key1 ? key1 : KEYUNDEFINED;
196
    CONTROL_KeyMapping[which].key2 = key2 ? key2 : KEYUNDEFINED;
199
    CONTROL_KeyMapping[which].keySecondary = key2 ? key2 : KEYUNDEFINED;
197
}
200
}
198
201
199
#if 0
202
#if 0
200
void CONTROL_PrintKeyMap(void)
203
void CONTROL_PrintKeyMap(void)
201
{
204
{