/
p_control.c
878 lines (749 loc) · 22.5 KB
/
p_control.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
/**\file
*\section Copyright and License Summary
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2006 Jaakko Keränen <skyjake@dengine.net>
*\author Copyright © 2006 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/*
* p_control.c: Player Controls
*/
// HEADER FILES ------------------------------------------------------------
#include <ctype.h>
#include "de_base.h"
#include "de_play.h" // for P_LocalToConsole()
#include "de_network.h"
#include "de_misc.h"
#include "de_system.h"
// MACROS ------------------------------------------------------------------
// Number of triggered impulses buffered into each player's control state
// table. The buffer is emptied when a ticcmd is built.
#define MAX_IMPULSES 8
#define MAX_DESCRIPTOR_LENGTH 20
#define SLOW_TURN_TIME (6.0f / 35)
// TYPES -------------------------------------------------------------------
// Built-in controls.
enum
{
CTL_WALK = 0,
CTL_SIDESTEP,
CTL_TURN,
CTL_ZFLY,
CTL_LOOK
};
/*
* The control descriptors contain a mapping between symbolic control
* names and the identifier numbers.
*/
typedef struct controldesc_s {
char name[MAX_DESCRIPTOR_LENGTH + 1];
} controldesc_t;
typedef struct controlclass_s {
uint count;
controldesc_t *desc;
} controlclass_t;
/*
* Each player has his own control state table.
*/
typedef struct controlstate_s {
// The axes are updated whenever their values are needed,
// i.e. during the call to P_BuildCommand.
controlaxis_t *axes;
// The toggles are modified via console commands.
controltoggle_t *toggles;
// The triggered impulses are stored into a ring buffer.
uint head, tail;
impulse_t impulses[MAX_IMPULSES];
} controlstate_t;
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
D_CMD(ListPlayerControls);
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static uint controlFind(controlclass_t *cl, const char *name);
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern unsigned int numBindClasses;
// PUBLIC DATA DEFINITIONS -------------------------------------------------
// Control class names - [singular, plural].
const char *ctlClassNames[NUM_CONTROL_CLASSES][NUM_CONTROL_CLASSES] = {
{{"Axis"}, {"Axes"}},
{{"Toggle"}, {"Toggles"}},
{{"Impulse"}, {"Impulses"}}
};
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static controlclass_t ctlClass[NUM_CONTROL_CLASSES];
static controlstate_t ctlState[DDMAXPLAYERS];
// CODE --------------------------------------------------------------------
/**
* Register the console commands and cvars of the player controls subsystem.
*/
void P_RegisterControl(void)
{
C_CMD("listcontrols", "", ListPlayerControls);
}
/**
* Initialize the control state table of the specified player. The control
* descriptors must be fully initialized before this is called.
*/
void P_ControlTableInit(int player)
{
uint i;
controlstate_t *s = &ctlState[player];
// Allocate toggle states.
s->toggles =
M_Calloc(ctlClass[CC_TOGGLE].count * sizeof(controltoggle_t));
// Allocate an axis state for each axis control.
s->axes = M_Calloc(ctlClass[CC_AXIS].count * sizeof(controlaxis_t));
for(i = 0; i < ctlClass[CC_AXIS].count; ++i)
{
// The corresponding toggle control. (Always exists.)
s->axes[i].toggle = &s->toggles[
controlFind(&ctlClass[CC_TOGGLE],
ctlClass[CC_AXIS].desc[i].name) - 1];
}
// Clear the impulse buffer.
s->head = s->tail = 0;
}
/**
* Free the memory allocated for the player's control state table.
*/
static void controlTableFree(int player)
{
controlstate_t *s = &ctlState[player];
M_Free(s->axes);
M_Free(s->toggles);
memset(s, 0, sizeof(*s));
}
/**
* Free the control descriptors and state tables.
*/
void P_ControlShutdown(void)
{
uint i;
// Free the control tables of the local players.
for(i = 0; i < DDMAXPLAYERS; ++i)
{
if(players[i].flags & DDPF_LOCAL)
controlTableFree(i);
}
for(i = 0; i < NUM_CONTROL_CLASSES; ++i)
{
if(ctlClass[i].desc)
M_Free(ctlClass[i].desc);
}
memset(ctlClass, 0, sizeof(ctlClass));
}
/**
* Look up the index of the specified control.
*/
static uint controlFind(controlclass_t *cl, const char *name)
{
uint i;
for(i = 0; i < cl->count; ++i)
{
if(!stricmp(cl->desc[i].name, name))
return i + 1; // index + 1
}
return 0;
}
/**
* Look up the index of the specified axis control.
*/
uint P_ControlFindAxis(const char *name)
{
return controlFind(&ctlClass[CC_AXIS], name);
}
/**
* Update the state of the axis and return a pointer to it.
*/
float P_ControlGetAxis(int player, const char *name)
{
uint idx = controlFind(&ctlClass[CC_AXIS], name);
controlaxis_t *axis;
float pos;
#ifdef _DEBUG
if(idx == 0)
{
Con_Error("P_ControlGetAxis: '%s' is undefined.\n", name);
}
#endif
axis = &ctlState[player].axes[idx - 1];
pos = axis->pos;
// Update the axis position, if the axis toggle control is active.
if(axis->toggle && axis->toggle->state != TG_MIDDLE)
{
pos = (axis->toggle->state == TG_POSITIVE? 1 : -1);
// During the slow turn time, the speed is halved.
/* // DJS - Not with ALL axes!
if(Sys_GetSeconds() - axis->toggle->time < SLOW_TURN_TIME)
{
pos /= 2;
}
*/
}
return pos;
}
/**
* Retrieve the name of an axis control.
*
* @param index The index of the axis control to retrieve the name of.
*
* @return The name of an axis control at index.
*/
const char *P_ControlGetAxisName(uint index)
{
return ctlClass[CC_AXIS].desc[index].name;
}
/**
* Create a new control descriptor.
*/
static controldesc_t *controlAdd(uint class, const char *name)
{
controlclass_t *c = &ctlClass[class];
controldesc_t *d;
c->desc = M_Realloc(c->desc, sizeof(*c->desc) * ++c->count);
d = c->desc + c->count - 1;
memset(d, 0, sizeof(*d));
strncpy(d->name, name, sizeof(d->name) - 1);
return d;
}
/**
* Register a new player control descriptor.
* Part of the Doomsday public API.
*
* Axis controls will automatically get toggleable controls too.
*
* The controls whose names are in CAPITAL LETTERS will be included 'as is'
* in a ticcmd. The state of other controls won't be sent over the network.
*
* All the symbolic names must be unique and at most MAX_DESCRIPTOR_LENGTH
* chars long!
*
* @param class Control class of the descriptor being registered.
* @param name A unique name for the new control descriptor.
*/
void P_RegisterPlayerControl(uint cClass, const char *name)
{
uint i;
if(!name || !name[0])
Con_Error("P_RegisterPlayerControl: Control missing name.");
if(cClass >= NUM_CONTROL_CLASSES)
Con_Error("P_RegisterPlayerControl: Unknown class %i. "
"Could not register control \"%s\".", cClass, name);
// Names must be at most 16 chars long.
if(strlen(name) > MAX_DESCRIPTOR_LENGTH)
Con_Error("P_RegisterPlayerControl: Cannot register control \"%s\""
" - too many characters (%i max).",
name, MAX_DESCRIPTOR_LENGTH);
// Names must be unique.
// (Actually, there can be both upper and lower-case versions when
// dealing with axis controls but as far as the games are concerned;
// they must be completely unique).
for(i = 0; i < NUM_CONTROL_CLASSES; ++i)
{
if(controlFind(&ctlClass[i], name) > 0)
Con_Error("P_RegisterPlayerControl: There already exists a "
"control with the name \"%s\". Names must be unique.",
name);
}
controlAdd(cClass, name);
if(cClass == CC_AXIS)
{
char buf[MAX_DESCRIPTOR_LENGTH + 1];
// Also create a toggle for each axis, but use a lower case name so
// it won't be included in ticcmds.
strncpy(buf, name, sizeof(buf) - 1);
strlwr(buf);
controlAdd(CC_TOGGLE, buf);
}
}
/**
* Retrieve a bitmap that specifies which toggle controls are currently
* active. Only the UPPER CASE toggles are included. The other toggle
* controls are intended for local use only.
*
* @param player Player num whose toggle control states to collect.
* @return The created bitmap.
*/
int P_ControlGetToggles(int player)
{
int bits = 0;
uint pos = 0, i;
controlclass_t *cc = &ctlClass[CC_TOGGLE];
controlstate_t *state = &ctlState[player];
for(i = 0; i < cc->count; ++i)
{
// Only the upper case toggles are included.
if(isupper(cc->desc[i].name[0]))
{
if(state->toggles[i].state != TG_OFF)
{
bits |= 1 << pos;
}
pos++;
}
}
#ifdef _DEBUG
// We assume that we can only use up to seven bits for the controls.
if(pos >= 7)
Con_Error("P_ControlGetToggles: Out of bits (%i).\n", pos);
#endif
return bits;
}
/**
* Clear all toggle controls.
*
* @param player Player number whose toggle controls to clear.
* If negative, clear ALL player's toggle controls.
*/
void P_ControlReset(int player)
{
int console;
uint i, k;
controlstate_t *s;
if(player < 0)
{ // Clear toggles for ALL players.
for(i = 0, s = ctlState; i < DDMAXPLAYERS; ++i, s++)
{
if(!s->toggles)
continue;
for(k = 0; k < ctlClass[CC_TOGGLE].count; ++k)
{
s->toggles[k].state = TG_OFF;
}
}
}
else
{ // Clear toggles for local player #n.
console = P_LocalToConsole(player);
if(console >= 0 && console < DDMAXPLAYERS)
{
s = &ctlState[console];
for(k = 0; k < ctlClass[CC_TOGGLE].count; ++k)
{
s->toggles[k].state = TG_OFF;
}
}
}
}
/**
* Store the specified impulse to the player's impulse buffer.
*
* @param player Player number the impulse is for.
* @param impulse The impluse to be executed.
*/
static void controlImpulse(int player, impulse_t impulse)
{
controlstate_t *s = &ctlState[player];
uint old = s->tail;
s->impulses[s->tail] = impulse;
s->tail = (s->tail + 1) % MAX_IMPULSES;
if(s->tail == s->head)
{
// Oops, must cancel. The buffer is full.
s->tail = old;
}
}
/**
* Is the given string a valid control command?
*
* @param cmd Ptr to the string to be tested.
*
* @return <code>true</code> if valid.
*/
boolean P_IsValidControl(const char *cmd)
{
char name[20], *ptr;
uint idx;
int console, localPlayer = 0;
// Check the prefix to see what will be the new state of the
// toggle.
if(cmd[0] == '+' || cmd[0] == '-')
{
if(cmd[0] == cmd[1]) // ++ / --
cmd += 2;
else
cmd++;
}
// Copy the name of the control and find the end.
for(ptr = name; *cmd && *cmd != '/'; cmd++)
*ptr++ = *cmd;
*ptr++ = 0;
// Is the local player number specified?
if(*cmd == '/')
{
// The specified number could be bogus.
localPlayer = strtol(cmd + 1, NULL, 10);
}
// Which player will be affected?
console = P_LocalToConsole(localPlayer);
if(console >= 0 && console < DDMAXPLAYERS)
{
// Is the given name a valid control name? First check the toggle
// controls.
if((idx = controlFind(&ctlClass[CC_TOGGLE], name)) > 0)
return true;
// How about impulses?
if((idx = controlFind(&ctlClass[CC_IMPULSE], name)) > 0)
return true;
}
return false;
}
/**
* Execute a control command, which will modify the state of a toggle
* control or send a new impulse. Returns true if a control was
* successfully modified. The command is case-insensitive. This
* function is called by the console.
*
* The command syntax is as follows: [+|-]name[/N]
*
* name Toggle state of 'name', local player zero
* name/3 Toggle state of 'name', local player 3
* name/12 Toggle state of 'name', local player 12 (!)
* +name Set 'name' to on/positive state (local zero)
* ++name/4 Set 'name' to on/positive state (local 4)
* -name Set 'name' to off/middle state (local zero)
* --name/5 Set 'name' to negative state (local 5)
*
* @param cmd The action command to search for.
*
* @return <code>true</code> if the action was changed
* successfully.
*/
boolean P_ControlExecute(const char *cmd)
{
char name[MAX_DESCRIPTOR_LENGTH + 1], *ptr;
uint idx;
int console, localPlayer = 0;
togglestate_t newState = TG_TOGGLE;
controlstate_t *state = NULL;
if(!cmd || !cmd[0] || strlen(cmd) > MAX_DESCRIPTOR_LENGTH)
return false;
// Check the prefix to see what will be the new state of the
// toggle.
if(cmd[0] == '+' || cmd[0] == '-')
{
if(cmd[0] == cmd[1]) // ++ / --
{
newState = (cmd[0] == '+'? TG_POSITIVE : TG_NEGATIVE);
cmd += 2;
}
else
{
newState = (cmd[0] == '+'? TG_ON : TG_OFF);
cmd++;
}
}
// Copy the name of the control and find the end.
for(ptr = name; *cmd && *cmd != '/'; cmd++)
*ptr++ = *cmd;
*ptr++ = 0;
// Is the local player number specified?
if(*cmd == '/')
{
// The specified number could be bogus.
localPlayer = strtol(cmd + 1, NULL, 10);
}
// Which player will be affected?
console = P_LocalToConsole(localPlayer);
if(console >= 0 && console < DDMAXPLAYERS && ddplayers[console].ingame)
{
state = &ctlState[console];
}
if(state)
{
// Is the given name a valid control name? First check the toggle
// controls.
if((idx = controlFind(&ctlClass[CC_TOGGLE], name)) > 0)
{
// This is the control that must be changed.
controltoggle_t *toggle = state->toggles + idx - 1;
if(newState == TG_TOGGLE)
{
toggle->state = (toggle->state == TG_ON? TG_OFF : TG_ON);
}
else
{
toggle->state = newState;
}
// Update the toggle time.
toggle->time = Sys_GetSeconds();
return true;
}
// How about impulses?
if((idx = controlFind(&ctlClass[CC_IMPULSE], name)) > 0)
{
controlImpulse(console, idx - 1);
return true;
}
}
return false;
}
/**
* Update the position of an axis control. This is called periodically
* from the axis binding code (for STICK axes).
*/
void P_ControlSetAxis(int player, uint axisControlIndex, float pos)
{
if(player < 0 || player >= DDMAXPLAYERS)
return;
if(ctlState[player].axes == NULL)
return;
#if _DEBUG
if(axisControlIndex > ctlClass[CC_AXIS].count)
Con_Error("P_ControlSetAxis: Invlid axis index %i.",
axisControlIndex);
#endif
ctlState[player].axes[axisControlIndex].pos = pos;
}
/**
* Move a control bound to a POINTER type axis. This doesn't affect actual
* position of the axis control (!).
*/
void P_ControlAxisDelta(int player, uint axisControlIndex, float delta)
{
controldesc_t *desc;
ddplayer_t *plr;
if(player < 0 || player >= DDMAXPLAYERS)
return;
if(ctlState[player].axes == NULL)
return;
#if _DEBUG
if(axisControlIndex > ctlClass[CC_AXIS].count)
Con_Error("P_ControlAxisDelta: Invlid axis index %i.",
axisControlIndex);
#endif
plr = &players[player];
// Get a descriptor of the axis control.
desc = &ctlClass[CC_AXIS].desc[axisControlIndex];
switch(axisControlIndex)
{
case CTL_TURN:
/* $unifiedangles */
if(plr->mo)
plr->mo->angle -= (angle_t) (delta/180 * ANGLE_180);
break;
case CTL_LOOK:
// 110 corresponds 85 degrees.
/* $unifiedangles */
plr->lookdir += delta * 110.0f/85.0f;
// Clamp it.
if(plr->lookdir > 110)
plr->lookdir = 110;
if(plr->lookdir < -110)
plr->lookdir = -110;
break;
default:
// Undefined for other axis controls?
break;
}
}
/**
* Update view angles according to the "turn" or "look" axes.
* Done for all local players.
*/
void P_ControlTicker(timespan_t time)
{
// FIXME: Player class turn speed.
// angleturn[3] = {640, 1280, 320}; // + slow turn
uint i;
float pos, mul;
mul = time * TICSPERSEC * (640 << 16) * 45.0f/ANGLE_45;
for(i = 0; i < DDMAXPLAYERS; ++i)
{
if(!players[i].ingame || !(players[i].flags & DDPF_LOCAL))
continue;
pos = P_ControlGetAxis(i, "turn");
P_ControlAxisDelta(i, CTL_TURN, mul * pos);
pos = P_ControlGetAxis(i, "look");
P_ControlAxisDelta(i, CTL_LOOK, mul * pos);
}
}
#if 0
boolean buildEventFromCtlDescriptor(int player, controldesc_t *desc,
evtype_t type, evstate_t state,
ddevent_t *ev)
{
switch(type)
{
case EV_KEY:
if(!desc->defKey)
break;
if(ev)
{
ev->type = EV_KEY;
ev->state = state;
ev->data1 = desc->defKey;
}
return true;
case EV_MOUSE_BUTTON:
if(!desc->defMouse)
break;
if(ev)
{
ev->type = EV_MOUSE_BUTTON;
ev->state = state;
ev->data1 = 1 << (desc->defMouse - 1);
}
return true;
case EV_JOY_BUTTON:
if(!desc->defJoy)
break;
if(ev)
{
ev->type = EV_JOY_BUTTON;
ev->state = state;
ev->data1 = 1 << (desc->defJoy - 1);
}
return true;
default:
break; // unknown
}
return false;
}
void setDefaultBinding(int player controldesc_t *desc, boolean safe)
{
uint i, j;
ddevent_t ev;
char buff[80];
binding_t *existing;
for(i = 0; i < NUM_EVENT_TYPES; ++i)
{
for(j = 0; j < NUM_EVENT_STATES; ++j)
{
if(buildEventFromCtlDescriptor(player, desc, i, j, &ev))
{
B_FormEventString(buff, ev.type, ev.state, ev.type);
if(player > 0)
strcat(buff, "/%i", player);
if(safe && (existing = B_GetBinding(&ev, false)))
if(existing->commands[desc->bindClass].command[ev.state])
continue;
B_Bind(&ev, &buff, desc->bindClass);
}
}
}
}
void P_SetDefaultBinding(int player, const char *name, boolean safe)
{
uint i, idx;
controldesc_t *desc;
// An axis control?
/*
if((idx = controlFind(&ctlClass[CC_AXIS], name)) > 0)
{
desc = &ctlClass[CC_AXIS].desc[idx - 1];
if(player < 0)
{
for(i = 0; i < DDMAXPLAYERS; ++i)
setDefaultBinding(i, desc, safe);
}
else
{
setDefaultBinding(player, desc, safe);
}
return;
}
*/
// A toggle control?
if((idx = controlFind(&ctlClass[CC_TOGGLE], name)) > 0)
{
desc = &ctlClass[CC_TOGGLE].desc[idx - 1];
if(player < 0)
{
for(i = 0; i < DDMAXPLAYERS; ++i)
setDefaultBinding(i, desc, safe);
}
else
{
setDefaultBinding(player, desc, safe);
}
return;
}
// How about impulses?
if((idx = controlFind(&ctlClass[CC_IMPULSE], name)) > 0)
{
desc = &ctlClass[CC_IMPULSE].desc[idx - 1];
if(player < 0)
{
for(i = 0; i < DDMAXPLAYERS; ++i)
setDefaultBinding(i, desc, safe);
}
else
{
setDefaultBinding(player, desc, safe);
}
return;
}
/*
for(i = 0; i < NUM_CONTROL_CLASSES; ++i)
{
controlclass_t *cClass = &ctlClass[i];
for(j = 0; j < cClass->count; ++j)
{
if(desc->defKey)
{
if(i == CC_TOGGLE)
else
if(buildEventFromCtlDescriptor(player, desc, EV_KEY, &ev))
B_Bind(&ev, char *command, desc->bindClass);
}
if(desc->defMouse)
{
if(i == CC_TOGGLE)
else
if(buildEventFromCtlDescriptor(player, desc, EV_KEY, &ev))
B_Bind(&ev, char *command, desc->bindClass);
}
if(desc->defJoy)
{
if(i == CC_TO
if(buildEventFromCtlDescriptor(player, desc, EV_KEY, &ev))
B_Bind(&ev, char *command, desc->bindClass);
}
}
}
*/
}
#endif
/**
* Prints a list of the registered control descriptors.
*/
D_CMD(ListPlayerControls)
{
uint i, j;
char buf[MAX_DESCRIPTOR_LENGTH+1];
Con_Message("Player Controls:\n");
for(i = 0; i < NUM_CONTROL_CLASSES; ++i)
{
controlclass_t *cClass = &ctlClass[i];
if(cClass->count > 0)
{
Con_Message("%i %s:\n", cClass->count,
ctlClassNames[i][cClass->count > 1]);
for(j = 0; j < cClass->count; ++j)
{
strncpy(buf, cClass->desc[j].name, sizeof(buf) - 1);
strlwr(buf);
buf[strlen(cClass->desc[j].name)] = 0;
Con_Message(" %s\n", buf);
}
}
}
return true;
}