11. Advanced: immutable profile table and state machine
enum {
PROFILE_SOFT,
PROFILE_MEDIUM,
PROFILE_HARD,
PROFILE_COUNT
};
const int16 GAIN_PERCENT[] = { 75, 100, 125 };
int profile;
int raw_x;
int final_x;
main {
if(event_press(PS5_TRIANGLE)) {
profile = profile + 1;
if(profile >= PROFILE_COUNT) profile = PROFILE_SOFT;
}
raw_x = get_ival(PS5_RX);
final_x = (raw_x * GAIN_PERCENT[profile]) / 100;
if(final_x < -100) final_x = -100;
if(final_x > 100) final_x = 100;
set_val(PS5_RX, final_x);
set_val(TRACE_1, profile);
set_val(TRACE_2, GAIN_PERCENT[profile]);
}Previous10. Advanced: restartable timed comboNext12. Expert: indexed BVAR record with round-trip load
Last updated

