Add keyboard shortcut for enabling the USB stack test mode of the firmware. Resolves #735.
This commit is contained in:
@@ -87,6 +87,15 @@ export class DeviceService {
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(IpcEvents.device.enableUsbStackTest, (...args: any[]) => {
|
||||
this.queueManager.add({
|
||||
method: this.enableUsbStackTest,
|
||||
bind: this,
|
||||
params: args,
|
||||
asynchronous: true
|
||||
});
|
||||
});
|
||||
|
||||
logService.debug('[DeviceService] init success');
|
||||
}
|
||||
|
||||
@@ -224,6 +233,10 @@ export class DeviceService {
|
||||
event.sender.send(IpcEvents.device.updateFirmwareReply, response);
|
||||
}
|
||||
|
||||
public async enableUsbStackTest(event: Electron.Event) {
|
||||
await this.device.enableUsbStackTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* HID API not support device attached and detached event.
|
||||
* This method check the keyboard is attached to the computer or not.
|
||||
|
||||
@@ -30,6 +30,7 @@ export class Device {
|
||||
public static readonly updateFirmwareReply = 'device-update-firmware-reply';
|
||||
public static readonly startConnectionPoller = 'device-start-connection-poller';
|
||||
public static readonly recoveryDevice = 'device-recovery';
|
||||
public static readonly enableUsbStackTest = 'enable-usb-stack-test';
|
||||
}
|
||||
|
||||
export class IpcEvents {
|
||||
|
||||
@@ -23,7 +23,12 @@ export enum UsbCommand {
|
||||
GetDebugBuffer = 0x0b,
|
||||
GetAdcValue = 0x0c,
|
||||
SetLedPwmBrightness = 0x0d,
|
||||
GetModuleProperty = 0x0e
|
||||
GetModuleProperty = 0x0e,
|
||||
GetSlaveI2cErrors = 0x0f,
|
||||
SetI2cBaudRate = 0x10,
|
||||
SwitchKeymap = 0x11,
|
||||
GetVariable = 0x12,
|
||||
SetVariable = 0x13
|
||||
}
|
||||
|
||||
export enum EepromOperation {
|
||||
@@ -86,3 +91,10 @@ export enum KbootCommands {
|
||||
export enum ModulePropertyId {
|
||||
protocolVersions = 0
|
||||
}
|
||||
|
||||
export enum UsbVariables {
|
||||
testSwitches = 0,
|
||||
testUsbStack = 1,
|
||||
debounceTimePress = 2,
|
||||
debounceTimeRelease = 3
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
KbootCommands,
|
||||
ModuleSlotToI2cAddress,
|
||||
ModuleSlotToId,
|
||||
UsbCommand
|
||||
UsbCommand,
|
||||
UsbVariables
|
||||
} from './constants';
|
||||
import { bufferToString, getTransferData, isUhkDevice, retry, snooze } from './util';
|
||||
|
||||
@@ -133,6 +134,11 @@ export class UhkHidDevice {
|
||||
await this.waitUntilKeyboardBusy();
|
||||
}
|
||||
|
||||
public async enableUsbStackTest(): Promise<void> {
|
||||
await this.write(new Buffer([UsbCommand.SetVariable, UsbVariables.testUsbStack, 1]));
|
||||
await this.waitUntilKeyboardBusy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the communication chanel with UHK Device
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Action, Store } from '@ngrx/store';
|
||||
import 'rxjs/add/operator/last';
|
||||
|
||||
import { DoNotUpdateAppAction, UpdateAppAction } from './store/actions/app-update.action';
|
||||
import { EnableUsbStackTestAction } from './store/actions/device';
|
||||
import {
|
||||
AppState,
|
||||
getShowAppUpdateAvailable,
|
||||
@@ -64,6 +65,16 @@ export class MainAppComponent implements OnDestroy {
|
||||
this.clickedOnProgressButton(this.saveToKeyboardState.action);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (event.shiftKey &&
|
||||
event.ctrlKey &&
|
||||
event.altKey &&
|
||||
event.metaKey &&
|
||||
event.key === '|' &&
|
||||
!event.defaultPrevented) {
|
||||
this.enableUsbStackTest();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
updateApp() {
|
||||
@@ -77,4 +88,8 @@ export class MainAppComponent implements OnDestroy {
|
||||
clickedOnProgressButton(action: Action) {
|
||||
return this.store.dispatch(action);
|
||||
}
|
||||
|
||||
enableUsbStackTest() {
|
||||
this.store.dispatch(new EnableUsbStackTestAction());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ export class DeviceRendererService {
|
||||
this.ipcRenderer.send(IpcEvents.device.recoveryDevice);
|
||||
}
|
||||
|
||||
enableUsbStackTest(): void {
|
||||
this.ipcRenderer.send(IpcEvents.device.enableUsbStackTest);
|
||||
}
|
||||
|
||||
private registerEvents(): void {
|
||||
this.ipcRenderer.on(IpcEvents.device.deviceConnectionStateChanged, (event: string, arg: DeviceConnectionState) => {
|
||||
this.dispachStoreAction(new ConnectionStateChangedAction(arg));
|
||||
|
||||
@@ -28,7 +28,8 @@ export const ActionTypes = {
|
||||
HAS_BACKUP_USER_CONFIGURATION: type(PREFIX + 'Store backup user configuration'),
|
||||
RESTORE_CONFIGURATION_FROM_BACKUP: type(PREFIX + 'Restore configuration from backup'),
|
||||
RESTORE_CONFIGURATION_FROM_BACKUP_SUCCESS: type(PREFIX + 'Restore configuration from backup success'),
|
||||
RECOVERY_DEVICE: type(PREFIX + 'Recovery device')
|
||||
RECOVERY_DEVICE: type(PREFIX + 'Recovery device'),
|
||||
ENABLE_USB_STACK_TEST: type(PREFIX + 'USB stack test')
|
||||
};
|
||||
|
||||
export class SetPrivilegeOnLinuxAction implements Action {
|
||||
@@ -144,6 +145,10 @@ export class RecoveryDeviceAction implements Action {
|
||||
type = ActionTypes.RECOVERY_DEVICE;
|
||||
}
|
||||
|
||||
export class EnableUsbStackTestAction implements Action {
|
||||
type = ActionTypes.ENABLE_USB_STACK_TEST;
|
||||
}
|
||||
|
||||
export type Actions
|
||||
= SetPrivilegeOnLinuxAction
|
||||
| SetPrivilegeOnLinuxReplyAction
|
||||
@@ -166,4 +171,5 @@ export type Actions
|
||||
| HasBackupUserConfigurationAction
|
||||
| RestoreUserConfigurationFromBackupSuccessAction
|
||||
| RecoveryDeviceAction
|
||||
| EnableUsbStackTestAction
|
||||
;
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
import {
|
||||
ActionTypes,
|
||||
ConnectionStateChangedAction,
|
||||
EnableUsbStackTestAction,
|
||||
HideSaveToKeyboardButton,
|
||||
RecoveryDeviceAction,
|
||||
ResetUserConfigurationAction,
|
||||
@@ -230,6 +231,10 @@ export class DeviceEffects {
|
||||
.ofType<RecoveryDeviceAction>(ActionTypes.RECOVERY_DEVICE)
|
||||
.do(() => this.deviceRendererService.recoveryDevice());
|
||||
|
||||
@Effect({dispatch: false}) enableUsbStackTest$ = this.actions$
|
||||
.ofType<EnableUsbStackTestAction>(ActionTypes.ENABLE_USB_STACK_TEST)
|
||||
.do(() => this.deviceRendererService.enableUsbStackTest());
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private router: Router,
|
||||
private deviceRendererService: DeviceRendererService,
|
||||
|
||||
Reference in New Issue
Block a user