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
+52 -140
View File
@@ -8,7 +8,6 @@
#include "util/detour.h"
#include "util/logging.h"
#include "util/memutils.h"
#include "misc/vrutil.h"
#pragma pack(push)
@@ -148,15 +147,11 @@ namespace games::drs {
return 1;
}
char DRS_TAPELED[38 * 49][3] {};
bool VR_STARTED = false;
linalg::aliases::float3 VR_SCALE(100, 100, 1.f);
linalg::aliases::float3 VR_OFFSET(0.f, 0.f, -0.1f);
float VR_ROTATION = 0.f;
VRFoot VR_FOOTS[2] {
{1},
{2},
};
char DRS_TAPELED[DRS_TAPELED_COLS_TOTAL][3] {};
bool DISABLE_TOUCH = false;
bool TRANSPOSE_TOUCH = false;
std::vector<TouchEvent> TOUCH_EVENTS;
inline DWORD scale_double_to_xy(double val) {
return static_cast<DWORD>(val * 32768);
@@ -221,138 +216,54 @@ namespace games::drs {
touch_callback(&dev, game_touches.get(), (int) event_count, 0, user_data);
}
uint32_t VRFoot::get_index() {
if (index == ~0u) {
if (id == 1) return vrutil::INDEX_LEFT;
if (id == 2) return vrutil::INDEX_RIGHT;
}
return index;
}
void start_touch() {
std::thread t([] {
log_info("drs", "starting touch input thread");
linalg::aliases::float3 VRFoot::to_world(linalg::aliases::float3 pos) {
pos = linalg::aliases::float3(-pos.z, pos.x, pos.y);
const float deg_to_rad = (float) (1 / 180.f * M_PI);
auto s = sinf(VR_ROTATION * deg_to_rad);
auto c = cosf(VR_ROTATION * deg_to_rad);
pos = linalg::aliases::float3(pos.x * c - pos.y * s,
pos.x * s + pos.y * c,
pos.z);
return pos * VR_SCALE + VR_OFFSET;
}
// main loop
while (TRUE) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
void start_vr() {
if (vrutil::STATUS != vrutil::VRStatus::Running) return;
if (!VR_STARTED) {
VR_STARTED = true;
std::thread t([] {
log_info("drs", "starting VR thread");
// dance floor plane
const linalg::aliases::float3 plane_normal(0, 0, 1);
const linalg::aliases::float3 plane_point(0, 0, 0);
const float touch_width = 1.f;
const float touch_height = 1.f;
// main loop
while (vrutil::STATUS == vrutil::VRStatus::Running) {
// iterate foots
for (auto &foot : VR_FOOTS) {
vr::TrackedDevicePose_t pose;
vr::VRControllerState_t state;
vrutil::get_con_pose(foot.get_index(), &pose, &state);
// only accept valid poses
if (pose.bPoseIsValid) {
auto length = std::max(foot.length, 0.001f);
// get components
auto translation = foot.to_world(vrutil::get_translation(
pose.mDeviceToAbsoluteTracking));
auto direction = -linalg::qzdir(linalg::qmul(
vrutil::get_rotation(pose.mDeviceToAbsoluteTracking.m),
foot.rotation));
direction = linalg::aliases::float3 {
-direction.z, direction.x, direction.y
};
// get intersection point
auto intersection = vrutil::intersect_point(
direction, translation,
plane_normal, plane_point);
auto distance = linalg::distance(
translation, intersection);
// update event details
foot.height = std::max(0.f, translation.z - intersection.z);
foot.event.id = foot.id;
foot.event.x = (intersection.x / 38.f) * touch_width;
foot.event.y = (intersection.y / 49.f) * touch_height;
if (translation.z > intersection.z) {
foot.event.width = foot.size_base
+ foot.size_scale * std::max(0.f, 1.f - distance / length);
} else {
foot.event.width = foot.size_base + foot.size_scale;
}
foot.event.height = foot.event.width;
// check if controller points down
if (direction.z < 0) {
// check if plane in range
if (distance <= length) {
// check previous event
switch (foot.event.type) {
case DRS_UP:
// generate down event
foot.event.type = DRS_DOWN;
break;
case DRS_DOWN:
case DRS_MOVE:
// generate move event
foot.event.type = DRS_MOVE;
break;
default:
break;
}
// send event
drs::fire_touches(&foot.event, 1);
continue;
}
}
// foot not intersecting with plane
switch (foot.event.type) {
case DRS_DOWN:
case DRS_MOVE:
// generate up event
foot.event.type = DRS_UP;
drs::fire_touches(&foot.event, 1);
break;
case DRS_UP:
default:
break;
}
}
TOUCH_EVENTS.clear();
touch_get_events(TOUCH_EVENTS);
for (auto &te : TOUCH_EVENTS) {
drs_touch_t drs_event;
switch (te.type) {
case TOUCH_DOWN:
drs_event.type = DRS_DOWN;
break;
case TOUCH_UP:
drs_event.type = DRS_UP;
break;
case TOUCH_MOVE:
drs_event.type = DRS_MOVE;
break;
}
drs_event.id = te.id;
// slow down
vrutil::scan();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// DRS uses 100x100 (px) as default foot size, so use that
const float w = 100.1/1920.f;
const float h = 100.1/1080.f;
drs_event.width = w;
drs_event.height = h;
const float x = te.x / 1920.f;
const float y = te.y / 1080.f;
// note that only x-y are transposed, not w-h
if (TRANSPOSE_TOUCH) {
drs_event.x = y;
drs_event.y = x;
} else {
drs_event.x = x;
drs_event.y = y;
}
drs::fire_touches(&drs_event, 1);
}
VR_STARTED = false;
return nullptr;
});
t.detach();
}
}
return nullptr;
});
t.detach();
}
DRSGame::DRSGame() : Game("DANCERUSH") {
@@ -397,9 +308,10 @@ namespace games::drs {
detour::iat("?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z",
(void *) &TouchSDK_InitTouch, avs::game::DLL_INSTANCE);
// VR
if (vrutil::STATUS == vrutil::VRStatus::Running) {
start_vr();
if (!DISABLE_TOUCH) {
start_touch();
} else {
log_info("drs", "no native input method detected");
}
}
+13 -19
View File
@@ -2,6 +2,7 @@
#include "games/game.h"
#include "external/linalg.h"
#include "touch/touch.h"
namespace games::drs {
@@ -11,7 +12,7 @@ namespace games::drs {
DRS_MOVE = 2,
};
typedef struct {
typedef struct drs_touch {
int type = DRS_UP;
int id = 0;
double x = 0.0;
@@ -20,27 +21,20 @@ namespace games::drs {
double height = 1;
} drs_touch_t;
struct VRFoot {
uint32_t id;
uint32_t index = ~0u;
float length = 3.1f;
float size_base = 0.05f;
float size_scale = 0.1f;
float height = 3.f;
linalg::aliases::float4 rotation {0, 0, 0, 1};
drs_touch_t event {};
uint32_t get_index();
linalg::aliases::float3 to_world(linalg::aliases::float3 pos);
};
#define DRS_TAPELED_ROWS 49
#define DRS_TAPELED_COLS 38
#define DRS_TAPELED_COLS_TOTAL (DRS_TAPELED_ROWS * DRS_TAPELED_COLS)
extern char DRS_TAPELED[38 * 49][3];
extern linalg::aliases::float3 VR_SCALE;
extern linalg::aliases::float3 VR_OFFSET;
extern float VR_ROTATION;
extern VRFoot VR_FOOTS[2];
// each r,g,b value is stored in a char but 215 is the highest you'll see from the game at 100% brightness in the test menu
#define DRS_TAPELED_MAX_VAL 215
extern char DRS_TAPELED[DRS_TAPELED_COLS_TOTAL][3];
extern std::vector<TouchEvent> TOUCH_EVENTS;
extern bool DISABLE_TOUCH;
extern bool TRANSPOSE_TOUCH;
void fire_touches(drs_touch_t *events, size_t event_count);
void start_vr();
void start_touch();
class DRSGame : public games::Game {
public:
+30 -6
View File
@@ -27,15 +27,39 @@ std::vector<Button> &games::drs::get_buttons() {
return buttons;
}
std::string games::drs::get_buttons_help() {
// keep to max 100 characters wide
return
"Motion camera required for DOWN movement.\n"
"Touchscreen supported for dance floor."
;
}
std::vector<Light> &games::drs::get_lights() {
static std::vector<Light> lights;
//if (lights.empty()) {
//lights = GameAPI::Lights::getLights("DANCERUSH");
//GameAPI::Lights::sortLights(
// &lights,
//);
//}
if (lights.empty()) {
lights = GameAPI::Lights::getLights("DANCERUSH");
GameAPI::Lights::sortLights(
&lights,
"P1 Start",
"P1 Menu Up",
"P1 Menu Down",
"P1 Menu Left",
"P1 Menu Right",
"P2 Start",
"P2 Menu Up",
"P2 Menu Down",
"P2 Menu Left",
"P2 Menu Right",
"Card Reader R",
"Card Reader G",
"Card Reader B",
"Title Panel R",
"Title Panel G",
"Title Panel B"
);
}
return lights;
}
+17
View File
@@ -27,10 +27,27 @@ namespace games::drs {
// all lights in correct order
namespace Lights {
enum {
P1_START,
P1_MENU_UP,
P1_MENU_DOWN,
P1_MENU_LEFT,
P1_MENU_RIGHT,
P2_START,
P2_MENU_UP,
P2_MENU_DOWN,
P2_MENU_LEFT,
P2_MENU_RIGHT,
CARD_READER_R,
CARD_READER_G,
CARD_READER_B,
TITLE_PANEL_R,
TITLE_PANEL_G,
TITLE_PANEL_B,
};
}
// getters
std::vector<Button> &get_buttons();
std::string get_buttons_help();
std::vector<Light> &get_lights();
}