##### Shinobi library - Peripheral Data Structure

# PDS_PERIPHERAL

Structure that stores control pad status information

### DEFINITION

      typedef struct {
       Uint32 id;
       Uint32 support;
       Uint32 on;
       Uint32 off;
       Uint32 press;
       Uint32 release;
       Uint16 r;
       Uint16 l;
       Sint16 x1;
       Sint16 y1;
       Sint16 x2;
       Sint16 y2;
       Sint8* name;
       void* extend;
       Uint32 old;
       PDS_PERIPHERALINFO* info;
      } PDS_PERIPHERAL;

### MEMBER

  `id` | Device ID
  `support` | Button, lever support status
  `on` | Digital button status
  `off` | Digital button status (reverse)
  `press` | Digital button down edge status
  `release` | Digital button up edge status
  `r` | R trigger value (from 0 to 255)
  `l` | L trigger value (from 0 to255)
  `x1` | X-value (from -128 to 127) of analog directional key 1
  `y1` | Y-value (from -128 to 127) of analog directional key 1
  `x2` | X-value (from -128 to 127) of analog directional key 2
  `y2` | Y-value (from -128 to 127) of analog directional key 2
  `name` | Device name
  `extend` | Extended data address (unused)
  `old` | Reserved

### DESCRIPTION

  Structure that stores the status of the control pad.

  Member `support` has the following bit assignments.

  Bits are stored as 1 if the front has buttons and levers and 0 if the front has no buttons or levers.

  Constant for bit assignment | Button or Lever
  PDD_DEV_SUPPORT_KU | Directional button A up
  PDD_DEV_SUPPORT_KD | Directional button A down
  PDD_DEV_SUPPORT_KL | Directional button A left
  PDD_DEV_SUPPORT_KR | Directional button A right
  PDD_DEV_SUPPORT_KUB | Directional button B up
  PDD_DEV_SUPPORT_KDB | Directional button B down
  PDD_DEV_SUPPORT_KLB | Directional button B left
  PDD_DEV_SUPPORT_KRB | Directional button B right
  PDD_DEV_SUPPORT_ST | Start button
  PDD_DEV_SUPPORT_TA | A button
  PDD_DEV_SUPPORT_TB | B button
  PDD_DEV_SUPPORT_TC | C button
  PDD_DEV_SUPPORT_TD | D button
  PDD_DEV_SUPPORT_TX | X button
  PDD_DEV_SUPPORT_TY | Y button
  PDD_DEV_SUPPORT_TZ | Z button
  PDD_DEV_SUPPORT_AR | R trigger
  PDD_DEV_SUPPORT_AL | L trigger
  PDD_DEV_SUPPORT_AX1 | Analog directional key 1x
  PDD_DEV_SUPPORT_AY1 | Analog directional key 1y
  PDD_DEV_SUPPORT_AX2 | Analog directional key 2x
  PDD_DEV_SUPPORT_AY2 | Analog directional key 2y

  For the four members of `on`, `off`, `press` and `release`, digital information is stored and used as needed.

  Buttons are allocated in the bits of each member and have the property of 1 if pressed, 0 if not pressed (positive logic). Furthermore, the logic status is set to negative logic when the initialization function `pdInitPeripheral()` is called.

  Bit assignments | Digital button
  PDD_DGT_KU | Directional button A up
  PDD_DGT_KD | Directional button A down
  PDD_DGT_KL | Directional button A left
  PDD_DGT_KR | Directional button A right
  PDD_DGT_KUB | Directional button B up
  PDD_DGT_KDB | Directional button B down
  PDD_DGT_KLB | Directional button B left
  PDD_DGT_KRB | Directional button B right
  PDD_DGT_ST | Start button
  PDD_DGT_TA | A button
  PDD_DGT_TB | B button
  PDD_DGT_TC | C button
  PDD_DGT_TD | D button
  PDD_DGT_TX | X button
  PDD_DGT_TY | Y button
  PDD_DGT_TZ | Z button
  PDD_DGT_TL | L button
  PDD_DGT_TR | R button

  The corresponding bit for member `on` becomes 1 when the button is pressed (button down). When the button is not pressed, the bit is 0.

  Member `off` is the reverse bit of member `on`. The corresponding bit for member `off` is 1 when the button is not pressed (button up).

  When member `press` status changes from the button not being pressed to a pressed status (button down edge), the corresponding bit is 1. Otherwise the bit is 0.

  When member `release` status changes from the the button being pressed to the button not being pressed (button up edge), the corresponding bit is 1. Otherwise, the bit is 0.

  If negative logic is set, all bits for `button`, `on`, `off`, `press`, `release` are inversely stored.

  Digital LR button information is imitated by the software from the LR trigger information. Note that if there is no LR trigger device, the bit does not change. (There is no device that physically has digital LR buttons).

  Analog data is stored in members r, l, x1, y1, x2, and y2. These center position values are 0.

  The display ID of device type and device name are stored in a gotten structure. In the Maple Bus specs, the device ID is not oriented for handling by the application because the device ID that can be acquired has a complicated format.

  Acquiring the device ID is simplified in the Shinobi library and is defined as follows.

  Device | DeviceID (id) | Device name (name)
  Standard control pad | PDD_DEV_CONTROLER | The brand name for the device

### NOTE

  Because controller devices always have the direction key A, start button, A button, B button, it is possible to maintain compatibility by combining applications using only these buttons.

### REFERENCE

  `pdExecPeripheralServer()
  pdGetPeripheral()
  pdGetPeripheralInfo()
  `

PDS_PERIPHERAL

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999