Update to spice2x-25-04-25 (pre-apply)

> broken commit
This commit is contained in:
[ ]
2025-05-07 00:25:31 +09:00
parent 04dee88276
commit c94de456b5
543 changed files with 78491 additions and 91698 deletions
+151 -13
View File
@@ -22,6 +22,7 @@ const char *ButtonAnalogTypeStr[] = {
"MIDI Control On/Off",
"MIDI Pitch Down",
"MIDI Pitch Up",
"Any Direction",
};
std::string Button::getVKeyString() {
@@ -267,6 +268,15 @@ std::string Button::getVKeyString() {
}
}
std::string Button::getMidiNoteString() {
static const std::string note_names[] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
int channel;
int index;
this->getMidiVKey(channel, index);
return fmt::format("{}{}", note_names[index % 12], ((index / 12) - 1));
}
std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
// get VKey string
@@ -317,8 +327,16 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
else
return "Invalid button (" + device->desc + ")";
case BAT_NEGATIVE:
case BAT_POSITIVE: {
const char *sign = this->analog_type == BAT_NEGATIVE ? "-" : "+";
case BAT_POSITIVE:
case BAT_ANY: {
const char *sign;
if (this->analog_type == BAT_NEGATIVE) {
sign = "-";
} else if (this->analog_type == BAT_POSITIVE) {
sign = "+";
} else {
sign = "*";
}
if (vKey < hid->value_caps_names.size()) {
return hid->value_caps_names[vKey] + sign + " (" + device->desc + ")";
} else {
@@ -347,23 +365,34 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
return "Unknown analog type (" + device->desc + ")";
}
}
case rawinput::MIDI:
case rawinput::MIDI: {
int channel = 0;
int ctrl = 0;
this->getMidiVKey(channel, ctrl);
switch (this->analog_type) {
case BAT_NONE:
return "MIDI " + vKeyString + " (" + device->desc + ")";
case BAT_MIDI_CTRL_PRECISION:
return "MIDI PREC " + vKeyString + " (" + device->desc + ")";
case BAT_MIDI_CTRL_SINGLE:
return "MIDI CTRL " + vKeyString + " (" + device->desc + ")";
case BAT_MIDI_CTRL_ONOFF:
return "MIDI ONOFF " + vKeyString + " (" + device->desc + ")";
// update strings in analog.cpp as well
case BAT_NONE: {
const auto note = this->getMidiNoteString();
return fmt::format("MIDI Note Ch.{} #{} {} ({})", channel, ctrl, note, device->desc);
}
case BAT_MIDI_CTRL_PRECISION: {
return fmt::format("MIDI Prec Ctrl Ch.{} CC#{} ({})", channel, ctrl, device->desc);
}
case BAT_MIDI_CTRL_SINGLE: {
return fmt::format("MIDI Ctrl Ch.{} CC#{} ({})", channel, ctrl, device->desc);
}
case BAT_MIDI_CTRL_ONOFF: {
return fmt::format("MIDI OnOff Ch.{} CC#{} ({})", channel, ctrl, device->desc);
}
case BAT_MIDI_PITCH_DOWN:
return "MIDI Pitch Down (" + device->desc + ")";
return fmt::format("MIDI Pitch Down Ch.{} ({})", channel, device->desc);
case BAT_MIDI_PITCH_UP:
return "MIDI Pitch Up (" + device->desc + ")";
return fmt::format("MIDI Pitch Up Ch.{} ({})", channel, device->desc);
default:
return "MIDI Unknown " + vKeyString + " (" + device->desc + ")";
}
return "";
}
case rawinput::PIUIO_DEVICE:
return "PIUIO " + vKeyString;
case rawinput::DESTROYED:
@@ -374,6 +403,115 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
}
}
void Button::getMidiVKey(int& channel, int& index) {
switch (this->analog_type) {
// update strings in analog.cpp as well
case BAT_NONE:
channel = (vKey / 0x80) + 1;
index = vKey & 0x7f;
break;
case BAT_MIDI_CTRL_PRECISION:
channel = (vKey / 32) + 1;
index = (vKey % 32);
break;
case BAT_MIDI_CTRL_SINGLE:
channel = (vKey / 44) + 1;
index = (vKey % 44);
if (index <= 25) {
index += 0x46; // single byte range
} else {
index = index - 26 + 0x66; // undefined single byte range
}
break;
case BAT_MIDI_CTRL_ONOFF:
channel = (vKey / 6) + 1;
index = (vKey % 6) + 0x40;
break;
case BAT_MIDI_PITCH_DOWN:
case BAT_MIDI_PITCH_UP:
channel = vKey + 1;
index = 0;
break;
default:
channel = 0;
index = 0;
break;
}
}
void Button::setMidiVKey(rawinput::RawInputManager* manager, bool is_note, int channel, int index) {
int vKey = 0;
if (is_note) {
vKey = (channel - 1) * 0x80 + index;
this->setVKey(vKey);
this->setAnalogType(BAT_NONE);
// ensure that velocity threshold is read back from what rawinput has for other bindings
if (manager && !this->device_identifier.empty()) {
auto device = manager->devices_get(this->device_identifier);
if (device &&
device->midiInfo &&
(size_t)vKey < device->midiInfo->v2_velocity_threshold.size()) {
this->setVelocityThreshold(device->midiInfo->v2_velocity_threshold[vKey]);
}
}
return;
}
if (channel < 1 || 16 < channel) {
this->setVKey(0);
this->setAnalogType(BAT_NONE);
return;
}
if (index < 0 || 127 < index) {
this->setVKey(0);
this->setAnalogType(BAT_NONE);
return;
}
// continuous controller MSB
if (0x00 <= index && index <= 0x1F) {
vKey = (channel - 1) * 32 + index;
this->setVKey(vKey);
this->setAnalogType(BAT_MIDI_CTRL_PRECISION);
return;
}
// continuous controller LSB
if (0x20 <= index && index <= 0x3F) {
vKey = (channel - 1) * 32 + index - 0x20;
this->setVKey(vKey);
this->setAnalogType(BAT_MIDI_CTRL_PRECISION);
return;
}
// on/off controls
if (0x40 <= index && index <= 0x45) {
vKey = (channel - 1) * 6 + (index - 0x40);
this->setVKey(vKey);
this->setAnalogType(BAT_MIDI_CTRL_ONOFF);
return;
}
// single byte controllers
if (0x46 <= index && index <= 0x5F) {
vKey = (channel - 1) * 44;
vKey += index - 0x46; // single byte range
this->setVKey(vKey);
this->setAnalogType(BAT_MIDI_CTRL_SINGLE);
return;
}
// undefined single byte controllers
if (0x66 <= index && index <= 0x77) {
vKey = (channel - 1) * 44;
vKey += index - 0x66 + (0x5F - 0x46 + 1) ; // undefined single byte range
this->setVKey(vKey);
this->setAnalogType(BAT_MIDI_CTRL_SINGLE);
return;
}
}
#define HAT_SWITCH_INCREMENT (1.f / 7)
void Button::getHatSwitchValues(float analog_state, ButtonAnalogType* buffer) {