The cl-gamepad Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-gamepad Reference Manual

This is the cl-gamepad Reference Manual, version 2.0.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:17:06 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

About cl-gamepad

This is a small wrapper library around libstem_gamepad, providing independent gamepad input support.

How To

Precompiled versions of the library are already provided in the repository for most major platforms. However, you may build your own version from the above repository if you so please.

Simply load cl-gamepad with ASDF or Quicklisp

(ql:quickload :cl-gamepad)

Before you can handle any devices, you must call init in order to set the environment up and prepare everything. If you would like to use a notification based mechanism, you should also define overrides for the device-attached, device-removed, button-pressed, button-released, and axis-moved functions. For illustrative purposes we will do so just for two of those here:

(defun cl-gamepad:device-attached (device)
  (format T "~&Found new device: ~a" device))

(defun cl-gamepad:device-removed (device)
  (format T "~&Device removed: ~a" device))

(cl-gamepad:init)

Next you need to call detect-devices whenever your application is ready to add new devices (this may or may not be always) and call process-events in your game/event/whatever loop to receive and process events. For simplicity's sake we will just call both in a loop here.

(loop (cl-gamepad:detect-devices)
      (cl-gamepad:process-events)
      (format T "~&Device status: ~&~a" (mapcar #'cl-gamepad:device-plist (cl-gamepad:devices)))
      (sleep 0.5))

Note that the button and axis IDs you receive in the callback are just numbers and may differ between controllers and platforms. In order to help standardise this, cl-gamepad includes a device-map functionality. Using axis-label, axis-multiplier, and button-label, the various features can be normalised. See the corresponding docstrings for the defined set of labels and what they mean.

Unfortunately the mapping is not automatable and the current database of known devices included in cl-gamepad is rather small. It is thus very well possible that the functions will just return :unknown instead. However, using the visualizer below you can figure out that mapping and define it yourself. If you have a controller that isn't in the database yet, please take the time to map it out and send the definition to us, either as a PR or as an issue.

You can view and set the complete mapping for a given controller via device-map. It takes the controller's vendor and product IDs to identify the controller kind. Usually however you'll want a more convenient way to define a mapping, which you can do through define-gamepad. An example mapping for the Buffalo BSGP801 controller on Linux looks like this:

(define-gamepad buffalo-bsgp801 (1411 8288)
  (:buttons
   ( 0 :b)
   ( 1 :a)
   ( 2 :x)
   ( 3 :y)
   ( 4 :l1)
   ( 5 :r1)
   ( 6 :select)
   ( 7 :start))
  (:axes
   ( 0 :dpad-h)
   ( 1 :dpad-v)))

For a listing of existing device mappings, see the database-lin, database-mac, database-win files.

Finally, during shut down of your application -- or whenever you no longer want to receive input -- you should call shutdown to clean everything up.

(cl-gamepad:shutdown)

Visualizer

Cl-gamepad includes a little visualizer Qt application that lets you view the complete controller state graphically. You can use this to test the library, your controller, or figure out the ID mapping of the buttons and axis.

(ql:quickload :cl-gamepad-visualizer)
(cl-gamepad-visualizer:main)

By clicking on an axis or button you can assign the label you deem fitting to it. Once all the buttons and axes have been assigned, you can click on the export button to get a nicely formatted definition form that you can use to persist the configuration in code.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-gamepad

Maintainer

Nicolas Hafner <shinmera@tymoon.eu>

Author

Nicolas Hafner <shinmera@tymoon.eu>

Home Page

https://github.com/Shirakumo/cl-gamepad

License

Artistic

Description

Bindings to libstem_gamepad, allowing the handling of gamepad input.

Version

2.0.0

Dependencies
Source

cl-gamepad.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-gamepad.asd

Location

cl-gamepad.asd

Systems

cl-gamepad (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-gamepad/package.lisp

Parent

cl-gamepad (system)

Location

package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cl-gamepad/low-level.lisp

Dependency

package.lisp (file)

Parent

cl-gamepad (system)

Location

low-level.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 cl-gamepad/wrapper.lisp

Dependency

low-level.lisp (file)

Parent

cl-gamepad (system)

Location

wrapper.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 cl-gamepad/documentation.lisp

Dependency

wrapper.lisp (file)

Parent

cl-gamepad (system)

Location

documentation.lisp


Previous: , Up: Lisp files   [Contents][Index]

3.1.6 cl-gamepad/database-lin.lisp

Dependency

documentation.lisp (file)

Parent

cl-gamepad (system)

Location

database-lin.lisp


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 cl-gamepad

Source

package.lisp (file)

Nickname

org.shirakumo.fraf.gamepad

Use List
Exported Definitions
Internal Definitions

Previous: , Up: Packages   [Contents][Index]

4.2 cl-gamepad-cffi

Source

package.lisp (file)

Nickname

org.shirakumo.fraf.gamepad.cffi

Use List
Used By List

cl-gamepad

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Constants

Constant: device-map-max

Returns the maximum ID that can be referenced from a device-map.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: define-gamepad NAME (VENDOR PRODUCT &key INHERIT) &body MAP

Define the mapping for a particular gamepad device.

The MAP should follow the same schema as the one defined in the DEVICE-MAP docstring. if the INHERIT option is passed, the defined mappings are merged together with those of the inherited gamepad mapping definition. This allows you to easily define gamepads that are otherwise very similar.

See DEVICE-MAP
See GAMEPAD-DEFINITION

Package

cl-gamepad

Source

wrapper.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Compiler macros

Compiler Macro: axis-count DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: button-count DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: description DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: detect-devices ()
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: device-count ()
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: id DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: process-events ()
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: product DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Compiler Macro: vendor DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Functions

Function: axes DEVICE

Returns a vector of the state of each axis on the gamepad device.

See DEVICE
See AXIS

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: axis DEVICE AXIS

Return the current state of a particular axis on the gamepad device.

The axis should be a number from 0 below DEVICE-AXIS-COUNT.
If an invalid axis id is passed, an INDEX-OUT-OF-RANGE error is signalled.
Returned is a float in the range [-1 1].
The axis direction is normalised per the axis multiplier in the corresponding device map.

See DEVICE
See AXIS-COUNT

Package

cl-gamepad-cffi

Source

wrapper.lisp (file)

Function: axis-count DEVICE

Returns the number of axes the controller seems to have.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: axis-label DEVICE AXIS

Return the label for the given physical axis on the gamepad device.

The axis should be a number from 0 below DEVICE-AXIS-COUNT.
If an invalid axis id is passed, :UNKNOWN is returned.
Returned is a keyword out of the following set:

:unknown — An unknown axis. The default.
:l-h — The horizontal movement of the left analog stick. :l-v — The vertical movement of the right analog stick. :r-h — The horizontal movement of the right analog stick. :r-v — The vertical movement of the right analog stick- :dpad-h — The horizontal movement of the dpad.
:dpad-v — The vertical movement of the dpad.
:dpad-l — The movement of the left dpad button.
:dpad-r — The movement of the right dpad button.
:dpad-u — The movement of the up dpad button.
:dpad-d — The movement of the down dpad button. :button-x — The amount the X (left) button is pressed. :button-y — The amount the Y (up) button is pressed. :button-z — The amount the Z button is pressed. :button-a — The amount the A (down) button is pressed. :button-b — The amount the B (right) button is pressed. :button-c — The amount the C button is pressed. :l1 — The amount the left upper trigger is pressed. :l2 — The amount the left lower trigger is pressed. :r1 — The amount the right upper trigger is pressed. :r2 — The amount the right lower trigger is pressed. :tilt-x — The tilting of the controller in X direction. :tilt-y — The tilting of the controller in Y direction. :tilt-z — The tilting of the controller in Z direction. :move-x — The acceleration in X direction.
:move-y — The acceleration in Y direction.
:move-z — The acceleration in Z direction.
:wheel — The turning of the wheel.
:accelerator — The amount the accelerator is pressed.
:brake — The amount the brake is pressed.
:x — The movement of the joystick in X direction. :y — The movement of the joystick in Y direction. :z — The rotation of the joystick in Z direction. :throttle — The value of the throttle.

The button map is mostly modelled after the XBOX360 controller.

See DEVICE
See DEVICE-MAP

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: axis-moved AXIS LAST-VALUE VALUE TIME DEVICE

This function is called whenever an axis is moved.

AXIS is an integer identifying the axis on the controller. LAST-VALUE is a float representing the value of this axis at the previous time AXIS-MOVED was called.
VALUE is a float representing the current value of this axis. TIME is a float representing the time at which the movement occurred precisely.

LAST-VALUE and VALUE are in the range of [-1 1].

Note that the values are NOT multiplied by the axis-multiplier defined in the corresponding device map. You are responsible for normalising the direction yourself.

You should override this function if you want to use a notification mechanism. By default this function does nothing.

This function is called in the same thread as the DETECT-DEVICES or PROCESS-EVENTS call occurs that triggers it and may thus block it.

See DEVICE
See DETECT-DEVICES
See PROCESS-EVENTS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: axis-multiplier DEVICE AXIS

Return the multiplier for the axis value.

Returns either 1 or -1 depending on whether the value of the axis should be inverted or not.
The axis should be a number from 0 below DEVICE-AXIS-COUNT. If an invalid axis id is passed, 1 is returned.

See DEVICE
See DEVICE-MAP

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: button DEVICE BUTTON

Return the current state of a particular button on the gamepad device.

The button should be a number from 0 below DEVICE-BUTTON-COUNT.
If an invalid button id is passed, an INDEX-OUT-OF-RANGE error is signalled.
Returned is T for pressed and NIL for released.

See DEVICE
See DEVICE-BUTTON-COUNT

Package

cl-gamepad-cffi

Source

wrapper.lisp (file)

Function: button-count DEVICE

Returns the number of buttons the controller seems to have.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: button-label DEVICE BUTTON

Return the label for the given physical button on the gamepad device.

The button should be a number from 0 below DEVICE-BUTTON-COUNT. If an invalid button id is passed, :UNKNOWN is returned.
Returned is a keyword out of the following set:

:unknown — An unknown button. This is the default.
:x — The X (left) button.
:y — The Y (up) button.
:z — The Z button.
:a — The A (down) button.
:b — The B (right) button.
:c — The C button.
:l1 — The left upper trigger.
:l2 — The left lower trigger.
:r1 — The right upper trigger.
:r2 — The right lower trigger.
:l — Whether the left analog stick is pressed in.
:r — Whether the right analog stick is pressed in. :dpad-l — The left direction of the dpad.
:dpad-r — The right direction of the dpad.
:dpad-u — The up direction of the dpad.
:dpad-d — The down direction of the dpad.
:select — The select (left) button.
:home — The home (center) button.
:start — The start (right) button.
:trigger — The trigger button.

The button map is mostly modelled after the XBOX360 controller.

See DEVICE
See DEVICE-MAP

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: button-pressed BUTTON TIME DEVICE

This function is called whenever a button is pressed.

BUTTON is an integer identifying the button on the controller. TIME is a float representing the time at which the movement occurred precisely.

You should override this function if you want to use a notification mechanism. By default this function does nothing.

This function is called in the same thread as the DETECT-DEVICES or PROCESS-EVENTS call occurs that triggers it and may thus block it.

See DEVICE
See DETECT-DEVICES
See PROCESS-EVENTS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: button-released BUTTON TIME DEVICE

This function is called whenever a button is released.

BUTTON is an integer identifying the button on the controller. TIME is a float representing the time at which the movement occurred precisely.

You should override this function if you want to use a notification mechanism. By default this function does nothing.

This function is called in the same thread as the DETECT-DEVICES or PROCESS-EVENTS call occurs that triggers it and may thus block it.

See DEVICE
See DETECT-DEVICES
See PROCESS-EVENTS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: buttons DEVICE

Returns a vector of the state of each button on the gamepad device.

See DEVICE
See BUTTON

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: description DEVICE

Returns the description string for the gamepad device.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: detect-devices ()

Polls for new devices.

May call DEVICE-ATTACHED BUTTON-PRESSED BUTTON-RELEASED AXIS-MOVED

New devices will not be noticed unless and until you call this function. As such you should call it at any time it is appropriate for new controllers to be introduced to your program.

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: device INDEX

Returns the device at the specified index.

The index should be a number from 0 below DEVICE-COUNT. Passing an invalid number results in undefined behaviour, going as far as potentially crashing your program.

See DEVICE

Package

cl-gamepad-cffi

Source

wrapper.lisp (file)

Function: device-attached DEVICE

This function is called whenever a new device is attached.

You should override this function if you want to use a notification mechanism. By default this function does nothing.

This function is called in the same thread as the DETECT-DEVICES call occurs that triggers it and may thus block it.

See DEVICE
See DETECT-DEVICES

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-axis-count POINTER-TO-DEVICE

Accesses the number of axes the controller seems to have.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-axis-count) (function)

Function: (setf device-axis-count) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-axis-count (function)

Function: device-axis-states POINTER-TO-DEVICE

Accesses the pointer to the float array that describes the state of the various axes.

See DEVICE
See DEVICE-AXIS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-axis-states) (function)

Function: (setf device-axis-states) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-axis-states (function)

Function: device-button-count POINTER-TO-DEVICE

Accesses the number of buttons the controller seems to have.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-button-count) (function)

Function: (setf device-button-count) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-button-count (function)

Function: device-button-states POINTER-TO-DEVICE

Accesses the pointer to the bool array that describes the state of the various buttons. Note that the bools are not strict in the sense that anything greater than 0
should be taken as TRUE.

See DEVICE
See DEVICE-BUTTON

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-button-states) (function)

Function: (setf device-button-states) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-button-states (function)

Function: device-count ()

Returns an integer of how many devices we know of right now.

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: device-description POINTER-TO-DEVICE

Accesses the description string for the gamepad device.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-description) (function)

Function: (setf device-description) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-description (function)

Function: device-device-map POINTER-TO-DEVICE

Accesses the pointer to the device map that describes the button and axis layout.

See DEVICE
See DEVICE-MAP

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-device-map) (function)

Function: (setf device-device-map) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-device-map (function)

Function: device-id POINTER-TO-DEVICE

Accesses the unique identifier for the gamepad device.

Starts at 0 and increases for each new gamepad that is detected. If a particular gamepad is disconnected and later reconnected, it will receive a different id.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-id) (function)

Function: (setf device-id) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-id (function)

Function: device-map VENDOR PRODUCT

Accessor to the device map for the given vendor and product.

The device map assigns labels to the buttons and axes and normalises
the axes’ direction if necessary. The map is a list of the following structure:

DEVICE-MAP ::= (BUTTON-MAP AXIS-MAP)
BUTTON-MAP ::= (:buttons BUTTON*)
BUTTON ::= (ID LABEL)
AXIS-MAP ::= (:axes AXIS*)
AXIS ::= (ID LABEL MULTIPLIER)
ID — A numerical ID of a button or axis
LABEL — The keyword label for the button or axis’ functionality. MULTIPLIER — Either 1 or -1 to potentially reverse the axis’ direction.

See AXIS-LABEL and BUTTON-LABEL for the available labels and their intended usage. A sample map for the Xbox360 controller as recognised
on Linux platforms follows.

((:axes
( 0 :l-h)
( 1 :l-v)
( 2 :l2)
( 3 :r-h)
( 4 :r-v)
( 5 :r2)
( 6 :dpad-h)
( 7 :dpad-v))
(:buttons
( 0 :a)
( 1 :b)
( 2 :x)
( 3 :y)
( 4 :l1)
( 5 :r1)
( 6 :select)
( 7 :start)
( 8 :home)
( 9 :l)
(10 :r)))

Note that the IDs for each button and axis are unfortunately very
much platform-dependent and a mapping for each platform must be
created individually.

Package

cl-gamepad-cffi

Source

wrapper.lisp (file)

Writer

(setf device-map) (function)

Function: (setf device-map) MAP VENDOR PRODUCT
Package

cl-gamepad-cffi

Source

wrapper.lisp (file)

Reader

device-map (function)

Function: device-map-axes DEVICE-MAP

Accessor to the C array of the axis mappings.

See DEVICE-MAP

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-map-axis-multipliers DEVICE-MAP

Accessor to the C array of the axis multipliers.

See DEVICE-MAP

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-map-buttons DEVICE-MAP

Accessor to the C array of the button mappings.

See DEVICE-MAP

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-plist DEVICE

Constructs a plist from the device’s values.

Returned is:
(:ID id
:VENDOR vendor
:PRODUCT product
:DESCRIPTION description
:AXES axes
:BUTTONS buttons)

See ID
See VENDOR
See PRODUCT
See DESCRIPTION
See AXES
See BUTTONS
See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: device-private-data POINTER-TO-DEVICE

Accesses the pointer to the private data of the gamepad device struct.

You should never need this.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-private-data) (function)

Function: (setf device-private-data) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-private-data (function)

Function: device-product POINTER-TO-DEVICE

Accesses the product ID for the gamepad device.

This along with DEVICE-VENDOR may be useful to detect default behaviour for a particular controller.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-product) (function)

Function: (setf device-product) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-product (function)

Function: device-removed DEVICE

This function is called whenever a device is removed.

You should override this function if you want to use a notification mechanism. By default this function does nothing.

This function is called in the same thread as the PROCESS-EVENTS call occurs that triggers it and may thus block it.

See DEVICE
See PROCESS-EVENTS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-vendor POINTER-TO-DEVICE

Accesses the vendor ID for the gamepad device.

This along with DEVICE-PRODUCT may be useful to detect default behaviour for a particular controller.

See DEVICE

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Writer

(setf device-vendor) (function)

Function: (setf device-vendor) VALUE POINTER-TO-DEVICE
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Reader

device-vendor (function)

Function: devices ()

Returns a list of all known devices.

See DEVICE-COUNT
See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: gamepad-axis-move-func CALLBACK CONTEXT

Calls the Gamepad_axisMoveFunc C function, registering the callback function.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-button-down-func CALLBACK CONTEXT

Calls the Gamepad_buttonDownFunc C function, registering the callback function.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-button-up-func CALLBACK CONTEXT

Calls the Gamepad_buttonUpFunc C function, registering the callback function.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-definition DEVICE

Returns a string representation of a valid mapping definition for the given device.

This function is useful if you want to extract the available device
mapping information to turn it into a static gamepad definition as
used by DEFINE-GAMEPAD.

See DEFINE-GAMEPAD

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: gamepad-detect-devices ()

Calls the Gamepad_detectDevices C function, leading to new devices being recognised.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-device-at-index DEVICE-INDEX

Calls the Gamepad_deviceAtIndex C function, returning a device pointer corresponding to the index.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-device-attach-func CALLBACK CONTEXT

Calls the Gamepad_deviceAttachFunc C function, registering the callback function.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-device-map VENDOR-ID PRODUCT-ID

Retrieves the device map for the given vendor and product. If no specific map is known, a generic one is returned.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-device-remove-func CALLBACK CONTEXT

Calls the Gamepad_deviceRemoveFunc C function, registering the callback function.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-init ()

Calls the Gamepad_init C function to initialize the library.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-num-devices ()

Calls the Gamepad_numDevices C function, returning the number of devices currently known to the library.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-process-events ()

Calls the Gamepad_processEvents C function, leading to input events being captured and the callbacks being invoked.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-set-device-map VENDOR-ID PRODUCT-ID MAP

Set the device map for a given vendor and product. The struct’s contents are copied, and you should free the one you pass in yourself.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: gamepad-shutdown ()

Calls the Gamepad_shutdown C function to clean up the library.

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: id DEVICE

Returns the unique identifier for the gamepad device.

Starts at 0 and increases for each new gamepad that is detected. If a particular gamepad is disconnected and later reconnected, it will receive a different id.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: init ()

Sets everything up and prepares the library to process input events.

This function must be called before any of the other functions are called. It is safe to call this function any number of times in sequence, but only one "actual" init is performed before another SHUTDOWN.

See SHUTDOWN

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: print-device DEVICE STREAM

Prints an unreadable representation of DEVICE to STREAM.

Useful for debugging prints.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: process-events ()

Processes input events from all known controllers.

May call DEVICE-REMOVED BUTTON-PRESSED BUTTON-RELEASED AXIS-MOVED

If a device is unplugged, you will not be notified of this until this function is called. The corresponding DEVICE-REMOVED function is then called. If a new device is plugged in, events for it will not be processed until it is registered through DETECT-DEVICES.

See DETECT-DEVICES

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: product DEVICE

Returns the product ID for the gamepad device.

This along with DEVICE-VENDOR may be useful to detect default behaviour for a particular controller.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: shutdown ()

Cleans everything up so that it’s back to being tidy and neat.

No other functions but INIT should ever be called after this function has been called. It is safe to call this function any number of times in sequence, but only one "actual" shutdown is performed before another INIT.

See INIT

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: update-device-map VENDOR PRODUCT UPDATE

Update the device map for a select few records.

Unlike (SETF DEVICE-MAP) this does not clear out the mappings that are not explicitly given, and instead leaves those to their default values.

See DEVICE-MAP

Package

cl-gamepad

Source

wrapper.lisp (file)

Function: vendor DEVICE

Returns the vendor ID for the gamepad device.

This along with DEVICE-PRODUCT may be useful to detect default behaviour for a particular controller.

See DEVICE

Package

cl-gamepad

Source

wrapper.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Generic functions

Generic Function: index CONDITION

Reader to the index that the condition happened on.

See INDEX-OUT-OF-RANGE

Package

cl-gamepad

Methods
Method: index (CONDITION index-out-of-range)
Source

wrapper.lisp (file)

Generic Function: range CONDITION

Reader to the range that the condition happened on.

See INDEX-OUT-OF-RANGE

Package

cl-gamepad

Methods
Method: range (CONDITION index-out-of-range)
Source

wrapper.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.6 Conditions

Condition: index-out-of-range ()

Condition signalled when an index is out of its allowed range.

See INDEX
See RANGE

Package

cl-gamepad

Source

wrapper.lisp (file)

Direct superclasses

error (condition)

Direct methods
Direct slots
Slot: index
Initargs

:index

Readers

index (generic function)

Slot: range
Initargs

:range

Readers

range (generic function)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.7 Classes

Class: device ()

C struct that contains all relevant information about a gamepad device.

You should never SETF any of its fields unless you really
know what you’re doing. Passing a pointer to this struct
outside of the dynamic-extent in which it was provided will
cause undefined behaviour and even lead as far as crashing
your program. If you need to pass it around, you should use DEVICE-PLIST to serialise it.

See ID
See VENDOR
See PRODUCT
See DESCRIPTION
See AXIS-COUNT
See AXIS
See AXIS-LABEL
See AXIS-MULTIPLIER
See AXES
See BUTTON-COUNT
See BUTTON
See BUTTON-LABEL
See BUTTONS
See DEVICE-PLIST
See DEVICE-MAP
See UPDATE-DEVICE-MAP

See DEVICE-ID
See DEVICE-VENDOR
See DEVICE-PRODUCT
See DEVICE-DESCRIPTION
See DEVICE-AXIS-COUNT
See DEVICE-AXIS-STATES
See DEVICE-BUTTON-COUNT
See DEVICE-BUTTON-STATES
See DEVICE-DEVICE-MAP
See DEVICE-PRIVATE-DATA
See DETECT-DEVICES

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)
Class: device-map ()

Contains information to map physical buttons and axes to standardised labels relating to their function.

The map contains three particular mappings, limited to at most
a physical ID of DEVICE-MAP-MAX minus one.

button map — Each slot maps to a BUTTON enum value that
describes the button’s function.
axis map — Each slot maps to an AXIS enum value that
describes the axis’ function.
axis multiplier — Each slot maps to a char of either 1 or -1
representing a multiplier to standardise the
axis’ direction.

Note that the functionality of the buttons and axes should be
normalised based on the layout of an XBOX 360 controller.

See DEVICE-MAP-MAX
See BUTTON
See AXIS
See DEVICE-MAP-BUTTON-MAP
See DEVICE-MAP-BUTTONS
See DEVICE-MAP-AXIS-MAP
See DEVICE-MAP-AXES
See DEVICE-MAP-AXIS-MULTIPLIER
See DEVICE-MAP-AXIS-MULTIPLIERS

Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)

Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *here*
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Special Variable: *init*
Package

cl-gamepad

Source

wrapper.lisp (file)

Special Variable: *static*
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Special Variable: *vendor-product-names*
Package

cl-gamepad

Source

wrapper.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: define-alias (NAME ORIGINAL) ARGS
Package

cl-gamepad

Source

wrapper.lisp (file)

Macro: with-callback-handling () &body BODY
Package

cl-gamepad-cffi

Source

low-level.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: device-mapaxis-map POINTER-TO-DEVICE-MAP
Function: (setf device-mapaxis-map) VALUE POINTER-TO-DEVICE-MAP
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-mapaxis-multipliers POINTER-TO-DEVICE-MAP
Function: (setf device-mapaxis-multipliers) VALUE POINTER-TO-DEVICE-MAP
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-mapbutton-map POINTER-TO-DEVICE-MAP
Function: (setf device-mapbutton-map) VALUE POINTER-TO-DEVICE-MAP
Package

cl-gamepad-cffi

Source

low-level.lisp (file)

Function: device-name DEVICE
Package

cl-gamepad

Source

wrapper.lisp (file)

Function: merge-maps MAP DEFAULTS
Package

cl-gamepad

Source

wrapper.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-gamepad.asd: The cl-gamepad<dot>asd file
cl-gamepad/database-lin.lisp: The cl-gamepad/database-lin<dot>lisp file
cl-gamepad/documentation.lisp: The cl-gamepad/documentation<dot>lisp file
cl-gamepad/low-level.lisp: The cl-gamepad/low-level<dot>lisp file
cl-gamepad/package.lisp: The cl-gamepad/package<dot>lisp file
cl-gamepad/wrapper.lisp: The cl-gamepad/wrapper<dot>lisp file

F
File, Lisp, cl-gamepad.asd: The cl-gamepad<dot>asd file
File, Lisp, cl-gamepad/database-lin.lisp: The cl-gamepad/database-lin<dot>lisp file
File, Lisp, cl-gamepad/documentation.lisp: The cl-gamepad/documentation<dot>lisp file
File, Lisp, cl-gamepad/low-level.lisp: The cl-gamepad/low-level<dot>lisp file
File, Lisp, cl-gamepad/package.lisp: The cl-gamepad/package<dot>lisp file
File, Lisp, cl-gamepad/wrapper.lisp: The cl-gamepad/wrapper<dot>lisp file

L
Lisp File, cl-gamepad.asd: The cl-gamepad<dot>asd file
Lisp File, cl-gamepad/database-lin.lisp: The cl-gamepad/database-lin<dot>lisp file
Lisp File, cl-gamepad/documentation.lisp: The cl-gamepad/documentation<dot>lisp file
Lisp File, cl-gamepad/low-level.lisp: The cl-gamepad/low-level<dot>lisp file
Lisp File, cl-gamepad/package.lisp: The cl-gamepad/package<dot>lisp file
Lisp File, cl-gamepad/wrapper.lisp: The cl-gamepad/wrapper<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
A   B   C   D   F   G   I   M   P   R   S   U   V   W  
Index Entry  Section

(
(setf device-axis-count): Exported functions
(setf device-axis-states): Exported functions
(setf device-button-count): Exported functions
(setf device-button-states): Exported functions
(setf device-description): Exported functions
(setf device-device-map): Exported functions
(setf device-id): Exported functions
(setf device-map): Exported functions
(setf device-mapaxis-map): Internal functions
(setf device-mapaxis-multipliers): Internal functions
(setf device-mapbutton-map): Internal functions
(setf device-private-data): Exported functions
(setf device-product): Exported functions
(setf device-vendor): Exported functions

A
axes: Exported functions
axis: Exported functions
axis-count: Exported compiler macros
axis-count: Exported functions
axis-label: Exported functions
axis-moved: Exported functions
axis-multiplier: Exported functions

B
button: Exported functions
button-count: Exported compiler macros
button-count: Exported functions
button-label: Exported functions
button-pressed: Exported functions
button-released: Exported functions
buttons: Exported functions

C
Compiler Macro, axis-count: Exported compiler macros
Compiler Macro, button-count: Exported compiler macros
Compiler Macro, description: Exported compiler macros
Compiler Macro, detect-devices: Exported compiler macros
Compiler Macro, device-count: Exported compiler macros
Compiler Macro, id: Exported compiler macros
Compiler Macro, process-events: Exported compiler macros
Compiler Macro, product: Exported compiler macros
Compiler Macro, vendor: Exported compiler macros

D
define-alias: Internal macros
define-gamepad: Exported macros
description: Exported compiler macros
description: Exported functions
detect-devices: Exported compiler macros
detect-devices: Exported functions
device: Exported functions
device-attached: Exported functions
device-axis-count: Exported functions
device-axis-states: Exported functions
device-button-count: Exported functions
device-button-states: Exported functions
device-count: Exported compiler macros
device-count: Exported functions
device-description: Exported functions
device-device-map: Exported functions
device-id: Exported functions
device-map: Exported functions
device-map-axes: Exported functions
device-map-axis-multipliers: Exported functions
device-map-buttons: Exported functions
device-mapaxis-map: Internal functions
device-mapaxis-multipliers: Internal functions
device-mapbutton-map: Internal functions
device-name: Internal functions
device-plist: Exported functions
device-private-data: Exported functions
device-product: Exported functions
device-removed: Exported functions
device-vendor: Exported functions
devices: Exported functions

F
Function, (setf device-axis-count): Exported functions
Function, (setf device-axis-states): Exported functions
Function, (setf device-button-count): Exported functions
Function, (setf device-button-states): Exported functions
Function, (setf device-description): Exported functions
Function, (setf device-device-map): Exported functions
Function, (setf device-id): Exported functions
Function, (setf device-map): Exported functions
Function, (setf device-mapaxis-map): Internal functions
Function, (setf device-mapaxis-multipliers): Internal functions
Function, (setf device-mapbutton-map): Internal functions
Function, (setf device-private-data): Exported functions
Function, (setf device-product): Exported functions
Function, (setf device-vendor): Exported functions
Function, axes: Exported functions
Function, axis: Exported functions
Function, axis-count: Exported functions
Function, axis-label: Exported functions
Function, axis-moved: Exported functions
Function, axis-multiplier: Exported functions
Function, button: Exported functions
Function, button-count: Exported functions
Function, button-label: Exported functions
Function, button-pressed: Exported functions
Function, button-released: Exported functions
Function, buttons: Exported functions
Function, description: Exported functions
Function, detect-devices: Exported functions
Function, device: Exported functions
Function, device-attached: Exported functions
Function, device-axis-count: Exported functions
Function, device-axis-states: Exported functions
Function, device-button-count: Exported functions
Function, device-button-states: Exported functions
Function, device-count: Exported functions
Function, device-description: Exported functions
Function, device-device-map: Exported functions
Function, device-id: Exported functions
Function, device-map: Exported functions
Function, device-map-axes: Exported functions
Function, device-map-axis-multipliers: Exported functions
Function, device-map-buttons: Exported functions
Function, device-mapaxis-map: Internal functions
Function, device-mapaxis-multipliers: Internal functions
Function, device-mapbutton-map: Internal functions
Function, device-name: Internal functions
Function, device-plist: Exported functions
Function, device-private-data: Exported functions
Function, device-product: Exported functions
Function, device-removed: Exported functions
Function, device-vendor: Exported functions
Function, devices: Exported functions
Function, gamepad-axis-move-func: Exported functions
Function, gamepad-button-down-func: Exported functions
Function, gamepad-button-up-func: Exported functions
Function, gamepad-definition: Exported functions
Function, gamepad-detect-devices: Exported functions
Function, gamepad-device-at-index: Exported functions
Function, gamepad-device-attach-func: Exported functions
Function, gamepad-device-map: Exported functions
Function, gamepad-device-remove-func: Exported functions
Function, gamepad-init: Exported functions
Function, gamepad-num-devices: Exported functions
Function, gamepad-process-events: Exported functions
Function, gamepad-set-device-map: Exported functions
Function, gamepad-shutdown: Exported functions
Function, id: Exported functions
Function, init: Exported functions
Function, merge-maps: Internal functions
Function, print-device: Exported functions
Function, process-events: Exported functions
Function, product: Exported functions
Function, shutdown: Exported functions
Function, update-device-map: Exported functions
Function, vendor: Exported functions

G
gamepad-axis-move-func: Exported functions
gamepad-button-down-func: Exported functions
gamepad-button-up-func: Exported functions
gamepad-definition: Exported functions
gamepad-detect-devices: Exported functions
gamepad-device-at-index: Exported functions
gamepad-device-attach-func: Exported functions
gamepad-device-map: Exported functions
gamepad-device-remove-func: Exported functions
gamepad-init: Exported functions
gamepad-num-devices: Exported functions
gamepad-process-events: Exported functions
gamepad-set-device-map: Exported functions
gamepad-shutdown: Exported functions
Generic Function, index: Exported generic functions
Generic Function, range: Exported generic functions

I
id: Exported compiler macros
id: Exported functions
index: Exported generic functions
index: Exported generic functions
init: Exported functions

M
Macro, define-alias: Internal macros
Macro, define-gamepad: Exported macros
Macro, with-callback-handling: Internal macros
merge-maps: Internal functions
Method, index: Exported generic functions
Method, range: Exported generic functions

P
print-device: Exported functions
process-events: Exported compiler macros
process-events: Exported functions
product: Exported compiler macros
product: Exported functions

R
range: Exported generic functions
range: Exported generic functions

S
shutdown: Exported functions

U
update-device-map: Exported functions

V
vendor: Exported compiler macros
vendor: Exported functions

W
with-callback-handling: Internal macros

Jump to:   (  
A   B   C   D   F   G   I   M   P   R   S   U   V   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
C   D   I   R   S  
Index Entry  Section

*
*here*: Internal special variables
*init*: Internal special variables
*static*: Internal special variables
*vendor-product-names*: Internal special variables

C
Constant, device-map-max: Exported constants

D
device-map-max: Exported constants

I
index: Exported conditions

R
range: Exported conditions

S
Slot, index: Exported conditions
Slot, range: Exported conditions
Special Variable, *here*: Internal special variables
Special Variable, *init*: Internal special variables
Special Variable, *static*: Internal special variables
Special Variable, *vendor-product-names*: Internal special variables

Jump to:   *  
C   D   I   R   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   D   I   P   S  
Index Entry  Section

C
cl-gamepad: The cl-gamepad system
cl-gamepad: The cl-gamepad package
cl-gamepad-cffi: The cl-gamepad-cffi package
Class, device: Exported classes
Class, device-map: Exported classes
Condition, index-out-of-range: Exported conditions

D
device: Exported classes
device-map: Exported classes

I
index-out-of-range: Exported conditions

P
Package, cl-gamepad: The cl-gamepad package
Package, cl-gamepad-cffi: The cl-gamepad-cffi package

S
System, cl-gamepad: The cl-gamepad system

Jump to:   C   D   I   P   S