generated from SteamDeckHomebrew/decky-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: eXhumer <[email protected]>
- Loading branch information
Showing
3 changed files
with
80 additions
and
64 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { gamepadDialogClasses, joinClassNames, PanelSectionRow } from "@decky/ui"; | ||
import { IController } from "../types"; | ||
import { IconContext } from "react-icons"; | ||
import { BiBluetooth, BiUsb } from "react-icons/bi"; | ||
import VendorIcon from "./VendorIcon"; | ||
import BatteryIcon from "./BatteryIcon"; | ||
|
||
const FieldWithSeparator = joinClassNames(gamepadDialogClasses.Field, gamepadDialogClasses.WithBottomSeparatorStandard); | ||
|
||
type ControllersViewProps = { | ||
controllers: IController[]; | ||
}; | ||
|
||
const ControllersView = ({ controllers }: ControllersViewProps) => { | ||
return ( | ||
controllers.sort((a, b) => a.name.localeCompare(b.name)).map((controller) => ( | ||
<PanelSectionRow key={controller.productId}> | ||
<div className={FieldWithSeparator}> | ||
<div className={gamepadDialogClasses.FieldLabelRow}> | ||
<div className={gamepadDialogClasses.FieldLabel}> | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginRight: '10px' } }}> | ||
{controller.bluetooth ? <BiBluetooth /> : <BiUsb />} | ||
</IconContext.Provider> | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginRight: '5px' } }}> | ||
<VendorIcon controller={controller}/> | ||
</IconContext.Provider> | ||
{controller.name} | ||
</div> | ||
{ | ||
(controller.capacity > 0 || controller.status !== "unknown") && | ||
<div className={gamepadDialogClasses.FieldChildrenInner}> | ||
{ | ||
// only show battery capacity for non-MS vendors unless capacity is > 0 and over BT | ||
// since we don't have the battery capacity yet for Xbox over USB | ||
(controller.vendorId != 0x045E || (controller.capacity > 0 && controller.bluetooth)) && | ||
<span style={{ display: "inline-block", textAlign: "right", }}>{controller.capacity}%</span> | ||
} | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginLeft: "6px" }, size: '2em' }}> | ||
<BatteryIcon controller={controller}/> | ||
</IconContext.Provider> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
</PanelSectionRow> | ||
)) | ||
); | ||
}; | ||
|
||
export default ControllersView; |
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 @@ | ||
import { gamepadDialogClasses, joinClassNames, PanelSectionRow } from "@decky/ui"; | ||
|
||
const FieldWithSeparator = joinClassNames(gamepadDialogClasses.Field, gamepadDialogClasses.WithBottomSeparatorStandard); | ||
|
||
type NoControllersViewProps = { | ||
loading: boolean; | ||
}; | ||
|
||
const NoControllersView = ({ loading }: NoControllersViewProps) => { | ||
return ( | ||
<PanelSectionRow> | ||
<div className={FieldWithSeparator}> | ||
<div className={gamepadDialogClasses.FieldLabelRow}> | ||
<div className={gamepadDialogClasses.FieldLabel}> | ||
{loading ? 'Loading...' : 'No controllers found'} | ||
</div> | ||
</div> | ||
</div> | ||
</PanelSectionRow> | ||
); | ||
}; | ||
|
||
export default NoControllersView; |
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