一些控制器共享相同的布局,但具有不同的面,即 360 和 PS3(X 是 A,三角形是 Y,等等)。带有额外的外围设备,如战斗棒、飞行棒、吉他等 - 它们只是映射到控制台期望的不同面孔。由于按钮通常是在任何控制器成型之前定义的,因此您也可以这样做。
每个映射并非都适用于每个控制器,因此可能并不理想 - 考虑到现代控制台控制器,应该没问题。如果添加 Intellivision 控制器和键盘/鼠标,事情可能会开始变得奇怪。
// using CHAR(8) for absolutely no good reason. change at will.
CREATE TABLE button_maps (
id tinyint unsigned not null auto_increment,
map_id char(8) not null,
primary key (id),
unique key map_id (map_id)
);
INSERT INTO button_maps (map_id)
VALUES
// dual analog, any direction
('ANA_LFT'), ('ANA_RT'),
// 4-button compass face
('BT_N'), ('BT_S'), ('BT_E'), ('BT_W'),
// shoulder buttons
('BT_LT1'), ('BT_LT2'), ('BT_RT1'), ('BT_RT2'),
// system buttons
('BT_START'), ('BT_SEL'), ('BT_MENU'),
// analog stick click-in, usually called "L/R 3"
('ANA_L3'), ('ANA_R3'),
// 8-direction d-pad - add clockface points for both analogs too
('DPAD_N'), ('DPAD_S'), ('DPAD_E'), ('DPAD_W'),
('DPAD_NW'), ('DPAD_NE'), ('DPAD_SW'), ('DPAD_SE'),
// and DS stylus so it's not obvious what I'm looking at right now
('STL_TAP'), ('STL_DTAP'), ('STL_DRAG'),
// and so on
注意:我不知道那些全身运动控制的东西是如何在内部处理的,如果你不得不处理它们,祝你好运。 LFOOT_HOKEYPOKEY 什么的。
注意 2:说真的,不要在那里使用 char(8)。获取详细信息,但要保持足够通用以适用于通用控制器样式而不是品牌。
现在每个品牌的控制器的按钮及其名称(假设是“控制器”表):
CREATE TABLE buttons (
id tinyint unsigned not null auto_increment,
controller_id tinyint unsigned not null references controllers.id,
map_id tinyint unsigned not null references button_maps.id,
button_name varchar(32) not null,
primary key (id),
unique key controller_map (controller_id, map_id)
);
INSERT INTO buttons (controller_id, map_id, button_name)
VALUES
(2, 1, 'Left Analog'), (2, 2, 'Right Analog'),
(2, 3, 'Y'), (2, 4, 'A'), (2, 5, 'B'), (2, 6, 'X'),
(2, 7, 'Left Trigger (LT)'), (2, 8, 'Right Trigger (RT)'),
(2, 9, 'Left Bumper (LB)'), (2, 10, 'Right Bumper (RB)')
// and so on. PS3 with button shapes and R1/2, L1/2 instead of trigger/bumper
现在,对于一个按钮按下(或多个按钮,或一个序列)代表游戏的动作。这不考虑上下文(原始问题的 2 和 3),例如游戏模式或备用按钮配置,但 Josh Smeaton 和 littlegreen 已经介绍过。
这定义了每个单独游戏的操作,这不是很有效。通过添加游戏“类型”的通用层,您可能能够显着压缩事物。某种类型/视角中的许多游戏都有共同的控制,而且它只会变得越来越普遍(控制台 FPS 添加了预定义的 Halo 和 CoD 风格的按钮配置,因为玩家知道它们,等等)。因此,如果您可以为每种类型定义一组通用操作,并仅根据需要使用它来覆盖/扩展这些默认值,那么您可能会获得一个更简洁的解决方案。
首先,定义每个动作:
CREATE TABLE game_actions (
id int unsigned not null auto_increment,
game_id int unsigned not null references games.id,
action varchar(32) not null,
primary key (id)
);
INSERT INTO game_actions (game_id, action)
VALUES (1, 'Shoot'), (1, 'Reload'), (1, 'Turn Left'), (1, 'Turn Right')
// and so on
最后,定义与每个操作关联的按钮按下。 “序数”字段用于组合序列,例如格斗游戏组合 - 单个动作是第 0 个序数,序列从 1 开始计数,只是为了使它们易于区分。它不考虑时间,因此对于一些更复杂的组合游戏(Soul Caliber 等),您可能需要一个“无”按钮作为休息。
CREATE TABLE game_action_buttons (
id int unsigned not null auto_increment,
game_action_id int unsigned not null references game_actions.id,
ordinal tinyint unsigned not null,
button_map_id tinyint unsigned not null references button_maps.id,
primary key (id)
);
INSERT INTO game_action_buttons (game_action_id, ordinal, button_map_id)
VALUES
(1, 0, 8), // right trigger to shoot
(2, 0, 6), // west face button (X/square) to reload
(3, 0, 7), (3, 0, 9) // combo: both bumpers for rear view look-back while driving
// and a Street Fighter shoryuken on the d-pad to show a sequence:
(4, 1, 21), // DPAD_E: right
(4, 2, 20), // DPAD_S: down
(4, 3, 26), (4, 3, 4) // DPAD_SE + BT_S: down/right + fierce... i think.
(免责声明:我为我工作的游戏工作室创建了一个类似的数据库。不完全相同,但足够相似,以至于我有意遗漏了很多内容。抱歉!希望这足以启动一些想法,这是一个有趣的问题。)