nx package¶
Submodules¶
nx.audio module¶
Yet to be implemented.
nx.controllers module¶
-
class
nx.controllers.
Button
(player, *key_bits)[source]¶ Bases:
object
Represents a button or button-like object.
-
is_pressed
¶ Indicates whether the Button is pressed.
-
-
class
nx.controllers.
ButtonGroup
(*buttons)[source]¶ Bases:
nx.controllers.Button
Represents a group of
Button
objects.-
pressed
¶
-
-
class
nx.controllers.
Controller
(player)[source]¶ Bases:
object
Represents an abstract controller.
Attribute: player Type: Player The player to whom the Controller belongs to.
Attribute: a_button Type: Button The A button of the controller.
Attribute: b_button Type: Button The B button of the controller.
Attribute: x_button Type: Button The X button of the controller.
Attribute: y_button Type: Button The Y button of the controller.
-
static
from_player
(player)[source]¶ <todo>
Parameters: player – <todo> Returns: <todo> Controller class Return type: Controller
-
static
-
class
nx.controllers.
DualJoyconController
(player)[source]¶ Bases:
nx.controllers.StandardController
Represents two Joy-Cons in combination, attached to rails
-
is_attached
= True¶
-
-
class
nx.controllers.
FreeDualJoyconController
(player)[source]¶ Bases:
nx.controllers.DualJoyconController
Represents two Joy-Cons in combination, detached from rails
-
is_attached
= False¶
-
-
class
nx.controllers.
JoyconController
(player, is_left, parent=None)[source]¶ Bases:
nx.controllers.Controller
Represents a single Joycon controller.
Attribute: is_left Type: bool Whether the JoyconController is the left or right Joy-Con.
Attribute: parent Type: <todo> The parent Controller of the Joy-Con.
Attribute: stick_button Type: Button The button located in the analogue stick, when it is pressed.
Attribute: l_or_r_button Type: Button Either the L or R button on the controller, dependent on which Joy-Con.
Attribute: zl_or_zr_button Type: Button Either the ZL or ZR button on the controller, dependent on which Joy-Con.
Attribute: plus_or_minus_button Type: Button Either the + or - button on the controller, dependent on which Joy-Con.
Attribute: stick Type: Stick The analogue stick of the controller.
Attribute: left Type: Button The analogue stick in the left position.
Attribute: right Type: Button The analogue stick in the right position.
Attribute: up Type: Button The analogue stick in the up position.
Attribute: down Type: Button The analogue stick in the down position.
-
class
nx.controllers.
StandardController
(player)[source]¶ Bases:
nx.controllers.Controller
-
class
nx.controllers.
Stick
(player, is_left)[source]¶ Bases:
object
Represents the analogue stick on the controller.
-
down
¶ Returns: A value indicating whether or not the stick is in the down position Return type: bool
-
left
¶ Returns: A value indicating whether or not the stick is in the left position Return type: bool
-
right
¶ Returns: A value indicating whether or not the stick is in the right position Return type: bool
-
up
¶ Returns: A value indicating whether or not the stick is in the up position Return type: bool
-
x
¶ The current x value of the analogue stick
Returns: The float value of the stick’s x location. Return type: float
-
y
¶ The current y value of the analogue stick
Returns: The float value of the stick’s y location. Return type: float
-
-
class
nx.controllers.
SwitchProController
(player)[source]¶ Bases:
nx.controllers.StandardController
Represents a Switch Pro Controller. Can also be a similar controller with the same buttons.
-
nx.controllers.
any_pressed
(player, *buttons, refresh_input=False)[source]¶ Checks if any of the given buttons are pressed, or if any buttons are pressed at all in case no buttons are given.
- player:
Player
- The player to check with.
- buttons: Optional[one or more
Button
objects OR Tuple[Button]] - Buttons to check for. Checks if no Button is pressed if none given.
- refresh_input: Optional[bool]
- Whether or not to check for new inputs. Checks with inputs from last refresh if False. Defaults to False.
- player:
-
nx.controllers.
is_pressed
(player, button: nx.controllers.Button, refresh_input=False)[source]¶ Checks if any of the given buttons are pressed, or if any buttons are pressed at all in case no buttons are given.
- player:
Player
- The player to check with.
- button:
Button
- Button to check for.
- refresh_input: Optional[bool]
- Whether or not to check for new inputs. Checks with inputs from last refresh if False. Defaults to False.
- player:
-
nx.controllers.
refresh_inputs
()[source]¶ Refreshes inputs. Should normally be called at least once within every iteration of your main loop.
-
nx.controllers.
which_pressed
(player, *buttons, refresh_input=False)[source]¶ Checks which of the given buttons are pressed.
- player:
Player
- The player to check with.
- buttons: one or more
Button
objects OR Tuple[Button] - Buttons to check for.
- refresh_input: Optional[bool]
- Whether or not to check for new inputs. Checks with inputs from last refresh if False. Defaults to False.
A list of
Button
objects.- player:
nx.filesystem module¶
-
class
nx.filesystem.
FileSystem
(base_path: str)[source]¶ Bases:
object
Represents a filesystem.
- base_path: pathlib.Path
- The base path of the filesystem.
-
open
(file_path: str, mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]¶ Opens a file given a file path and returns a file-like object. Apart from the
file_path: str
parameter, this method works the same way aspathlib.Path.open
, thus it works pretty much the same way as theopen
function.
-
class
nx.filesystem.
MountableFileSystem
(base_path)[source]¶ Bases:
nx.filesystem.FileSystem
Represents a filesystem that is able to be mounted.
- base_path: pathlib.Path
- The base path of the filesystem.
-
is_mounted
¶ Whether or not the filesystem is currently mounted.
-
open
(file_path: str, mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]¶ Opens a file given a file path and returns a file-like object. Apart from the
file_path: str
parameter, this method works the same way aspathlib.Path.open
, thus it works pretty much the same way as theopen
function.
-
class
nx.filesystem.
RomFS
(title)[source]¶ Bases:
nx.filesystem.MountableFileSystem
Represents the data filesystem of a title. Do not instantiate this. Rather, get a RomFS object via
nx.titles[MY_TITLE_ID].romfs
.- title:
Title
- The title this RomFS belongs to.
- base_path: pathlib.Path
- The base path of the RomFS.
-
is_mounted
¶ Whether the RomFS is mounted.
- title:
-
class
nx.filesystem.
Savedata
(title, user=None)[source]¶ Bases:
nx.filesystem.MountableFileSystem
Represents the savedata filesystem of a title. Do not instantiate this. Rather, get a Savedata object via
nx.titles[MY_TITLE_ID].savedata
.- title:
Title
- The title this Savedata belongs to.
- base_path: pathlib.Path
- The base path of the savedata filesystem.
-
backup
(destination: str = None)[source]¶ Creates a backup of the savedata.
- destination: str
- Directory path where the backup will be created. If the directory doesn’t exist already, it will be created. The operation will fail if the directory already exists and is not empty. Defaults to ‘/backups/savedata/{title_id}/’.
-
is_mounted
¶ Whether the savedata filesystem has been mounted.
- title:
nx.players module¶
-
class
nx.players.
Player
(number)[source]¶ Bases:
object
Represents a player. You shouldn’t instantiate this yourself. Rather, access Player objects via
nx.p1
,nx.p2
, …nx.p8
.- number: int
- The player’s number, e.g. Player 1’s number is 1.
- controller:
Controller
- The player’s controller.
In addition, a Player has several properties depending on the type of
Controller
they are using. To begin with, a Player will have a property that points to aButton
for each of the Buttons their Controller has. These properties can returnNone
if a Button is not available on the Controller used by the Player. Furthermore, a Player will always have the propertiesleft
,right
,up
,down
andstick
. These work similar to the ones found in the Controller classes. Finally, a Player can also have the propertiesleft_stick
,right_stick
,left_joycon
andright_joycon
if their controller has these attributes.
nx.title module¶
-
class
nx.title.
Title
(id: int)[source]¶ Bases:
object
Represents a title that is installed on or inserted into the Switch. Do not instantiate this. Rather, get a Title object via
nx.titles[MY_TITLE_ID]
- id: int
- The title ID.
- romfs:
RomFS
- The title’s ROM filesystem.
- savedata:
Savedata
- The title’s savedata filesystem.
nx.touch module¶
-
class
nx.touch.
Touch
(x, y, dx, dy, angle)[source]¶ Bases:
object
Represents a touch point.
- x: float
- The x coordinate of the touch.
- y: float
- The y coordinate of the touch.
- dx: float
- The width of the touch in pixels.
- dy: float
- The height of the touch in pixels.
- angle: float
- The angle of the touch.
-
class
nx.touch.
TouchScreen
[source]¶ Bases:
nx.controllers.Button
Represents the Switch’s touchscreen.