Compare commits

..

48 Commits

Author SHA1 Message Date
bicarus e4b08064b7 rawinput: fix incorrect usage of HidP_GetUsages when descriptor is not range (#565)
## Link to GitHub Issue or related Pull Request, if one exists
Fixes #563 

## Description of change
When buttons are presented as NotRange and instead an array of single
buttons, we are calling `HidP_GetUsages` expecting at most one result
back, but in reality we need to expect all possible buttons on that
usage page since `HidP_GetUsages` returns all buttons in the usage page
+ link collection which would be the entire array of buttons - see
documentation for `HidP_GetUsages` on MSDN.

## Testing
Tested with my own controller modifying USB descriptors... more
controller testing is needed.
2026-03-05 20:41:47 -08:00
bicarus-dev 1e6b4c16cc asio bit difference message 2026-03-04 03:59:03 -08:00
bicarus-dev d6eb8f7125 fix duplicated text 2026-03-04 02:50:02 -08:00
bicarus dc6850e479 overlay: helper modal dialog for picking option values (#561)
## Link to GitHub Issue or related Pull Request, if one exists

## Description of change
Introduce a new modal dialog for picking out some of the options to
improve UX.

Implemented a few for now:

1. UI for picking ASIO drivers from a list (for -iidxasio, -sdvxasio,
-asioconvert, etc)
2. Button to generate card numbers for -card0 and card1
3. Processor Affinity selector (very similar to what's in Windows Task
Manager, list of checkboxes)
4. file selector (file open dialog for various file path overrides like
log file)
5. folder selector (folder override)

I wrote a selector for COM ports as well but how we use the value was
inconsistent (\\\\.\\COMx vs. COMx) and didn't see a huge point in it so
I didn't check it in.

## Testing
2026-03-02 12:08:20 -08:00
bicarus 2d623e179b audio: simplify ASIO backend conversion (#560)
## Link to GitHub Issue or related Pull Request, if one exists

## Description of change
Deprecate backend conversion options and replace with one unified option
for enabling WASAPI exclusive conversion to ASIO.

The new option takes in a string (ASIO driver name) and when filled out,
it automatically enables the ASIO backend.

This is to avoid confusion that was caused by the previous option - the
fact that it was split into two (one to enable the conversion, another
to optionally pick which ASIO driver to use) and that user needed to
specify an integer as opposed to the driver name.

## Testing
Tested on IIDX33. Old options should continue to work.
2026-03-01 13:06:18 -08:00
bicarus 884d665c1c sdvx, touch: account for 270 degree monitor rotation in wintouchemu (#559)
## Link to GitHub Issue or related Pull Request, if one exists
#558 

## Description of change
Same as #558 but this PR fixes the non-native touch cases (when
wintouchemu is active).

## Testing
Tested 90 and 270 degree rotation, 1080p and 1440p.
2026-02-27 17:17:00 -08:00
bicarus 2842fe7ec6 Update pull_request_template.md 2026-02-27 16:56:03 -08:00
bicarus 954e6022d9 sdvx, touch: hook Windows touch API when main monitor is rotated 270 degrees (portrait flipped) (#558)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Game expects primary monitor to be in 90 deg rotation, and does the
touch calculation accordingly.

If the user does 270 deg rotation ("portrait, flipped") then the game's
touch calculation is flipped upside down. Detect this and provide the
fixed up values in the touch hook.

## Testing
Tested with SDVX in 90 deg, 270 deg rotation, and 1080p, forced 1440p.
2026-02-27 14:22:56 -08:00
Emma 955c50a9f3 api: fix for setting drs touch state (#557)
## Link to GitHub Issue, if one exists
N/A

## Description of change
Changes the array size used for collecting touch inputs from the API to
be dynamic according to the size of the input data, rather than fixed.
This fixes a crash.

## Testing
An API client was made sending touch states, both valid and invalid
(oversized). The valid states are handled identically in the test menu
while the oversized states no longer crash.
2026-02-26 10:47:08 -08:00
bicarus dc82c980b1 iidx: show error message for emulated I/O mismatch in LDJ/TDJ sub overlay (#555)
## Link to GitHub Issue, if one exists
#345 

## Description of change
When DLL is configured to use TDJ I/O but spice is in LDJ mode, show an
error in LED ticker suggesting the user to turn on `-iidxtdj`.

When DLL is configured to use LDJ I/O but spice is in TDJ mode, show an
error in TDJ overaly suggesting the user to fix the DLL.

Fix a small bug that caused a white window to be created when `-w` is
enabled even when `-iidxtdj` is not, but DLL is using TDJ I/O.
2026-02-15 19:49:07 -08:00
bicarus 408ed17521 cfg: turn a handful of parameter parsing errors into fatal (#554)
For parameters that require two values (`width, height` or `x, y`), if
the string fails to parse, turn into runtime failure.
2026-02-13 03:22:20 -08:00
bicarus f4050e9adb graphics: custom resolution for subscreen (#553)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Allow user to specify a custom resolution for the sub monitor, in
addition to the existing refresh rate option

This would allow practically any touch monitor (including ones with
weird resolution / aspect ratio / refresh rate) to be used with
IIDX/SDVX.

## Testing
Tested with various resolution / refresh rate combinations on IIDX /
SDVX.
2026-02-12 17:51:38 -08:00
din badae01357 bt5api fix (#552)
## Description of change
use case: user with two ICCA readers in a daisy chain configuration (as
is wired in og IIDX/DDR) wanted to play DDR using their existing
equipment.

Existing `reader/` implementation is only designed for a single reader
per com port vs two readers on one daisy chained com port. This can be
implemented and improved at a future date.

Due to time constraints `eamio-icca.dll` from btools did support both
wavepass and slotted in a daisy chain configuration, and spice does
support bt5api calls.

However, the implementation was not sufficient to allow use of both
modules correctly, often stalling, not did it allow the ability to eject
the card.

I have cleaned up the implementation such that it matches the btools
`eamiotest` implementation and allows the user to use decimal to eject
the card as desired.

As well as properly staging the requests for state of the two individual
readers, like `eamio-icca` expects.

## Testing
Tested with both wavepass and slotted (ICCA and ICCB) modules and in
combination with released `eamio-icca.dll` binaries from btools 5.49 as
released by their github using `MDX` as a test subject.

Works as expected and allows end users to use real readers (if they have
them) as virtual readers in spice's emulation layer.
2026-02-04 19:34:25 -08:00
bicarus 38d9939eb7 cfg: fix early game detection for Polaris Chord and MFG (#551)
## Link to GitHub Issue, if one exists


## Description of change
Some parts of the UI (e.g., Card tab) rely on early auto detection of
the game, which relies on file hints and not the game code. Two games
(PC and MFG) rely on directory presence and not file presence.
2026-02-04 11:40:07 -08:00
bicarus f5a3caf536 signal: avoid spamming log with hook hit messages (#550)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Some people have weird DLLs that keep calling
`AddVectoredExceptionHandler` which ends up spamming the log.

## Testing
Tested IIDX with error + signaldisable to confirm the warning message
being shown, ran Polaris Chord once to check "hook hit" message.
2026-02-03 20:08:15 -08:00
bicarus 027445afb1 overlay: add context menu for overflow operations (#547)
Remove the green + button, remove the bottom checkbox row, and instead
put extra operations like `Add alternate` and `Bind many` to a context
menu.
2026-01-31 23:57:08 -08:00
bicarus 63a3900b79 overlay: add skip button to bind many (#546) 2026-01-31 20:58:15 -08:00
bicarus f542a78347 overlay: add hover delay to tooltip (#545)
Clean up flags used for tooltip display, which adds a tiny delay by
default.
2026-01-31 15:47:23 -08:00
bicarus 4d32dde83e overlay: remove multiple pages from Buttons/Overlay/Lights tabs, replace with tree layout (#541)
The old pages UI was not intuitive and often led to questions like:

* How do I bind multiple controllers to a single input?? (failure to
discover)
* I have a ghost input that won't go away, how do I fix this? Is this a
bug? (non-intuitive UI - there are too many pages and finding out where
each binding is potentially requires scrolling through 100 pages)
* Potential perf issue - user binds too many by accident, or puts
bindings all the way in page 99, requiring us to walk each element in
the vector, wasting precious CPU cycles during an input poll.

This PR removes the multiple pages, and puts everything on a single
page, showing multiple binds in a tree structure.

It also puts a hard limit on how many alternate bindings can be made (8
for buttons, 16 for lights), though if the user has configured more in
older version they will be respected.
2026-01-31 15:16:19 -08:00
bicarus 927170ce73 api: fix unbounded access in getting analog state (#544)
## Link to GitHub Issue, if one exists
#0

## Description of change
Occasionally we would read a bad "vKey" for an analog axis and end up
accessing invalid memory (beyond the size of a vector) and potentially
crash or read junk values.

## Testing
Fixed based on minidump, this was a rare repro though.
2026-01-30 20:53:13 -08:00
bicarus 875a0f0765 overlay: address small polish issues (#543)
* Make a custom widget for truncated text that shows a tooltip only when
truncated
* Use the above widget more consistently in various places
* Ensure tooltips still show even when the preceding widget is disabled
2026-01-30 19:17:44 -08:00
bicarus 3ad88ef15c overlay: fixes for naive binding (#542)
## Description of change
Three bugs:

* Some keys are IME-dependent. Right Alt can be IME mode switch for
Japanese / Korean, and Right Ctrl is often the Kanji button.
* If you press modifiers like Ctrl during bind-many-naive, it will skip
over a button, because of broken for loop logic that ends up calling
`inc_buttons_many_index` too many times
* trying to cancel out of bind-many-naive with left and right mouse
buttons swap doesn't work

## Testing
Validating various IME. I don't have a keyboard in another language
though..
2026-01-30 13:16:14 -08:00
bicarus 7a6cadb176 overlay: refactor code for lights (#539)
No functional change.
2026-01-29 16:13:56 -08:00
Will 4feca23240 Build scripts: support paths with spaces (#540)
Doing dumb things and building inside a path that contains spaces.
Quoted the relevant bits in the build script (and a couple more
shellcheck brought up that realistically won't ever be an issue, but the
squigglies annoy me.
2026-01-29 16:12:23 -08:00
bicarus 2e52bebd3d overlay: bring back "-" placeholder for unbound io, clean up code (#538) 2026-01-29 11:53:16 -08:00
bicarus aa218d5be7 overlay: fix colors of new extension widgets (#537) 2026-01-29 01:58:43 -08:00
bicarus 94f009991a overlay: simplify various input controls by introducing new custom ImGUI widgets (#536)
## Description of change

* Add a red `x` button to replace `Clear` button in binding tabs
(Buttons/Analog/Lights).
* Add a gray `x` button to replace `Clear` button in options tabs next
to input widgets
* Add helper for truncating text and adding ellipsis (...) to deal with
text overflow in tables.
* Reword some UI text for clarity
2026-01-28 02:17:40 -08:00
bicarus c3b9ce3fdc cfg: fix mouse names out of bounds (#535)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Improper bounds check resulting in crash when binding mouse buttons
beyond Mouse 5.

## Testing
Tested with `Edit` function.
2026-01-26 23:42:12 -08:00
bicarus 1517cf9a7c overlay: refactor UI code for I/O binding tabs (#533)
No functional changes, refactor of code only.
2026-01-26 22:24:14 -08:00
bicarus f0f46296f2 cfg: clean up stale buttons and lights alt bindings on save (#534)
## Link to GitHub Issue, if one exists
n/a

## Description of change
For buttons and lights, it's possible to have multiple alternatives.

When you create alternatives and then clear then, the config files
continue to have stale entries. This is because alternatives are stored
in a vector and elements are never deleted when unbound; they get
written out to the XML on modification.

These stale XML entries live forever, and get loaded on next startup of
spice.

This PR fixes that by deleting stale entries - basically, XML nodes will
be kept only until the last valid node (properly bound button or light),
trimming the trailing invalid entries.

## Testing
Manual testing, validating XML.
2026-01-26 22:12:04 -08:00
bicarus 1d1981fcde rb: prevent window moves and resizes in windowed mode (#532)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Disable all window options that change dimensions or position as they
cause problems with touch overlay in windowed mode. Always On Top is the
only thing that's still possible.

## Testing
2026-01-24 18:49:16 -08:00
bicarus 2f538fe2e4 gitadora: fix order of drums in Buttons tab (#531)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Before this PR, drums were in the order they appear in test menu.

This is really confusing. Change it so that they appear in the order
they do in default drummania layout.

## Testing
validated manually in gw
2026-01-23 10:22:24 -08:00
bicarus-dev 8e01b2e5c8 update gitadora help text 2026-01-23 03:03:18 -08:00
bicarus cd14ca800e graphics: fix window resize not working properly in some games (#530)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Need to filter out system-created windows (such as `CicMarshalWnd`) when
looking up which window to mess with when user interacts with F11 menu.

While I'm here, clean up the hack for gfdm arena model that remembers
the main window.

## Testing
Tested:

DDR
gfdm arena 4 / 1 window modes
iidx (windowed mode, with/without nosub option)
sdvx with sub windows

Need to check:
full screen games
2026-01-22 19:06:31 -08:00
bicarus cb59fe14e9 gitadora: prevent window resize (#529)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Gitadora (pre-Delta) tends to soft lock, have graphical issues (menu bg
render as black), or take a long time (minutes) between scene
transitions when window is resized.
2026-01-22 00:51:12 -08:00
bicarus 9fd9290cd3 gitadora: option for guitar picking algorithm (#528)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Adds an option to pick from four algorithms for guitar picking input.

The default behavior is being switched from legacy (rising edge only,
always 1 frame of input) to SOCD "prefer recent" algorithm. This makes
it slightly easier to navigate the menu with the guitar.

## Testing
Validated gw, gwdelta, and sdvx just in case.
2026-01-21 21:14:28 -08:00
bicarus-dev 1dd99aac74 update error message for module auto detection failure 2026-01-20 18:04:54 -08:00
bicarus 9e376f373e patcher: load auto-enable settings even if dest/spec/rev don't match (#527)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Before this change, if user changes `dest`/`spec`/`rev`, then the "auto
enable patches" settings doesn't get loaded. This is because the patch
manager config file relies on having an exact match of
`model+dest+spec+rev+ext`.

This causes a lot of confusion for:

* people who edit prop files - e.g., to switch between sdvx nemsys/valk
cab modes - and forget to re-enable patches
* people who use batch scripts to change xml files on launch - e.g., for
gitadora, omnimix, etc - even if they checked auto-apply in spicecfg,
when they use the batch script to launch the game, the setting won't be
loaded

This PR solves this by just ignoring the `dest`/`spec`/`rev` fields when
checking if patches should be auto applied on launch. Yes, this may
cause false positive cases, but probably very unlikely, and it's pretty
harmless anyway.

For future consideration: should we fix up gitadora XG disparity (K32 vs
K33 etc)?

## Testing
Manually validated
2026-01-20 04:00:15 -08:00
bicarus d4e51b77d1 overlay: options tab tooltip formatting consistency (#526) 2026-01-20 00:24:40 -08:00
bicarus 61181836b0 nvapi: set refresh rate / framerate settings (#525) 2026-01-20 00:23:14 -08:00
bicarus 4e26c8afa5 drs: rgb camera hook (#524)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Add plug&play hooks for RGB camera in DRS.

## Testing
Seems to work with my crappy Logitech C270

Camera options (brightness etc) seem to work in test menu as well).

Tested by another user with realsense camera + logitech camera, both
cams were detected correctly.
2026-01-19 02:54:01 -08:00
bicarus 7684028f99 io: fix bi2x_hook implementation in various games (#522)
## Link to GitHub Issue, if one exists
similar issue as #499

## Description of change
Fix broken bi2x_hook implementations that did not properly allocate I/O
buffers with correct sizes.

People keep copy-pasting other implementation that allocate 0 bytes of
memory, but we run the risk of memory corruption or/or game crashes if
we keep doing this.

We've seen some mystery crashes with CCJ for example, maybe this will
fix that.

While I'm here, implement SOCD cleaner for Polaris Chord.

## Testing
Tested I/O menu with CCJ, play through tutorial (didn't test matches)
Tested GWDelta (test menu and a few songs in guitar)
Tested PC (played a credit)
Tested QKS (still can't get past the title screen)
2026-01-18 18:06:15 -08:00
bicarus-dev 1d6be8fe4b fix print message 2026-01-17 20:24:18 -08:00
bicarus c70cf40af3 graphics: fix monitor auto-rotate for reflec beat (#521)
## Link to GitHub Issue, if one exists
Fixes #341

## Description of change
fix monitor auto-rotate for reflec beat

## Testing
Tested KBR, LBR, MBR (volzza2), MBR (reflesia)
2026-01-17 19:57:47 -08:00
bicarus 5715d4e605 gitadora: (arena model) override app-config (#520)
## Link to GitHub Issue, if one exists
#477 

## Description of change
Just like the old `sys_code_get_cmdline`, override command line
parameters in `app-config*` so that we can control windowed mode / full
screen.

## Testing
Tested both GF and DM.

Technically both games can boot into the correct mode using `-d -DM` but
we'll try to use the right one just in case.
2026-01-17 17:49:50 -08:00
bicarus 821a705a7d gitadora: (arena model) single window mode + subscreen overlay (#486)
## Link to GitHub Issue, if one exists
#477 

## Description of change
This is a work in progress.

What works:
- [x] subscreen overlay shows the touch screen image (in windowed mode)
- [x] touch works in the overlay
- [x] only the main window is shown, other windows are not launched

What doesn't:
- [ ] game occasionally crashes when entering test menu?
- [ ] full screen mode is not tested at all due to monitor requirements
- [ ] need more polish (various options to control the behavior)
2026-01-17 02:17:33 -08:00
bicarus-dev 86f2a1fd39 remove asio failure message 2026-01-14 10:05:54 -08:00
bicarus-dev 86f218329a fix typo 2026-01-14 01:07:46 -08:00
83 changed files with 4249 additions and 2314 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
> >
> Feel free to remove this section after you have read it. > Feel free to remove this section after you have read it.
## Link to GitHub Issue, if one exists ## Link to GitHub Issue or related Pull Request, if one exists
#0 #0
## Description of change ## Description of change
+4 -2
View File
@@ -170,8 +170,8 @@ else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
# file prefix map for relative working directory # file prefix map for relative working directory
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffile-prefix-map=\"${CMAKE_SOURCE_DIR}=.\"")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffile-prefix-map=\"${CMAKE_SOURCE_DIR}=.\"")
endif() endif()
# release with debug info flags # release with debug info flags
@@ -441,6 +441,7 @@ set(SOURCE_FILES ${SOURCE_FILES}
games/scotto/io.cpp games/scotto/io.cpp
games/drs/drs.cpp games/drs/drs.cpp
games/drs/io.cpp games/drs/io.cpp
games/drs/rgb_cam.cpp
games/we/we.cpp games/we/we.cpp
games/we/io.cpp games/we/io.cpp
games/we/touchpanel.cpp games/we/touchpanel.cpp
@@ -554,6 +555,7 @@ set(SOURCE_FILES ${SOURCE_FILES}
overlay/windows/camera_control.cpp overlay/windows/camera_control.cpp
overlay/windows/card_manager.cpp overlay/windows/card_manager.cpp
overlay/windows/drs_dancefloor.cpp overlay/windows/drs_dancefloor.cpp
overlay/windows/gfdm_sub.cpp
overlay/windows/screen_resize.cpp overlay/windows/screen_resize.cpp
overlay/windows/sdvx_sub.cpp overlay/windows/sdvx_sub.cpp
overlay/windows/config.cpp overlay/windows/config.cpp
+2 -2
View File
@@ -34,7 +34,7 @@ namespace api::modules {
void DRS::touch_set(Request &req, Response &res) { void DRS::touch_set(Request &req, Response &res) {
// get all touch points // get all touch points
games::drs::drs_touch_t touches[16]; auto touches = std::make_unique<games::drs::drs_touch_t[]>(req.params.Size());
size_t i = 0; size_t i = 0;
for (Value &param : req.params.GetArray()) { for (Value &param : req.params.GetArray()) {
@@ -86,6 +86,6 @@ namespace api::modules {
} }
// apply touch points // apply touch points
games::drs::fire_touches(touches, i); games::drs::fire_touches(touches.get(), i);
} }
} }
+24 -1
View File
@@ -5,8 +5,9 @@
#include "build/defs.h" #include "build/defs.h"
#include "easrv/easrv.h" #include "easrv/easrv.h"
#include "easrv/smartea.h" #include "easrv/smartea.h"
#include "games/mfc/mfc.h" #include "games/gitadora/gitadora.h"
#include "hooks/avshook.h" #include "hooks/avshook.h"
#include "hooks/graphics/graphics.h"
#include "util/detour.h" #include "util/detour.h"
#include "util/deferlog.h" #include "util/deferlog.h"
#include "util/fileutils.h" #include "util/fileutils.h"
@@ -528,6 +529,28 @@ namespace avs {
} }
} }
// update -WINDOW in app-config
if (games::gitadora::is_arena_model()) {
avs::core::property_search_remove_safe(app_config, nullptr, "/param/cmdline");
std::string cmdline{};
if (games::gitadora::is_drum()) {
if (GRAPHICS_WINDOWED) {
cmdline = "-d -DM -WINDOW";
} else {
cmdline = "-d -DM";
}
} else {
if (GRAPHICS_WINDOWED) {
cmdline = "-g -GF -WINDOW";
} else {
cmdline = "-g -GF";
}
}
log_info("avs-ea3", "using cmdline: `{}`", cmdline);
avs::core::property_node_create(app_config, nullptr,
avs::core::NODE_TYPE_str, "/param/cmdline", cmdline.c_str());
}
auto app_param = avs::core::property_search_safe(app_config, nullptr, "/param"); auto app_param = avs::core::property_search_safe(app_config, nullptr, "/param");
// call the game init // call the game init
+7 -7
View File
@@ -74,7 +74,7 @@ then
BUILD_TYPE="Debug" BUILD_TYPE="Debug"
BUILDDIR_32=${BUILDDIR_32_DEBUG} BUILDDIR_32=${BUILDDIR_32_DEBUG}
BUILDDIR_64=${BUILDDIR_64_DEBUG} BUILDDIR_64=${BUILDDIR_64_DEBUG}
DIST_NAME=$(echo ${DIST_NAME} | sed 's/\.[^.]*$/-dbg&/') DIST_NAME=$(echo "${DIST_NAME}" | sed 's/\.[^.]*$/-dbg&/')
fi fi
# determine number of cores # determine number of cores
@@ -114,7 +114,7 @@ time (
fi fi
mkdir -p ${BUILDDIR_32} mkdir -p ${BUILDDIR_32}
pushd ${BUILDDIR_32} > /dev/null pushd ${BUILDDIR_32} > /dev/null
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_32} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} $OLDPWD && ninja ${TARGETS_32} cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_32} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} "$OLDPWD" && ninja ${TARGETS_32}
popd > /dev/null popd > /dev/null
# 64 bit # 64 bit
@@ -127,7 +127,7 @@ time (
fi fi
mkdir -p ${BUILDDIR_64} mkdir -p ${BUILDDIR_64}
pushd ${BUILDDIR_64} > /dev/null pushd ${BUILDDIR_64} > /dev/null
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_64} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} $OLDPWD && ninja ${TARGETS_64} cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_64} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} "$OLDPWD" && ninja ${TARGETS_64}
popd > /dev/null popd > /dev/null
echo "" echo ""
@@ -234,7 +234,7 @@ mkdir -p ${OUTDIR}/src
if ((INCLUDE_SRC > 0)) if ((INCLUDE_SRC > 0))
then then
echo "Generating source file archive..." echo "Generating source file archive..."
git archive --format tar.gz --prefix=spice2x/ HEAD ./ > ${OUTDIR}/src/spice2x-${GIT_BRANCH}.tar.gz 2>/dev/null || \ git archive --format tar.gz --prefix=spice2x/ HEAD ./ > "${OUTDIR}/src/spice2x-${GIT_BRANCH}.tar.gz" 2>/dev/null || \
echo "WARNING: Couldn't get git to create the archive. Is this a git repository?" echo "WARNING: Couldn't get git to create the archive. Is this a git repository?"
fi fi
@@ -249,11 +249,11 @@ if ((DIST_ENABLE > 0))
then then
echo "Building dist..." echo "Building dist..."
mkdir -p ${DIST_FOLDER} mkdir -p ${DIST_FOLDER}
rm -rf ${DIST_FOLDER}/${DIST_NAME} rm -rf "${DIST_FOLDER}/${DIST_NAME}"
pushd ${OUTDIR}/.. > /dev/null pushd ${OUTDIR}/.. > /dev/null
zip -qrXT9 $OLDPWD/${DIST_FOLDER}/${DIST_NAME} spice2x -x "spice2x/extras/*" -z <<< "$DIST_COMMENT" zip -qrXT9 "$OLDPWD/${DIST_FOLDER}/${DIST_NAME}" spice2x -x "spice2x/extras/*" -z <<< "$DIST_COMMENT"
echo "Building extras..." echo "Building extras..."
zip -qrXT9 $OLDPWD/${DIST_FOLDER}/${DIST_NAME_EXTRAS} spice2x -z <<< "$DIST_COMMENT" zip -qrXT9 "$OLDPWD/${DIST_FOLDER}/${DIST_NAME_EXTRAS}" spice2x -z <<< "$DIST_COMMENT"
popd > /dev/null popd > /dev/null
fi fi
+3 -3
View File
@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
docker build --pull $PWD/external/docker -t spicetools/deps --platform linux/x86_64 docker build --pull "$PWD/external/docker" -t spicetools/deps --platform linux/x86_64
docker build --build-context gitroot=$PWD/../../.git . -t spicetools/spice:latest docker build --build-context gitroot="$PWD/../../.git" . -t spicetools/spice:latest
docker run --rm -v $PWD/dist:/src/src/spice2x/dist -v $PWD/bin:/src/src/spice2x/bin -v $PWD/.ccache:/src/src/spice2x/.ccache spicetools/spice "$@" docker run --rm -v "$PWD/dist:/src/src/spice2x/dist" -v "$PWD/bin:/src/src/spice2x/bin" -v "$PWD/.ccache:/src/src/spice2x/.ccache" spicetools/spice "$@"
+2
View File
@@ -644,11 +644,13 @@ float GameAPI::Analogs::getState(rawinput::Device *device, Analog &analog) {
case rawinput::HID: { case rawinput::HID: {
// get value // get value
if (index < device->hidInfo->value_states.size()) {
if (inverted) { if (inverted) {
value = 1.f - device->hidInfo->value_states[index]; value = 1.f - device->hidInfo->value_states[index];
} else { } else {
value = device->hidInfo->value_states[index]; value = device->hidInfo->value_states[index];
} }
}
// deadzone // deadzone
if (analog.isDeadzoneSet()) { if (analog.isDeadzoneSet()) {
+24 -4
View File
@@ -58,8 +58,28 @@ std::string Button::getVKeyString() {
return "Pause"; return "Pause";
case 0x14: case 0x14:
return "Caps Lock"; return "Caps Lock";
case 0x15:
return "IME Kana/Hangul";
case 0x16:
return "IME On";
case 0x17:
return "IME Junja";
case 0x18:
return "IME Final";
case 0x19:
return "IME Hanja/Kanji";
case 0x1A:
return "IME Off";
case 0x1B: case 0x1B:
return "Escape"; return "Escape";
case 0x1C:
return "IME Convert";
case 0x1D:
return "IME Nonconvert";
case 0x1E:
return "IME Accept";
case 0x1F:
return "IME Mode Change";
case 0x20: case 0x20:
return "Space"; return "Space";
case 0x21: case 0x21:
@@ -255,9 +275,9 @@ std::string Button::getVKeyString() {
case 0xA3: case 0xA3:
return "Right Control"; return "Right Control";
case 0xA4: case 0xA4:
return "Left Menu"; return "Left Alt";
case 0xA5: case 0xA5:
return "Right Menu"; return "Right Alt";
default: default:
// check win API // check win API
@@ -301,7 +321,7 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
switch (device->type) { switch (device->type) {
case rawinput::MOUSE: { case rawinput::MOUSE: {
const char *btn = "Unknown"; const char *btn = "Unknown";
static const char *MOUSE_NAMES[] = { static const std::array<const char *, 8>MOUSE_NAMES = {
"Left Mouse", "Left Mouse",
"Right Mouse", "Right Mouse",
"Middle Mouse", "Middle Mouse",
@@ -311,7 +331,7 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
"Mouse 4", "Mouse 4",
"Mouse 5", "Mouse 5",
}; };
if (vKey < sizeof(MOUSE_NAMES)) { if (vKey < MOUSE_NAMES.size()) {
btn = MOUSE_NAMES[vKey]; btn = MOUSE_NAMES[vKey];
} }
return fmt::format("{} ({})", btn, device->desc); return fmt::format("{} ({})", btn, device->desc);
+23
View File
@@ -45,6 +45,7 @@ private:
double debounce_up = 0.0; double debounce_up = 0.0;
double debounce_down = 0.0; double debounce_down = 0.0;
bool invert = false; bool invert = false;
bool is_temporary = false;
GameAPI::Buttons::State last_state = GameAPI::Buttons::BUTTON_NOT_PRESSED; GameAPI::Buttons::State last_state = GameAPI::Buttons::BUTTON_NOT_PRESSED;
float last_velocity = 0.f; float last_velocity = 0.f;
@@ -164,6 +165,14 @@ public:
this->last_velocity = last_velocity; this->last_velocity = last_velocity;
} }
inline bool isTemporary() const {
return this->is_temporary;
}
inline void setTemporary(bool is_temporary) {
this->is_temporary = is_temporary;
}
inline unsigned short getVelocityThreshold() const { inline unsigned short getVelocityThreshold() const {
return this->velocity_threshold; return this->velocity_threshold;
} }
@@ -172,6 +181,20 @@ public:
this->velocity_threshold = velocity_threshold; this->velocity_threshold = velocity_threshold;
} }
inline bool isValid() {
// temporarily created by UI
if (isTemporary()) {
return true;
}
// nothing is set
if (getDeviceIdentifier().empty() && getVKey() == INVALID_VKEY) {
return false;
}
return true;
}
void getMidiVKey(int& channel, int& index); void getMidiVKey(int& channel, int& index);
void setMidiVKey(rawinput::RawInputManager* manager, bool is_note, int channel, int index); void setMidiVKey(rawinput::RawInputManager* manager, bool is_note, int channel, int index);
+76 -1
View File
@@ -1,5 +1,6 @@
#include "config.h" #include "config.h"
#include "util/logging.h" #include "util/logging.h"
#include "cfg/button.h"
/* /*
* This code absolutely sucks. * This code absolutely sucks.
@@ -10,6 +11,14 @@
// settings // settings
std::string CONFIG_PATH_OVERRIDE = ""; std::string CONFIG_PATH_OVERRIDE = "";
#define CFG_DEBUG_VERBOSE 0
#if CFG_DEBUG_VERBOSE
#define log_debug(module, format_str, ...) logger::push( \
LOG_FORMAT("M", module, format_str, ## __VA_ARGS__), logger::Style::GREY)
#else
#define log_debug(module, format_str, ...)
#endif
/////////////////// ///////////////////
/// Constructor /// /// Constructor ///
@@ -510,8 +519,10 @@ bool Config::updateBinding(const Game &game, const Button &button, int alternati
return false; return false;
} }
tinyxml2::XMLElement *gameButtonNode = nullptr;
// iterate button nodes // iterate button nodes
tinyxml2::XMLElement *gameButtonNode = gameButtonsNode->FirstChildElement("button"); gameButtonNode = gameButtonsNode->FirstChildElement("button");
int button_count = 0; int button_count = 0;
while (gameButtonNode != nullptr) { while (gameButtonNode != nullptr) {
const char *buttonNodeName = gameButtonNode->Attribute("name"); const char *buttonNodeName = gameButtonNode->Attribute("name");
@@ -574,6 +585,39 @@ bool Config::updateBinding(const Game &game, const Button &button, int alternati
} }
} }
// trim the trailing invalid (unbound) alternatives
tinyxml2::XMLElement *to_delete = nullptr;
gameButtonNode = gameButtonsNode->LastChildElement("button");
while (gameButtonNode != nullptr) {
const char *name = gameButtonNode->Attribute("name");
const char *devid = gameButtonNode->Attribute("devid");
int vkey = INVALID_VKEY;
gameButtonNode->QueryIntAttribute("vkey", &vkey);
// wrong button, ignore and keep iterating backwards
if (name == nullptr || std::string(name) != button.getName()) {
gameButtonNode = gameButtonNode->PreviousSiblingElement("button");
continue;
}
// found a node for this button, which means to_delete is not the first one
// delete the node for to_delete
if (to_delete != nullptr) {
log_debug("cfg", "deleting excessive button binding for {}", name);
gameButtonsNode->DeleteChild(to_delete);
to_delete = nullptr;
}
if ((devid == nullptr || strlen(devid) == 0) && vkey == INVALID_VKEY) {
// unbound button with no device ID, make a note of it so it can be deleted later
to_delete = gameButtonNode;
gameButtonNode = gameButtonNode->PreviousSiblingElement("button");
} else {
// valid binding found; stop iterating
break;
}
}
// check if button was not found // check if button was not found
if (button_count == 0) { if (button_count == 0) {
return false; return false;
@@ -760,6 +804,37 @@ bool Config::updateBinding(const Game &game, const Light &light, int alternative
} }
} }
// trim the trailing invalid (unbound) alternatives
tinyxml2::XMLElement *to_delete = nullptr;
gameLightNode = gameLightsNode->LastChildElement("light");
while (gameLightNode != nullptr) {
const char *name = gameLightNode->Attribute("name");
const char *devid = gameLightNode->Attribute("devid");
// wrong light, ignore and keep iterating backwards
if (name == nullptr || std::string(name) != light.getName()) {
gameLightNode = gameLightNode->PreviousSiblingElement("light");
continue;
}
// found a node for this button, which means to_delete is not the first one
// delete the node for to_delete
if (to_delete != nullptr) {
log_debug("cfg", "deleting excessive light binding for {}", name);
gameLightsNode->DeleteChild(to_delete);
to_delete = nullptr;
}
if (devid == nullptr || strlen(devid) == 0) {
// unbound light, make a note of it so it can be deleted later
to_delete = gameLightNode;
gameLightNode = gameLightNode->PreviousSiblingElement("light");
} else {
// valid binding found; stop iterating
break;
}
}
// check if light was not found // check if light was not found
if (light_count == 0) { if (light_count == 0) {
return false; return false;
+23
View File
@@ -13,6 +13,7 @@ private:
std::string lightName; std::string lightName;
std::string deviceIdentifier = ""; std::string deviceIdentifier = "";
unsigned int index = 0; unsigned int index = 0;
bool is_temporary = false;
public: public:
float last_state = 0.f; float last_state = 0.f;
@@ -65,4 +66,26 @@ public:
inline void setIndex(unsigned int index) { inline void setIndex(unsigned int index) {
this->index = index; this->index = index;
} }
inline bool isTemporary() const {
return this->is_temporary;
}
inline void setTemporary(bool is_temporary) {
this->is_temporary = is_temporary;
}
inline bool isValid() {
// temporarily created by UI
if (isTemporary()) {
return true;
}
// nothing is set
if (getDeviceIdentifier().empty()) {
return false;
}
return true;
}
}; };
+13
View File
@@ -13,6 +13,15 @@ enum class OptionType {
Hex, Hex,
}; };
enum class OptionPickerType {
None,
AsioDriver,
EACard,
CpuAffinity,
FilePath,
DirectoryPath,
};
struct OptionDefinition { struct OptionDefinition {
std::string title; std::string title;
// unique identifier used for flag matching but also stored in config files // unique identifier used for flag matching but also stored in config files
@@ -32,6 +41,10 @@ struct OptionDefinition {
bool sensitive = false; bool sensitive = false;
std::vector<std::pair<std::string, std::string>> elements = {}; std::vector<std::pair<std::string, std::string>> elements = {};
bool disabled = false; bool disabled = false;
OptionPickerType picker = OptionPickerType::None;
// for OptionPickerType::FilePath
std::string file_extension = "";
}; };
class Option { class Option {
+14
View File
@@ -1,5 +1,7 @@
#include "bi2x_hook.h" #include "bi2x_hook.h"
#if SPICE64
#include <cstdint> #include <cstdint>
#include "util/detour.h" #include "util/detour.h"
#include "util/logging.h" #include "util/logging.h"
@@ -16,15 +18,19 @@ namespace games::ccj {
*/ */
struct AIO_SCI_COMM { struct AIO_SCI_COMM {
uint8_t data[0xf8];
}; };
struct AIO_NMGR_IOB2 { struct AIO_NMGR_IOB2 {
uint8_t data[0xe30];
}; };
struct AIO_IOB2_BI2X_TBS { struct AIO_IOB2_BI2X_TBS {
uint8_t data[0x4680];
}; };
struct AIO_IOB2_BI2X_WRFIRM { struct AIO_IOB2_BI2X_WRFIRM {
uint8_t data[0x20f48];
}; };
struct AIO_NMGR_IOB__NODEINFO { struct AIO_NMGR_IOB__NODEINFO {
@@ -72,6 +78,12 @@ namespace games::ccj {
AIO_IOB2_BI2X_AC1__OUTPUTDATA OutputData; AIO_IOB2_BI2X_AC1__OUTPUTDATA OutputData;
}; };
// checked with UJK-001-2024060400
static_assert(sizeof(AIO_SCI_COMM) == 0xf8);
static_assert(sizeof(AIO_NMGR_IOB2) == 0xe30);
static_assert(sizeof(AIO_IOB2_BI2X_TBS) == 0x4680);
static_assert(sizeof(AIO_IOB2_BI2X_WRFIRM) == 0x20f48);
static void write_iccr_led(Lights::ccj_lights_t light, uint8_t value); static void write_iccr_led(Lights::ccj_lights_t light, uint8_t value);
/* /*
@@ -622,3 +634,5 @@ namespace games::ccj {
aioNodeCtl_IsError, &aioNodeCtl_IsError_orig); aioNodeCtl_IsError, &aioNodeCtl_IsError_orig);
} }
} }
#endif
+4
View File
@@ -1,5 +1,9 @@
#pragma once #pragma once
#if SPICE64
namespace games::ccj { namespace games::ccj {
void bi2x_hook_init(); void bi2x_hook_init();
} }
#endif
+4
View File
@@ -68,9 +68,13 @@ namespace games::ccj {
detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(11), detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(11),
(void*)execexe_CreateFileW_hook,(void**)&execexe_CreateFileW_orig); (void*)execexe_CreateFileW_hook,(void**)&execexe_CreateFileW_orig);
#if SPICE64
// insert BI2X hooks // insert BI2X hooks
bi2x_hook_init(); bi2x_hook_init();
#endif
// insert trackball hooks // insert trackball hooks
trackball_hook_init(); trackball_hook_init();
+6
View File
@@ -8,6 +8,7 @@
#include "util/detour.h" #include "util/detour.h"
#include "util/logging.h" #include "util/logging.h"
#include "util/memutils.h" #include "util/memutils.h"
#include "rgb_cam.h"
#pragma pack(push) #pragma pack(push)
@@ -150,6 +151,7 @@ namespace games::drs {
char DRS_TAPELED[DRS_TAPELED_COLS_TOTAL][3] {}; char DRS_TAPELED[DRS_TAPELED_COLS_TOTAL][3] {};
bool DISABLE_TOUCH = false; bool DISABLE_TOUCH = false;
bool TRANSPOSE_TOUCH = false; bool TRANSPOSE_TOUCH = false;
bool RGB_CAMERA_HOOK = false;
std::vector<TouchEvent> TOUCH_EVENTS; std::vector<TouchEvent> TOUCH_EVENTS;
@@ -313,6 +315,10 @@ namespace games::drs {
} else { } else {
log_info("drs", "no native input method detected"); log_info("drs", "no native input method detected");
} }
if (RGB_CAMERA_HOOK) {
init_rgb_camera_hook();
}
} }
void DRSGame::detach() { void DRSGame::detach() {
+1
View File
@@ -31,6 +31,7 @@ namespace games::drs {
extern std::vector<TouchEvent> TOUCH_EVENTS; extern std::vector<TouchEvent> TOUCH_EVENTS;
extern bool DISABLE_TOUCH; extern bool DISABLE_TOUCH;
extern bool TRANSPOSE_TOUCH; extern bool TRANSPOSE_TOUCH;
extern bool RGB_CAMERA_HOOK;
void fire_touches(drs_touch_t *events, size_t event_count); void fire_touches(drs_touch_t *events, size_t event_count);
void start_touch(); void start_touch();
+170
View File
@@ -0,0 +1,170 @@
#include "games/drs/rgb_cam.h"
// set version to Windows 7 to enable Media Foundation functions
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0601
// turn on C-style COM objects
#define CINTERFACE
#include <mfobjects.h>
#include <mfidl.h>
#include <string>
#include "avs/game.h"
#include "cfg/configurator.h"
#include "hooks/cfgmgr32hook.h"
#include "util/detour.h"
#include "util/memutils.h"
#include "util/logging.h"
#include "util/utils.h"
static VTBL_TYPE(IMFActivate, GetAllocatedString) GetAllocatedString_orig = nullptr;
static decltype(MFEnumDeviceSources) *MFEnumDeviceSources_orig = nullptr;
namespace games::drs {
/*
* Camera related stuff
*/
static std::wstring CAMERA0_ID;
static HRESULT WINAPI GetAllocatedString_hook(IMFActivate* This, REFGUID guidKey, LPWSTR *ppwszValue,
UINT32 *pcchLength)
{
// call the original
HRESULT result = GetAllocatedString_orig(This, guidKey, ppwszValue, pcchLength);
// log the cam name
log_misc("drs::rgbcam", "obtained {}", ws2s(*ppwszValue));
// try first camera
wchar_t *pwc = nullptr;
if (CAMERA0_ID.length() == 23) {
pwc = wcsstr(*ppwszValue, CAMERA0_ID.c_str());
}
// check if camera could be identified
if (pwc) {
// fake the USB IDs
pwc[4] = L'2';
pwc[5] = L'8';
pwc[6] = L'8';
pwc[7] = L'c';
pwc[13] = L'0';
pwc[14] = L'0';
pwc[15] = L'0';
pwc[16] = L'2';
pwc[21] = L'0';
pwc[22] = L'0';
log_misc("drs::rgbcam", "replaced {}", ws2s(*ppwszValue));
}
// return original result
return result;
}
static void hook_camera(std::wstring camera_id, std::string camera_instance) {
// don't hook if camera 0 is already hooked
if (CAMERA0_ID.length() > 0) {
return;
}
// save the camera ID
CAMERA0_ID = camera_id;
// cfgmgr hook
CFGMGR32_HOOK_SETTING camera_setting;
camera_setting.device_instance = 0xDEADBEEF;
camera_setting.parent_instance = ~camera_setting.device_instance;
camera_setting.device_id = "USB\\VEN_8086&DEV_8C2D";
camera_setting.device_node_id = "USB\\VID_288C&PID_0002&MI_00\\?&????????&?&????";
if (camera_instance.length() == 17) {
for (int i = 0; i < 17; i++) {
camera_setting.device_node_id[28 + i] = camera_instance[i];
}
}
cfgmgr32hook_add(camera_setting);
log_info("drs::rgbcam", "hooked camera @ {}", ws2s(camera_id));
}
static void hook_camera_vtable(IMFActivate *camera) {
// hook allocated string method for camera identification
memutils::VProtectGuard camera_guard(camera->lpVtbl);
camera->lpVtbl->GetAllocatedString = GetAllocatedString_hook;
}
static HRESULT WINAPI MFEnumDeviceSources_hook(IMFAttributes *pAttributes, IMFActivate ***pppSourceActivate,
UINT32 *pcSourceActivate) {
// call original function
HRESULT result_orig = MFEnumDeviceSources_orig(pAttributes, pppSourceActivate, pcSourceActivate);
// check for capture devices
if (FAILED(result_orig) || !*pcSourceActivate) {
return result_orig;
}
// get camera
IMFActivate *camera = **pppSourceActivate;
// save original method for later use
if (GetAllocatedString_orig == nullptr) {
GetAllocatedString_orig = camera->lpVtbl->GetAllocatedString;
}
// hook allocated string method for camera identification
hook_camera_vtable(camera);
// get camera link
LPWSTR camera_link_lpwstr;
UINT32 camera_link_length;
if (SUCCEEDED(GetAllocatedString_orig(
camera,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
&camera_link_lpwstr,
&camera_link_length))) {
// cut name to make ID
std::wstring camera_link_ws = std::wstring(camera_link_lpwstr);
std::wstring camera_id = camera_link_ws.substr(8, 23);
log_info("drs::rgbcam", "found video capture device: {}", ws2s(camera_link_ws));
// only support cameras that start with \\?\usb
if (!string_begins_with(camera_link_ws, L"\\\\?\\usb")) {
return result_orig;
}
// get camera instance
std::string camera_link = ws2s(camera_link_ws);
std::string camera_instance = camera_link.substr(32, 17);
// hook the camera
hook_camera(camera_id, camera_instance);
} else {
log_warning("drs::rgbcam", "failed to open camera");
}
// return result
return result_orig;
}
void init_rgb_camera_hook() {
log_info("drs::rgbcam", "initializing camera hook");
cfgmgr32hook_init(avs::game::DLL_INSTANCE);
// camera media framework hook
MFEnumDeviceSources_orig = detour::iat_try(
"MFEnumDeviceSources", MFEnumDeviceSources_hook, avs::game::DLL_INSTANCE);
}
}
+5
View File
@@ -0,0 +1,5 @@
#pragma once
namespace games::drs {
void init_rgb_camera_hook();
}
+18
View File
@@ -1,5 +1,7 @@
#include "bi2x_hook.h" #include "bi2x_hook.h"
#if SPICE64
#include <optional> #include <optional>
#include <cstdint> #include <cstdint>
#include "util/detour.h" #include "util/detour.h"
@@ -18,24 +20,29 @@ namespace games::gitadora {
// */ // */
struct AIO_NMGR_IOB2 { struct AIO_NMGR_IOB2 {
uint8_t data[0xe18];
}; };
struct AIO_IOB2_BI2X_AC1__SETTING { struct AIO_IOB2_BI2X_AC1__SETTING {
}; };
struct AIO_NMGR_IOB5 { struct AIO_NMGR_IOB5 {
uint8_t data[0xb10];
}; };
struct AIO_SCI_COMM { struct AIO_SCI_COMM {
uint8_t data[0x100];
}; };
struct AIO_IOB5_Y32D { struct AIO_IOB5_Y32D {
uint8_t data[0x2e8];
}; };
// struct AIO_IOB5_Y33I { // struct AIO_IOB5_Y33I {
// }; // };
struct AIO_IOB2_BI2X_AC1 { struct AIO_IOB2_BI2X_AC1 {
uint8_t data[0x4570];
}; };
struct AIO_NMGR_IOB__NODEINFO { struct AIO_NMGR_IOB__NODEINFO {
@@ -43,6 +50,7 @@ namespace games::gitadora {
}; };
struct AIO_IOB2_BI2X_WRFIRM { struct AIO_IOB2_BI2X_WRFIRM {
uint8_t data[0x20f48];
}; };
struct AIO_SCI_COMM_T { struct AIO_SCI_COMM_T {
@@ -159,6 +167,14 @@ namespace games::gitadora {
uint8_t unk[0xB1]; uint8_t unk[0xB1];
}; };
// verified with M32-007-2025092400
static_assert(sizeof(AIO_NMGR_IOB2) == 0xe18);
static_assert(sizeof(AIO_NMGR_IOB5) == 0xb10);
static_assert(sizeof(AIO_SCI_COMM) == 0x100);
static_assert(sizeof(AIO_IOB5_Y32D) == 0x2e8);
static_assert(sizeof(AIO_IOB2_BI2X_AC1) == 0x4570);
static_assert(sizeof(AIO_IOB2_BI2X_WRFIRM) == 0x20f48);
/* /*
* typedefs * typedefs
*/ */
@@ -702,3 +718,5 @@ namespace games::gitadora {
aioNodeCtl_UpdateDevicesStatus, &aioNodeCtl_UpdateDevicesStatus_orig); aioNodeCtl_UpdateDevicesStatus, &aioNodeCtl_UpdateDevicesStatus_orig);
} }
} }
#endif
+4
View File
@@ -1,5 +1,9 @@
#pragma once #pragma once
#if SPICE64
namespace games::gitadora { namespace games::gitadora {
void bi2x_hook_init(); void bi2x_hook_init();
} }
#endif
+18
View File
@@ -5,6 +5,7 @@
#include "cfg/configurator.h" #include "cfg/configurator.h"
#include "hooks/audio/mme.h" #include "hooks/audio/mme.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "misc/wintouchemu.h"
#include "overlay/overlay.h" #include "overlay/overlay.h"
#include "util/cpuutils.h" #include "util/cpuutils.h"
#include "util/detour.h" #include "util/detour.h"
@@ -19,8 +20,11 @@ namespace games::gitadora {
// settings // settings
bool TWOCHANNEL = false; bool TWOCHANNEL = false;
std::optional<unsigned int> CAB_TYPE = std::nullopt; std::optional<unsigned int> CAB_TYPE = std::nullopt;
bool ARENA_SINGLE_WINDOW = false;
bool P1_LEFTY = false; bool P1_LEFTY = false;
bool P2_LEFTY = false; bool P2_LEFTY = false;
std::optional<std::string> SUBSCREEN_OVERLAY_SIZE;
std::optional<socd::SocdAlgorithm> PICK_ALGO = socd::SocdAlgorithm::PreferRecent;
/* /*
* Prevent GitaDora from creating folders on F drive * Prevent GitaDora from creating folders on F drive
@@ -226,6 +230,13 @@ namespace games::gitadora {
// for guitar wail SOCD cleaning // for guitar wail SOCD cleaning
socd::ALGORITHM = socd::SocdAlgorithm::PreferRecent; socd::ALGORITHM = socd::SocdAlgorithm::PreferRecent;
// for guitar picking
if (PICK_ALGO.has_value()) {
log_info("gitadora", "guitar pick SOCD algorithm: {}", static_cast<int>(PICK_ALGO.value()));
} else {
log_info("gitadora", "guitar pick SOCD algorithm: legacy");
}
} }
} }
@@ -285,6 +296,13 @@ namespace games::gitadora {
// volume change prevention // volume change prevention
hooks::audio::mme::init(avs::game::DLL_INSTANCE); hooks::audio::mme::init(avs::game::DLL_INSTANCE);
// touch hook
if (ARENA_SINGLE_WINDOW) {
wintouchemu::FORCE = true;
wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true;
wintouchemu::hook("GITADORA", avs::game::DLL_INSTANCE);
}
return; return;
} }
+4
View File
@@ -4,14 +4,18 @@
#include "avs/game.h" #include "avs/game.h"
#include "games/game.h" #include "games/game.h"
#include "util/socd_cleaner.h"
namespace games::gitadora { namespace games::gitadora {
// settings // settings
extern bool TWOCHANNEL; extern bool TWOCHANNEL;
extern std::optional<unsigned int> CAB_TYPE; extern std::optional<unsigned int> CAB_TYPE;
extern bool ARENA_SINGLE_WINDOW;
extern bool P1_LEFTY; extern bool P1_LEFTY;
extern bool P2_LEFTY; extern bool P2_LEFTY;
extern std::optional<std::string> SUBSCREEN_OVERLAY_SIZE;
extern std::optional<socd::SocdAlgorithm> PICK_ALGO;
class GitaDoraGame : public games::Game { class GitaDoraGame : public games::Game {
public: public:
+14 -15
View File
@@ -65,17 +65,18 @@ std::vector<Button> &games::gitadora::get_buttons() {
"Drum Help", "Drum Help",
"Drum Button Extra 1", "Drum Button Extra 1",
"Drum Button Extra 2", "Drum Button Extra 2",
"Drum Left Cymbal",
"Drum Hi-Hat", "Drum Hi-Hat",
"Drum Hi-Hat Closed", "Drum Left Pedal",
"Drum Hi-Hat Half-Open",
"Drum Snare", "Drum Snare",
"Drum Hi-Tom", "Drum Hi-Tom",
"Drum Low-Tom",
"Drum Right Cymbal",
"Drum Bass Pedal", "Drum Bass Pedal",
"Drum Left Cymbal", "Drum Low-Tom",
"Drum Left Pedal", "Drum Floor Tom",
"Drum Floor Tom" "Drum Right Cymbal",
"Drum Hi-Hat Closed",
"Drum Hi-Hat Half-Open"
); );
} }
@@ -110,11 +111,11 @@ std::string games::gitadora::get_buttons_help() {
"\n" "\n"
" < R G B Y P --- Pick ] \n" " < R G B Y P --- Pick ] \n"
"\n" "\n"
" If you hold your guitar left-handed (frets on the right hand):\n" " If you normally hold your guitar left-handed (frets on right hand):\n"
" * bind the buttons here as righty and use the in-game option\n" " * here, hold the guitar as right-handed (frets on left hand),\n"
" to turn on LEFT mode to flip the order of buttons.\n" " and bind the buttons, pick, and wail controls\n"
" * turn on GitaDora Lefty Guitar option in Options tab so that\n" " * in Options tab, turn on GitaDora Lefty Guitar\n"
" wailing is recognized correctly.\n" " * finally, use the in-game option to turn on LEFT mode\n"
"\n" "\n"
"\n" "\n"
"drums:\n" "drums:\n"
@@ -126,8 +127,6 @@ std::string games::gitadora::get_buttons_help() {
" Left Bass\n" " Left Bass\n"
" Pedal Pedal\n" " Pedal Pedal\n"
"\n" "\n"
" Drums are NOT velocity-sensitive!\n"
"\n"
" For MIDI drums with Open/Closed HiHat configurations or pads with\n" " For MIDI drums with Open/Closed HiHat configurations or pads with\n"
" multiple hit zones, ensure you bind all variation using the Pages\n" " multiple hit zones, ensure you bind all variation using the Pages\n"
" button at the bottom." " button at the bottom."
@@ -138,7 +137,7 @@ std::string games::gitadora::get_analogs_help() {
return return
"guitar:\n" "guitar:\n"
"\n" "\n"
"X axis: 0% when body is held facing monitor, 50% when facing flat on a table\n" "X axis: 0% when body is held facing monitor, 50% when flat on a table\n"
"Y axis: 50% when held horizontal, 0% when neck is raised, 100% pointing down\n" "Y axis: 50% when held horizontal, 0% when neck is raised, 100% pointing down\n"
"Z axis: 50% at rest, 100% when swinging neck toward monitor (only used in XG series)\n" "Z axis: 50% at rest, 100% when swinging neck toward monitor (only used in XG series)\n"
"\n" "\n"
+11 -8
View File
@@ -66,18 +66,21 @@ namespace games::gitadora {
DrumHelp, DrumHelp,
DrumButtonExtra1, DrumButtonExtra1,
DrumButtonExtra2, DrumButtonExtra2,
// note: this is the order they appear in the test menu // note: this is the order of drums in the default layout
DrumLeftCymbal,
DrumHiHat, DrumHiHat,
DrumHiHatClosed, DrumLeftPedal,
DrumHiHatHalfOpen,
DrumSnare, DrumSnare,
DrumHiTom, DrumHiTom,
DrumLowTom,
DrumRightCymbal,
DrumBassPedal, DrumBassPedal,
DrumLeftCymbal, DrumLowTom,
DrumLeftPedal, DrumFloorTom,
DrumFloorTom DrumRightCymbal,
// these only exist for back compat
// (created before it was possible to map multiple input to a button)
DrumHiHatClosed,
DrumHiHatHalfOpen
}; };
} }
+24 -2
View File
@@ -92,7 +92,12 @@ bool games::gitadora::J33ISerialDevice::parse_msg(
payload.buttons |= 1 << GUITAR_BTN_P; payload.buttons |= 1 << GUITAR_BTN_P;
} }
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::GuitarP1PickUp])) {
const auto pick_up = GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::GuitarP1PickUp]);
const auto pick_down = GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::GuitarP1PickDown]);
if (!games::gitadora::PICK_ALGO.has_value()) {
// legacy behavior (detect rising edges only, input for 1 frame)
if (pick_up) {
if (!GFDM_GF_PICK_STATE_UP) { if (!GFDM_GF_PICK_STATE_UP) {
GFDM_GF_PICK_STATE_UP = true; GFDM_GF_PICK_STATE_UP = true;
payload.buttons |= 1 << GUITAR_PICK_UP; payload.buttons |= 1 << GUITAR_PICK_UP;
@@ -101,7 +106,7 @@ bool games::gitadora::J33ISerialDevice::parse_msg(
GFDM_GF_PICK_STATE_UP = false; GFDM_GF_PICK_STATE_UP = false;
} }
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::GuitarP1PickDown])) { if (pick_down) {
if (!GFDM_GF_PICK_STATE_DOWN) { if (!GFDM_GF_PICK_STATE_DOWN) {
GFDM_GF_PICK_STATE_DOWN = true; GFDM_GF_PICK_STATE_DOWN = true;
payload.buttons |= 1 << GUITAR_PICK_DOWN; payload.buttons |= 1 << GUITAR_PICK_DOWN;
@@ -109,6 +114,23 @@ bool games::gitadora::J33ISerialDevice::parse_msg(
} else { } else {
GFDM_GF_PICK_STATE_DOWN = false; GFDM_GF_PICK_STATE_DOWN = false;
} }
} else {
const auto socd = socd::socd_clean(
0,
pick_up,
pick_down,
get_performance_milliseconds(),
games::gitadora::PICK_ALGO.value()
);
if (socd == socd::SocdCCW) {
payload.buttons |= 1 << GUITAR_PICK_UP;
} else if (socd == socd::SocdCW) {
payload.buttons |= 1 << GUITAR_PICK_DOWN;
} else if (socd == socd::SocdBoth) {
payload.buttons |= 1 << GUITAR_PICK_UP;
payload.buttons |= 1 << GUITAR_PICK_DOWN;
}
}
auto &analogs = get_analogs(); auto &analogs = get_analogs();
+4 -1
View File
@@ -82,6 +82,7 @@ namespace games::iidx {
bool IIDXIO_LED_TICKER_READONLY = false; bool IIDXIO_LED_TICKER_READONLY = false;
std::mutex IIDX_LED_TICKER_LOCK; std::mutex IIDX_LED_TICKER_LOCK;
bool IIDX_TDJ_MONITOR_WARNING = false; bool IIDX_TDJ_MONITOR_WARNING = false;
iidx_aio_emulation_state CURRENT_IO_EMULATION_STATE = iidx_aio_emulation_state::unknown;
// io // io
static bool HAS_LIBAIO; // this is how we detect iidx27+ static bool HAS_LIBAIO; // this is how we detect iidx27+
@@ -453,7 +454,7 @@ namespace games::iidx {
} }
// windowed subscreen, enabled by default, unless turned off by user // windowed subscreen, enabled by default, unless turned off by user
if (GRAPHICS_WINDOWED && !options->at(launcher::Options::spice2x_IIDXNoSub).value_bool()) { if (GRAPHICS_WINDOWED && !options->at(launcher::Options::spice2x_IIDXNoSub).value_bool() && TDJ_MODE) {
GRAPHICS_IIDX_WSUB = true; GRAPHICS_IIDX_WSUB = true;
} }
@@ -934,6 +935,8 @@ namespace games::iidx {
return; return;
} }
CURRENT_IO_EMULATION_STATE = state;
// log_warning below could be turned into log_fatal in the future once we gain confidence // log_warning below could be turned into log_fatal in the future once we gain confidence
// that this isn't triggering when it's not supposed to // that this isn't triggering when it's not supposed to
if (state == iidx_aio_emulation_state::bi2a_com2 && TDJ_MODE) { if (state == iidx_aio_emulation_state::bi2a_com2 && TDJ_MODE) {
+7 -4
View File
@@ -11,6 +11,12 @@
namespace games::iidx { namespace games::iidx {
enum class iidx_aio_emulation_state {
unknown,
bi2a_com2,
bi2x_hook
};
// settings // settings
extern bool FLIP_CAMS; extern bool FLIP_CAMS;
@@ -38,6 +44,7 @@ namespace games::iidx {
constexpr int IIDX_TAPELED_TOTAL = 17; constexpr int IIDX_TAPELED_TOTAL = 17;
// data mapping // data mapping
extern tapeledutils::tape_led TAPELED_MAPPING[IIDX_TAPELED_TOTAL]; extern tapeledutils::tape_led TAPELED_MAPPING[IIDX_TAPELED_TOTAL];
extern iidx_aio_emulation_state CURRENT_IO_EMULATION_STATE;
class IIDXGame : public games::Game { class IIDXGame : public games::Game {
public: public:
@@ -64,9 +71,5 @@ namespace games::iidx {
bool is_tdj_fhd(); bool is_tdj_fhd();
void apply_audio_hacks(); void apply_audio_hacks();
enum class iidx_aio_emulation_state {
bi2a_com2,
bi2x_hook
};
void update_io_emulation_state(iidx_aio_emulation_state state); void update_io_emulation_state(iidx_aio_emulation_state state);
} }
+1 -1
View File
@@ -324,7 +324,7 @@ namespace games {
buttons_help.insert({ pc, pc::get_buttons_help() }); buttons_help.insert({ pc, pc::get_buttons_help() });
analogs.insert({ pc, pc::get_analogs() }); analogs.insert({ pc, pc::get_analogs() });
lights.insert({ pc, pc::get_lights() }); lights.insert({ pc, pc::get_lights() });
file_hints[pc].emplace_back("game/svm_Data"); file_hints[pc].emplace_back("game/svm.exe");
} }
const std::vector<std::string> &get_games() { const std::vector<std::string> &get_games() {
+38 -11
View File
@@ -1,5 +1,7 @@
#include "bi2x_hook.h" #include "bi2x_hook.h"
#if SPICE64
#include "util/execexe.h" #include "util/execexe.h"
#include "util/logging.h" #include "util/logging.h"
#include "rawinput/rawinput.h" #include "rawinput/rawinput.h"
@@ -9,9 +11,10 @@
#include "util/tapeled.h" #include "util/tapeled.h"
#include "pc.h" #include "pc.h"
#include "util/utils.h" #include "util/utils.h"
#include "util/time.h"
#include "util/socd_cleaner.h"
namespace games::pc { namespace games::pc {
bool PC_KNOB_MODE = false;
constexpr float RELATIVE_DECAY = 0.02f; constexpr float RELATIVE_DECAY = 0.02f;
struct FADER_RELATIVE { struct FADER_RELATIVE {
@@ -75,18 +78,22 @@ namespace games::pc {
*/ */
struct AIO_SCI_COMM { struct AIO_SCI_COMM {
uint8_t data[0xf8];
}; };
struct AIO_NMGR_IOB2 { struct AIO_NMGR_IOB2 {
uint8_t data[0xe30];
}; };
struct AIO_IOB2_BI2X_AC1 { struct AIO_IOB2_BI2X_AC1 {
uint8_t data[0x4538];
}; };
struct AIO_IOB2_BI2X_AC1__SETTING { struct AIO_IOB2_BI2X_AC1__SETTING {
}; };
struct AIO_IOB2_BI2X_WRFIRM { struct AIO_IOB2_BI2X_WRFIRM {
uint8_t data[0x20f48];
}; };
struct AIO_IOB2_BI2X_AC1__INPUT struct AIO_IOB2_BI2X_AC1__INPUT
@@ -191,6 +198,12 @@ namespace games::pc {
AIO_IOB2_BI2X_AC1__ICNPIN ICnPinHist[20]; AIO_IOB2_BI2X_AC1__ICNPIN ICnPinHist[20];
}; };
// verified with XIF-2024122300
static_assert(sizeof(AIO_SCI_COMM) == 0xf8);
static_assert(sizeof(AIO_NMGR_IOB2) == 0xe30);
static_assert(sizeof(AIO_IOB2_BI2X_AC1) == 0x4538);
static_assert(sizeof(AIO_IOB2_BI2X_WRFIRM) == 0x20f48);
/* /*
* typedefs * typedefs
*/ */
@@ -338,14 +351,21 @@ namespace games::pc {
val = (GameAPI::Analogs::getState(RI_MGR, analogs[Analogs::FaderL]) - 0.5f) * 2; val = (GameAPI::Analogs::getState(RI_MGR, analogs[Analogs::FaderL]) - 0.5f) * 2;
} }
} }
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Left]) &&
GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Right])) { const auto now = get_performance_milliseconds();
val = 0.f;
} else if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Left])) { const auto fader_l_socd = socd::socd_clean(
0, // Fader-L
GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Left]),
GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Right]),
now);
if (fader_l_socd == socd::SocdCCW) {
val = -1.0f; val = -1.0f;
} else if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderL_Right])) { } else if (fader_l_socd == socd::SocdCW) {
val = +1.0f; val = +1.0f;
} }
o_DevStatus->Input.CN15_7 = (val < 0.2f) ? 0xFF : 0; o_DevStatus->Input.CN15_7 = (val < 0.2f) ? 0xFF : 0;
o_DevStatus->Input.CN15_6 = (val > -0.85f && val < 0.35f) ? 0xFF : 0; o_DevStatus->Input.CN15_6 = (val > -0.85f && val < 0.35f) ? 0xFF : 0;
o_DevStatus->Input.CN15_5 = (val > -0.6f && val < 0.6f) ? 0xFF : 0; o_DevStatus->Input.CN15_5 = (val > -0.6f && val < 0.6f) ? 0xFF : 0;
@@ -363,14 +383,19 @@ namespace games::pc {
val = (GameAPI::Analogs::getState(RI_MGR, analogs[Analogs::FaderR]) - 0.5f) * 2; val = (GameAPI::Analogs::getState(RI_MGR, analogs[Analogs::FaderR]) - 0.5f) * 2;
} }
} }
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Left]) &&
GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Right])) { const auto fader_r_socd = socd::socd_clean(
val = 0.f; 1, // Fader-R
} else if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Left])) { GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Left]),
GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Right]),
now);
if (fader_r_socd == socd::SocdCCW) {
val = -1.0f; val = -1.0f;
} else if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::FaderR_Right])) { } else if (fader_r_socd == socd::SocdCW) {
val = +1.0f; val = +1.0f;
} }
o_DevStatus->Input.CN11_20 = (val < 0.2f) ? 0xFF : 0; o_DevStatus->Input.CN11_20 = (val < 0.2f) ? 0xFF : 0;
o_DevStatus->Input.CN11_19 = (val > -0.85f && val < 0.35f) ? 0xFF : 0; o_DevStatus->Input.CN11_19 = (val > -0.85f && val < 0.35f) ? 0xFF : 0;
o_DevStatus->Input.CN9_10 = (val > -0.6f && val < 0.6f) ? 0xFF : 0; o_DevStatus->Input.CN9_10 = (val > -0.6f && val < 0.6f) ? 0xFF : 0;
@@ -737,3 +762,5 @@ namespace games::pc {
} }
} }
#endif
+4
View File
@@ -1,5 +1,9 @@
#pragma once #pragma once
#if SPICE64
namespace games::pc { namespace games::pc {
void bi2x_hook_init(); void bi2x_hook_init();
} }
#endif
+12
View File
@@ -12,10 +12,12 @@
#include "misc/wintouchemu.h" #include "misc/wintouchemu.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "rawinput/rawinput.h" #include "rawinput/rawinput.h"
#include "util/socd_cleaner.h"
namespace games::pc { namespace games::pc {
std::string PC_INJECT_ARGS = ""; std::string PC_INJECT_ARGS = "";
bool PC_NO_IO = false; bool PC_NO_IO = false;
bool PC_KNOB_MODE = false;
static acioemu::ACIOHandle *acioHandle = nullptr; static acioemu::ACIOHandle *acioHandle = nullptr;
static std::wstring portName = L"COM1"; static std::wstring portName = L"COM1";
@@ -61,6 +63,11 @@ namespace games::pc {
return ERROR_NOT_SUPPORTED; return ERROR_NOT_SUPPORTED;
} }
void PCGame::pre_attach() {
// SOCD
socd::ALGORITHM = socd::SocdAlgorithm::PreferRecent;
}
void PCGame::attach() { void PCGame::attach() {
Game::attach(); Game::attach();
@@ -78,9 +85,14 @@ namespace games::pc {
execexe::load_library("libaio-iob2_video.dll"); execexe::load_library("libaio-iob2_video.dll");
execexe::load_library("win10actlog.dll"); execexe::load_library("win10actlog.dll");
#if SPICE64
if (!PC_NO_IO) { if (!PC_NO_IO) {
bi2x_hook_init(); bi2x_hook_init();
} }
#endif
}); });
const auto user32Dll = "user32.dll"; const auto user32Dll = "user32.dll";
+1
View File
@@ -11,6 +11,7 @@ namespace games::pc {
public: public:
PCGame() : Game("Polaris Chord") {} PCGame() : Game("Polaris Chord") {}
virtual void pre_attach() override;
virtual void attach() override; virtual void attach() override;
virtual void detach() override; virtual void detach() override;
}; };
+14
View File
@@ -1,5 +1,7 @@
#include "bi2x_hook.h" #include "bi2x_hook.h"
#if SPICE64
#include "util/detour.h" #include "util/detour.h"
#include "util/logging.h" #include "util/logging.h"
#include "rawinput/rawinput.h" #include "rawinput/rawinput.h"
@@ -15,15 +17,19 @@ namespace games::qks {
*/ */
struct AIO_SCI_COMM { struct AIO_SCI_COMM {
uint8_t data[0xf8];
}; };
struct AIO_NMGR_IOB { struct AIO_NMGR_IOB {
uint8_t data[0xa00];
}; };
struct AIO_IOB2_BI2X_AC1 { struct AIO_IOB2_BI2X_AC1 {
uint8_t data[0x3908];
}; };
struct AIO_IOB2_BI2X_WRFIRM { struct AIO_IOB2_BI2X_WRFIRM {
uint8_t data[0x20f48];
}; };
struct AIO_NMGR_IOB__NODEINFO { struct AIO_NMGR_IOB__NODEINFO {
@@ -174,6 +180,12 @@ namespace games::qks {
AIO_IOB2_BI2X_AC1__SETTING Setting; AIO_IOB2_BI2X_AC1__SETTING Setting;
}; };
// verified with UKS-001-2024030600
static_assert(sizeof(AIO_IOB2_BI2X_AC1) == 0x3908);
static_assert(sizeof(AIO_SCI_COMM) == 0xf8);
static_assert(sizeof(AIO_NMGR_IOB) == 0xa00);
static_assert(sizeof(AIO_IOB2_BI2X_WRFIRM) == 0x20f48);
/* /*
* typedefs * typedefs
*/ */
@@ -603,3 +615,5 @@ namespace games::qks {
aioNodeCtl_IsError, &aioNodeCtl_IsError_orig); aioNodeCtl_IsError, &aioNodeCtl_IsError_orig);
} }
} }
#endif
+4
View File
@@ -1,7 +1,11 @@
#pragma once #pragma once
#if SPICE64
#include <stdint.h> #include <stdint.h>
namespace games::qks { namespace games::qks {
void bi2x_hook_init(); void bi2x_hook_init();
} }
#endif
+4
View File
@@ -86,9 +86,13 @@ namespace games::qks {
detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(9), detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(9),
execexe_CreateFileA_hook,&execexe_CreateFileA_orig); execexe_CreateFileA_hook,&execexe_CreateFileA_orig);
#if SPICE64
// insert BI2X hooks // insert BI2X hooks
bi2x_hook_init(); bi2x_hook_init();
#endif
// add card reader // add card reader
acioHandle = new acioemu::ACIOHandle(portName.c_str()); acioHandle = new acioemu::ACIOHandle(portName.c_str());
devicehook_init_trampoline(); devicehook_init_trampoline();
+5 -6
View File
@@ -21,8 +21,9 @@
#include "util/socd_cleaner.h" #include "util/socd_cleaner.h"
#include "util/time.h" #include "util/time.h"
#include "util/libutils.h" #include "util/libutils.h"
#include "misc/wintouchemu.h"
#include "misc/eamuse.h" #include "misc/eamuse.h"
#include "misc/nativetouchhook.h"
#include "misc/wintouchemu.h"
#include "bi2x_hook.h" #include "bi2x_hook.h"
#include "camera.h" #include "camera.h"
#include "io.h" #include "io.h"
@@ -65,10 +66,6 @@ namespace games::sdvx {
// prevent the game from randomly picking an ASIO device // prevent the game from randomly picking an ASIO device
if (!USE_ASIO) { if (!USE_ASIO) {
log_info(
"sdvx::asio",
"game tried to access HKLM\\SOFTWARE\\ASIO but ASIO is disabled; "
"access prevented, ASIO init will fail");
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
} }
// convince the game to use our hook (so we can swap in the preferred device) // convince the game to use our hook (so we can swap in the preferred device)
@@ -420,9 +417,11 @@ namespace games::sdvx {
} }
if (is_valkyrie_model()) { if (is_valkyrie_model()) {
if (NATIVETOUCH) {
nativetouchhook::hook(avs::game::DLL_INSTANCE);
} else if (!NATIVETOUCH && !GRAPHICS_WINDOWED) {
// hook touch window // hook touch window
// in windowed mode, game can accept mouse input on the second screen // in windowed mode, game can accept mouse input on the second screen
if (!NATIVETOUCH && !GRAPHICS_WINDOWED) {
wintouchemu::FORCE = true; wintouchemu::FORCE = true;
wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true; wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true;
wintouchemu::hook_title_ends( wintouchemu::hook_title_ends(
+2 -1
View File
@@ -42,7 +42,8 @@ namespace hooks::audio {
bool USE_DUMMY = false; bool USE_DUMMY = false;
WAVEFORMATEXTENSIBLE FORMAT {}; WAVEFORMATEXTENSIBLE FORMAT {};
std::optional<Backend> BACKEND = std::nullopt; std::optional<Backend> BACKEND = std::nullopt;
size_t ASIO_DRIVER_ID = 0; std::optional<size_t> ASIO_DRIVER_ID = std::nullopt;
std::string ASIO_DRIVER_NAME = "";
bool ASIO_FORCE_UNLOAD_ON_STOP = false; bool ASIO_FORCE_UNLOAD_ON_STOP = false;
// private globals // private globals
+3 -1
View File
@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <optional> #include <optional>
#include <string>
#include <windows.h> #include <windows.h>
#include <mmreg.h> #include <mmreg.h>
@@ -20,7 +21,8 @@ namespace hooks::audio {
extern bool USE_DUMMY; extern bool USE_DUMMY;
extern WAVEFORMATEXTENSIBLE FORMAT; extern WAVEFORMATEXTENSIBLE FORMAT;
extern std::optional<Backend> BACKEND; extern std::optional<Backend> BACKEND;
extern size_t ASIO_DRIVER_ID; extern std::optional<size_t> ASIO_DRIVER_ID;
extern std::string ASIO_DRIVER_NAME;
extern bool ASIO_FORCE_UNLOAD_ON_STOP; extern bool ASIO_FORCE_UNLOAD_ON_STOP;
extern bool LOW_LATENCY_SHARED_WASAPI; extern bool LOW_LATENCY_SHARED_WASAPI;
@@ -218,13 +218,40 @@ void AsioBackend::set_thread_state(AsioThreadState state) {
bool AsioBackend::load_driver() { bool AsioBackend::load_driver() {
AsioDriverList asio_driver_list; AsioDriverList asio_driver_list;
for (const auto &driver : asio_driver_list.driver_list) { size_t driver_id = 0;
log_info("audio::asio", "Driver {}", driver.id); std::string driver_name = "";
log_info("audio::asio", "... Name : {}", driver.name); if (hooks::audio::ASIO_DRIVER_ID.has_value()) {
log_info("audio::asio", "... Path : {}", driver.dll_path); driver_id = hooks::audio::ASIO_DRIVER_ID.value();
} }
const auto driver_id = hooks::audio::ASIO_DRIVER_ID; for (const auto &driver : asio_driver_list.driver_list) {
log_info("audio::asio", " Driver ID : {}", driver.id);
log_info("audio::asio", " ... Name : {}", driver.name);
log_info("audio::asio", " ... Path : {}", driver.dll_path);
if (!hooks::audio::ASIO_DRIVER_NAME.empty()) {
// match on driver name
if (driver.name == hooks::audio::ASIO_DRIVER_NAME) {
driver_id = driver.id;
driver_name = driver.name;
}
} else if (driver.id == driver_id) {
// match on driver index (0 for default or user-specified)
driver_name = driver.name;
}
}
if (driver_name.empty()) {
if (!hooks::audio::ASIO_DRIVER_NAME.empty()) {
log_warning(
"audio::asio",
"tried to look for ASIO driver but failed: {}", hooks::audio::ASIO_DRIVER_NAME);
}
log_fatal(
"audio::asio",
"could not find ASIO driver to use for conversion, fix your audio options and try again");
}
log_info("audio::asio", "will attempt to use the following ASIO driver: ID = {}, Name = {}", driver_id, driver_name);
IAsio *driver = nullptr; IAsio *driver = nullptr;
auto ret = asio_driver_list.open_driver(driver_id, reinterpret_cast<void **>(&driver)); auto ret = asio_driver_list.open_driver(driver_id, reinterpret_cast<void **>(&driver));
@@ -13,6 +13,7 @@
#include "avs/game.h" #include "avs/game.h"
#include "cfg/screen_resize.h" #include "cfg/screen_resize.h"
#include "games/gitadora/gitadora.h"
#include "games/iidx/iidx.h" #include "games/iidx/iidx.h"
#include "games/sdvx/sdvx.h" #include "games/sdvx/sdvx.h"
#include "games/mfc/mfc.h" #include "games/mfc/mfc.h"
@@ -944,7 +945,8 @@ HRESULT STDMETHODCALLTYPE WrappedIDirect3D9::CreateDeviceEx(
for (size_t i = 0; i < num_adapters; i++) { for (size_t i = 0; i < num_adapters; i++) {
auto *params = &pPresentationParameters[i]; auto *params = &pPresentationParameters[i];
if (!GRAPHICS_WINDOWED && i == 0) { if (!GRAPHICS_WINDOWED){
if (i == 0) {
GRAPHICS_FS_ORIGINAL_WIDTH = params->BackBufferWidth; GRAPHICS_FS_ORIGINAL_WIDTH = params->BackBufferWidth;
GRAPHICS_FS_ORIGINAL_HEIGHT = params->BackBufferHeight; GRAPHICS_FS_ORIGINAL_HEIGHT = params->BackBufferHeight;
log_misc("graphics::d3d9", "original resolution: {}x{}", GRAPHICS_FS_ORIGINAL_WIDTH, GRAPHICS_FS_ORIGINAL_HEIGHT); log_misc("graphics::d3d9", "original resolution: {}x{}", GRAPHICS_FS_ORIGINAL_WIDTH, GRAPHICS_FS_ORIGINAL_HEIGHT);
@@ -965,6 +967,16 @@ HRESULT STDMETHODCALLTYPE WrappedIDirect3D9::CreateDeviceEx(
params->BackBufferHeight, params->BackBufferWidth); params->BackBufferHeight, params->BackBufferWidth);
std::swap(params->BackBufferWidth, params->BackBufferHeight); std::swap(params->BackBufferWidth, params->BackBufferHeight);
} }
} else if (i == 1 && GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.has_value()) {
log_misc(
"graphics::d3d9",
"use custom sub resolution {}x{} => {}x{}",
params->BackBufferWidth, params->BackBufferHeight,
GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().first,
GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().second);
params->BackBufferWidth = GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().first;
params->BackBufferHeight = GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().second;
}
} }
log_info("graphics::d3d9", log_info("graphics::d3d9",
@@ -991,13 +1003,18 @@ HRESULT STDMETHODCALLTYPE WrappedIDirect3D9::CreateDeviceEx(
for (size_t i = 0; i < num_adapters; i++) { for (size_t i = 0; i < num_adapters; i++) {
auto *fullscreen_display_mode = &pFullscreenDisplayMode[i]; auto *fullscreen_display_mode = &pFullscreenDisplayMode[i];
if (!GRAPHICS_WINDOWED && i == 0) { if (!GRAPHICS_WINDOWED) {
if (i == 0) {
if (GRAPHICS_FS_CUSTOM_RESOLUTION.has_value()) { if (GRAPHICS_FS_CUSTOM_RESOLUTION.has_value()) {
fullscreen_display_mode->Width = GRAPHICS_FS_CUSTOM_RESOLUTION.value().first; fullscreen_display_mode->Width = GRAPHICS_FS_CUSTOM_RESOLUTION.value().first;
fullscreen_display_mode->Height = GRAPHICS_FS_CUSTOM_RESOLUTION.value().second; fullscreen_display_mode->Height = GRAPHICS_FS_CUSTOM_RESOLUTION.value().second;
} else if (GRAPHICS_FS_ORIENTATION_SWAP) { } else if (GRAPHICS_FS_ORIENTATION_SWAP) {
std::swap(fullscreen_display_mode->Width, fullscreen_display_mode->Height); std::swap(fullscreen_display_mode->Width, fullscreen_display_mode->Height);
} }
} else if (i == 1 && GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.has_value()) {
fullscreen_display_mode->Width = GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().first;
fullscreen_display_mode->Height = GRAPHICS_FS_CUSTOM_RESOLUTION_SUB.value().second;
}
} }
log_info("graphics::d3d9", log_info("graphics::d3d9",
@@ -1170,9 +1187,15 @@ IDirect3DSurface9 *graphics_d3d9_ldj_get_sub_screen() {
} }
static void graphics_d3d9_ldj_on_present(IDirect3DDevice9 *wrapped_device) { static void graphics_d3d9_ldj_on_present(IDirect3DDevice9 *wrapped_device) {
// iidx/sdvx
int swapchain = 1;
if (games::gitadora::is_arena_model()) {
swapchain = 3;
}
if (!ATTEMPTED_SUB_SWAP_CHAIN_ACQUIRE && SUB_SWAP_CHAIN == nullptr) { if (!ATTEMPTED_SUB_SWAP_CHAIN_ACQUIRE && SUB_SWAP_CHAIN == nullptr) {
ATTEMPTED_SUB_SWAP_CHAIN_ACQUIRE = true; ATTEMPTED_SUB_SWAP_CHAIN_ACQUIRE = true;
HRESULT hr = wrapped_device->GetSwapChain(1, &SUB_SWAP_CHAIN); HRESULT hr = wrapped_device->GetSwapChain(swapchain, &SUB_SWAP_CHAIN);
if (FAILED(hr)) { if (FAILED(hr)) {
log_warning( log_warning(
"graphics::d3d9", "graphics::d3d9",
@@ -1383,7 +1406,9 @@ void graphics_d3d9_on_present(
// for IIDX TDJ / SDVX UFC, handle subscreen // for IIDX TDJ / SDVX UFC, handle subscreen
const bool is_vm = games::sdvx::is_valkyrie_model(); const bool is_vm = games::sdvx::is_valkyrie_model();
const bool is_tdj = avs::game::is_model("LDJ") && games::iidx::TDJ_MODE; const bool is_tdj = avs::game::is_model("LDJ") && games::iidx::TDJ_MODE;
if (is_vm || is_tdj) { const bool is_gfdm_arena =
games::gitadora::is_arena_model() && games::gitadora::ARENA_SINGLE_WINDOW;
if (is_vm || is_tdj || is_gfdm_arena) {
graphics_d3d9_ldj_on_present(wrapped_device); graphics_d3d9_ldj_on_present(wrapped_device);
} }
@@ -4,6 +4,7 @@
#include <mutex> #include <mutex>
#include "avs/game.h" #include "avs/game.h"
#include "games/gitadora/gitadora.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "overlay/overlay.h" #include "overlay/overlay.h"
#include "util/flags_helper.h" #include "util/flags_helper.h"
@@ -249,8 +250,16 @@ HRESULT STDMETHODCALLTYPE WrappedIDirect3DDevice9::CreateAdditionalSwapChain(
WRAP_VERBOSE; WRAP_VERBOSE;
HRESULT hr = pReal->CreateAdditionalSwapChain(pPresentationParameters, ppSwapChain); HRESULT hr = pReal->CreateAdditionalSwapChain(pPresentationParameters, ppSwapChain);
bool create_swap_chain = false;
if (avs::game::is_model({"LDJ", "KFC"})) { if (avs::game::is_model({"LDJ", "KFC"})) {
create_swap_chain = true;
} else if (games::gitadora::is_arena_model() &&
games::gitadora::ARENA_SINGLE_WINDOW &&
pPresentationParameters->BackBufferWidth == 800) {
create_swap_chain = true;
}
if (create_swap_chain) {
if (SUCCEEDED(hr) && !sub_swapchain) { if (SUCCEEDED(hr) && !sub_swapchain) {
sub_swapchain = new WrappedIDirect3DSwapChain9(this, *ppSwapChain); sub_swapchain = new WrappedIDirect3DSwapChain9(this, *ppSwapChain);
sub_swapchain->should_run_hooks = false; sub_swapchain->should_run_hooks = false;
@@ -295,7 +304,17 @@ HRESULT STDMETHODCALLTYPE WrappedIDirect3DDevice9::GetSwapChain(
return D3D_OK; return D3D_OK;
} }
bool swap = false;
if (iSwapChain == 1 && avs::game::is_model({"LDJ", "KFC"})) { if (iSwapChain == 1 && avs::game::is_model({"LDJ", "KFC"})) {
swap = true;
}
if (games::gitadora::is_arena_model() &&
games::gitadora::ARENA_SINGLE_WINDOW &&
iSwapChain == 3) {
swap = true;
}
if (swap) {
if (sub_swapchain) { if (sub_swapchain) {
sub_swapchain->AddRef(); sub_swapchain->AddRef();
*ppSwapChain = static_cast<IDirect3DSwapChain9 *>(sub_swapchain); *ppSwapChain = static_cast<IDirect3DSwapChain9 *>(sub_swapchain);
+76 -19
View File
@@ -61,7 +61,6 @@ bool GRAPHICS_SHOW_CURSOR = false;
graphics_orientation GRAPHICS_ADJUST_ORIENTATION = ORIENTATION_NORMAL; graphics_orientation GRAPHICS_ADJUST_ORIENTATION = ORIENTATION_NORMAL;
bool GRAPHICS_WINDOWED = false; bool GRAPHICS_WINDOWED = false;
std::vector<HWND> GRAPHICS_WINDOWS; std::vector<HWND> GRAPHICS_WINDOWS;
std::optional<HWND> GRAPHICS_WINDOW_MAIN;
UINT GRAPHICS_FORCE_REFRESH = 0; UINT GRAPHICS_FORCE_REFRESH = 0;
std::optional<uint32_t> GRAPHICS_FORCE_REFRESH_SUB; std::optional<uint32_t> GRAPHICS_FORCE_REFRESH_SUB;
std::optional<int> GRAPHICS_FORCE_VSYNC_BUFFER; std::optional<int> GRAPHICS_FORCE_VSYNC_BUFFER;
@@ -72,6 +71,7 @@ bool GRAPHICS_9_ON_12_REQUESTED_BY_GAME = false;
bool SUBSCREEN_FORCE_REDRAW = false; bool SUBSCREEN_FORCE_REDRAW = false;
bool D3D9_DEVICE_HOOK_DISABLE = false; bool D3D9_DEVICE_HOOK_DISABLE = false;
std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION; std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION;
std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION_SUB;
bool GRAPHICS_FS_ORIENTATION_SWAP = false; bool GRAPHICS_FS_ORIENTATION_SWAP = false;
uint32_t GRAPHICS_FS_ORIGINAL_WIDTH = 0; uint32_t GRAPHICS_FS_ORIGINAL_WIDTH = 0;
uint32_t GRAPHICS_FS_ORIGINAL_HEIGHT = 0; uint32_t GRAPHICS_FS_ORIGINAL_HEIGHT = 0;
@@ -98,6 +98,7 @@ static decltype(SetCursor) *SetCursor_orig = nullptr;
static decltype(SetWindowLongA) *SetWindowLongA_orig = nullptr; static decltype(SetWindowLongA) *SetWindowLongA_orig = nullptr;
static decltype(SetWindowLongW) *SetWindowLongW_orig = nullptr; static decltype(SetWindowLongW) *SetWindowLongW_orig = nullptr;
static decltype(SetWindowPos) *SetWindowPos_orig = nullptr; static decltype(SetWindowPos) *SetWindowPos_orig = nullptr;
static decltype(ShowWindow) *ShowWindow_orig = nullptr;
static void reset_window_hook(HWND hWnd) { static void reset_window_hook(HWND hWnd) {
overlay::destroy(hWnd); overlay::destroy(hWnd);
@@ -300,6 +301,30 @@ static BOOL WINAPI ClipCursor_hook(const RECT *lpRect) {
return ClipCursor_orig(lpRect); return ClipCursor_orig(lpRect);
} }
static void fix_up_rb_auto_rotate_dimensions(DWORD &w, DWORD &h) {
// reflec beat
// for whatever reason, rb creates the first window it weird dimensions (774x1389 for reflesia, for example)
// so doing ChangeDisplaySettings as-is ends up with DISP_CHANGE_BADMODE
// while a second window (with title D3DProxyWindow) does get created with correct dimensions, it's
// too late to rotate the window then; as a workaround force the display change now with patched up dimensions
bool changed = false;
if (w == 774) {
// LBR, MBR reflesia
w = 768;
h = 1360;
changed = true;
} else if (w == 1086) {
// MBR (before reflesia)
w = 1080;
h = 1920;
changed = true;
}
if (changed) {
log_misc("graphics", "fix auto-rotate dimensions for reflec beat: w={}, h={}", w, h);
}
}
static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName,
DWORD dwStyle, int x, int y, int nWidth, int nHeight, DWORD dwStyle, int x, int y, int nWidth, int nHeight,
HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance,
@@ -324,10 +349,19 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
// set display orientation and/or refresh rate // set display orientation and/or refresh rate
// only set orientation when the target window is portrait // only set orientation when the target window is portrait
// (avoid doing this for SDVX subscreen which is in landscape, for example) // (avoid doing this for SDVX subscreen which is in landscape, for example)
const auto adjust_orientation = auto adjust_orientation =
(GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CW || (GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CW ||
GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CCW); GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CCW);
// reflec beat
if (avs::game::is_model("KBR")) {
// KBR (rb1) launches landscape and draws rotated by itself, don't do any rotation
adjust_orientation = false;
} else if (avs::game::is_model({"LBR", "MBR"}) && window_name == "D3DProxyWindow") {
// do not auto-rotate for second window (D3DProxyWindow)
adjust_orientation = false;
}
if ((nHeight > nWidth && adjust_orientation) || GRAPHICS_FORCE_REFRESH > 0) { if ((nHeight > nWidth && adjust_orientation) || GRAPHICS_FORCE_REFRESH > 0) {
DEVMODE mode {}; DEVMODE mode {};
@@ -337,11 +371,16 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
DWORD orientation = GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CW ? DMDO_90 : DMDO_270; DWORD orientation = GRAPHICS_ADJUST_ORIENTATION == ORIENTATION_CW ? DMDO_90 : DMDO_270;
log_misc( log_misc(
"graphics", "graphics",
"auto-rotate: call ChangeDisplaySettings and rotate display to DMDO_xx mode {}", "auto-rotate: call ChangeDisplaySettings and rotate display to DMDO_xx mode {}, w={}, h={}",
orientation); orientation, nWidth, nHeight);
mode.dmPelsWidth = nWidth; mode.dmPelsWidth = nWidth;
mode.dmPelsHeight = nHeight; mode.dmPelsHeight = nHeight;
mode.dmDisplayOrientation = orientation; mode.dmDisplayOrientation = orientation;
// reflec beat
if (avs::game::is_model({"LBR", "MBR"})) {
fix_up_rb_auto_rotate_dimensions(mode.dmPelsWidth, mode.dmPelsHeight);
}
} }
if (GRAPHICS_FORCE_REFRESH > 0) { if (GRAPHICS_FORCE_REFRESH > 0) {
@@ -356,7 +395,7 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
const auto disp_res = ChangeDisplaySettings(&mode, CDS_FULLSCREEN); const auto disp_res = ChangeDisplaySettings(&mode, CDS_FULLSCREEN);
if (disp_res != DISP_CHANGE_SUCCESSFUL) { if (disp_res != DISP_CHANGE_SUCCESSFUL) {
log_warning("graphics", "failed to change display settings: {}", disp_res); log_warning("graphics", "ChangeDisplaySettings failed: {}", disp_res);
} }
} else { } else {
log_warning("graphics", "failed to get display settings"); log_warning("graphics", "failed to get display settings");
@@ -364,12 +403,10 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
} }
// gfdm // gfdm
bool is_gitadora_main_window = false;
if (avs::game::is_model({"J32", "J33", "K32", "K33", "L32", "L33", "M32"})) { if (avs::game::is_model({"J32", "J33", "K32", "K33", "L32", "L33", "M32"})) {
// set window name // set window name
if (!lpWindowName) { if (!lpWindowName) {
lpWindowName = "GITADORA"; lpWindowName = "GITADORA";
is_gitadora_main_window = true;
} }
} }
@@ -377,7 +414,7 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
bool is_sdvx_sub_window = avs::game::is_model("KFC") && window_name.ends_with(" Sub Screen"); bool is_sdvx_sub_window = avs::game::is_model("KFC") && window_name.ends_with(" Sub Screen");
bool is_gfdm_sub_window = games::gitadora::is_arena_model() && window_name.ends_with("SMALL"); bool is_gfdm_sub_window = games::gitadora::is_arena_model() && window_name.ends_with("SMALL");
// TDJ windowed mode with subscreen: hide maximize button // hide maximize button (prevent misaligned touches)
if ((is_tdj_sub_window && GRAPHICS_IIDX_WSUB) || is_sdvx_sub_window || is_gfdm_sub_window) { if ((is_tdj_sub_window && GRAPHICS_IIDX_WSUB) || is_sdvx_sub_window || is_gfdm_sub_window) {
dwStyle &= ~(WS_MAXIMIZEBOX); dwStyle &= ~(WS_MAXIMIZEBOX);
} }
@@ -385,7 +422,7 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
if (is_gfdm_sub_window) { if (is_gfdm_sub_window) {
dwStyle &= ~(WS_SIZEBOX); dwStyle &= ~(WS_SIZEBOX);
} }
if ((is_tdj_sub_window || is_sdvx_sub_window || is_gfdm_sub_window) && GRAPHICS_WSUB_BORDERLESS) { if ((is_tdj_sub_window || is_sdvx_sub_window) && GRAPHICS_WSUB_BORDERLESS) {
dwStyle &= ~(WS_OVERLAPPEDWINDOW); dwStyle &= ~(WS_OVERLAPPEDWINDOW);
} }
@@ -412,11 +449,6 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
hWndParent, hMenu, hInstance, lpParam); hWndParent, hMenu, hInstance, lpParam);
GRAPHICS_WINDOWS.push_back(result); GRAPHICS_WINDOWS.push_back(result);
// this is only really needed for arena model, but pre-arena model was single window anyway
if (is_gitadora_main_window) {
GRAPHICS_WINDOW_MAIN = result;
}
if (is_tdj_sub_window) { if (is_tdj_sub_window) {
// TDJ windowed mode: remember the subscreen window handle for later // TDJ windowed mode: remember the subscreen window handle for later
TDJ_SUBSCREEN_WINDOW = result; TDJ_SUBSCREEN_WINDOW = result;
@@ -433,13 +465,19 @@ static HWND WINAPI CreateWindowExA_hook(DWORD dwExStyle, LPCSTR lpClassName, LPC
graphics_hook_subscreen_window(SDVX_SUBSCREEN_WINDOW); graphics_hook_subscreen_window(SDVX_SUBSCREEN_WINDOW);
} }
if (is_gfdm_sub_window) { // only hook touch window if multiple windows are allowed
if (is_gfdm_sub_window && !games::gitadora::ARENA_SINGLE_WINDOW) {
GFDM_SUBSCREEN_WINDOW = result; GFDM_SUBSCREEN_WINDOW = result;
graphics_hook_subscreen_window(GFDM_SUBSCREEN_WINDOW); graphics_hook_subscreen_window(GFDM_SUBSCREEN_WINDOW);
} }
disable_touch_indicators(result); disable_touch_indicators(result);
log_misc("graphics", "CreateWindowExA returned {}", fmt::ptr(result)); log_misc(
"graphics",
"CreateWindowExA returned {}, {}",
fmt::ptr(result),
lpWindowName ? lpWindowName : "(null)");
return result; return result;
} }
@@ -471,7 +509,8 @@ static HWND WINAPI CreateWindowExW_hook(DWORD dwExStyle, LPCWSTR lpClassName, LP
} }
// windowed mode adjustments // windowed mode adjustments
if (GRAPHICS_WINDOWED) { // check the width to filter out invisible system-created windows
if (GRAPHICS_WINDOWED && nWidth > 0) {
// change window style // change window style
dwExStyle = 0; dwExStyle = 0;
@@ -506,7 +545,12 @@ static HWND WINAPI CreateWindowExW_hook(DWORD dwExStyle, LPCWSTR lpClassName, LP
hWndParent, hMenu, hInstance, lpParam); hWndParent, hMenu, hInstance, lpParam);
GRAPHICS_WINDOWS.push_back(result); GRAPHICS_WINDOWS.push_back(result);
log_misc("graphics", "CreateWindowExW returned {}", fmt::ptr(result)); log_misc(
"graphics",
"CreateWindowExW returned {}, {}",
fmt::ptr(result),
lpWindowName ? ws2s(lpWindowName) : "(null)");
disable_touch_indicators(result); disable_touch_indicators(result);
return result; return result;
} }
@@ -673,7 +717,7 @@ static BOOL WINAPI SetWindowPos_hook(HWND hWnd, HWND hWndInsertAfter,
// prevent gitadora arena model from shifting windows around if the user has preferences // prevent gitadora arena model from shifting windows around if the user has preferences
if (GRAPHICS_WINDOWED && games::gitadora::is_arena_model() && if (GRAPHICS_WINDOWED && games::gitadora::is_arena_model() &&
GRAPHICS_WINDOW_MAIN.has_value() && hWnd == GRAPHICS_WINDOW_MAIN.value() && GRAPHICS_HOOKED_WINDOW.has_value() && hWnd == GRAPHICS_HOOKED_WINDOW.value() &&
cfg::SCREENRESIZE->enable_window_resize) { cfg::SCREENRESIZE->enable_window_resize) {
return TRUE; return TRUE;
} }
@@ -682,6 +726,18 @@ static BOOL WINAPI SetWindowPos_hook(HWND hWnd, HWND hWndInsertAfter,
return SetWindowPos_orig(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags); return SetWindowPos_orig(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
} }
static BOOL WINAPI ShowWindow_hook(HWND hWnd, int nCmdShow) {
if (games::gitadora::is_arena_model() &&
games::gitadora::ARENA_SINGLE_WINDOW &&
hWnd != GRAPHICS_HOOKED_WINDOW) {
log_info("graphics", "ShowWindow_hook - hiding sub window {}", fmt::ptr(hWnd));
return true;
}
// call original
return ShowWindow_orig(hWnd, nCmdShow);
}
static ATOM WINAPI RegisterClassA_hook(const WNDCLASSA *lpWndClass) { static ATOM WINAPI RegisterClassA_hook(const WNDCLASSA *lpWndClass) {
// check for null // check for null
@@ -824,6 +880,7 @@ void graphics_init() {
SetWindowLongA_orig = detour::iat_try("SetWindowLongA", SetWindowLongA_hook); SetWindowLongA_orig = detour::iat_try("SetWindowLongA", SetWindowLongA_hook);
SetWindowLongW_orig = detour::iat_try("SetWindowLongW", SetWindowLongW_hook); SetWindowLongW_orig = detour::iat_try("SetWindowLongW", SetWindowLongW_hook);
SetWindowPos_orig = detour::iat_try("SetWindowPos", SetWindowPos_hook); SetWindowPos_orig = detour::iat_try("SetWindowPos", SetWindowPos_hook);
ShowWindow_orig = detour::iat_try("ShowWindow", ShowWindow_hook);
detour::iat_try("MessageBoxA", MessageBoxA_hook); detour::iat_try("MessageBoxA", MessageBoxA_hook);
detour::iat_try("MessageBoxExA", MessageBoxExA_hook); detour::iat_try("MessageBoxExA", MessageBoxExA_hook);
+6 -2
View File
@@ -31,13 +31,13 @@ extern bool GRAPHICS_SHOW_CURSOR;
extern bool GRAPHICS_WINDOWED; extern bool GRAPHICS_WINDOWED;
extern graphics_orientation GRAPHICS_ADJUST_ORIENTATION; extern graphics_orientation GRAPHICS_ADJUST_ORIENTATION;
extern std::vector<HWND> GRAPHICS_WINDOWS; extern std::vector<HWND> GRAPHICS_WINDOWS;
extern std::optional<HWND> GRAPHICS_WINDOW_MAIN;
extern UINT GRAPHICS_FORCE_REFRESH; extern UINT GRAPHICS_FORCE_REFRESH;
extern std::optional<uint32_t> GRAPHICS_FORCE_REFRESH_SUB; extern std::optional<uint32_t> GRAPHICS_FORCE_REFRESH_SUB;
extern std::optional<int> GRAPHICS_FORCE_VSYNC_BUFFER; extern std::optional<int> GRAPHICS_FORCE_VSYNC_BUFFER;
extern bool GRAPHICS_FORCE_SINGLE_ADAPTER; extern bool GRAPHICS_FORCE_SINGLE_ADAPTER;
extern bool GRAPHICS_PREVENT_SECONDARY_WINDOW; extern bool GRAPHICS_PREVENT_SECONDARY_WINDOW;
extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION; extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION;
extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION_SUB;
extern bool GRAPHICS_FS_ORIENTATION_SWAP; extern bool GRAPHICS_FS_ORIENTATION_SWAP;
extern uint32_t GRAPHICS_FS_ORIGINAL_WIDTH; extern uint32_t GRAPHICS_FS_ORIGINAL_WIDTH;
extern uint32_t GRAPHICS_FS_ORIGINAL_HEIGHT; extern uint32_t GRAPHICS_FS_ORIGINAL_HEIGHT;
@@ -50,6 +50,7 @@ extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_WINDOW_SIZE;
extern std::optional<std::string> GRAPHICS_WINDOW_POS; extern std::optional<std::string> GRAPHICS_WINDOW_POS;
extern bool GRAPHICS_WINDOW_ALWAYS_ON_TOP; extern bool GRAPHICS_WINDOW_ALWAYS_ON_TOP;
extern bool GRAPHICS_WINDOW_BACKBUFFER_SCALE; extern bool GRAPHICS_WINDOW_BACKBUFFER_SCALE;
extern std::optional<HWND> GRAPHICS_HOOKED_WINDOW;
extern bool GRAPHICS_IIDX_WSUB; extern bool GRAPHICS_IIDX_WSUB;
extern std::optional<std::string> GRAPHICS_WSUB_SIZE; extern std::optional<std::string> GRAPHICS_WSUB_SIZE;
@@ -101,5 +102,8 @@ void graphics_capture_initial_window(HWND hWnd);
void graphics_update_window_style(HWND hWnd); void graphics_update_window_style(HWND hWnd);
void graphics_update_z_order(HWND hWnd, bool always_on_top); void graphics_update_z_order(HWND hWnd, bool always_on_top);
void graphics_move_resize_window(HWND hWnd); void graphics_move_resize_window(HWND hWnd);
bool graphics_window_change_crashes_game(); bool graphics_window_options_breaks_game();
bool graphics_window_decoration_change_crashes_game();
bool graphics_window_resize_breaks_game();
bool graphics_window_move_and_resize_breaks_game();
void graphics_load_windowed_subscreen_parameters(); void graphics_load_windowed_subscreen_parameters();
@@ -1,6 +1,7 @@
#include "graphics.h" #include "graphics.h"
#include "avs/game.h" #include "avs/game.h"
#include "games/gitadora/gitadora.h"
#include "cfg/screen_resize.h" #include "cfg/screen_resize.h"
#include "overlay/overlay.h" #include "overlay/overlay.h"
#include "util/logging.h" #include "util/logging.h"
@@ -23,6 +24,7 @@ std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_WINDOW_SIZE;
std::optional<std::string> GRAPHICS_WINDOW_POS; std::optional<std::string> GRAPHICS_WINDOW_POS;
bool GRAPHICS_WINDOW_ALWAYS_ON_TOP = false; bool GRAPHICS_WINDOW_ALWAYS_ON_TOP = false;
bool GRAPHICS_WINDOW_BACKBUFFER_SCALE = false; bool GRAPHICS_WINDOW_BACKBUFFER_SCALE = false;
std::optional<HWND> GRAPHICS_HOOKED_WINDOW;
// IIDX Windowed Subscreen - starts out as false, enabled by IIDX module on pre-attach as needed // IIDX Windowed Subscreen - starts out as false, enabled by IIDX module on pre-attach as needed
bool GRAPHICS_IIDX_WSUB = false; bool GRAPHICS_IIDX_WSUB = false;
@@ -55,6 +57,8 @@ void graphics_capture_initial_window(HWND hWnd) {
graphics_load_windowed_parameters(); graphics_load_windowed_parameters();
GRAPHICS_HOOKED_WINDOW = hWnd;
cfg::SCREENRESIZE->init_window_style = GetWindowLong(hWnd, GWL_STYLE); cfg::SCREENRESIZE->init_window_style = GetWindowLong(hWnd, GWL_STYLE);
cfg::SCREENRESIZE->init_window_style_ex = GetWindowLong(hWnd, GWL_EXSTYLE); cfg::SCREENRESIZE->init_window_style_ex = GetWindowLong(hWnd, GWL_EXSTYLE);
@@ -66,8 +70,9 @@ void graphics_capture_initial_window(HWND hWnd) {
RECT rect; RECT rect;
if (!GetClientRect(hWnd, &rect)) { if (!GetClientRect(hWnd, &rect)) {
log_warning( log_warning(
"graphics", "graphics-windowed",
"graphics_capture_initial_window - GetClientRect failed, GLE: {}", "[{}] graphics_capture_initial_window - GetClientRect failed, GLE: {}",
fmt::ptr(hWnd),
GetLastError()); GetLastError());
return; return;
} }
@@ -79,12 +84,22 @@ void graphics_capture_initial_window(HWND hWnd) {
cfg::SCREENRESIZE->init_client_aspect_ratio = (float)client_w / (float)client_h; cfg::SCREENRESIZE->init_client_aspect_ratio = (float)client_w / (float)client_h;
log_debug( log_debug(
"graphics-windowed", "graphics-windowed",
"graphics_capture_initial_window initial window size {}x{}, ratio {}", "[{}] graphics_capture_initial_window initial window size {}x{}, ratio {}",
fmt::ptr(hWnd),
client_w, client_h, cfg::SCREENRESIZE->init_client_aspect_ratio); client_w, client_h, cfg::SCREENRESIZE->init_client_aspect_ratio);
// ensure frame size is captured // ensure frame size is captured
graphics_wm_style_changed(hWnd, false); graphics_wm_style_changed(hWnd, false);
// if the game is not compatible, ignore user-supplied values and keep the current size
if (graphics_window_resize_breaks_game()) {
cfg::SCREENRESIZE->client_width = client_w;
cfg::SCREENRESIZE->client_height = client_h;
}
if (graphics_window_move_and_resize_breaks_game()) {
cfg::SCREENRESIZE->enable_window_resize = false;
}
// if there was no user-supplied dimension, seed it with the current size // if there was no user-supplied dimension, seed it with the current size
// so that the next resize operation will work // so that the next resize operation will work
if (cfg::SCREENRESIZE->client_width == 0) { if (cfg::SCREENRESIZE->client_width == 0) {
@@ -98,7 +113,8 @@ void graphics_capture_initial_window(HWND hWnd) {
// resize must be done before applying the border // resize must be done before applying the border
if (cfg::SCREENRESIZE->enable_window_resize) { if (cfg::SCREENRESIZE->enable_window_resize) {
log_info( log_info(
"graphics-windowed", "change window rect - window offset: {}x{}, client size: {}x{}", "graphics-windowed", "[{}] change window rect - window offset: {}x{}, client size: {}x{}",
fmt::ptr(hWnd),
cfg::SCREENRESIZE->window_offset_x, cfg::SCREENRESIZE->window_offset_x,
cfg::SCREENRESIZE->window_offset_y, cfg::SCREENRESIZE->window_offset_y,
cfg::SCREENRESIZE->client_width, cfg::SCREENRESIZE->client_width,
@@ -108,12 +124,13 @@ void graphics_capture_initial_window(HWND hWnd) {
// ddr hangs when window frame doesn't have overlapped // ddr hangs when window frame doesn't have overlapped
if (cfg::SCREENRESIZE->window_decoration != cfg::WindowDecorationMode::Default) { if (cfg::SCREENRESIZE->window_decoration != cfg::WindowDecorationMode::Default) {
log_info( log_info(
"graphics-windowed", "change window style - decoration: {}", "graphics-windowed", "[{}] change window style - decoration: {}",
fmt::ptr(hWnd),
cfg::SCREENRESIZE->window_decoration); cfg::SCREENRESIZE->window_decoration);
graphics_update_window_style(hWnd); graphics_update_window_style(hWnd);
} }
if (cfg::SCREENRESIZE->window_always_on_top) { if (cfg::SCREENRESIZE->window_always_on_top) {
log_info("graphics-windowed", "change window z-order - always on top"); log_info("graphics-windowed", "[{}] change window z-order - always on top", fmt::ptr(hWnd));
graphics_update_z_order(hWnd, true); graphics_update_z_order(hWnd, true);
} }
@@ -156,7 +173,7 @@ void graphics_load_windowed_parameters() {
cfg::SCREENRESIZE->window_offset_x = result.first; cfg::SCREENRESIZE->window_offset_x = result.first;
cfg::SCREENRESIZE->window_offset_y = result.second; cfg::SCREENRESIZE->window_offset_y = result.second;
} else { } else {
log_warning("graphics-windowed", "failed to parse -windowpos"); log_fatal("graphics-windowed", "failed to parse -windowpos");
} }
} }
@@ -185,7 +202,7 @@ void graphics_load_windowed_subscreen_parameters() {
GRAPHICS_WSUB_WIDTH = result.first; GRAPHICS_WSUB_WIDTH = result.first;
GRAPHICS_WSUB_HEIGHT = result.second; GRAPHICS_WSUB_HEIGHT = result.second;
} else { } else {
log_warning("graphics-windowed", "failed to parse -wsubsize"); log_fatal("graphics-windowed", "failed to parse -iidxwsubsize / -sdvxwsubsize");
} }
} }
@@ -199,7 +216,7 @@ void graphics_load_windowed_subscreen_parameters() {
GRAPHICS_WSUB_X = result.first; GRAPHICS_WSUB_X = result.first;
GRAPHICS_WSUB_Y = result.second; GRAPHICS_WSUB_Y = result.second;
} else { } else {
log_warning("graphics-windowed", "failed to parse -wsubpos"); log_fatal("graphics-windowed", "failed to parse -iidxwsubpos / -sdvxwsubpos");
} }
} }
} }
@@ -372,7 +389,7 @@ void graphics_update_window_style(HWND hWnd) {
if (!GRAPHICS_WINDOWED) { if (!GRAPHICS_WINDOWED) {
return; return;
} }
if (graphics_window_change_crashes_game()) { if (graphics_window_decoration_change_crashes_game()) {
return; return;
} }
@@ -392,6 +409,9 @@ void graphics_update_window_style(HWND hWnd) {
break; break;
case cfg::WindowDecorationMode::ResizableFrame: case cfg::WindowDecorationMode::ResizableFrame:
style |= WS_OVERLAPPEDWINDOW; style |= WS_OVERLAPPEDWINDOW;
if (graphics_window_resize_breaks_game()) {
style &= ~WS_SIZEBOX;
}
break; break;
case cfg::WindowDecorationMode::Default: case cfg::WindowDecorationMode::Default:
default: default:
@@ -479,12 +499,19 @@ void graphics_move_resize_window(HWND hWnd) {
log_debug("graphics-windowed", "graphics_move_resize_window returned"); log_debug("graphics-windowed", "graphics_move_resize_window returned");
} }
bool graphics_window_change_crashes_game() { bool graphics_window_decoration_change_crashes_game() {
static std::once_flag flag; static std::once_flag flag;
static bool result = false; static bool result = false;
std::call_once(flag, []() { std::call_once(flag, []() {
// ddr crashes when frame style changes // ddr crashes when frame style changes
result = avs::game::is_model("MDX"); result = avs::game::is_model("MDX");
// changing window decoration also changes dimensions and position
// so this must be prevented
if (graphics_window_move_and_resize_breaks_game()) {
result = true;
}
if (result) { if (result) {
log_warning( log_warning(
"graphics-windowed", "graphics-windowed",
@@ -493,3 +520,43 @@ bool graphics_window_change_crashes_game() {
}); });
return result; return result;
} }
bool graphics_window_move_and_resize_breaks_game() {
static std::once_flag flag;
static bool result = false;
std::call_once(flag, []() {
// games like reflec beat in use spice touch overlay for windowed mode
// and mouse input breaks if window is moved as the overlay does not
// currently support window moves/resizes
result = avs::game::is_model({"KBR", "LBR", "MBR"});
if (result) {
log_warning(
"graphics-windowed",
"ignoring changes to window properties due to incompatibility with this game");
}
});
return result;
}
bool graphics_window_resize_breaks_game() {
// for whatever reason, gitadora games on dx/sd/sd2 cabs behave poorly when window is resized
// (eihter at launch or while it's running)
// usually results in: soft lock during scene transtions or really long transitions,
// backgrounds of menus not rendering, etc.
bool is_gitadora = avs::game::is_model({ "J32", "J33", "K32", "K33", "L32", "L33", "M32" });
bool is_arena = games::gitadora::is_arena_model();
bool result = graphics_window_move_and_resize_breaks_game() || (is_gitadora && !is_arena);
static std::once_flag flag;
std::call_once(flag, [&result]() {
if (result) {
log_warning(
"graphics-windowed",
"ignoring changes to window size due to incompatibility with this game");
}
});
return result;
}
+55 -7
View File
@@ -589,9 +589,25 @@ int main_implementation(int argc, char *argv[]) {
if (options[launcher::Options::GitaDoraCabinetType].is_active()) { if (options[launcher::Options::GitaDoraCabinetType].is_active()) {
games::gitadora::CAB_TYPE = options[launcher::Options::GitaDoraCabinetType].value_uint32(); games::gitadora::CAB_TYPE = options[launcher::Options::GitaDoraCabinetType].value_uint32();
} }
if (options[launcher::Options::GitaDoraArenaSingleWindow].value_bool() && GRAPHICS_WINDOWED) {
games::gitadora::ARENA_SINGLE_WINDOW = true;
}
if (options[launcher::Options::GitaDoraWailHold].is_active()) { if (options[launcher::Options::GitaDoraWailHold].is_active()) {
socd::TILT_HOLD_MS = options[launcher::Options::GitaDoraWailHold].value_uint32(); socd::TILT_HOLD_MS = options[launcher::Options::GitaDoraWailHold].value_uint32();
} }
if (options[launcher::Options::GitaDoraPickAlgo].is_active()) {
const auto text = options[launcher::Options::GitaDoraPickAlgo].value_text();
if (text == "legacy") {
games::gitadora::PICK_ALGO.reset();
} else if (text == "neutral") {
games::gitadora::PICK_ALGO = socd::SocdAlgorithm::Neutral;
} else if (text == "raw") {
games::gitadora::PICK_ALGO = socd::SocdAlgorithm::None;
}
}
if (options[launcher::Options::GitaDoraSubOverlaySize].is_active()) {
games::gitadora::SUBSCREEN_OVERLAY_SIZE = options[launcher::Options::GitaDoraSubOverlaySize].value_text();
}
if (options[launcher::Options::LoadNostalgiaModule].value_bool()) { if (options[launcher::Options::LoadNostalgiaModule].value_bool()) {
attach_nostalgia = true; attach_nostalgia = true;
} }
@@ -995,18 +1011,26 @@ int main_implementation(int argc, char *argv[]) {
if (options[launcher::Options::spice2x_DisableVolumeHook].value_bool()) { if (options[launcher::Options::spice2x_DisableVolumeHook].value_bool()) {
hooks::audio::VOLUME_HOOK_ENABLED = false; hooks::audio::VOLUME_HOOK_ENABLED = false;
} }
if (options[launcher::Options::AudioBackend].is_active()) { if (options[launcher::Options::AudioBackend].is_active()) {
auto &name = options[launcher::Options::AudioBackend].value_text(); auto &name = options[launcher::Options::AudioBackend].value_text();
auto backend = hooks::audio::name_to_backend(name.c_str()); auto backend = hooks::audio::name_to_backend(name.c_str());
if (!backend.has_value() && !cfg::CONFIGURATOR_STANDALONE) { if (!backend.has_value() && !cfg::CONFIGURATOR_STANDALONE) {
log_fatal("launcher", "invalid audio backend: {}", name); log_fatal("launcher", "invalid audio backend: {}", name);
} }
hooks::audio::BACKEND = backend; hooks::audio::BACKEND = backend;
} }
if (options[launcher::Options::AsioDriverId].is_active()) { if (options[launcher::Options::AsioDriverId].is_active()) {
hooks::audio::ASIO_DRIVER_ID = options[launcher::Options::AsioDriverId].value_uint32(); hooks::audio::ASIO_DRIVER_ID = options[launcher::Options::AsioDriverId].value_uint32();
} }
if (options[launcher::Options::AsioDriverName].is_active()) {
hooks::audio::BACKEND = hooks::audio::name_to_backend("asio");
hooks::audio::ASIO_DRIVER_NAME = options[launcher::Options::AsioDriverName].value_text();
// this new option overrides the old one
hooks::audio::ASIO_DRIVER_ID.reset();
}
if (options[launcher::Options::AudioDummy].value_bool()) { if (options[launcher::Options::AudioDummy].value_bool()) {
hooks::audio::USE_DUMMY = true; hooks::audio::USE_DUMMY = true;
} }
@@ -1067,8 +1091,8 @@ int main_implementation(int argc, char *argv[]) {
std::pair<uint32_t, uint32_t> result; std::pair<uint32_t, uint32_t> result;
if (parse_width_height(options[launcher::Options::spice2x_WindowSize].value_text(), result)) { if (parse_width_height(options[launcher::Options::spice2x_WindowSize].value_text(), result)) {
GRAPHICS_WINDOW_SIZE = result; GRAPHICS_WINDOW_SIZE = result;
} else { } else if (!cfg_run && !cfg::CONFIGURATOR_STANDALONE) {
log_warning("launcher", "failed to parse -windowsize"); log_fatal("launcher", "failed to parse -windowsize");
} }
} }
if (options[launcher::Options::spice2x_WindowPosition].is_active()) { if (options[launcher::Options::spice2x_WindowPosition].is_active()) {
@@ -1112,6 +1136,9 @@ int main_implementation(int argc, char *argv[]) {
if (options[launcher::Options::spice2x_DRSTransposeTouch].value_bool()) { if (options[launcher::Options::spice2x_DRSTransposeTouch].value_bool()) {
games::drs::TRANSPOSE_TOUCH = true; games::drs::TRANSPOSE_TOUCH = true;
} }
if (options[launcher::Options::DRSRGBCameraHook].value_bool()) {
games::drs::RGB_CAMERA_HOOK = true;
}
if (options[launcher::Options::spice2x_AutoCard].is_active()) { if (options[launcher::Options::spice2x_AutoCard].is_active()) {
const auto text = options[launcher::Options::spice2x_AutoCard].value_text(); const auto text = options[launcher::Options::spice2x_AutoCard].value_text();
if (text == "p1") { if (text == "p1") {
@@ -1366,12 +1393,33 @@ int main_implementation(int argc, char *argv[]) {
); );
} }
if (launcher::signal::DISABLE && !cfg::CONFIGURATOR_STANDALONE) {
log_warning(
"launcher",
"WARNING - user specified -signaldisable option\n\n\n"
"!!! !!!\n"
"!!! Using -signaldisable option disables all exception handling, !!!\n"
"!!! which means when the game crashes it will likely just vanish !!!\n"
"!!! without troubleshooting information in the logs. !!!\n"
"!!! !!!\n"
);
}
if (options[launcher::Options::FullscreenResolution].is_active()) { if (options[launcher::Options::FullscreenResolution].is_active()) {
std::pair<uint32_t, uint32_t> result; std::pair<uint32_t, uint32_t> result;
if (parse_width_height(options[launcher::Options::FullscreenResolution].value_text(), result)) { if (parse_width_height(options[launcher::Options::FullscreenResolution].value_text(), result)) {
GRAPHICS_FS_CUSTOM_RESOLUTION = result; GRAPHICS_FS_CUSTOM_RESOLUTION = result;
} else { } else if (!cfg_run && !cfg::CONFIGURATOR_STANDALONE) {
log_warning("launcher", "failed to parse -forceres"); log_fatal("launcher", "failed to parse -forceres");
}
}
if (options[launcher::Options::FullscreenSubResolution].is_active()) {
std::pair<uint32_t, uint32_t> result;
if (parse_width_height(options[launcher::Options::FullscreenSubResolution].value_text(), result)) {
GRAPHICS_FS_CUSTOM_RESOLUTION_SUB = result;
} else if (!cfg_run && !cfg::CONFIGURATOR_STANDALONE) {
log_fatal("launcher", "failed to parse -forceressub");
} }
} }
@@ -1848,7 +1896,7 @@ int main_implementation(int argc, char *argv[]) {
} }
// Polaris Chord // Polaris Chord
if (check_dll("kamunity.dll") && fileutils::dir_exists("game/svm_Data")) { if (check_dll("kamunity.dll") && fileutils::file_exists("game/svm.exe")) {
avs::game::DLL_NAME = "kamunity.dll"; avs::game::DLL_NAME = "kamunity.dll";
attach_io = true; attach_io = true;
attach_pc = true; attach_pc = true;
@@ -1887,7 +1935,7 @@ int main_implementation(int argc, char *argv[]) {
"This usually means one of the following:\n\n" "This usually means one of the following:\n\n"
" 1. You put spice executables in the wrong place, or\n" " 1. You put spice executables in the wrong place, or\n"
" 2. XML files in prop directory are malformed or missing, or\n" " 2. XML files in prop directory are malformed or missing, or\n"
" 3. You passed in invalid options (usually, path overrides like -exec)\n\n" " 3. You passed in invalid options (do not specify -exec or -modules if you don't know what you're doing)\n\n"
); );
log_fatal("launcher", "module auto detection failed, see log.txt for troubleshooting"); log_fatal("launcher", "module auto detection failed, see log.txt for troubleshooting");
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -31,6 +31,7 @@ namespace launcher {
GraphicsForceRefresh, GraphicsForceRefresh,
FullscreenResolution, FullscreenResolution,
FullscreenOrientationFlip, FullscreenOrientationFlip,
FullscreenSubResolution,
FullscreenSubRefreshRate, FullscreenSubRefreshRate,
Graphics9On12, Graphics9On12,
spice2x_Dx9On12, spice2x_Dx9On12,
@@ -85,11 +86,11 @@ namespace launcher {
SDVXPrinterJPGQuality, SDVXPrinterJPGQuality,
SDVXDisableCameras, SDVXDisableCameras,
SDVXNativeTouch, SDVXNativeTouch,
spice2x_SDVXSubRedraw,
spice2x_SDVXDigitalKnobSensitivity, spice2x_SDVXDigitalKnobSensitivity,
SDVXDigitalKnobSocd, SDVXDigitalKnobSocd,
spice2x_SDVXAsioDriver, spice2x_SDVXAsioDriver,
spice2x_SDVXSubPos, spice2x_SDVXSubPos,
spice2x_SDVXSubRedraw,
LoadDDRModule, LoadDDRModule,
DDR43Mode, DDR43Mode,
DDRSkipCodecRegisteration, DDRSkipCodecRegisteration,
@@ -100,8 +101,11 @@ namespace launcher {
LoadGitaDoraModule, LoadGitaDoraModule,
GitaDoraTwoChannelAudio, GitaDoraTwoChannelAudio,
GitaDoraCabinetType, GitaDoraCabinetType,
GitaDoraArenaSingleWindow,
GitaDoraLefty, GitaDoraLefty,
GitaDoraWailHold, GitaDoraWailHold,
GitaDoraPickAlgo,
GitaDoraSubOverlaySize,
LoadJubeatModule, LoadJubeatModule,
LoadReflecBeatModule, LoadReflecBeatModule,
LoadShogikaiModule, LoadShogikaiModule,
@@ -183,6 +187,7 @@ namespace launcher {
spice2x_DisableVolumeHook, spice2x_DisableVolumeHook,
AudioBackend, AudioBackend,
AsioDriverId, AsioDriverId,
AsioDriverName,
AudioDummy, AudioDummy,
DelayBy5Seconds, DelayBy5Seconds,
spice2x_DelayByNSeconds, spice2x_DelayByNSeconds,
@@ -234,6 +239,7 @@ namespace launcher {
spice2x_IIDXWindowedTDJ, spice2x_IIDXWindowedTDJ,
spice2x_DRSDisableTouch, spice2x_DRSDisableTouch,
spice2x_DRSTransposeTouch, spice2x_DRSTransposeTouch,
DRSRGBCameraHook,
spice2x_IIDXNativeTouch, spice2x_IIDXNativeTouch,
spice2x_IIDXNoSub, spice2x_IIDXNoSub,
spice2x_IIDXEmulateSubscreenKeypadTouch, spice2x_IIDXEmulateSubscreenKeypadTouch,
+14 -5
View File
@@ -185,21 +185,30 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception
} }
static BOOL WINAPI SetConsoleCtrlHandler_hook(PHANDLER_ROUTINE pHandlerRoutine, BOOL Add) { static BOOL WINAPI SetConsoleCtrlHandler_hook(PHANDLER_ROUTINE pHandlerRoutine, BOOL Add) {
log_misc("signal", "SetConsoleCtrlHandler hook hit"); static std::once_flag printed;
std::call_once(printed, []() {
log_misc("signal", "SetConsoleCtrlHandler hook hit (printing once)");
});
return TRUE; return TRUE;
} }
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter_hook( static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter_hook(
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) {
{
log_info("signal", "SetUnhandledExceptionFilter hook hit"); static std::once_flag printed;
std::call_once(printed, []() {
log_info("signal", "SetUnhandledExceptionFilter hook hit (printing once)");
});
return nullptr; return nullptr;
} }
static PVOID WINAPI AddVectoredExceptionHandler_hook(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler) { static PVOID WINAPI AddVectoredExceptionHandler_hook(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler) {
log_info("signal", "AddVectoredExceptionHandler hook hit"); static std::once_flag printed;
std::call_once(printed, []() {
log_info("signal", "AddVectoredExceptionHandler hook hit (printing once)");
});
return launcher::signal::USE_VEH_WORKAROUND ? INVALID_HANDLE_VALUE : nullptr; return launcher::signal::USE_VEH_WORKAROUND ? INVALID_HANDLE_VALUE : nullptr;
} }
+46 -14
View File
@@ -119,6 +119,7 @@ static std::string EAMIO_DLL_NAME = "eamio.dll";
static robin_hood::unordered_map<int, std::thread *> BT5API_THREADS; static robin_hood::unordered_map<int, std::thread *> BT5API_THREADS;
static robin_hood::unordered_map<int, int> BT5API_THREAD_RESULTS; static robin_hood::unordered_map<int, int> BT5API_THREAD_RESULTS;
static uint8_t BT5API_CARD_STATES[] = {0, 0}; static uint8_t BT5API_CARD_STATES[] = {0, 0};
static uint16_t BT5API_KEYPAD_STATES[] = {0, 0};
static void bt5api_log(const char *bt5_module, const char *fmt, ...) { static void bt5api_log(const char *bt5_module, const char *fmt, ...) {
@@ -240,46 +241,77 @@ void bt5api_hook(HINSTANCE module) {
void bt5api_poll_reader_card(uint8_t unit_no) { void bt5api_poll_reader_card(uint8_t unit_no) {
// check if initialized // check if initialized or out of bounds
if (!EAMIO_DLL) { if (!EAMIO_DLL || unit_no >= eamuse_get_game_keypads()) {
return; return;
} }
// poll // poll
if (!eam_io_poll(unit_no)) { if (!eam_io_poll(unit_no)) {
log_warning("bt5api", "polling bt5api reader {} returned failure", log_warning("bt5api", "polling bt5api reader card {} returned failure",
static_cast<int>(unit_no)); static_cast<int>(unit_no));
return;
} }
// get sensor state // get sensor state
uint8_t sensor_state = eam_io_get_sensor_state(unit_no); uint8_t sensor_state = eam_io_get_sensor_state(unit_no);
// check for card in // if we have a change in state.
if (sensor_state > BT5API_CARD_STATES[unit_no]) { if(sensor_state != BT5API_CARD_STATES[unit_no]) {
// card inserted into the back.
if(sensor_state & (1 << EAM_IO_SENSOR_BACK)) {
uint8_t card_id[8]; uint8_t card_id[8];
log_info("bt5api", "card unit {} inserted", static_cast<int>(unit_no));
// do the bt5 dance
eam_io_card_slot_cmd(unit_no, EAM_IO_CARD_SLOT_CMD_CLOSE);
eam_io_poll(unit_no);
eam_io_card_slot_cmd(unit_no, EAM_IO_CARD_SLOT_CMD_READ);
eam_io_poll(unit_no);
// ask the api for the card, then insert it into our engine.
eam_io_read_card(unit_no, card_id, 8); eam_io_read_card(unit_no, card_id, 8);
eamuse_card_insert(unit_no, card_id); eamuse_card_insert(unit_no, card_id);
} }
// save state // if card removed entirely, do another bt5 dance!
if(sensor_state == 0) {
eam_io_card_slot_cmd(unit_no, EAM_IO_CARD_SLOT_CMD_CLOSE);
eam_io_poll(unit_no);
eam_io_card_slot_cmd(unit_no, EAM_IO_CARD_SLOT_CMD_OPEN);
log_info("bt5api", "card unit {} removed", static_cast<int>(unit_no));
}
}
// save prev state
BT5API_CARD_STATES[unit_no] = sensor_state; BT5API_CARD_STATES[unit_no] = sensor_state;
} }
void bt5api_poll_reader_keypad(uint8_t unit_no) { void bt5api_poll_reader_keypad(uint8_t unit_no) {
// check if initialized // check if initialized or out of bounds
if (!EAMIO_DLL) { if (!EAMIO_DLL || unit_no >= eamuse_get_game_keypads()) {
return; return;
} }
// poll uint16_t keypad_current = eam_io_get_keypad_state(unit_no);
if (!eam_io_poll(unit_no)) { uint16_t keypad_changes = ~BT5API_KEYPAD_STATES[unit_no] & keypad_current;
log_warning("bt5api", "polling bt5api reader {} returned failure",
static_cast<int>(unit_no)); // if user has pressed decimal for the first time, eject the slotted reader.
if(keypad_changes & (1 << EAM_IO_KEYPAD_DECIMAL)) {
log_info("bt5api", "card unit {} ejecting", static_cast<int>(unit_no));
eam_io_card_slot_cmd(unit_no, EAM_IO_CARD_SLOT_CMD_EJECT);
} }
// get keypad // save the last pressed.
eamuse_set_keypad_overrides_bt5(unit_no, eam_io_get_keypad_state(unit_no)); BT5API_KEYPAD_STATES[unit_no] = keypad_current;
// send off the state to the main engine.
eamuse_set_keypad_overrides_bt5(unit_no, keypad_current);
} }
void bt5api_dispose() { void bt5api_dispose() {
+7
View File
@@ -202,8 +202,15 @@ bool eamuse_card_insert_consume(int active_count, int unit_id) {
// bt5api // bt5api
if (BT5API_ENABLED) { if (BT5API_ENABLED) {
// some bt5api want to be polled in order.
if (eamuse_get_game_keypads() > 1) {
bt5api_poll_reader_card(1);
bt5api_poll_reader_card(0);
}
else {
bt5api_poll_reader_card((uint8_t) index); bt5api_poll_reader_card((uint8_t) index);
} }
}
// auto insert card // auto insert card
if (AUTO_INSERT_CARD[index]) { if (AUTO_INSERT_CARD[index]) {
+22 -4
View File
@@ -522,8 +522,11 @@ static long __cdecl gfdm_unit_get_input_p(int device, size_t player) {
if (games::gitadora::is_guitar()) { if (games::gitadora::is_guitar()) {
auto offset = player * 11; auto offset = player * 11;
// pick up const auto pick_up = Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[3 + offset]));
if (Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[3 + offset]))) { const auto pick_down = Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[4 + offset]));
if (!games::gitadora::PICK_ALGO.has_value()) {
// legacy behavior (detect rising edges only, input for 1 frame)
if (pick_up) {
if (!GFDM_GF_PICK_STATE_UP[player]) { if (!GFDM_GF_PICK_STATE_UP[player]) {
GFDM_GF_PICK_STATE_UP[player] = true; GFDM_GF_PICK_STATE_UP[player] = true;
ret |= 0x80 | 0x20; ret |= 0x80 | 0x20;
@@ -532,8 +535,7 @@ static long __cdecl gfdm_unit_get_input_p(int device, size_t player) {
GFDM_GF_PICK_STATE_UP[player] = false; GFDM_GF_PICK_STATE_UP[player] = false;
} }
// pick down if (pick_down) {
if (Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[4 + offset]))) {
if (!GFDM_GF_PICK_STATE_DOWN[player]) { if (!GFDM_GF_PICK_STATE_DOWN[player]) {
GFDM_GF_PICK_STATE_DOWN[player] = true; GFDM_GF_PICK_STATE_DOWN[player] = true;
ret |= 0x100 | 0x20; ret |= 0x100 | 0x20;
@@ -541,6 +543,22 @@ static long __cdecl gfdm_unit_get_input_p(int device, size_t player) {
} else { } else {
GFDM_GF_PICK_STATE_DOWN[player] = false; GFDM_GF_PICK_STATE_DOWN[player] = false;
} }
} else {
const auto socd = socd::socd_clean(
player,
pick_up,
pick_down,
get_performance_milliseconds(),
games::gitadora::PICK_ALGO.value()
);
if (socd == socd::SocdCCW) {
ret |= 0x80 | 0x20; // pick up
} else if (socd == socd::SocdCW) {
ret |= 0x100 | 0x20; // pick down
} else if (socd == socd::SocdBoth) {
ret |= 0x100 | 0x80 | 0x20; // up and down
}
}
// button R // button R
if (Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[5 + offset]))) { if (Buttons::getState(RI_MGR, buttons.at(gitadora_button_mapping[5 + offset]))) {
+27
View File
@@ -2,7 +2,10 @@
// mingw otherwise doesn't load touch stuff // mingw otherwise doesn't load touch stuff
#define _WIN32_WINNT 0x0601 #define _WIN32_WINNT 0x0601
#include "avs/game.h"
#include "wintouchemu.h" #include "wintouchemu.h"
#include "rawinput/touch.h"
#include "hooks/graphics/graphics.h"
#include "util/detour.h" #include "util/detour.h"
#include "util/logging.h" #include "util/logging.h"
@@ -63,6 +66,11 @@ namespace nativetouchhook {
point->cyContact = 0; point->cyContact = 0;
} }
static void flip_touch_points(PTOUCHINPUT point) {
point->x = rawinput::touch::DISPLAY_SIZE_X * 100 - point->x;
point->y = rawinput::touch::DISPLAY_SIZE_Y * 100 - point->y;
}
static BOOL WINAPI GetTouchInputInfoHook( static BOOL WINAPI GetTouchInputInfoHook(
HTOUCHINPUT hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) { HTOUCHINPUT hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) {
@@ -72,11 +80,30 @@ namespace nativetouchhook {
return result; return result;
} }
bool flip_values = false;
if (avs::game::is_model("KFC") && rawinput::touch::DISPLAY_INITIALIZED) {
log_debug(
"touch::native", "DISPLAY_ORIENTATION = {}, DISPLAY_SIZE_X = {}, DISPLAY_SIZE_Y = {}",
rawinput::touch::DISPLAY_ORIENTATION,
rawinput::touch::DISPLAY_SIZE_X,
rawinput::touch::DISPLAY_SIZE_Y);
if (rawinput::touch::DISPLAY_ORIENTATION == DMDO_270) {
flip_values = true;
}
}
for (size_t i = 0; i < cInputs; i++) { for (size_t i = 0; i < cInputs; i++) {
PTOUCHINPUT point = &pInputs[i]; PTOUCHINPUT point = &pInputs[i];
if (avs::game::is_model("LDJ")) {
strip_contact_size(point); strip_contact_size(point);
} }
if (flip_values) {
flip_touch_points(point);
}
}
return result; return result;
} }
+17 -1
View File
@@ -10,6 +10,7 @@
#include <thread> #include <thread>
#include "cfg/screen_resize.h" #include "cfg/screen_resize.h"
#include "games/gitadora/gitadora.h"
#include "games/iidx/iidx.h" #include "games/iidx/iidx.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "overlay/overlay.h" #include "overlay/overlay.h"
@@ -19,6 +20,7 @@
#include "util/logging.h" #include "util/logging.h"
#include "util/time.h" #include "util/time.h"
#include "util/utils.h" #include "util/utils.h"
#include "rawinput/touch.h"
#include "avs/game.h" #include "avs/game.h"
@@ -125,6 +127,11 @@ namespace wintouchemu {
WINDOW_TITLE_END = window_title_end; WINDOW_TITLE_END = window_title_end;
} }
static void flip_touch_points(PTOUCHINPUT point) {
point->x = rawinput::touch::DISPLAY_SIZE_X * 100 - point->x;
point->y = rawinput::touch::DISPLAY_SIZE_Y * 100 - point->y;
}
static BOOL WINAPI GetTouchInputInfoHook(HANDLE hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) { static BOOL WINAPI GetTouchInputInfoHook(HANDLE hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) {
// check if original should be called // check if original should be called
@@ -219,6 +226,12 @@ namespace wintouchemu {
touch_input->cxContact = 0; touch_input->cxContact = 0;
touch_input->cyContact = 0; touch_input->cyContact = 0;
if (avs::game::is_model("KFC") &&
rawinput::touch::DISPLAY_INITIALIZED &&
rawinput::touch::DISPLAY_ORIENTATION == DMDO_270) {
flip_touch_points(touch_input);
}
} else if (USE_MOUSE && !mouse_used) { } else if (USE_MOUSE && !mouse_used) {
// disable further mouse inputs this call // disable further mouse inputs this call
@@ -390,7 +403,10 @@ namespace wintouchemu {
} else if (avs::game::is_model("LDJ") && !GENERIC_SUB_WINDOW_FULLSIZE) { } else if (avs::game::is_model("LDJ") && !GENERIC_SUB_WINDOW_FULLSIZE) {
// overlay subscreen in IIDX // overlay subscreen in IIDX
// use mouse position as ImGui overlay will block the touch window // use mouse position as ImGui overlay will block the touch window
log_info("wintouchemu", "use mouse cursor API for overlay subscreen"); log_info("wintouchemu", "use mouse cursor API for ldj overlay subscreen");
USE_MOUSE = true;
} else if (games::gitadora::is_arena_model() && games::gitadora::ARENA_SINGLE_WINDOW) {
log_info("wintouchemu", "use mouse cursor API for gitadora overlay subscreen");
USE_MOUSE = true; USE_MOUSE = true;
} else { } else {
// create touch window - create overlay if not yet existing at this point // create touch window - create overlay if not yet existing at this point
+30 -6
View File
@@ -236,6 +236,26 @@ namespace nvapi {
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting); return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
} }
NvAPI_Status set_refresh_rate(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
auto drs_setting = NVDRS_SETTING {};
drs_setting.version = NVDRS_SETTING_VER;
drs_setting.settingId = REFRESH_RATE_OVERRIDE_ID;
drs_setting.settingType = NVDRS_DWORD_TYPE;
drs_setting.u32PredefinedValue = REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED;
drs_setting.u32CurrentValue = REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED;
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
}
NvAPI_Status set_max_fps(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
auto drs_setting = NVDRS_SETTING {};
drs_setting.version = NVDRS_SETTING_VER;
drs_setting.settingId = FRL_FPS_ID;
drs_setting.settingType = NVDRS_DWORD_TYPE;
drs_setting.u32PredefinedValue = FRL_FPS_DISABLED;
drs_setting.u32CurrentValue = FRL_FPS_DISABLED;
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
}
void set_profile_settings() { void set_profile_settings() {
if (!NVAPI_MODULE_LOAD_SUCCEEDED) { if (!NVAPI_MODULE_LOAD_SUCCEEDED) {
return; return;
@@ -266,22 +286,26 @@ namespace nvapi {
log_info("nvapi", "setting VSync to Application Controlled..."); log_info("nvapi", "setting VSync to Application Controlled...");
if ((status = set_vsync_mode(h_session, h_profile)) != NVAPI_OK) { if ((status = set_vsync_mode(h_session, h_profile)) != NVAPI_OK) {
log_warning("nvapi", "could not set VSync mode: {}", get_error_message(status)); log_warning("nvapi", "could not set VSync mode: {}", get_error_message(status));
NvAPI_DRS_DestroySession(h_session);
return;
} }
log_info("nvapi", "applying preferred PState to Maximum Performance..."); log_info("nvapi", "applying preferred PState to Maximum Performance...");
if ((status = set_gpu_power_state(h_session, h_profile)) != NVAPI_OK) { if ((status = set_gpu_power_state(h_session, h_profile)) != NVAPI_OK) {
log_warning("nvapi", "could not set preferred PState: {}", get_error_message(status)); log_warning("nvapi", "could not set preferred PState: {}", get_error_message(status));
NvAPI_DRS_DestroySession(h_session);
return;
} }
log_info("nvapi", "disabling G-SYNC..."); log_info("nvapi", "disabling G-SYNC...");
if ((status = set_gsync_mode(h_session, h_profile)) != NVAPI_OK) { if ((status = set_gsync_mode(h_session, h_profile)) != NVAPI_OK) {
log_warning("nvapi", "could not set G-Sync mode: {}", get_error_message(status)); log_warning("nvapi", "could not set G-Sync mode: {}", get_error_message(status));
NvAPI_DRS_DestroySession(h_session); }
return;
log_info("nvapi", "setting preferred refresh rate to Application Controlled...");
if ((status = set_refresh_rate(h_session, h_profile)) != NVAPI_OK) {
log_warning("nvapi", "could not set preferred refresh rate: {}", get_error_message(status));
}
log_info("nvapi", "disabling max framerate...");
if ((status = set_max_fps(h_session, h_profile)) != NVAPI_OK) {
log_warning("nvapi", "could not disable max framerate: {}", get_error_message(status));
} }
log_info("nvapi", "saving settings for DRS session..."); log_info("nvapi", "saving settings for DRS session...");
+73 -2
View File
@@ -26,7 +26,7 @@ namespace ImGui {
void HelpMarker(const char* desc) { void HelpMarker(const char* desc) {
ImGui::TextDisabled("(?)"); ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(TOOLTIP_FLAGS)) {
HelpTooltip(desc); HelpTooltip(desc);
} }
} }
@@ -59,7 +59,7 @@ namespace ImGui {
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.f, 1.f, 0.f, 1.f)); ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.f, 1.f, 0.f, 1.f));
ImGui::TextDisabled("(!)"); ImGui::TextDisabled("(!)");
ImGui::PopStyleColor(); ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(TOOLTIP_FLAGS)) {
WarnTooltip(desc, warn); WarnTooltip(desc, warn);
} }
} }
@@ -92,4 +92,75 @@ namespace ImGui {
ImGui::GetColorU32(ImGuiCol_PlotHistogram), ImGui::GetColorU32(ImGuiCol_PlotHistogram),
thickness); thickness);
} }
std::string TruncateText(const std::string& p_text, float p_truncated_width, bool &truncated) {
std::string truncated_text = p_text;
const float text_width =
ImGui::CalcTextSize(p_text.c_str(), nullptr, true).x;
if (text_width > p_truncated_width) {
truncated = true;
constexpr const char* ELLIPSIS = " ...";
const float ellipsis_size = ImGui::CalcTextSize(ELLIPSIS).x;
int visible_chars = 0;
for (size_t i = 0; i < p_text.size(); i++) {
const float current_width = ImGui::CalcTextSize(
p_text.substr(0, i).c_str(), nullptr, true)
.x;
if (current_width + ellipsis_size > p_truncated_width) {
break;
}
visible_chars = i;
}
truncated_text = (p_text.substr(0, visible_chars) + ELLIPSIS).c_str();
}
return truncated_text;
}
void TextTruncated(const std::string& p_text, float p_truncated_width) {
if (p_text.empty()) {
ImGui::TextDisabled("-");
return;
}
bool truncated = false;
ImGui::TextUnformatted(TruncateText(p_text, p_truncated_width, truncated).c_str());
if (truncated && ImGui::IsItemHovered(TOOLTIP_FLAGS)) {
ImGui::HelpTooltip(p_text.c_str());
}
}
bool DeleteButton(const std::string& tooltip) {
ImGui::PushID(tooltip.c_str());
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_Button, 0.7f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(3.f, 2.f));
bool clicked = ImGui::SmallButton("\u00D7"); // multiplication sign (×)
ImGui::PopStyleVar();
ImGui::PopStyleColor();
if (!tooltip.empty() && ImGui::IsItemHovered(TOOLTIP_FLAGS)) {
ImGui::HelpTooltip(tooltip.c_str());
}
ImGui::PopID();
return clicked;
}
bool ClearButton(const std::string& tooltip) {
ImGui::PushID(tooltip.c_str());
// same colors as a checkbox
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_FrameBg));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_FrameBgHovered));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetColorU32(ImGuiCol_FrameBgActive));
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.97f, 0.97f, 0.97f, 1.00f));
bool clicked = ImGui::Button("\u00D7"); // multiplication sign (×)
ImGui::PopStyleColor(4);
if (!tooltip.empty() && ImGui::IsItemHovered(TOOLTIP_FLAGS)) {
ImGui::HelpTooltip(tooltip.c_str());
}
ImGui::PopID();
return clicked;
}
} }
+11
View File
@@ -1,12 +1,23 @@
#pragma once #pragma once
#include <string>
#include "external/imgui/imgui.h"
namespace ImGui { namespace ImGui {
constexpr ImGuiHoveredFlags TOOLTIP_FLAGS =
(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled);
void HelpTooltip(const char* desc); void HelpTooltip(const char* desc);
void HelpMarker(const char* desc); void HelpMarker(const char* desc);
void WarnTooltip(const char* desc, const char* warn); void WarnTooltip(const char* desc, const char* warn);
void WarnMarker(const char* desc, const char* warn); void WarnMarker(const char* desc, const char* warn);
void DummyMarker(); void DummyMarker();
void Knob(float fraction, float size, float thickness = 2.f, void Knob(float fraction, float size, float thickness = 2.f,
float pos_x = -1.f, float pos_y = -1.f); float pos_x = -1.f, float pos_y = -1.f);
void TextTruncated(const std::string& p_text, float p_truncated_width);
bool DeleteButton(const std::string& tooltip);
bool ClearButton(const std::string& tooltip);
} }
+1 -1
View File
@@ -283,7 +283,7 @@ void ImGui_ImplSpice_NewFrame() {
memset(io.MouseDown, false, sizeof(io.MouseDown)); memset(io.MouseDown, false, sizeof(io.MouseDown));
// early quit if window not in focus // early quit if window not in focus
if (!superexit::has_focus()) { if (!superexit::has_focus() || rawinput::OS_WINDOW_ACTIVE) {
return; return;
} }
+4
View File
@@ -29,6 +29,7 @@
#include "windows/generic_sub.h" #include "windows/generic_sub.h"
#include "windows/iidx_seg.h" #include "windows/iidx_seg.h"
#include "windows/iidx_sub.h" #include "windows/iidx_sub.h"
#include "windows/gfdm_sub.h"
#include "windows/drs_dancefloor.h" #include "windows/drs_dancefloor.h"
#include "windows/iopanel.h" #include "windows/iopanel.h"
#include "windows/iopanel_ddr.h" #include "windows/iopanel_ddr.h"
@@ -410,7 +411,10 @@ void overlay::SpiceOverlay::init() {
window_sub = new overlay::windows::DRSDanceFloorDisplay(this); window_sub = new overlay::windows::DRSDanceFloorDisplay(this);
} else if (avs::game::is_model("KFC")) { } else if (avs::game::is_model("KFC")) {
window_sub = new overlay::windows::SDVXSubScreen(this); window_sub = new overlay::windows::SDVXSubScreen(this);
} else if (games::gitadora::is_arena_model() && games::gitadora::ARENA_SINGLE_WINDOW) {
window_sub = new overlay::windows::GitaDoraSubScreen(this);
} }
if (window_sub) { if (window_sub) {
this->window_add(window_sub); this->window_add(window_sub);
if (AUTO_SHOW_SUBSCREEN) { if (AUTO_SHOW_SUBSCREEN) {
File diff suppressed because it is too large Load Diff
+45 -15
View File
@@ -38,7 +38,6 @@ namespace overlay::windows {
ConfigTab tab_selected = ConfigTab::CONFIG_TAB_INVALID; ConfigTab tab_selected = ConfigTab::CONFIG_TAB_INVALID;
// buttons tab // buttons tab
int buttons_page = 0;
bool buttons_keyboard_state[0xFF]; bool buttons_keyboard_state[0xFF];
bool buttons_bind_active = false; bool buttons_bind_active = false;
bool buttons_many_active = false; bool buttons_many_active = false;
@@ -55,7 +54,6 @@ namespace overlay::windows {
int analogs_devices_control_selected = -1; int analogs_devices_control_selected = -1;
// lights tab // lights tab
int lights_page = 0;
std::vector<rawinput::Device *> lights_devices; std::vector<rawinput::Device *> lights_devices;
int lights_devices_selected = -1; int lights_devices_selected = -1;
int lights_devices_control_selected = -1; int lights_devices_control_selected = -1;
@@ -78,6 +76,51 @@ namespace overlay::windows {
std::string search_filter = ""; std::string search_filter = "";
std::string search_filter_in_lower_case = ""; std::string search_filter_in_lower_case = "";
std::filesystem::path file_picker_path;
std::thread *file_picker_thread = nullptr;
bool file_picker_done = false;
void build_buttons(const std::string &name, std::vector<Button> *buttons, int min = 0, int max = -1);
void build_button(
const std::string &name,
Button &primary_button,
Button *button,
const int button_it,
const int button_it_max,
const int alt_index);
void bind_button_popup(const std::string &bind_name, Button *button, const int button_it_max, const int alt_index);
void naive_button_popup(const std::string &naive_string, Button *button, const int button_it_max, const int alt_index);
void edit_button_popup(
const std::string &edit_name,
const std::string &button_display,
Button *button,
const float button_velocity,
const int alt_index);
void clear_button(Button *button, const int alt_index);
void build_analogs(const std::string &name, std::vector<Analog> *analogs);
void edit_analog_popup(Analog &analog);
void build_lights(const std::string &name, std::vector<Light> *lights);
void build_light(Light &primary_light, Light *light, const int light_index, const int alt_index);
void clear_light(Light *light, const int alt_index);
void edit_light_popup(Light &primary_light, Light *light, const int alt_index);
void build_cards();
std::string build_option_value_picker_title(const OptionDefinition& option);
void build_option_value_picker(Option& option);
void build_options(
std::vector<Option> *options, const std::string &category, const std::string *filter=nullptr);
void build_about();
void build_launcher();
void launch_shell(LPCSTR app, LPCSTR file=nullptr);
void build_menu(int *game_selected);
void shutdown_system(bool force, bool reboot_instead);
void set_alternating_row_colors(const int row_index);
public: public:
Config(SpiceOverlay *overlay); Config(SpiceOverlay *overlay);
~Config() override; ~Config() override;
@@ -85,19 +128,6 @@ namespace overlay::windows {
void read_card(int player = -1); void read_card(int player = -1);
void write_card(int player); void write_card(int player);
void build_content() override; void build_content() override;
void build_buttons(const std::string &name, std::vector<Button> *buttons,
int min = 0, int max = -1);
void build_analogs(const std::string &name, std::vector<Analog> *analogs);
void build_lights(const std::string &name, std::vector<Light> *lights);
void build_cards();
void build_options(
std::vector<Option> *options, const std::string &category, const std::string *filter=nullptr);
void build_about();
void build_launcher();
void launch_shell(LPCSTR app, LPCSTR file=nullptr);
static void build_page_selector(int *page);
void build_menu(int *game_selected);
void shutdown_system(bool force, bool reboot_instead);
}; };
} }
@@ -3,6 +3,7 @@
#include "misc/eamuse.h" #include "misc/eamuse.h"
#include "util/logging.h" #include "util/logging.h"
#include "games/iidx/iidx.h" #include "games/iidx/iidx.h"
#include "games/gitadora/gitadora.h"
namespace overlay::windows { namespace overlay::windows {
@@ -69,6 +70,8 @@ namespace overlay::windows {
sub = "Show Valkyrie Subscreen"; sub = "Show Valkyrie Subscreen";
} else if (avs::game::is_model("REC")) { } else if (avs::game::is_model("REC")) {
sub = "Show DRS Dance Floor"; sub = "Show DRS Dance Floor";
} else if (games::gitadora::is_arena_model() && games::gitadora::ARENA_SINGLE_WINDOW) {
sub = "Show GITADORA Subscreen";
} }
build_button(this->overlay->window_sub, sub, size, NextItem::NEW_LINE, false); build_button(this->overlay->window_sub, sub, size, NextItem::NEW_LINE, false);
@@ -85,10 +85,12 @@ namespace overlay::windows {
} }
void GenericSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {} void GenericSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {}
void GenericSubScreen::check_for_errors() {}
void GenericSubScreen::build_content() { void GenericSubScreen::build_content() {
this->flags |= ImGuiWindowFlags_NoBackground; this->flags |= ImGuiWindowFlags_NoBackground;
check_for_errors();
if (this->disabled_message.has_value()) { if (this->disabled_message.has_value()) {
this->draws_window = true; this->draws_window = true;
this->flags &= ~ImGuiWindowFlags_NoBackground; this->flags &= ~ImGuiWindowFlags_NoBackground;
@@ -31,6 +31,7 @@ namespace overlay::windows {
protected: protected:
virtual void touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out); virtual void touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out);
virtual void check_for_errors();
ImVec2 overlay_content_top_left; ImVec2 overlay_content_top_left;
ImVec2 overlay_content_size; ImVec2 overlay_content_size;
std::optional<std::string> disabled_message = std::nullopt; std::optional<std::string> disabled_message = std::nullopt;
+54
View File
@@ -0,0 +1,54 @@
#include "avs/game.h"
#include "gfdm_sub.h"
#include "games/gitadora/gitadora.h"
#include "hooks/graphics/graphics.h"
#include "touch/touch.h"
namespace overlay::windows {
GitaDoraSubScreen::GitaDoraSubScreen(SpiceOverlay *overlay) : GenericSubScreen(overlay) {
this->title = "GITADORA Subscreen";
if (!games::gitadora::is_arena_model()) {
this->disabled_message = "Requires Arena Model!";
}
this->resize_callback = keep_10_by_16;
// medium size - perfect for "layout B" in GW Delta, though in drums it covers the pacemaker
float size = 0.64f;
if (games::gitadora::SUBSCREEN_OVERLAY_SIZE.has_value()) {
if (games::gitadora::SUBSCREEN_OVERLAY_SIZE.value() == "large") {
// enough to not cover the FPS overlay
size = 0.88f;
} else if (games::gitadora::SUBSCREEN_OVERLAY_SIZE.value() == "small") {
size = 0.48f;
}
}
const float height = ImGui::GetIO().DisplaySize.y * size;
const float width = height * 10 / 16;
this->init_size = ImVec2(width, height + ImGui::GetFrameHeight());
// bottom right
this->init_pos = ImVec2(
ImGui::GetIO().DisplaySize.x - ImGui::GetFrameHeight() / 4 - this->init_size.x,
ImGui::GetIO().DisplaySize.y - this->init_size.y - (ImGui::GetFrameHeight() / 4));
}
void GitaDoraSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {
if (!this->get_active()) {
return;
}
if (GRAPHICS_WINDOWED) {
// Touch needs to be registered on global coords
*x_out = SPICETOUCH_TOUCH_X + xy_in.x * SPICETOUCH_TOUCH_WIDTH;
*y_out = SPICETOUCH_TOUCH_Y + xy_in.y * SPICETOUCH_TOUCH_HEIGHT;
} else {
// Fullscreen mode, scale to game coords
*x_out = xy_in.x * ImGui::GetIO().DisplaySize.x;
*y_out = xy_in.y * ImGui::GetIO().DisplaySize.y;
}
}
}
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#include "overlay/window.h"
#include "overlay/windows/generic_sub.h"
namespace overlay::windows {
class GitaDoraSubScreen : public GenericSubScreen {
public:
GitaDoraSubScreen(SpiceOverlay *overlay);
protected:
void touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) override;
private:
static void keep_10_by_16(ImGuiSizeCallbackData* data) {
data->DesiredSize.y = (data->DesiredSize.x * 16.f / 10.f) + ImGui::GetFrameHeight();
}
};
}
+18
View File
@@ -14,6 +14,7 @@ namespace overlay::windows {
static const size_t TICKER_SIZE = 9; static const size_t TICKER_SIZE = 9;
static const ImVec4 DARK_GRAY(0.1f, 0.1f, 0.1f, 1.f); static const ImVec4 DARK_GRAY(0.1f, 0.1f, 0.1f, 1.f);
static const ImVec4 YELLOW(1.f, 1.f, 0.f, 1.f);
static const ImVec4 RED(1.f, 0.f, 0.f, 1.f); static const ImVec4 RED(1.f, 0.f, 0.f, 1.f);
static const float PADDING_Y = 8.f; static const float PADDING_Y = 8.f;
static const float PADDING_X = 4.f; static const float PADDING_X = 4.f;
@@ -91,6 +92,23 @@ namespace overlay::windows {
} }
void IIDXSegmentDisplay::build_content() { void IIDXSegmentDisplay::build_content() {
// explicitly check if TDJ I/O is enabled to account for the fact that I/O emulation may be
// disabled
if (games::iidx::CURRENT_IO_EMULATION_STATE == games::iidx::iidx_aio_emulation_state::bi2x_hook) {
ImGui::TextUnformatted("");
ImGui::TextColored(
YELLOW,
"%s",
"Invalid I/O mode; DLL is configured for TDJ I/O!\n"
"Enable -iidxtdj if you want TDJ subscreen overlay.");
ImGui::TextUnformatted("");
if (ImGui::Button("Close")) {
this->set_active(false);
}
return;
}
char input_ticker[TICKER_SIZE]; char input_ticker[TICKER_SIZE];
// get ticker content from game // get ticker content from game
+14 -4
View File
@@ -12,11 +12,9 @@ namespace overlay::windows {
this->title = "IIDX TDJ Subscreen"; this->title = "IIDX TDJ Subscreen";
if (GRAPHICS_IIDX_WSUB) { if (GRAPHICS_IIDX_WSUB) {
this->disabled_message = this->disabled_message = "Close this overlay and use the second window. (try ALT+TAB)";
"Close this overlay and use the second window.\n"
"If you don't see the window, double check your DLL type and apply TDJ I/O patches as needed.";
} else if (games::iidx::IIDX_TDJ_MONITOR_WARNING) { } else if (games::iidx::IIDX_TDJ_MONITOR_WARNING) {
this->disabled_message = "TDJ mode subscreen overlay is not compatible with -monitor option"; this->disabled_message = "TDJ mode subscreen overlay is not compatible with -monitor option.";
} }
float size = 0.5f; float size = 0.5f;
@@ -44,6 +42,18 @@ namespace overlay::windows {
ImGui::GetIO().DisplaySize.y - this->init_size.y - (ImGui::GetFrameHeight() / 2)); ImGui::GetIO().DisplaySize.y - this->init_size.y - (ImGui::GetFrameHeight() / 2));
} }
void IIDXSubScreen::check_for_errors() {
if (games::iidx::CURRENT_IO_EMULATION_STATE ==
games::iidx::iidx_aio_emulation_state::bi2a_com2) {
// explicitly check if LDJ I/O is enabled (as opposed to checking if NOT TDJ I/O)
// to account for the fact that I/O emulation may be disabled
this->disabled_message =
"LDJ I/O detected; TDJ mode subscreen overlay requires TDJ I/O.\n"
"Ensure you apply applicable TDJ I/O patches, or run with TDJ DLL.";
}
}
void IIDXSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) { void IIDXSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {
if (!this->get_active()) { if (!this->get_active()) {
return; return;
+1
View File
@@ -12,6 +12,7 @@ namespace overlay::windows {
protected: protected:
void touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) override; void touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) override;
void check_for_errors() override;
}; };
} }
+1 -1
View File
@@ -81,7 +81,7 @@ namespace overlay::windows {
{ {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetFrameHeightWithSpacing()); ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetFrameHeightWithSpacing());
this->build_button("+", tall, this->test_button, this->service_button); this->build_button("+", tall, this->test_button, this->service_button);
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
ImGui::HelpTooltip("SERVICE + TEST"); ImGui::HelpTooltip("SERVICE + TEST");
} }
} }
+2 -2
View File
@@ -136,7 +136,7 @@ namespace overlay::windows {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetFrameHeightWithSpacing()); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetFrameHeightWithSpacing());
this->build_button("<", leftright_size, this->left[p], nullptr, this->leftright_light[p]); this->build_button("<", leftright_size, this->left[p], nullptr, this->leftright_light[p]);
this->build_button("+", tiny_size, this->help[p], this->start[p], nullptr); this->build_button("+", tiny_size, this->help[p], this->start[p], nullptr);
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
ImGui::HelpTooltip("HELP + START"); ImGui::HelpTooltip("HELP + START");
} }
} }
@@ -167,7 +167,7 @@ namespace overlay::windows {
ImGui::BeginGroup(); ImGui::BeginGroup();
{ {
this->build_button("?", tiny_size, this->help[p], nullptr, this->help_light[p]); this->build_button("?", tiny_size, this->help[p], nullptr, this->help_light[p]);
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
ImGui::HelpTooltip("HELP"); ImGui::HelpTooltip("HELP");
} }
this->build_button(">", leftright_size, this->right[p], nullptr, this->leftright_light[p]); this->build_button(">", leftright_size, this->right[p], nullptr, this->leftright_light[p]);
+1 -1
View File
@@ -120,7 +120,7 @@ namespace overlay::windows {
"Lightning Model cabinets (TDJ) do not have any keypads; they use the subscreen.\n\n" "Lightning Model cabinets (TDJ) do not have any keypads; they use the subscreen.\n\n"
"Fullscreen mode: bind a key in Overlay tab, and press it in game to show the subscreen, " "Fullscreen mode: bind a key in Overlay tab, and press it in game to show the subscreen, "
"then use your mouse to click. Page Up button is the default binding.\n\n" "then use your mouse to click. Page Up button is the default binding.\n\n"
"Windowed mode: look for the second window in the taskbar.\n\n" "Windowed mode: look for the second window in the taskbar (or ALT+TAB).\n\n"
"Windowed mode with -iidxnosub: bring up the subscreen overlay (default Page Up).\n\n" "Windowed mode with -iidxnosub: bring up the subscreen overlay (default Page Up).\n\n"
); );
+37 -8
View File
@@ -721,7 +721,7 @@ namespace overlay::windows {
if (style_color_pushed) { if (style_color_pushed) {
ImGui::PopStyleColor(style_color_pushed); ImGui::PopStyleColor(style_color_pushed);
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
show_patch_tooltip(patch); show_patch_tooltip(patch);
} }
@@ -762,7 +762,7 @@ namespace overlay::windows {
patch.last_status = is_patch_active(patch); patch.last_status = is_patch_active(patch);
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
show_patch_tooltip(patch); show_patch_tooltip(patch);
} }
@@ -791,7 +791,7 @@ namespace overlay::windows {
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
show_patch_tooltip(patch); show_patch_tooltip(patch);
} }
} else if (patch.type == PatchType::Integer) { } else if (patch.type == PatchType::Integer) {
@@ -807,7 +807,7 @@ namespace overlay::windows {
apply_patch(patch, true); apply_patch(patch, true);
config_dirty = true; config_dirty = true;
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
show_patch_tooltip(patch); show_patch_tooltip(patch);
} }
} }
@@ -824,7 +824,7 @@ namespace overlay::windows {
ImGui::InputInt("##dummy_int_input", &patch.patch_number.value); ImGui::InputInt("##dummy_int_input", &patch.patch_number.value);
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
show_patch_tooltip(patch); show_patch_tooltip(patch);
} }
} }
@@ -930,6 +930,13 @@ namespace overlay::windows {
} }
} }
// match on model and ext, ignoring dest/spec/rev
// sample: LDJ:J:E:A:2025011400
bool PatchManager::is_game_id_wildcard_matched(const std::string& id_from_config) {
return ((id_from_config.compare(0, 3, avs::game::MODEL) == 0) &&
(id_from_config.compare(10, 10, avs::game::EXT) == 0));
}
void PatchManager::config_load() { void PatchManager::config_load() {
log_info("patchmanager", "loading config"); log_info("patchmanager", "loading config");
@@ -955,7 +962,7 @@ namespace overlay::windows {
if (auto_apply != doc.MemberEnd() && auto_apply->value.IsArray()) { if (auto_apply != doc.MemberEnd() && auto_apply->value.IsArray()) {
// get game id // get game id
auto game_id = avs::game::get_identifier(); const auto game_id = avs::game::get_identifier();
// iterate entries // iterate entries
setting_auto_apply = false; setting_auto_apply = false;
@@ -964,15 +971,37 @@ namespace overlay::windows {
if (entry.IsString()) { if (entry.IsString()) {
// check if this is our game identifier // check if this is our game identifier
std::string entry_id = entry.GetString(); const std::string entry_id = entry.GetString();
if (!setting_auto_apply) {
if (game_id == entry_id) { if (game_id == entry_id) {
// exact match
setting_auto_apply = true; setting_auto_apply = true;
log_misc(
"patchmanager",
"matched auto apply entry by full game identifier: {}",
entry_id);
} else if (is_game_id_wildcard_matched(entry_id)) {
// match on model and ext, ignoring dest/spec/rev
// sample: LDJ:J:E:A:2025011400
setting_auto_apply = true;
log_misc(
"patchmanager",
"matched auto apply entry by partial game identifier: {}:?:?:?:{}",
avs::game::MODEL, avs::game::EXT);
}
} }
// move to list // move to list
setting_auto_apply_list.emplace_back(entry_id); setting_auto_apply_list.emplace_back(entry_id);
} }
} }
if (!setting_auto_apply) {
log_misc(
"patchmanager",
"no auto apply entry matched, patches will not load automatically");
}
} }
// read enabled patches // read enabled patches
@@ -1060,7 +1089,7 @@ namespace overlay::windows {
auto game_id = avs::game::get_identifier(); auto game_id = avs::game::get_identifier();
bool game_id_added = false; bool game_id_added = false;
for (auto &entry : setting_auto_apply_list) { for (auto &entry : setting_auto_apply_list) {
if (entry == game_id) { if (entry == game_id || is_game_id_wildcard_matched(entry)) {
if (!setting_auto_apply) { if (!setting_auto_apply) {
continue; continue;
} }
@@ -143,6 +143,8 @@ namespace overlay::windows {
std::string pe_identifier_for_patch = ""); std::string pe_identifier_for_patch = "");
void show_patch_tooltip(const PatchData& patch); void show_patch_tooltip(const PatchData& patch);
bool is_game_id_wildcard_matched(const std::string& id_from_config);
}; };
PatchStatus is_patch_active(PatchData &patch); PatchStatus is_patch_active(PatchData &patch);
+23 -5
View File
@@ -27,11 +27,12 @@ namespace overlay::windows {
} }
HWND ScreenResize::get_first_window() { HWND ScreenResize::get_first_window() {
// hack for gitadora arena model which races to create many windows // this is ideal
// so [0] is not always the main one if (GRAPHICS_HOOKED_WINDOW.has_value()) {
if (GRAPHICS_WINDOW_MAIN.has_value()) { return GRAPHICS_HOOKED_WINDOW.value();
return GRAPHICS_WINDOW_MAIN.value();
} }
// we typically do not want to check GRAPHICS_WINDOWS because it may include
// system windows (e.g., CicMarshalWnd)
if (GRAPHICS_WINDOWS.size() == 0) { if (GRAPHICS_WINDOWS.size() == 0) {
return NULL; return NULL;
} }
@@ -201,7 +202,7 @@ namespace overlay::windows {
return; return;
} }
ImGui::BeginDisabled(graphics_window_change_crashes_game()); ImGui::BeginDisabled(graphics_window_decoration_change_crashes_game());
if (ImGui::Combo( if (ImGui::Combo(
"Window Style", "Window Style",
&cfg::SCREENRESIZE->window_decoration, &cfg::SCREENRESIZE->window_decoration,
@@ -226,20 +227,31 @@ namespace overlay::windows {
"Reduces pixelated scaling artifacts. Works great on some games, but completely broken on others.\n\n" "Reduces pixelated scaling artifacts. Works great on some games, but completely broken on others.\n\n"
"This can't be changed in-game; instead, set -windowscale option in spicecfg and restart."); "This can't be changed in-game; instead, set -windowscale option in spicecfg and restart.");
ImGui::BeginDisabled(graphics_window_move_and_resize_breaks_game());
{
ImGui::Checkbox("Keep Aspect Ratio", &cfg::SCREENRESIZE->client_keep_aspect_ratio); ImGui::Checkbox("Keep Aspect Ratio", &cfg::SCREENRESIZE->client_keep_aspect_ratio);
ImGui::Checkbox("Manual window move/resize", &cfg::SCREENRESIZE->enable_window_resize); ImGui::Checkbox("Manual window move/resize", &cfg::SCREENRESIZE->enable_window_resize);
}
ImGui::EndDisabled();
ImGui::BeginDisabled(!cfg::SCREENRESIZE->enable_window_resize); ImGui::BeginDisabled(!cfg::SCREENRESIZE->enable_window_resize);
bool changed = false; bool changed = false;
const uint32_t step = 1; const uint32_t step = 1;
const uint32_t step_fast = 10; const uint32_t step_fast = 10;
ImGui::BeginDisabled(graphics_window_resize_breaks_game());
{
ImGui::BeginDisabled(cfg::SCREENRESIZE->client_keep_aspect_ratio); ImGui::BeginDisabled(cfg::SCREENRESIZE->client_keep_aspect_ratio);
{
ImGui::InputScalar( ImGui::InputScalar(
"Width", "Width",
ImGuiDataType_U32, ImGuiDataType_U32,
&cfg::SCREENRESIZE->client_width, &cfg::SCREENRESIZE->client_width,
&step, &step_fast, nullptr); &step, &step_fast, nullptr);
changed |= ImGui::IsItemDeactivatedAfterEdit(); changed |= ImGui::IsItemDeactivatedAfterEdit();
}
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::InputScalar( ImGui::InputScalar(
@@ -248,7 +260,11 @@ namespace overlay::windows {
&cfg::SCREENRESIZE->client_height, &cfg::SCREENRESIZE->client_height,
&step, &step_fast, nullptr); &step, &step_fast, nullptr);
changed |= ImGui::IsItemDeactivatedAfterEdit(); changed |= ImGui::IsItemDeactivatedAfterEdit();
}
ImGui::EndDisabled();
ImGui::BeginDisabled(graphics_window_move_and_resize_breaks_game());
{
ImGui::InputScalar( ImGui::InputScalar(
"X Offset", "X Offset",
ImGuiDataType_S32, ImGuiDataType_S32,
@@ -262,6 +278,8 @@ namespace overlay::windows {
&cfg::SCREENRESIZE->window_offset_y, &cfg::SCREENRESIZE->window_offset_y,
&step, &step_fast, nullptr); &step, &step_fast, nullptr);
changed |= ImGui::IsItemDeactivatedAfterEdit(); changed |= ImGui::IsItemDeactivatedAfterEdit();
}
ImGui::EndDisabled();
if (changed) { if (changed) {
if (cfg::SCREENRESIZE->client_keep_aspect_ratio) { if (cfg::SCREENRESIZE->client_keep_aspect_ratio) {
+1 -1
View File
@@ -18,7 +18,7 @@ namespace overlay::windows {
if (GRAPHICS_PREVENT_SECONDARY_WINDOW) { if (GRAPHICS_PREVENT_SECONDARY_WINDOW) {
this->disabled_message = "Subscreen has been disabled by the user (-sdvxnosub)."; this->disabled_message = "Subscreen has been disabled by the user (-sdvxnosub).";
} else { } else {
this->disabled_message = "Overlay unavailable in windowed mode! Use the second window instead."; this->disabled_message = "Overlay unavailable in windowed mode! Use the second window instead. (ALT+TAB)";
} }
} }
+7
View File
@@ -4,6 +4,7 @@
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
#include <map>
#include <windows.h> #include <windows.h>
@@ -120,9 +121,15 @@ namespace rawinput {
std::vector<std::string> value_caps_names; std::vector<std::string> value_caps_names;
std::vector<HIDP_VALUE_CAPS> value_output_caps_list; std::vector<HIDP_VALUE_CAPS> value_output_caps_list;
std::vector<std::string> value_output_caps_names; std::vector<std::string> value_output_caps_names;
std::vector<std::vector<bool>> button_states; std::vector<std::vector<bool>> button_states;
std::vector<std::vector<double>> button_up, button_down; std::vector<std::vector<double>> button_up, button_down;
std::vector<std::vector<bool>> button_output_states; std::vector<std::vector<bool>> button_output_states;
// key: usage page, link collection
// value: number of buttons for that key (combine ranges and nonranges)
std::map<std::pair<USAGE, ULONG>, ULONG> button_usage_pages;
std::vector<float> value_states; std::vector<float> value_states;
std::vector<LONG> value_states_raw; std::vector<LONG> value_states_raw;
std::vector<float> value_output_states; std::vector<float> value_output_states;
+50 -15
View File
@@ -38,6 +38,10 @@ namespace rawinput {
uint32_t MIDI_NOTE_SUSTAIN = 20; uint32_t MIDI_NOTE_SUSTAIN = 20;
static MidiNoteAlgorithm MIDI_NOTE_ALGORITHM = MidiNoteAlgorithm::V2; static MidiNoteAlgorithm MIDI_NOTE_ALGORITHM = MidiNoteAlgorithm::V2;
// the price we pay for making spice overlay consume from raw input
// making focus detection a nightmare
bool OS_WINDOW_ACTIVE = false;
} }
rawinput::MidiNoteAlgorithm rawinput::get_midi_algorithm() { rawinput::MidiNoteAlgorithm rawinput::get_midi_algorithm() {
@@ -401,6 +405,7 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
std::vector<std::string> button_caps_names; std::vector<std::string> button_caps_names;
std::vector<std::vector<bool>> button_states; std::vector<std::vector<bool>> button_states;
std::vector<std::vector<double>> button_up, button_down; std::vector<std::vector<double>> button_up, button_down;
std::map<std::pair<USAGE, ULONG>, ULONG> button_usage_pages;
for (int button_cap_num = 0; button_cap_num < button_cap_length; button_cap_num++) { for (int button_cap_num = 0; button_cap_num < button_cap_length; button_cap_num++) {
auto &button_caps = button_cap_data[button_cap_num]; auto &button_caps = button_cap_data[button_cap_num];
@@ -432,6 +437,7 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
button_states.emplace_back(std::vector<bool>(static_cast<unsigned int>(button_count), false)); button_states.emplace_back(std::vector<bool>(static_cast<unsigned int>(button_count), false));
button_up.emplace_back(std::vector<double>(static_cast<unsigned int>(button_count), 0.0)); button_up.emplace_back(std::vector<double>(static_cast<unsigned int>(button_count), 0.0));
button_down.emplace_back(std::vector<double>(static_cast<unsigned int>(button_count), 0.0)); button_down.emplace_back(std::vector<double>(static_cast<unsigned int>(button_count), 0.0));
button_usage_pages[std::make_pair(button_caps.UsagePage, button_caps.LinkCollection)] += button_count;
// names // names
for (USAGE usg = button_caps.Range.UsageMin; usg <= button_caps.Range.UsageMax; usg++) { for (USAGE usg = button_caps.Range.UsageMin; usg <= button_caps.Range.UsageMax; usg++) {
@@ -753,6 +759,7 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
new_device.hidInfo->button_up = std::move(button_up); new_device.hidInfo->button_up = std::move(button_up);
new_device.hidInfo->button_down = std::move(button_down); new_device.hidInfo->button_down = std::move(button_down);
new_device.hidInfo->button_output_states = std::move(button_output_states); new_device.hidInfo->button_output_states = std::move(button_output_states);
new_device.hidInfo->button_usage_pages = std::move(button_usage_pages);
new_device.hidInfo->value_states = std::move(value_states); new_device.hidInfo->value_states = std::move(value_states);
new_device.hidInfo->value_states_raw = std::move(value_states_raw); new_device.hidInfo->value_states_raw = std::move(value_states_raw);
new_device.hidInfo->value_output_states = std::move(value_output_states); new_device.hidInfo->value_output_states = std::move(value_output_states);
@@ -1709,6 +1716,38 @@ LRESULT CALLBACK rawinput::RawInputManager::input_wnd_proc(
// get HID data // get HID data
auto &data_hid = data->data.hid; auto &data_hid = data->data.hid;
// parse reports
for (const auto &pair : device.hidInfo->button_usage_pages) {
const auto usage_page = pair.first.first;
const auto link_collection = pair.first.second;
const auto button_count = pair.second;
ULONG usages_length = button_count;
std::vector<USAGE> usages(static_cast<size_t>(usages_length));
if (HidP_GetUsages(
HidP_Input,
usage_page,
link_collection,
usages.data(),
&usages_length,
reinterpret_cast<PHIDP_PREPARSED_DATA>(device.hidInfo->preparsed_data.get()),
reinterpret_cast<PCHAR>(data_hid.bRawData),
data_hid.dwSizeHid) != HIDP_STATUS_SUCCESS) {
// log_warning(
// "rawinput",
// "failed to get usages for device {}, usage page {:x} and link collection {:x}",
// device.desc,
// usage_page, link_collection);
continue;
}
// log_info(
// "rawinput",
// "processing HID input for device {}, usage page {:x} and link collection {:x} with {} buttons, got {} reports",
// device.desc,
// usage_page, link_collection, button_count, usages_length);
// buttons // buttons
for (size_t cap_num = 0; cap_num < device.hidInfo->button_caps_list.size(); cap_num++) { for (size_t cap_num = 0; cap_num < device.hidInfo->button_caps_list.size(); cap_num++) {
auto &button_caps = device.hidInfo->button_caps_list[cap_num]; auto &button_caps = device.hidInfo->button_caps_list[cap_num];
@@ -1716,30 +1755,25 @@ LRESULT CALLBACK rawinput::RawInputManager::input_wnd_proc(
auto &button_down = device.hidInfo->button_down[cap_num]; auto &button_down = device.hidInfo->button_down[cap_num];
auto &button_up = device.hidInfo->button_up[cap_num]; auto &button_up = device.hidInfo->button_up[cap_num];
// is this the right usage page and link collection?
if (button_caps.UsagePage != usage_page || button_caps.LinkCollection != link_collection) {
continue;
}
// get button count // get button count
int button_count = button_caps.Range.UsageMax - button_caps.Range.UsageMin + 1; int button_count = button_caps.Range.UsageMax - button_caps.Range.UsageMin + 1;
if (button_count <= 0) { if (button_count <= 0) {
continue; continue;
} }
// get usages
auto usages_length = static_cast<ULONG>(button_count);
std::vector<USAGE> usages(static_cast<size_t>(usages_length));
if (HidP_GetUsages(
HidP_Input,
button_caps.UsagePage,
button_caps.LinkCollection,
usages.data(),
&usages_length,
reinterpret_cast<PHIDP_PREPARSED_DATA>(device.hidInfo->preparsed_data.get()),
reinterpret_cast<PCHAR>(data_hid.bRawData),
data_hid.dwSizeHid) != HIDP_STATUS_SUCCESS) {
continue;
}
// update buttons // update buttons
std::vector<bool> new_states(button_count); std::vector<bool> new_states(button_count);
for (ULONG usage_num = 0; usage_num < usages_length; usage_num++) { for (ULONG usage_num = 0; usage_num < usages_length; usage_num++) {
if (usages[usage_num] < button_caps.Range.UsageMin ||
usages[usage_num] > button_caps.Range.UsageMax) {
continue;
}
USAGE usage = usages[usage_num] - button_caps.Range.UsageMin; USAGE usage = usages[usage_num] - button_caps.Range.UsageMin;
// guard against some buggy device sending an event for a usage below `UsageMin` // guard against some buggy device sending an event for a usage below `UsageMin`
@@ -1759,6 +1793,7 @@ LRESULT CALLBACK rawinput::RawInputManager::input_wnd_proc(
} }
} }
} }
}
// analogs // analogs
for (auto cap_num = 0; cap_num < device.hidInfo->caps.NumberInputValueCaps; cap_num++) { for (auto cap_num = 0; cap_num < device.hidInfo->caps.NumberInputValueCaps; cap_num++) {
+10
View File
@@ -10,6 +10,7 @@
#include "device.h" #include "device.h"
#include "hotplug.h" #include "hotplug.h"
#include "util/scope_guard.h"
namespace rawinput { namespace rawinput {
@@ -31,6 +32,15 @@ namespace rawinput {
extern bool NAIVE_REQUIRE_FOCUS; extern bool NAIVE_REQUIRE_FOCUS;
extern bool RAWINPUT_REQUIRE_FOCUS; extern bool RAWINPUT_REQUIRE_FOCUS;
// while active, prevents overlay from accepting any input
// can be used while OS modal dialog is shown on top of overlay/spicecfg
// always prefer RAII set_os_window_focus_guard instead of the global bool
extern bool OS_WINDOW_ACTIVE;
inline scope_guard set_os_window_focus_guard() {
rawinput::OS_WINDOW_ACTIVE = true;
return scope_guard {[]() { rawinput::OS_WINDOW_ACTIVE = false; }};
}
struct DeviceCallback { struct DeviceCallback {
void *data; void *data;
std::function<void(void*, Device*)> f; std::function<void(void*, Device*)> f;
+4 -4
View File
@@ -26,10 +26,10 @@ namespace rawinput::touch {
bool INVERTED = false; bool INVERTED = false;
// state // state
static bool DISPLAY_INITIALIZED = false; DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT;
static DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT; long DISPLAY_SIZE_X = 1920L;
static long DISPLAY_SIZE_X = 1920L; long DISPLAY_SIZE_Y = 1080L;
static long DISPLAY_SIZE_Y = 1080L; bool DISPLAY_INITIALIZED = false;
bool is_touchscreen(Device *device) { bool is_touchscreen(Device *device) {
+6
View File
@@ -9,6 +9,12 @@ namespace rawinput::touch {
extern bool DISABLED; extern bool DISABLED;
extern bool INVERTED; extern bool INVERTED;
// global state
extern DWORD DISPLAY_ORIENTATION;
extern long DISPLAY_SIZE_X;
extern long DISPLAY_SIZE_Y;
extern bool DISPLAY_INITIALIZED;
bool is_touchscreen(Device *device); bool is_touchscreen(Device *device);
void enable(Device *device); void enable(Device *device);
void disable(Device *device); void disable(Device *device);
+24 -12
View File
@@ -15,18 +15,23 @@ namespace socd {
SocdAlgorithm ALGORITHM = SocdAlgorithm::Neutral; SocdAlgorithm ALGORITHM = SocdAlgorithm::Neutral;
static double last_rising_edge[2][2] = {}; static double last_rising_edge[4][2] = {};
static bool last_button_state[2][2] = {}; static bool last_button_state[4][2] = {};
// this has no locking, use only if you know there is only one i/o thread that will call this // this has no locking, use only if you know there is only one i/o thread that will call this
SocdResult socd_clean(uint8_t device, bool ccw, bool cw, double time_now) { SocdResult socd_clean(
if (device >= 2) { uint8_t device, bool ccw, bool cw, double time_now,
std::optional<SocdAlgorithm> algorithm_override) {
if (device >= 4) {
log_fatal("socd", "invalid device index in socd_clean: {}", device); log_fatal("socd", "invalid device index in socd_clean: {}", device);
} }
// SOCD last input algorithm needs to keep track of rising edge times SocdAlgorithm algo =
if (ALGORITHM != SocdAlgorithm::Neutral) { algorithm_override.has_value() ? algorithm_override.value() : ALGORITHM;
// detect rising edges
// keep track of rising edge times
if (algo == SocdAlgorithm::PreferRecent || algo == SocdAlgorithm::PreferFirst) {
if (!last_button_state[device][SocdCCW] && ccw) { if (!last_button_state[device][SocdCCW] && ccw) {
last_rising_edge[device][SocdCCW] = time_now; last_rising_edge[device][SocdCCW] = time_now;
} }
@@ -55,7 +60,7 @@ namespace socd {
const auto cw_time = last_rising_edge[device][SocdCW]; const auto cw_time = last_rising_edge[device][SocdCW];
log_debug("socd", "ccw={}, cw ={}", ccw_time, cw_time); log_debug("socd", "ccw={}, cw ={}", ccw_time, cw_time);
if (ALGORITHM == SocdAlgorithm::PreferRecent) { if (algo == SocdAlgorithm::PreferRecent) {
// SOCD: prefer last input // SOCD: prefer last input
if (ccw_time < cw_time) { if (ccw_time < cw_time) {
// while CCW is being held, CW got pressed // while CCW is being held, CW got pressed
@@ -67,7 +72,7 @@ namespace socd {
// it's a tie; instead of none, we'll pick a direction // it's a tie; instead of none, we'll pick a direction
return SocdCW; return SocdCW;
} }
} else if (ALGORITHM == SocdAlgorithm::PreferFirst) { } else if (algo == SocdAlgorithm::PreferFirst) {
// SOCD: keep first input // SOCD: keep first input
if (ccw_time < cw_time) { if (ccw_time < cw_time) {
// while CCW is being held, CW got pressed // while CCW is being held, CW got pressed
@@ -79,9 +84,15 @@ namespace socd {
// it's a tie; instead of none, we'll pick a direction // it's a tie; instead of none, we'll pick a direction
return SocdCW; return SocdCW;
} }
} else { } else if (algo == SocdAlgorithm::Neutral) {
// SOCD: neutral when both are pressed // SOCD: neutral when both are pressed
return SocdNone; return SocdNone;
} else if (algo == SocdAlgorithm::None) {
// SOCD: both are pressed
return SocdBoth;
} else {
log_fatal("socd", "invalid SOCD algorithm");
return SocdNone;
} }
} }
@@ -97,7 +108,8 @@ namespace socd {
log_fatal("socd", "invalid device index in socd_clean: {}", device); log_fatal("socd", "invalid device index in socd_clean: {}", device);
} }
const auto socd_result = socd_clean(device, up, down, time_now); const auto socd_result = socd_clean(
device + 2, up, down, time_now, SocdAlgorithm::PreferRecent);
if (up) { if (up) {
most_recent_active[device][TiltUp] = time_now; most_recent_active[device][TiltUp] = time_now;
@@ -125,7 +137,7 @@ namespace socd {
result = TiltUp; result = TiltUp;
} else if (socd_result == SocdCW) { } else if (socd_result == SocdCW) {
result = TiltDown; result = TiltDown;
} else { } else if (socd_result == SocdBoth) {
result = TiltUp; result = TiltUp;
} }
} else if (is_up) { } else if (is_up) {
+11 -3
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <optional>
#include <cstdint> #include <cstdint>
namespace socd { namespace socd {
@@ -9,7 +10,8 @@ namespace socd {
enum class SocdAlgorithm { enum class SocdAlgorithm {
Neutral, Neutral,
PreferRecent, PreferRecent,
PreferFirst PreferFirst,
None,
}; };
extern SocdAlgorithm ALGORITHM; extern SocdAlgorithm ALGORITHM;
@@ -17,10 +19,16 @@ namespace socd {
typedef enum _SocdResult { typedef enum _SocdResult {
SocdCCW = 0, SocdCCW = 0,
SocdCW = 1, SocdCW = 1,
SocdNone = 2 SocdNone = 2,
SocdBoth = 3
} SocdResult; } SocdResult;
SocdResult socd_clean(uint8_t device, bool ccw, bool cw, double time_now); SocdResult socd_clean(
uint8_t device,
bool ccw,
bool cw,
double time_now,
std::optional<SocdAlgorithm> algorithm = std::nullopt);
// for guitar wail (up/down only) // for guitar wail (up/down only)