Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .husky/pre-commit
100755 → 100644
Empty file.
47 changes: 47 additions & 0 deletions src/dicta_sonicMic_3_device.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {ButtonEvent, DeviceType, DictationDeviceBase, ImplementationType} from './dictation_device_base';

const BUTTON_MAPPINGS = new Map<ButtonEvent, number>([
[ButtonEvent.REWIND, 1 << 0],
// returns "3" in reality, see getInputBitmask
[ButtonEvent.FORWARD, 1 << 1],
[ButtonEvent.PLAY, 1 << 2],
[ButtonEvent.RECORD, 1 << 8],
[ButtonEvent.INSTR, 1 << 9],
[ButtonEvent.TAB_BACKWARD, 1 << 10],
[ButtonEvent.F2_B, 1 << 11],
[ButtonEvent.TAB_FORWARD, 1 << 12],
[ButtonEvent.F3_C, 1 << 13],
[ButtonEvent.F1_A, 1 << 15],
[ButtonEvent.TRANSCRIBE, 1 << 16],
[ButtonEvent.INS_OVR, 1 << 17],
[ButtonEvent.ENTER_SELECT, 1 << 22],
]);

export class SonicMic3Device extends DictationDeviceBase {
readonly implType = ImplementationType.SONICMIC_3;

static create(hidDevice: HIDDevice) {
return new SonicMic3Device(hidDevice);
}

getDeviceType(): DeviceType {
return DeviceType.SONICMIC_3;
}

protected getButtonMappings(): Map<ButtonEvent, number> {
return BUTTON_MAPPINGS;
}

protected getInputBitmask(data: DataView): number {
const raw = data.getUint32(4, false);
// FORWARD returns value "3", which is "11" in binary.
// This makes it incompatible for single-bit bitmasking
// So we return 2 (10) instead & map this in BUTTON_MAPPINGS
if (raw === 3) return 1 << 1;
return raw;
}

protected getThisAsDictationDevice(): SonicMic3Device {
return this;
}
}
3 changes: 2 additions & 1 deletion src/dictation_device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* limitations under the License.
*/

import {SonicMic3Device} from './dicta_sonicMic_3_device';
import {FootControlDevice} from './foot_control_device';
import {PowerMic3Device} from './powermic_3_device';
import {SpeechMikeGamepadDevice} from './speechmike_gamepad_device';
import {SpeechMikeHidDevice} from './speechmike_hid_device';

export type DictationDevice =|SpeechMikeHidDevice|SpeechMikeGamepadDevice|
PowerMic3Device|FootControlDevice;
PowerMic3Device|FootControlDevice|SonicMic3Device;
2 changes: 2 additions & 0 deletions src/dictation_device_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum ImplementationType {
SPEECHMIKE_GAMEPAD = 1,
FOOT_CONTROL = 2,
POWERMIC_3 = 3,
SONICMIC_3 = 4,
}

export enum DeviceType {
Expand Down Expand Up @@ -49,6 +50,7 @@ export enum DeviceType {
POWERMIC_3 = 4097,
POWERMIC_4 = 100,
SPEECHMIKE_AMBIENT_PSM5000 = 5000,
SONICMIC_3 = 7000,
}

export enum ButtonEvent {
Expand Down
8 changes: 8 additions & 0 deletions src/dictation_device_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

import {SonicMic3Device} from './dicta_sonicMic_3_device';
import {DictationDevice} from './dictation_device';
import {ButtonEventListener, ImplementationType} from './dictation_device_base';
import {FootControlDevice} from './foot_control_device';
Expand Down Expand Up @@ -70,6 +71,11 @@ const DEVICE_FILTERS: Readonly<
Object.freeze(
{vendorId: 0x0554, productId: 0x1001, usagePage: 1, usage: 0}),
]),
[ImplementationType.SONICMIC_3]: Object.freeze([
// SonicMic III
Object.freeze(
{vendorId: 0x15D8, productId: 0x002A, usagePage: 65280, usage: 1}),
]),
});

export class DictationDeviceManager {
Expand Down Expand Up @@ -214,6 +220,8 @@ export class DictationDeviceManager {
return SpeechMikeGamepadDevice.create(hidDevice);
case ImplementationType.FOOT_CONTROL:
return FootControlDevice.create(hidDevice);
case ImplementationType.SONICMIC_3:
return SonicMic3Device.create(hidDevice);
default:
checkExhaustive(implType);
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './foot_control_device';
export * from './powermic_3_device';
export * from './speechmike_gamepad_device';
export * from './speechmike_hid_device';
export * from './dicta_sonicMic_3_device';