[ruamoko] Remove keys.h and keys.r

The functions haven't existed for two years now. And in the interest of
"throw one away", the controls_o.r has been gutted.
This commit is contained in:
Bill Currie 2023-12-21 08:40:09 +09:00
parent 5d4ce73ff4
commit 92f68844f5
19 changed files with 14 additions and 504 deletions

View file

@ -1,5 +1,6 @@
#include <QF/keys.h>
#include "draw.h" #include "draw.h"
#include "key.h"
#include "sound.h" #include "sound.h"
#include "CrosshairView.h" #include "CrosshairView.h"

View file

@ -1,5 +1,5 @@
#include <QF/keys.h>
#include "draw.h" #include "draw.h"
#include "key.h"
#include "sound.h" #include "sound.h"
#include "CvarColorView.h" #include "CvarColorView.h"

View file

@ -1,4 +1,4 @@
#include "key.h" #include <QF/keys.h>
#include "sound.h" #include "sound.h"
#include "legacy_string.h" #include "legacy_string.h"
#include "string.h" #include "string.h"

View file

@ -1,4 +1,4 @@
#include "key.h" #include <QF/keys.h>
#include "sound.h" #include "sound.h"
#include "string.h" #include "string.h"

View file

@ -1,3 +1,4 @@
#include <QF/keys.h>
#include "cvar.h" #include "cvar.h"
#include "CvarToggle.h" #include "CvarToggle.h"

View file

@ -1,4 +1,4 @@
#include "key.h" #include <QF/keys.h>
#include "sound.h" #include "sound.h"
#include "string.h" #include "string.h"

View file

@ -1,4 +1,4 @@
#include "key.h" #include <QF/keys.h>
#include "sound.h" #include "sound.h"
#include "Array.h" #include "Array.h"

View file

@ -1,5 +1,4 @@
#include "key.h" #include <QF/keys.h>
#include "menu.h" #include "menu.h"
#include "SubMenu.h" #include "SubMenu.h"

View file

@ -1,9 +1,9 @@
#include <QF/keys.h>
#include "AutoreleasePool.h" #include "AutoreleasePool.h"
#include "menu.h" #include "menu.h"
#include "cmd.h" #include "cmd.h"
#include "gib.h" #include "gib.h"
#include "draw.h" #include "draw.h"
#include "key.h"
#include "string.h" #include "string.h"
#include "cbuf.h" #include "cbuf.h"
#include "options.h" #include "options.h"

View file

@ -2,6 +2,5 @@
#define __controls_o_h #define __controls_o_h
@extern void MENU_control_binding (void); @extern void MENU_control_binding (void);
@extern void load_keybindings (void);
#endif//__controls_o_h #endif//__controls_o_h

View file

@ -32,468 +32,8 @@
#include "debug.h" #include "debug.h"
#include "legacy_string.h" #include "legacy_string.h"
#include "string.h" #include "string.h"
#include "key.h"
#include "options_util.h" #include "options_util.h"
int set_key_flag; // holds flag for the key-setting
// three global hashes for the main binding groups
Array *movement_bindings;
Array *misc_bindings;
Array *weapon_bindings;
struct binding_s {
string text;
string command;
string keys;
};
typedef struct binding_s binding_t;
@interface Binding : Object
{
@public
string text;
string command;
string keys;
}
-initWithBinding: (binding_t) binding;
@end
@implementation Binding
-initWithBinding: (binding_t) binding
{
self = [self init];
if (self) {
text = binding.text;
command = binding.command;
keys = binding.keys;
}
return self;
}
@end
binding_t movement_binding_list[16] = {
{"Jump/Swin up", "+jump"},
{"Walk forward", "+forward"},
{"Backpedal", "+back"},
{"Turn left", "+left"},
{"Turn right", "+right"},
{"Run", "+speed"},
{"Step left", "+moveleft"},
{"Step right", "+moveright"},
{"Sidestep", "+strafe"},
{"Look up", "+lookup"},
{"Look down", "+lookdown"},
{"Center view", "centerview"},
{"Mouse look", "+mlook"},
{"Keyboard look", "+klook"},
{"Swim up", "+moveup"},
{"Swim down", "+movedown"},
};
binding_t misc_binding_list [4] = {
{"Pause game", "pause"},
{"Tog. m.-grab", "toggle in_grab"},
{"Messagemode", "messagemode"},
{"Screenshot", "screenshot"},
};
binding_t weapon_binding_list [11] = {
{"Attack", "+attack"},
{"Next weapon", "impulse 10"},
{"Prev. weapon", "impulse 12"},
{"Axe", "impulse 1"},
{"Shotgun", "impulse 2"},
{"Super Shotgun", "impulse 3"},
{"Nailgun", "impulse 4"},
{"Super Nailgun", "impulse 5"},
{"Grenade L. ", "impulse 6"},
{"Rocket L. ", "impulse 7"},
{"Thunderbolt", "impulse 8"},
};
Binding *
new_binding (binding_t binding)
{
return [[Binding alloc] initWithBinding:binding];
}
/*
init_binding_hash
this function initializes the hashes for the binding menus
*/
void ()
init_binding_hash =
{
local int i;
movement_bindings = [[Array alloc] init];
for (i = 0; i < @sizeof (movement_binding_list) / @sizeof (movement_binding_list[0]); i++)
[movement_bindings addObject: new_binding (movement_binding_list[i])];
misc_bindings = [[Array alloc] init];
for (i = 0; i < @sizeof (misc_binding_list) / @sizeof (misc_binding_list[0]); i++)
[misc_bindings addObject: new_binding (misc_binding_list[i])];
weapon_bindings = [[Array alloc] init];
for (i = 0; i < @sizeof (weapon_binding_list) / @sizeof (weapon_binding_list[0]); i++)
[weapon_bindings addObject: new_binding (weapon_binding_list[i])];
};
/*
get_keyname
Gets the string of the key, which is bound to a special binding.
bindnum is the number of the binding.
As a command/binding can be bound to many keys, you can get the second,
third, etc. key by giving the bindnum.
*/
string (string binding, int bindnum)
get_keyname =
{
local int keynum;
local string keyname;
keynum = Key_LookupBinding("imt_0", bindnum, binding);
if(keynum == -1) {
keyname = "";
} else {
keyname = Key_KeynumToString(keynum);
// cut away the "K_", thats maybe enough as description for now
//keyname = String_Cut(0, 2, keyname);
}
return keyname;
};
/*
get_hash_keys
gets the keys for a keybinding-hash
*/
void
get_hash_keys (Array *list)
{
local int i,hlen;
local Binding *binding;
local string desc1 = "", desc2 = "";
hlen = [list count];
for(i = 0; i < hlen; i++) {
binding = [list objectAtIndex: i];
desc1 = get_keyname (binding.command, 1); // first key bound to
desc2 = get_keyname (binding.command, 2); // second key bound to
if (desc2 != "") {
desc1 += ", " + desc2;
}
if (binding.keys) {
str_free (binding.keys);
binding.keys = nil;
}
if (desc1) {
binding.keys = str_new ();
str_copy (binding.keys, desc1);
}
}
};
/*
load_keybindings
Loads the kername for into the hashes
*/
void ()
load_keybindings =
{
get_hash_keys (movement_bindings);
get_hash_keys (misc_bindings);
get_hash_keys (weapon_bindings);
};
/*******************
* BINDINGS OPTIONS
* Binding settings
*******************/
/*
DESIGN NOTE (by elmex):
Every sub-menu for control bindings has its own hash for holding the
keybindings. Thats why there are three different functions, which shadow
the CB_MAIN_control_binding() function. They get the binding from the
correct hash.
*/
/*
CB_MAIN_control_binding
The core function of all control_binding function.
It takes the binding as argument.
This function is called by the real callbacks.
*/
int
CB_MAIN_control_binding (Binding *binding, int key)
{
local int retval = 0, bindcnt = 0;
if(set_key_flag) {
bindcnt = Key_CountBinding("imt_0", binding.command);
/* we are not binding keys for more than one command
by the menu (maybe extended later) */
if(bindcnt < 2) {
Key_SetBinding ("imt_0", key, binding.command);
} else {
// else, remove a binding and assign a new one
Key_SetBinding ("imt_0", Key_LookupBinding("imt_0", 1, binding.command), "");
Key_SetBinding ("imt_0", key, binding.command);
}
set_key_flag = 0;
retval = 1;
} else {
if(key == QFK_RETURN) {
set_key_flag = 1;
retval = 1;
} else if(key == QFK_BACKSPACE || key == QFK_DELETE) {
Key_SetBinding ("imt_0", Key_LookupBinding("imt_0", 1, binding.command), "");
retval = 1;
}
}
return retval;
};
/*
CB_basic_control_binding
Callback for the basic control bindings menu
*/
int (string text, int key)
CB_basic_control_binding =
{
local Binding *binding = [movement_bindings objectAtIndex: stoi (text)];
local int ret = CB_MAIN_control_binding (binding, key);
// fetch all keynames (possible to optimize.. but not very neccessary)
get_hash_keys (movement_bindings);
return ret;
};
/*
CB_ME_basic_control_binding
Loading basic keynames when entering the menu
*/
void ()
CB_ME_basic_control_binding =
{
get_hash_keys (movement_bindings);
};
/*
DRAW_basic_control_binding
Draws the menu for the basic control bindins
*/
int (int x, int y)
DRAW_basic_control_binding =
{
local int cursor_pad = 40, bind_desc_pad, hl, i;
bind_desc_pad = 120;
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [movement_bindings count];
for(i = 0; i < hl; i++) {
local Binding *binding = [movement_bindings objectAtIndex: i];
draw_val_item (x + 20, y + 40 + ( i * 10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
return 0;
};
/*
MENU_basic_control_binding
Menu making function for the control bindings
*/
void ()
MENU_basic_control_binding =
{
local int i,hl;
Menu_Begin (54, 40, "Movement bindings");
Menu_FadeScreen (1);
Menu_EnterHook (CB_ME_basic_control_binding);
Menu_Draw (DRAW_basic_control_binding);
hl = [movement_bindings count];
for (i = 0; i < hl; i++) {
Menu_Item (20, 40 + i * 10, itos (i), CB_basic_control_binding, 1);
}
Menu_End ();
};
/*
CB_misc_control_binding
Callback for misc control bindings.
*/
int (string text, int key)
CB_misc_control_binding =
{
local Binding *binding = [misc_bindings objectAtIndex: stoi (text)];
local int ret = CB_MAIN_control_binding (binding, key);
// fetch all keynames (possible to optimize.. but not very neccessary)
get_hash_keys (misc_bindings);
return ret;
};
/*
CB_ME_misc_control_binding
Loading misc keynames when entering the menu
*/
void ()
CB_ME_misc_control_binding =
{
get_hash_keys(misc_bindings);
};
/*
DRAW_misc_control_binding
Draw the bindings for the misc controls
*/
int (int x, int y)
DRAW_misc_control_binding =
{
local int cursor_pad = 40, bind_desc_pad;
local int i, hl;
bind_desc_pad = 120;
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [misc_bindings count];
for(i=0;i < hl; i++) {
local Binding *binding = [misc_bindings objectAtIndex: i];
draw_val_item (x + 20, y + 40+(i*10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (x + 12, y + (Menu_GetIndex() * 10) + cursor_pad);
return 0;
};
/*
MENU_misc_control_binding
Menu maker function for the misc control binding
*/
void ()
MENU_misc_control_binding =
{
local int hl, i;
Menu_Begin (54, 50, "Misc bindings");
Menu_FadeScreen (1);
Menu_EnterHook (CB_ME_misc_control_binding);
Menu_Draw (DRAW_misc_control_binding);
hl = [misc_bindings count];
for (i = 0; i < hl; i++) {
Menu_Item (20, 40 + i * 10, itos (i), CB_misc_control_binding, 1);
}
Menu_End ();
};
/*
CB_weapon_control_binding
Callback function for the weapons control bindings
*/
int (string text, int key)
CB_weapon_control_binding =
{
local Binding *binding = [weapon_bindings objectAtIndex: stoi (text)];
local int ret = CB_MAIN_control_binding (binding, key);
// fetch all keynames (possible to optimize.. but not very neccessary)
get_hash_keys (weapon_bindings);
return ret;
};
/*
CB_ME_weapon_control_binding
Loading weapon keynames when entering the
menu
*/
void ()
CB_ME_weapon_control_binding =
{
get_hash_keys(weapon_bindings);
};
/*
DRAW_weapon_control_binding
Draw the weapon binding menu
*/
int (int x, int y)
DRAW_weapon_control_binding =
{
local int cursor_pad = 40, bind_desc_pad, hl, i;
bind_desc_pad = 120;
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [weapon_bindings count];
for(i = 0; i < hl; i++) {
local Binding *binding = [weapon_bindings objectAtIndex: i];
draw_val_item (x + 20, y + 40 + (i * 10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
return 0;
};
/*
MENU_weapon_control_binding
Menu maker for the weapons menu
*/
void ()
MENU_weapon_control_binding =
{
local int hl, i;
Menu_Begin (54, 60, "Weapon bindings");
Menu_FadeScreen (1);
Menu_EnterHook (CB_ME_weapon_control_binding);
Menu_Draw (DRAW_weapon_control_binding);
hl = [weapon_bindings count];
for (i = 0; i < hl; i++) {
Menu_Item (20, 40 + i * 10, itos (i), CB_weapon_control_binding, 1);
}
Menu_End ();
};
/* /*
MENU_control_binding MENU_control_binding
@ -502,17 +42,15 @@ MENU_weapon_control_binding =
void () void ()
MENU_control_binding = MENU_control_binding =
{ {
init_binding_hash (); // init the keybinding hashes
Menu_Begin (54, 60, "Bindings"); Menu_Begin (54, 60, "Bindings");
Menu_Pic (16, 4, "gfx/qplaque.lmp"); Menu_Pic (16, 4, "gfx/qplaque.lmp");
Menu_CenterPic (160, 4, "gfx/p_option.lmp"); Menu_CenterPic (160, 4, "gfx/p_option.lmp");
Menu_FadeScreen (1); Menu_FadeScreen (1);
MENU_basic_control_binding (); // MENU_basic_control_binding ();
MENU_misc_control_binding (); // MENU_misc_control_binding ();
MENU_weapon_control_binding(); // MENU_weapon_control_binding();
Menu_End (); Menu_End ();
}; };

View file

@ -32,7 +32,6 @@
#include "string.h" #include "string.h"
#include "draw.h" #include "draw.h"
#include "cvar.h" #include "cvar.h"
#include "key.h"
#include "controls_o.h" #include "controls_o.h"
#include "options_util.h" #include "options_util.h"
#include "qfs.h" #include "qfs.h"

View file

@ -68,7 +68,6 @@ void () servlist_all_menu =
int (string text, int key) sl_filter_in = int (string text, int key) sl_filter_in =
{ {
load_keybindings();
switch (text) { switch (text) {
case "isnfull": case "isnfull":
serv_nfull ^= 1; serv_nfull ^= 1;

View file

@ -57,6 +57,3 @@ ruamoko_gui_includedir = $(datarootdir)/qfcc/include/gui
ruamoko_include_HEADERS = $(ruamoko_include) ruamoko_include_HEADERS = $(ruamoko_include)
ruamoko_gui_include_HEADERS = $(ruamoko_gui_include) ruamoko_gui_include_HEADERS = $(ruamoko_gui_include)
EXTRA_DIST += \
ruamoko/include/key.h

View file

@ -1,12 +0,0 @@
#ifndef __ruamoko_key_h
#define __ruamoko_key_h
#include <QF/keys.h>
@extern int Key_keydown (int keynum);
@extern string Key_SetBinding (string imt, int keynum, string binding);
@extern int Key_LookupBinding (string imt, int bindnum, string binding);
@extern int Key_CountBinding (string imt, string binding);
@extern string Key_KeynumToString (int keynum);
#endif//__ruamoko_key_h

View file

@ -65,8 +65,7 @@ ruamoko_lib_libcsqc_a_src= \
ruamoko/lib/gib.r \ ruamoko/lib/gib.r \
ruamoko/lib/input.r \ ruamoko/lib/input.r \
ruamoko/lib/mersenne.r \ ruamoko/lib/mersenne.r \
ruamoko/lib/scene.r \ ruamoko/lib/scene.r
ruamoko/lib/key.r
ruamoko_lib_common_dep=$(call qcautodep,$(ruamoko_lib_common_src)) ruamoko_lib_common_dep=$(call qcautodep,$(ruamoko_lib_common_src))
include $(ruamoko_lib_common_dep) # am--include-marker include $(ruamoko_lib_common_dep) # am--include-marker

View file

@ -1,8 +0,0 @@
#include <key.h>
int Key_keydown (int keynum) = #0;
string (string imt, int keynum, string binding) Key_SetBinding = #0;
int (string imt, int bindnum, string binding) Key_LookupBinding = #0;
int (string imt, string binding) Key_CountBinding = #0;
string (int keynum) Key_KeynumToString = #0;
int (string keyname) Key_StringToKeynum = #0;

View file

@ -1,7 +1,6 @@
int fence; int fence;
#include <AutoreleasePool.h> #include <AutoreleasePool.h>
#include <key.h>
#include <string.h> #include <string.h>
#include "ruamoko/qwaq/ui/color.h" #include "ruamoko/qwaq/ui/color.h"

View file

@ -1,7 +1,6 @@
int fence; int fence;
#include <AutoreleasePool.h> #include <AutoreleasePool.h>
#include <key.h>
#include "ruamoko/qwaq/ui/color.h" #include "ruamoko/qwaq/ui/color.h"
#include "ruamoko/qwaq/ui/curses.h" #include "ruamoko/qwaq/ui/curses.h"