-
Notifications
You must be signed in to change notification settings - Fork 271
/
Copy pathfeaturehelper.js
121 lines (118 loc) · 4.7 KB
/
featurehelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { FeatureNone } from './featurenone';
import { FeatureStatic } from './featurestatic';
import { FeatureWaveExtended } from './featurewaveextended';
import { FeatureSpectrum } from './featurespectrum';
import { FeatureReactive } from './featurereactive';
import { FeatureBreathe } from './featurebreathe';
import { FeatureStarlight } from './featurestarlight';
import { FeatureRipple } from './featureripple';
import { FeatureWheel } from './featurewheel';
import { FeatureBrightness } from './featurebrightness';
import { FeatureWaveSimple } from './featurewavesimple';
import { FeatureOldMouseEffects } from './featureoldmouseeffects';
import { FeatureMouseBrightness } from './featuremousebrightness';
import { FeatureMousePollRate } from './featuremousepollrate';
import { FeatureMouseDPI } from './featuremousedpi';
import { RazerDeviceType } from '../device/razerdevicetype';
import { FeatureIdentifier } from './featureidentifier';
import { FeatureBattery } from './featurebattery';
export class FeatureHelper {
static createFeatureFrom(featureConfig) {
const featureIdentifier = Object.keys(featureConfig)[0];
const configuration = featureConfig[featureIdentifier];
switch (featureIdentifier) {
case FeatureIdentifier.NONE: return new FeatureNone(configuration);
case FeatureIdentifier.STATIC: return new FeatureStatic(configuration);
case FeatureIdentifier.WAVE_SIMPLE: return new FeatureWaveSimple(configuration);
case FeatureIdentifier.WAVE_EXTENDED: return new FeatureWaveExtended(configuration);
case FeatureIdentifier.SPECTRUM: return new FeatureSpectrum(configuration);
case FeatureIdentifier.REACTIVE: return new FeatureReactive(configuration);
case FeatureIdentifier.BREATHE: return new FeatureBreathe(configuration);
case FeatureIdentifier.STARLIGHT: return new FeatureStarlight(configuration);
case FeatureIdentifier.BRIGHTNESS: return new FeatureBrightness(configuration);
case FeatureIdentifier.RIPPLE: return new FeatureRipple(configuration);
case FeatureIdentifier.WHEEL: return new FeatureWheel(configuration);
case FeatureIdentifier.OLD_MOUSE_EFFECTS: return new FeatureOldMouseEffects(configuration);
case FeatureIdentifier.MOUSE_BRIGHTNESS: return new FeatureMouseBrightness(configuration);
case FeatureIdentifier.POLL_RATE: return new FeatureMousePollRate(configuration);
case FeatureIdentifier.MOUSE_DPI: return new FeatureMouseDPI(configuration);
case FeatureIdentifier.BATTERY: return new FeatureBattery(configuration);
default:
throw featureIdentifier+' is not a valid feature identifier!'
}
}
static getDefaultFeaturesFor(mainType) {
switch (mainType) {
case RazerDeviceType.KEYBOARD:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureWaveExtended(),
new FeatureSpectrum(),
new FeatureReactive(),
new FeatureBreathe(),
new FeatureStarlight(),
new FeatureRipple(),
new FeatureWheel(),
new FeatureBrightness(),
];
case RazerDeviceType.MOUSE:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureWaveSimple(),
new FeatureSpectrum(),
new FeatureReactive(),
new FeatureBreathe(),
new FeatureOldMouseEffects(),
new FeatureMouseBrightness(),
new FeatureMousePollRate(),
new FeatureMouseDPI(),
new FeatureBattery(),
];
case RazerDeviceType.MOUSEDOCK:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureSpectrum(),
new FeatureBreathe(),
new FeatureBattery(),
];
case RazerDeviceType.MOUSEMAT:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureWaveSimple(),
new FeatureSpectrum(),
new FeatureBreathe(),
new FeatureBrightness()
];
case RazerDeviceType.EGPU:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureWaveSimple(),
new FeatureSpectrum(),
new FeatureBreathe(),
];
case RazerDeviceType.HEADPHONE:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureSpectrum(),
new FeatureBreathe(),
];
case RazerDeviceType.ACCESSORY:
return [
new FeatureNone(),
new FeatureStatic(),
new FeatureWaveExtended(),
new FeatureSpectrum(),
new FeatureBreathe(),
];
default:
console.warn("Unknown mainType "+mainType+". Can't detect feature set.");
return [];
}
}
}