-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
library: add Libmanette entry #309
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1802fc0
add main.json
halfmexican 737a71b
add main.js
halfmexican 800f651
add main.blp
halfmexican 0f2aee0
attempt to iterate over devices
halfmexican 993c26b
fix typo in main.json
halfmexican 8eea582
use template literal
halfmexican d07a8c4
use template literal
halfmexican 9c2472b
add note and button
halfmexican 1368d47
update main.blp
halfmexican 7d7b704
add facebutton and d-pad support
halfmexican 3cb577e
add libmanette as a module in our flatpak manifest
halfmexican 271e72a
remove icon
halfmexican 586c8a0
add analog axis support
halfmexican 3010e60
add link to docs
halfmexican 0f62bbe
main.js: use const and update comments
halfmexican a9eea8e
main.json:update description
halfmexican 0659daa
add rumble
halfmexican File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Gtk 4.0; | ||
using Adw 1; | ||
|
||
Stack stack { | ||
visible-child: status_page; | ||
|
||
Adw.StatusPage status_page { | ||
title: _("Please connect a gamepad"); | ||
description: _("A controller is needed for this demo"); | ||
icon-name: "gamepad-symbolic"; | ||
|
||
Box { | ||
orientation: vertical; | ||
halign: center; | ||
|
||
LinkButton { | ||
label: "API Reference"; | ||
uri: "https://gnome.pages.gitlab.gnome.org/libmanette/"; | ||
margin-top: 24; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* IMPORTANT: To use USB devices in your app you will need to set the --device=all permission. | ||
Workbench doesn't have such permission by default so to run this example you have to run the command | ||
flatpak override re.sonny.Workbench --device=all */ | ||
|
||
import Gtk from "gi://Gtk"; | ||
import Manette from "gi://Manette"; | ||
|
||
const status_page = workbench.builder.get_object("status_page"); | ||
|
||
const monitor = Manette.Monitor.new(); | ||
const monitor_iter = monitor.iterate(); | ||
|
||
// Iterate over the devices and log their details | ||
let [has_next, device] = monitor_iter.next(); | ||
|
||
while (device !== null) { | ||
console.log("Device:", device.get_name()); | ||
|
||
status_page.title = _("Controller connected"); | ||
status_page.description = ""; | ||
|
||
// Face and Shoulder Buttons | ||
device.connect("button-press-event", (device, event) => { | ||
console.log( | ||
`Device: ${device.get_name()} pressed ${event.get_hardware_code()}`, | ||
); | ||
|
||
if (device.has_rumble()) { | ||
device.rumble(1000, 1500, 200); | ||
} | ||
}); | ||
|
||
// D-pads | ||
device.connect("hat-axis-event", (device, event) => { | ||
const [, hat_axis, hat_value] = event.get_hat(); | ||
console.log( | ||
`Device: ${device.get_name()} moved axis ${hat_axis} to ${hat_value}`, | ||
); | ||
}); | ||
|
||
// Analog Axis - Triggers and Joysticks | ||
device.connect("absolute-axis-event", (device, event) => { | ||
const [, axis, value] = event.get_absolute(); | ||
if (Math.abs(value) > 0.2) | ||
console.log( | ||
`Device: ${device.get_name()} moved axis ${axis} to ${value}`, | ||
); | ||
}); | ||
|
||
[has_next, device] = monitor_iter.next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "Gamepads", | ||
"category": "controls", | ||
"description": "Use Libmanette to access controllers and gamepads", | ||
"panels": ["code", "preview"], | ||
"autorun": false | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the
config-opts
what fixed it in flatpak?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gitlab.gnome.org/GNOME/gnome-build-meta/-/merge_requests/2217