Skip to content

Commit

Permalink
Merge branch 'main' of github.com:streetpea/chiaki4deck
Browse files Browse the repository at this point in the history
  • Loading branch information
streetpea committed Mar 26, 2024
2 parents 74fa093 + 68b90d8 commit 61bb66f
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Configure Chiaki4deck
run: |
cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCHIAKI_ENABLE_CLI=OFF -DCHIAKI_ENABLE_STEAM_SHORTCUT=OFF
cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCHIAKI_ENABLE_CLI=OFF
- name: Build Chiaki4deck
run: |
Expand All @@ -77,6 +77,7 @@ jobs:
run: |
mkdir Chiaki4deck-Win
cp build/gui/chiaki.exe Chiaki4deck-Win
cp build/third-party/cpp-steam-tools/libcpp-steam-tools.dll Chiaki4deck-Win/
cp /mingw64/bin/libcrypto-*.dll Chiaki4deck-Win/
cp /mingw64/bin/libssl-*.dll Chiaki4deck-Win/
cp /mingw64/bin/SDL2.dll Chiaki4deck-Win/
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
url = https://git.sr.ht/~thestr4ng3r/borealis
[submodule "third-party/cpp-steam-tools"]
path = third-party/cpp-steam-tools
url = https://github.com/nikorag/cpp-steam-tools.git
url = https://github.com/streetpea/cpp-steam-tools.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tri_option(CHIAKI_USE_SYSTEM_NANOPB "Use system-provided nanopb instead of submo

set(CHIAKI_VERSION_MAJOR 1)
set(CHIAKI_VERSION_MINOR 6)
set(CHIAKI_VERSION_PATCH 4)
set(CHIAKI_VERSION_PATCH 5)
set(CHIAKI_VERSION ${CHIAKI_VERSION_MAJOR}.${CHIAKI_VERSION_MINOR}.${CHIAKI_VERSION_PATCH})

set(CPACK_PACKAGE_NAME "chiaki4deck")
Expand Down
9 changes: 3 additions & 6 deletions docs/setup/controlling.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ I have also mapped gyro controls `As joystick`. Whenever you touch the right joy

!!! Info "Native Gyro for Steam Deck"

Gyro is also directly mapped under the hood for the Steam Deck controller. Thus, when you play a game that has native gyro controls, those will work without needing to do anything in your control mapping via Steam Input. When you are playing a game with native gyro support, you may want to change the gyro mapping from `As joystick` to `As mouse` so that gyro only maps to gyro in the game (i.e., you don't move the camera while trying to move a paintbrush using native gyro).
!!! Warning "Don't turn off gyro entirely, use `As mouse`"
You need to use `As mouse` instead of just turning off gyro altogether in Steam Input because turning off gyro altogether will pause gyro input and result in native gyro not working. This means games that have gyro in them for actions such as the flashlight in Last of Us or the paintbrush in Concrete Genie won't work properly. Using `As mouse` means only gyro set in the game itself will result in an action (since mouse movement by itself isn't mapped to anything in chiaki4deck) so it has the same effect of turning off gyro for games that don't use it for a required in-game control.
Gyro is also directly mapped under the hood for the Steam Deck controller. Thus, when you play a game that has native gyro controls, those will work without needing to do anything in your control mapping via Steam Input. When you are playing a game with native gyro support, you may want to change the gyro mapping from `As joystick` to `None` so that gyro only maps to gyro in the game (i.e., you don't move the camera while trying to move a paintbrush using native gyro).

Of course, you could leave the right stick mapping on (so that it maps to both gyro and right joystick), if that is truly what you want.

## Creating your Own Controller Profile
Expand Down Expand Up @@ -174,9 +173,7 @@ Gryo directly maps for games that support it (i.e., Concrete genie, Astro's Play
- DualSense, DualShock4 or other controller with gyro + accelerometer supported by SDL
- disable Steam Input for the controller following [Using a DualSense and/or DualShock4 Controller with `chiaki4deck`](#using-a-dualsense-andor-dualshock4-controller-with-chiaki4deck) below

Additionally, you can use gyro controls for camera options with any game by mapping gyro `As joystick` and adding a condition for when it's used (i.e., `On` with a condition of `right joystick touch`) in the gyro settings for `chiaki4deck`. I have done this in the [default `chiaki4deck` control setting](#default-chiaki4deck-layout-mapping-full-view) and you can do it in your custom control scheme. However, when playing games that have native gyro support (such as Concrete Genie or The Last of Us) you will most likely want to change the gyro mapping from `As joystick` to `As mouse` so that gyro only maps to gyro in the game (i.e., you don't make your camera move when you're trying to shake your flashlight, etc.).
!!! Warning "Don't turn off gyro entirely, use `As mouse`"
You need to use `As mouse` instead of just turning off gyro altogether in Steam Input because turning off gyro altogether will pause gyro input and result in native gyro not working. This means games that have gyro in them for actions such as the flashlight in Last of Us or the paintbrush in Concrete Genie won't work properly. Using `As mouse` means only gyro set in the game itself will result in an action (since mouse movement by itself isn't mapped to anything in chiaki4deck) so it has the same effect of turning off gyro for games that don't use it for a required in-game control.
Additionally, you can use gyro controls for camera options with any game by mapping gyro `As joystick` and adding a condition for when it's used (i.e., `On` with a condition of `right joystick touch`) in the gyro settings for `chiaki4deck`. I have done this in the [default `chiaki4deck` control setting](#default-chiaki4deck-layout-mapping-full-view) and you can do it in your custom control scheme. However, when playing games that have native gyro support (such as Concrete Genie or The Last of Us) you will most likely want to change the gyro mapping from `As joystick` to `None` so that gyro only maps to gyro in the game (i.e., you don't make your camera move when you're trying to shake your flashlight, etc.).

### Haptics and Adaptive Triggers

Expand Down
10 changes: 10 additions & 0 deletions docs/updates/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ In order to update your already installed `chiaki4deck` to the newest version, e

## Releases (Newest First)

### 1.6.5

Graduate DualSense features from experimental status

- Provides quiet haptic rumble for Steam Deck (default) in addition to optional noisy haptics
- Adds haptic rumble for MacOS
- Allow escape key to be selected for key mappings in Settings
- Add option to start the stream with the mic unmuted
- Add Steam Shortcut now also available on Windows

### 1.6.4

Enables creating steam shortcut with default controller profile from menu
Expand Down
6 changes: 6 additions & 0 deletions gui/include/qmlmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class QmlMainWindow : public QWindow
Q_PROPERTY(int droppedFrames READ droppedFrames NOTIFY droppedFramesChanged)
Q_PROPERTY(bool keepVideo READ keepVideo WRITE setKeepVideo NOTIFY keepVideoChanged)
Q_PROPERTY(VideoMode videoMode READ videoMode WRITE setVideoMode NOTIFY videoModeChanged)
Q_PROPERTY(float ZoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_PROPERTY(VideoPreset videoPreset READ videoPreset WRITE setVideoPreset NOTIFY videoPresetChanged)

public:
Expand Down Expand Up @@ -72,6 +73,9 @@ class QmlMainWindow : public QWindow
VideoMode videoMode() const;
void setVideoMode(VideoMode mode);

float zoomFactor() const;
void setZoomFactor(float factor);

VideoPreset videoPreset() const;
void setVideoPreset(VideoPreset mode);

Expand All @@ -88,6 +92,7 @@ class QmlMainWindow : public QWindow
void droppedFramesChanged();
void keepVideoChanged();
void videoModeChanged();
void zoomFactorChanged();
void videoPresetChanged();
void menuRequested();

Expand All @@ -113,6 +118,7 @@ class QmlMainWindow : public QWindow
int dropped_frames = 0;
int dropped_frames_current = 0;
VideoMode video_mode = VideoMode::Normal;
float zoom_factor = 0;
VideoPreset video_preset = VideoPreset::HighQuality;

QmlBackend *backend = {};
Expand Down
5 changes: 5 additions & 0 deletions gui/include/qmlsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class QmlSettings : public QObject
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
Q_PROPERTY(int windowType READ windowType WRITE setWindowType NOTIFY windowTypeChanged)
Q_PROPERTY(int videoPreset READ videoPreset WRITE setVideoPreset NOTIFY videoPresetChanged)
Q_PROPERTY(float sZoomFactor READ sZoomFactor WRITE setSZoomFactor NOTIFY sZoomFactorChanged)
Q_PROPERTY(QString autoConnectMac READ autoConnectMac WRITE setAutoConnectMac NOTIFY autoConnectMacChanged)
Q_PROPERTY(QString logDirectory READ logDirectory CONSTANT)
Q_PROPERTY(QStringList availableDecoders READ availableDecoders CONSTANT)
Expand Down Expand Up @@ -106,6 +107,9 @@ class QmlSettings : public QObject
int windowType() const;
void setWindowType(int type);

float sZoomFactor() const;
void setSZoomFactor(float factor);

int videoPreset() const;
void setVideoPreset(int preset);

Expand Down Expand Up @@ -152,6 +156,7 @@ class QmlSettings : public QObject
void wifiDroppedNotifChanged();
void decoderChanged();
void windowTypeChanged();
void sZoomFactorChanged();
void videoPresetChanged();
void autoConnectMacChanged();
void audioDevicesChanged();
Expand Down
3 changes: 3 additions & 0 deletions gui/include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class Settings : public QObject
PlaceboPreset GetPlaceboPreset() const;
void SetPlaceboPreset(PlaceboPreset preset);

float GetZoomFactor() const;
void SetZoomFactor(float factor);

RegisteredHost GetAutoConnectHost() const;
void SetAutoConnectHost(const QByteArray &mac);

Expand Down
10 changes: 10 additions & 0 deletions gui/io.github.streetpea.Chiaki4deck.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<update_contact>streetpea@proton.me</update_contact>
<content_rating type="oars-1.1" />
<releases>
<release date="2024-3-20" version="1.6.5">
<description>
<p>This release provides the following improvements:</p>
<ul>
<li>Provides quiet haptic rumble for Steam Deck (default) in addition to optional noisy haptics</li>
<li>Allow escape key to be selected for key mappings in Settings</li>
<li>Add option to start the stream with the mic unmuted</li>
</ul>
</description>
</release>
<release date="2024-3-15" version="1.6.4">
<description>
<p>This release provides the following improvements:</p>
Expand Down
2 changes: 1 addition & 1 deletion gui/src/qml/SettingsDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ DialogView {

C.ComboBox {
Layout.preferredWidth: 400
model: [qsTr("Selected Resolution"), qsTr("Fullscreen"), qsTr("Zoom"), qsTr("Stretch")]
model: [qsTr("Selected Resolution"), qsTr("Fullscreen"), qsTr("Zoom [adjust zoom using slider in stream menu]"), qsTr("Stretch")]
currentIndex: Chiaki.settings.windowType
onActivated: (index) => Chiaki.settings.windowType = index;
}
Expand Down
45 changes: 43 additions & 2 deletions gui/src/qml/StreamView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import QtQuick.Controls.Material

import org.streetpea.chiaki4deck

import "controls" as C

Item {
id: view

Expand Down Expand Up @@ -251,11 +253,45 @@ Item {
checked: Chiaki.window.videoMode == ChiakiWindow.VideoMode.Zoom
onToggled: Chiaki.window.videoMode = Chiaki.window.videoMode == ChiakiWindow.VideoMode.Zoom ? ChiakiWindow.VideoMode.Normal : ChiakiWindow.VideoMode.Zoom
KeyNavigation.left: muteButton
KeyNavigation.right: stretchButton
KeyNavigation.right: {
if(Chiaki.window.videoMode == ChiakiWindow.VideoMode.Zoom)
zoomFactor
else
stretchButton
}
Keys.onReturnPressed: toggled()
Keys.onEscapePressed: menuView.close()
}

Slider {
id: zoomFactor
orientation: Qt.Vertical
from: 0
to: 4
Layout.preferredHeight: 100
stepSize: 0.01
visible: Chiaki.window.videoMode == ChiakiWindow.VideoMode.Zoom
value: Chiaki.window.ZoomFactor
onMoved: {
Chiaki.window.ZoomFactor = value
Chiaki.settings.sZoomFactor = value
}
Label {
anchors {
top: parent.bottom
horizontalCenter: parent.horizontalCenter
leftMargin: 10
}
text: {
if(parent.value === 0)
qsTr("No Black Bars")
else
qsTr("%1 x").arg(parent.value + 1)
}

}
}

ToolSeparator {
Layout.leftMargin: -10
Layout.rightMargin: -10
Expand All @@ -269,7 +305,12 @@ Item {
checkable: true
checked: Chiaki.window.videoMode == ChiakiWindow.VideoMode.Stretch
onToggled: Chiaki.window.videoMode = Chiaki.window.videoMode == ChiakiWindow.VideoMode.Stretch ? ChiakiWindow.VideoMode.Normal : ChiakiWindow.VideoMode.Stretch
KeyNavigation.left: zoomButton
KeyNavigation.left: {
if(Chiaki.window.videoMode == ChiakiWindow.VideoMode.Zoom)
zoomFactor
else
zoomButton
}
KeyNavigation.right: defaultButton
Keys.onReturnPressed: toggled()
Keys.onEscapePressed: menuView.close()
Expand Down
22 changes: 21 additions & 1 deletion gui/src/qmlmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ void QmlMainWindow::setVideoMode(VideoMode mode)
emit videoModeChanged();
}

float QmlMainWindow::zoomFactor() const
{
return zoom_factor;
}

void QmlMainWindow::setZoomFactor(float factor)
{
zoom_factor = factor;
emit zoomFactorChanged();
}

QmlMainWindow::VideoPreset QmlMainWindow::videoPreset() const
{
return video_preset;
Expand Down Expand Up @@ -511,6 +522,7 @@ void QmlMainWindow::init(Settings *settings)
setVideoPreset(VideoPreset::HighQuality);
break;
}
setZoomFactor(settings->GetZoomFactor());
}

void QmlMainWindow::update()
Expand Down Expand Up @@ -783,7 +795,15 @@ void QmlMainWindow::render()
// Nothing to do, target.crop already covers the full image
break;
case VideoMode::Zoom:
pl_rect2df_aspect_copy(&target_frame.crop, &crop, 1.0);
if(zoom_factor == 0)
pl_rect2df_aspect_copy(&target_frame.crop, &crop, 1.0);
else
{
const float z = powf(2.0f, zoom_factor);
const float sx = z * fabsf(pl_rect_w(crop)) / pl_rect_w(target_frame.crop);
const float sy = z * fabsf(pl_rect_h(crop)) / pl_rect_h(target_frame.crop);
pl_rect2df_stretch(&target_frame.crop, sx, sy);
}
break;
}
pl_swapchain_colorspace_hint(placebo_swapchain, &current_frame.color);
Expand Down
11 changes: 11 additions & 0 deletions gui/src/qmlsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ void QmlSettings::setWindowType(int type)
emit windowTypeChanged();
}

float QmlSettings::sZoomFactor() const
{
return settings->GetZoomFactor();
}

void QmlSettings::setSZoomFactor(float factor)
{
settings->SetZoomFactor(factor);
emit sZoomFactorChanged();
}

int QmlSettings::videoPreset() const
{
return static_cast<int>(settings->GetPlaceboPreset());
Expand Down
10 changes: 10 additions & 0 deletions gui/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ void Settings::SetPlaceboPreset(PlaceboPreset preset)
settings.setValue("settings/placebo_preset", placebo_preset_values[preset]);
}

float Settings::GetZoomFactor() const
{
return settings.value("settings/zoom_factor", 0).toFloat();
}

void Settings::SetZoomFactor(float factor)
{
settings.setValue("settings/zoom_factor", factor);
}

static const QMap<WindowType, QString> window_type_values = {
{ WindowType::SelectedResolution, "Selected Resolution" },
{ WindowType::Fullscreen, "Fullscreen" },
Expand Down
11 changes: 10 additions & 1 deletion gui/src/streamsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,10 @@ void StreamSession::PushHapticsFrame(uint8_t *buf, size_t buf_size)
if(haptics_sdeck < 1 && controller->IsSteamDeck())
continue;
#endif
controller->SetHapticRumble(left, right, 10);
if(left > right)
controller->SetHapticRumble(left, left, 10);
else
controller->SetHapticRumble(right, right, 10);
}
});
return;
Expand Down Expand Up @@ -1404,6 +1407,12 @@ void StreamSession::HandleSDeckEvent(SDeckEvent *event)
sdeck_orient_dirty = true;
}
break;
case SDECK_EVENT_GYRO_ENABLE:
if(event->enabled)
CHIAKI_LOGI(GetChiakiLog(), "Gyro enabled for Steam Deck");
else
CHIAKI_LOGE(GetChiakiLog(), "Gyro could not be enabled for Steam Deck");
break;
}
}
#endif
Expand Down
10 changes: 8 additions & 2 deletions steamdeck_native/include/sdeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>

typedef struct sdeck_t SDeck;
//typedef struct freq_t FreqFinder;
Expand Down Expand Up @@ -80,7 +81,9 @@ typedef struct SDHaptic
// since that functionality is already provided w/ QT/SDL
typedef enum {
/* Event will have motion set (accel, gyro + orientation) */
SDECK_EVENT_MOTION
SDECK_EVENT_MOTION,
/* Event will have no data */
SDECK_EVENT_GYRO_ENABLE
} SDeckEventType;

typedef struct sdeck_motion_t
Expand All @@ -94,7 +97,10 @@ typedef struct sdeck_motion_t
typedef struct sdeck_event_t
{
SDeckEventType type;
SDeckMotion motion;
union {
SDeckMotion motion;
bool enabled;
};
} SDeckEvent;

typedef void (*SDeckEventCb)(SDeckEvent *event, void *user);
Expand Down
Loading

0 comments on commit 61bb66f

Please sign in to comment.