Skip to content

Input System Touch Controls #1104

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

Merged
merged 29 commits into from
Jun 24, 2025
Merged

Input System Touch Controls #1104

merged 29 commits into from
Jun 24, 2025

Conversation

Dhruv-0-Arora
Copy link
Collaborator

@Dhruv-0-Arora Dhruv-0-Arora commented Aug 21, 2024

Description

Creating touch controls joysticks for mobile devices. To enable the touch controls, you must be on a device with touch capabilities. When this happens, the Enable touch controls button will appear in the MainHUD.

Screenshot 2024-08-23 at 2 48 12 PM

After enabling the touch controls the controls themselves will appear on screen.

Screenshot 2024-08-23 at 2 49 06 PM

To use them, you must configure a inputscheme or use the preset "Brandon"

Notes

  • In the future we will create a queue of the different actions on the top of the screen that will appear as they are available to execute. For example, intake when there is an object in the intakesensor, eject when needed, and place assembly. These will be based off the design of the place assembly button.
  • When configuring the inputscheme, the useGamepad and useTouchControls checkboxes can be selected at the same time. This is a bug. To fix this, we will need to change the implementation of the Checkbox to utilize the checked={} prop instead of default value.
  • When creating a new configuration and enabling touch controls, the different joint configurations appear (which causes a bug of joints moving as the robot moves). To fix this, we should create a "add joint configuration" button when creating a new configuration.
  • In the future, on the top left of the screen there will be sliders for joints similar to the queue that will appear only if there is a configuration for a joint.

Testing

To test this on a mobile device:

  1. Enable SSL by going to vite.config.js and enabling the boolean to be true
  2. run bun run host or npm run host to expose it to the network
  3. Open the URL (not the localhost url) on your mobile device that is connected to the same network.

Note: Ensure you are not on a wifi network with a firewall that blocks external access (such as the Autodesk network). Alternatively, you can use a hotspot.

JIRA Issue

@Dhruv-0-Arora Dhruv-0-Arora added the gameplay Relating to the playability of Synthesis label Aug 21, 2024
@Dhruv-0-Arora Dhruv-0-Arora self-assigned this Aug 21, 2024
@Dhruv-0-Arora Dhruv-0-Arora changed the title Dhruv/1847/touch controls Touch Controls Aug 21, 2024
/** @returns {number} a number between -1 and 1 for this input. */
abstract getValue(useGamepad: boolean): number
// Returns the current value of the input. Range depends on input type
abstract getValue(useGamepad: boolean, useTouchControls: boolean): number
Copy link
Contributor

@LucaHaverty LucaHaverty Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead of getValue() taking in useTouchControls and useGamepad, the input scheme stored an enum InputType, replacing the boolean it currently has called useGamepad? That would avoid different input type conditions originating from different places and potentially overriding each other.

export enum InputType {
    KEYBOARD,
    GAMEPAD,
    TOUCH
 }

export type InputScheme = {
    schemeName: string
    descriptiveName: string
    customized: boolean
    inputType: InputType
    inputs: Input[]
}

@@ -18,8 +20,8 @@ abstract class Input {
this.inputName = inputName
}

/** @returns {number} a number between -1 and 1 for this input. */
abstract getValue(useGamepad: boolean): number
// Returns the current value of the input. Range depends on input type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every input should be between -1 and 1 for consistency

Changes that need to be made:
Only one of the usegamepad and usetouchcontrols checkboxes can be selected at a time
When creating a new scheme you may click an add joint button to add another joint configuration.
@Dhruv-0-Arora Dhruv-0-Arora marked this pull request as ready for review August 23, 2024 21:47
@Dhruv-0-Arora Dhruv-0-Arora requested review from HunterBarclay and a team as code owners August 23, 2024 21:47
@Dhruv-0-Arora Dhruv-0-Arora requested review from a-crowell and LucaHaverty and removed request for a team August 23, 2024 21:47
Copy link
Contributor

@LucaHaverty LucaHaverty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, but I have a couple requests and recommendations:

  1. If you aren't on a device that supports touch controls, the touch control scheme should not be selectable because there's not way to control it. If we keep a similar button, consider making it more opaque and blurring the background.
    image

  2. Instead of a button to open touch controls, they should automatically appear if there's a robot spawned that uses them.

  3. The place assembly button text is really hard to read with some backgrounds. It also looks a little out of place. I think this is because the colors and style are so different than the others buttons. Maybe it could appear on the panel that that loading bar is on once it finishes loading?

  4. When I connect to the network version, I get the error Uncaught TypeError: can't access property "getDirectory", navigator.storage is undefined MirabufLoader.ts:29. Is this just me?

@Dhruv-0-Arora Dhruv-0-Arora requested a review from a team as a code owner June 18, 2025 18:50
@Dhruv-0-Arora Dhruv-0-Arora removed the request for review from a-crowell June 18, 2025 18:50
@Dhruv-0-Arora Dhruv-0-Arora marked this pull request as draft June 20, 2025 16:27
@Dhruv-0-Arora Dhruv-0-Arora marked this pull request as ready for review June 20, 2025 22:26
Copy link
Member

@AlexD717 AlexD717 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of scaling issues on a phone, but I am assuming those either don't happen on a tablet/iPad or will be fixed later

@Dhruv-0-Arora
Copy link
Collaborator Author

There are a lot of scaling issues on a phone, but I am assuming those either don't happen on a tablet/iPad or will be fixed later

The scaling issues with be fixed with the UI refactor

@AlexD717 AlexD717 self-requested a review June 23, 2025 18:33
Copy link
Member

@AlexD717 AlexD717 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error when I try to spawn a robot after spawning a field. The error message is: Place assembly before spawning another (on desktop).

@Dhruv-0-Arora
Copy link
Collaborator Author

I get an error when I try to spawn a robot after spawning a field. The error message is: Place assembly before spawning another (on desktop).

Must be a merging error; I'll look into that

@Dhruv-0-Arora Dhruv-0-Arora requested a review from AlexD717 June 24, 2025 01:32
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: with the addition of the usesTouchControls, prettier will autoformat the axisInputs over multiple lines rather than condensing them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now why does prettier want to do this? Who knows 🤷

Copy link

@ariesninjadev ariesninjadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good.

As far as functionality goes, it was great. If I were to suggest anything, I'd say I think touch controls should be enabled by default on small screens, but not needed.

Also, I had trouble actually testing the functionality of the joysticks because seemingly the resolution of my Pixel 7 is too low and the config GUI was getting cut off (I couldn't close it). Ended up using a sim and it seemed fine.

To support more mobile devices, we may consider adding a fullscreen button, and UI scaling options.

@ariesninjadev ariesninjadev dismissed LucaHaverty’s stale review June 24, 2025 18:33

No longer a team member

Copy link
Member

@BrandonPacewic BrandonPacewic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think at this point these changes are good to go in. There is still lots of problems with getting everything working on mobile (particularly when it comes to smaller screens) however at this point the necessary changes are out of scope.

Few things to note for mobile updates that are needed:

  • Gamepad/Tough Control Checkbox Conflict AARD-1945.
  • Prevent Joint Auto-Configuration on New Touch Control Setup AARD-1946.
  • Implement Tough Control Top Auction UI AARD-1947.
  • Implement Tough Control Joint Slider UI AARD-1948.
  • General Mobile Device UI Updates (for small screen scaling issues +extra) AARD-1950.

That being said, these issues already existed and this PR is one more step to getting everything working on mobile. Glad to get the last major PR from last year done. 📵

@BrandonPacewic BrandonPacewic changed the title Touch Controls Input System Touch Controls Jun 24, 2025
@BrandonPacewic BrandonPacewic merged commit f76aaea into dev Jun 24, 2025
15 checks passed
@BrandonPacewic BrandonPacewic deleted the dhruv/1847/touch-controls branch June 24, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gameplay Relating to the playability of Synthesis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants