Skip to content

Latest commit

 

History

History
68 lines (39 loc) · 2.5 KB

Virtual_Key_Quick_Start_EN-US.md

File metadata and controls

68 lines (39 loc) · 2.5 KB

中文文档

Custom Virtual Key

Feature Overview

This document describes how to add virtual keys to your game.

After integrating the SDK, you can load a configuration file to generate custom virtual keys dynamically.

Framework component description

TCRVKey.framework: The virtual key extension library.

API overview

API Description
TCRVKeyGamepad initWithFrame:(CGRect)frame session:(TcrSession *)session; Creates a virtual key view.
TCRVKeyGamepad showKeyGamepad:(NSString *)cfg; Loads the virtual key layout and generates virtual keys.
TCRVKeyGamepad needConnected() Queries whether the current key layout needs to be notified to the cloud.

Sample call

- (void)initControlViews {
    self.gamepad = [[TCRVKeyGamepad alloc] initWithFrame:self.view.bounds session:self.session];
    [self.view addSubview:self.gamepad];
    [self.gamepad showKeyGamepad:[self readJsonFromFile:@"tcg_default_ps4"]];
}

Usage after integration

Supported keys

Three types of keys are supported: mouse and arrow keys, keyboard, and controller.

Mouse and arrow keys

  1. Mouse buttons: Left button, middle button, right button, scroll-up, and scroll-down

  2. Arrow keys: Up, down, left and right/W, A, S, and D Four common keys W, A, S, and D form arrow keys just like a D-pad on a controller. If the up direction is pressed, a message of the W key will be triggered. If a diagonal direction is pressed, its two adjacent keys will be triggered. Messages of the up, down, left, and right arrow keys are triggered in the same way.

Keyboard

  1. 78 commonly used keys on a physical keyboard

Controller

  1. Left and right sticks

  2. D-pad

  3. General pressable buttons: A, B, X, Y, △, ☐, ×, ○, Select, Start, LB, RB, L3, and R3

  4. Triggers: LT and RT (If a trigger is pressed, its message will be sent multiple times in a row instantly, and the message strength decreases gradually over time.)

Configuration file generation

A key layout file generation tool is provided here. The key layout configuration generated by this tool can be used by the SDK.

Note: You only need to save and import the generated configuration file for your game to use it with no need of caring about the content and generation rules in the file.