RetroArch
Classes | Typedefs | Functions | Variables
device_null.c File Reference
#include "hid_device_driver.h"
Include dependency graph for device_null.c:

Classes

struct  null_instance
 

Typedefs

typedef struct null_instance null_instance_t
 

Functions

static voidnull_init (void *handle)
 
static void null_free (void *data)
 
static void null_handle_packet (void *data, uint8_t *buffer, size_t size)
 
static bool null_detect (uint16_t vendor_id, uint16_t product_id)
 
static voidnull_pad_init (void *data, uint32_t slot, hid_driver_t *driver)
 
static void null_pad_deinit (void *data)
 
static void null_get_buttons (void *data, input_bits_t *state)
 
static void null_packet_handler (void *data, uint8_t *packet, uint16_t size)
 
static void null_set_rumble (void *data, enum retro_rumble_effect effect, uint16_t strength)
 
static int16_t null_get_axis (void *data, unsigned axis)
 
static const char * null_get_name (void *data)
 
static bool null_button (void *data, uint16_t joykey)
 

Variables

pad_connection_interface_t null_pad_connection
 
hid_device_t null_hid_device
 

Typedef Documentation

◆ null_instance_t

Function Documentation

◆ null_button()

static bool null_button ( void data,
uint16_t  joykey 
)
static

Read the state of a single button.

◆ null_detect()

static bool null_detect ( uint16_t  vendor_id,
uint16_t  product_id 
)
static

Return true if the passed in VID and PID are supported by the driver.

◆ null_free()

static void null_free ( void data)
static
Here is the call graph for this function:

◆ null_get_axis()

static int16_t null_get_axis ( void data,
unsigned  axis 
)
static

Read analog sticks. If the pad doesn't have any analog axis, just return 0 here.

The return value must conform to the following characteristics:

  • (0, 0) is center
  • (-32768,-32768) is top-left
  • (32767,32767) is bottom-right

◆ null_get_buttons()

static void null_get_buttons ( void data,
input_bits_t state 
)
static

Translate the button data from the pad into the input_bits_t format that RetroArch can use.

◆ null_get_name()

static const char* null_get_name ( void data)
static

The name the pad will show up as in the UI, also used to auto-assign buttons in input/input_autodetect_builtin.c

◆ null_handle_packet()

static void null_handle_packet ( void data,
uint8_t buffer,
size_t  size 
)
static

Handle a single packet from the device. For most pads you'd just forward it onto the pad driver (see below). A more complicated example is in the Wii U GC adapter driver.

◆ null_init()

static void* null_init ( void handle)
static

Use the HID_ macros (see input/include/hid_driver.h) to send data packets to the device. When this method returns, the device needs to be in a state where we can read data packets from the device. So, if there's any activation packets (see the ds3 and Wii U GameCube adapter drivers for examples), send them here.

While you can allocate the retro pad here, it isn't mandatory (see the Wii U GC adapter).

If initialization fails, return NULL.

Here is the call graph for this function:

◆ null_packet_handler()

static void null_packet_handler ( void data,
uint8_t packet,
uint16_t  size 
)
static

Handle a single packet for the pad.

Here is the call graph for this function:

◆ null_pad_deinit()

static void null_pad_deinit ( void data)
static

If you allocate any memory in null_pad_init() above, de-allocate it here.

◆ null_pad_init()

static void* null_pad_init ( void data,
uint32_t  slot,
hid_driver_t driver 
)
static

This is called via hid_pad_register(). In the common case where the device only controls one pad, you can simply return the data parameter. But if you need to track multiple pads attached to the same HID device (see: Wii U GC adapter), you can allocate that memory here.

◆ null_set_rumble()

static void null_set_rumble ( void data,
enum retro_rumble_effect  effect,
uint16_t  strength 
)
static

If the pad doesn't support rumble, then this can just be a no-op.

Variable Documentation

◆ null_hid_device

hid_device_t null_hid_device
Initial value:
= {
"Null HID device"
}
static void * null_init(void *handle)
Definition: device_null.c:50
static void null_handle_packet(void *data, uint8_t *buffer, size_t size)
Definition: device_null.c:93
static void null_free(void *data)
Definition: device_null.c:78
static bool null_detect(uint16_t vendor_id, uint16_t product_id)
Definition: device_null.c:104

Assign function pointers to the driver structure.

◆ null_pad_connection

pad_connection_interface_t null_pad_connection
Initial value:
= {
}
static void null_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength)
Definition: device_null.c:172
static int16_t null_get_axis(void *data, unsigned axis)
Definition: device_null.c:185
static const char * null_get_name(void *data)
Definition: device_null.c:194
static bool null_button(void *data, uint16_t joykey)
Definition: device_null.c:202
static void null_pad_deinit(void *data)
Definition: device_null.c:140
static void * null_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
Definition: device_null.c:126
static void null_packet_handler(void *data, uint8_t *packet, uint16_t size)
Definition: device_null.c:160
static void null_get_buttons(void *data, input_bits_t *state)
Definition: device_null.c:148

Fill in the joypad interface