このjoystickモージュールは、コンピューターに接続されたジョイスティック機器の管理を行います(ジョイスティックは複数接続できます)。ここでいうジョイスティック機器にはトラックボールやTVゲームに使うコントロールパッドなどが含まれます。このモジュールによって、ボタンやハットスイッチなど複数の入力装置を使用したゲーム操作が行えるようになります。
The joystick module manages the joystick devices on a computer (there can be more than one). Joystick devices include trackballs and video-game-style gamepads, and the module allows the use of multiple buttons and "hats".
この命令はpygame.init命令を実行したときに自動的に実行されます。
この命令でjoystickモジュールを初期化します。プレイヤーパソコン環境にて、接続されている全てのジョイスティック機器を使用可能かスキャンを行います。このページにある他のジョイスティック操作命令を実行する前には、この命令を必ず実行してください。
この命令は複数回実行しても特に問題ありません。
This function is called automatically by pygame.init - initialize all imported pygame modules.
It initializes the joystick module. This will scan the system for all joystick devices. The module must be initialized before any other functions will work.
It is safe to call this function more than once.
joystickモジュールの初期化を解除します。この命令を実行すると、作成済みのjoystickオブジェクトは一切動作しなくなります。
この命令は複数回実行しても特に問題ありません。
Uninitialize the joystick module. After you call this any existing joystick objects will no longer work.
It is safe to call this function more than once.
pygame.joystick.init命令が実行されているかを確認します。
Test if the pygame.joystick.init - initialize the joystick module function has been called.
パソコンに接続されているジョイスティック機器の数を戻り値として返します。ジョイスティック機器が一つも接続されてない場合は0が戻り値として返されます。
pygame.joystick.Joystick(id)命令を使用してJoystickオブジェクトを新規に作成する場合は、ここで取得された数値よりも低い数値を引数に設定しなければいけません。
Return the number of joystick devices on the system. The count will be 0 if there are no joysticks on the system.
When you create Joystick objects using Joystick(id), objects using , you pass an integer that must be lower than this count.
物理デバイスにアクセルするためのjoystickオブジェクトを新規に作成します。ここで設定するid引数は「0~pygame.joystick.get_count()の戻り値より1小さい値」でなければいけません。
Joystickオブジェクトの命令を実行するためには、あらかじめJoystickオブジェクトをinit()で初期化しておく必要があります。この初期化は、ジョイスティックモジュールの初期化とは別に行っておかなければなりません。同一のジョイスティック機器に対して複数のJoystickオブジェクトが設定された場合、(例えば、複数のJoystickオブジェクトに同じIDが設定されていた状態)、それらのオブジェクト間では現在の状態や内部情報が共有されます。
Joystickオブジェクトを使用することで、ジョイスティック機器の操作状況を取得することができます。ジョイスティック機器が初期化されると、Pygameのイベントキューはその機器からの入力情報のイベントを取得を開始します。
Joystickオブジェクトの初期化を行っていなくても、Joystick.get_name命令とJoystick.get_id命令については実行することができます。
Create a new joystick to access a physical device. The id argument must be a value from 0 to pygame.joystick.get_count()-1.
To access most of the Joystick methods, you'll need to init() the Joystick. This is separate from making sure the joystick module is initialized. When multiple Joysticks objects are created for the same physical joystick device (i.e., they have the same ID number), the state and values for those Joystick objects will be shared.
The Joystick object allows you to get information about the types of controls on a joystick device. Once the device is initialized the Pygame event queue will start receiving events about its input.
You can call the Joystick.get_name - get the Joystick system name and Joystick.get_id - get the Joystick ID functions without initializing the Joystick object.
ジョイスティックの操作状況を取得するためには、Joystickオブジェクト初期化しておかなければなりません。Joystickオブジェクトが初期化されると、Pygameのイベントキューはその機器からの入力情報の取得のイベントを開始します
この命令を複数回実行しても特に問題はありません。
The Joystick must be initialized to get most of the information about the controls. While the Joystick is initialized the Pygame event queue will receive events from the Joystick input.
Joystickオブジェクトの初期を解除します。この命令が実行された後は、Pygameのイベントキューはジョイスティック機器からのイベント情報を受け取ることができなくなります。
この命令を複数回実行しても特に問題はありません。
This will unitialize a Joystick. After this the Pygame event queue will no longer receive events from the device.
It is safe to call this more than once.
Joystickオブジェクトのinit()命令が実行済みの場合はTrueが戻り値として返ります。
Returns True if the init() method has already been called on this Joystick object.
ジョイスティック機器を識別するための数字IDを戻り値をして返します。ここで取得される数字は、pygame.joystick.Joystick(id)でオブジェクトを作成したときに設定したIDと同じものです。この命令はJoystickオブジェクトを初期化する前に実行しても特に問題ありません。
Returns the integer ID that represents this device. This is the same value that was passed to the Joystick() constructor. This method can safely be called while the Joystick is not initialized.
ジョイスティック機器のシステム名を戻り値として返します。システムがジョイスティック機器にどういった名前を割り振るかは分かりませんが、機器を識別するための固有のシステム名が割り振られます。この命令はJoystickオブジェクトを初期化する前に実行しても特に問題ありません。
Returns the system name for this joystick device. It is unknown what name the system will give to the Joystick, but it should be a unique name that identifies the device. This method can safely be called while the Joystick is not initialized.
ジョイスティック機器に搭載された入力用レバー数を戻り値として返します。通常のジョイスティックなら2が戻り値として返ります。ラダーペダルやスロットルレバーのようなコントローラーも追加のレバーとして扱われます。
pygame.JOYAXISMOTIONイベントでは、-1.0から1.0までの値が取得されます。値が0.0の場合、レバーは中央にあります。ゲームパッドを使用しているのなら取得される値は通常-1か0か1の三つの整数値となり、その間にある少数値になることはありません。古いアナログ式ジョイスティックのレバーの場合は、取得される値は-1や0や1といった整数ではなく0を中央とした少数値となります。 Analog joysticks usually have a bit of noise in their axis, which will generate a lot of rapid small motion events.
Returns the number of input axes are on a Joystick. There will usually be two for the position. Controls like rudders and throttles are treated as additional axes.
The pygame.JOYAXISMOTION events will be in the range from -1.0 to 1.0. A value of 0.0 means the axis is centered. Gamepad devices will usually be -1, 0, or 1 with no values in between. Older analog joystick axes will not always use the full -1 to 1 range, and the centered value will be some area around 0. Analog joysticks usually have a bit of noise in their axis, which will generate a lot of rapid small motion events.
ジョイスティックの操作用レバーの傾き位置を戻り値として返します。取得される値は-1から1の範囲となり、値が0の場合レバーは中央にあります。 You may want to take into account some tolerance to handle jitter, and joystick drift may keep the joystick from centering at 0 or using the full range of position values.
axis_number引数に設定する値は、「0~pygame.joystick.get_numaxes()の戻り値より1小さい値」でなければいけません。
Returns the current position of a joystick axis. The value will range from -1 to 1 with a value of 0 being centered. You may want to take into account some tolerance to handle jitter, and joystick drift may keep the joystick from centering at 0 or using the full range of position values.
The axis number must be an integer from zero to get_numaxes()-1.
ジョイスティック機器に搭載されたトラックボールの数を戻り値として返します。トラックボールはマウスと同じような操作機器ですが、絶対位置というものがありません。; 相対的な移動距離のみを入力できます。
トラックボールが動かされたとき、pygame.JOYBALLMOTIONイベントがイベントキューに送られます。トラックボールの動かされた距離が情報として伝えられるのです。
Returns the number of trackball devices on a Joystick. These devices work similar to a mouse but they have no absolute position; they only have relative amounts of movement.
The pygame.JOYBALLMOTION event will be sent when the trackball is rolled. It will report the amount of movement on the trackball.
ジョイスティックボタンの相対的な移動距離を戻り値として返します。ここで取得できるxとyの値は、最後にget_ball命令が呼び出された時の位置からどれだけ移動したかを表します。
ball_number引数に設定する値は、「0~pygame.joystick.get_numballs()の戻り値より1小さい値」でなければいけません。
Returns the relative movement of a joystick button. The value is a x, y pair holding the relative movement since the last call to get_ball.
The ball number must be an integer from zero to get_numballs()-1.
ジョイスティック機器に搭載されたプッシュボタンの数を戻り値として返します。これらのボタンは、押されているか押されていないかの状態を表すboolean型の値を持っています。
ボタンが押されたり離されたりすると、pygame.JOYBUTTONDOWNイベントやpygame.JOYBUTTONUPイベントが発生します。
Returns the number of pushable buttons on the joystick. These buttons have a boolean (on or off) state.
Buttons generate a pygame.JOYBUTTONDOWN and pygame.JOYBUTTONUP event when they are pressed and released.
ジョイスティック機器に搭載されたボタンの現在の状態を戻り値として返します。
Returns the current state of a joystick button.
ジョイスティック機器に搭載されたハットスイッチの数を戻り値として返します。ハットスイッチとは、ジョイスティック上にある小型の仮想ジョイスティックのようなものです。ハットスイッチには二つの入力用レバーが付いています。
ハットスイッチを動かすと、pygame.JOYHATMOTIONイベントが発生します。イベントには-1か0か1で位置情報を表すペアの値が含まれています。 位置情報が(0, 0)の場合はハットスイッチは中央にあります。
Returns the number of joystick hats on a Joystick. Hat devices are like miniature digital joysticks on a joystick. Each hat has two axes of input.
The pygame.JOYHATMOTION event is generated when the hat changes position. The position attribute for the event contains a pair of values that are either -1, 0, or 1. A position of (0, 0) means the hat is centered.
ハットスイッチの現在の傾き位置情報を戻り値として返します。ここで取得される位置情報は、ハットスイッチのX座標とY座標を表す二つの値となります。座標が(0, 0)の場合、ハットスイッチは中央にあります。-1の場合はスイッチが左もしくは下に動いていることを表し、1の場合は右か上へ動いていることを表します。:したがって、(-1, 0)は左位置; (1, 0)は右位置; (0, 1) は上位置; (1, 1)は右上位置;などとなります。
この値はデジタル値となります。つまり各座標の値は-1か0か1の三つの整数値にしかならず、その間にある少数値にはなりません。
hat_number引数に設定する値は、「0~pygame.joystick.get_numhats()の戻り値より1小さい値」でなければいけません。
Returns the current position of a position hat. The position is given as two values representing the X and Y position for the hat. (0, 0) means centered. A value of -1 means left/down and a value of 1 means right/up: so (-1, 0) means left; (1, 0) means right; (0, 1) means up; (1, 1) means upper-right; etc.
This value is digital, i.e., each coordinate can be -1, 0 or 1 but never in-between.
The hat number must be between 0 and get_numhats()-1.