Skip to content

Commit 61177c0

Browse files
Roderick ColenbranderJiri Kosina
authored andcommitted
leds: add new LED_FUNCTION_PLAYER for player LEDs for game controllers.
Player LEDs are commonly found on game controllers from Nintendo and Sony to indicate a player ID across a number of LEDs. For example, "Player 2" might be indicated as "-x--" on a device with 4 LEDs where "x" means on. This patch introduces LED_FUNCTION_PLAYER1-5 defines to properly indicate player LEDs from the kernel. Until now there was no good standard, which resulted in inconsistent behavior across xpad, hid-sony, hid-wiimote and other drivers. Moving forward new drivers should use LED_FUNCTION_PLAYERx. Note: management of Player IDs is left to user space, though a kernel driver may pick a default value. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent fc97b4d commit 61177c0

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Documentation/leds/well-known-leds.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ but then try the legacy ones, too.
1616

1717
Notice there's a list of functions in include/dt-bindings/leds/common.h .
1818

19+
* Gamepads and joysticks
20+
21+
Game controllers may feature LEDs to indicate a player number. This is commonly
22+
used on game consoles in which multiple controllers can be connected to a system.
23+
The "player LEDs" are then programmed with a pattern to indicate a particular
24+
player. For example, a game controller with 4 LEDs, may be programmed with "x---"
25+
to indicate player 1, "-x--" to indicate player 2 etcetera where "x" means on.
26+
Input drivers can utilize the LED class to expose the individual player LEDs
27+
of a game controller using the function "player".
28+
Note: tracking and management of Player IDs is the responsibility of user space,
29+
though drivers may pick a default value.
30+
31+
Good: "input*:*:player-{1,2,3,4,5}
32+
1933
* Keyboards
2034

2135
Good: "input*:*:capslock"

include/dt-bindings/leds/common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@
6060
#define LED_FUNCTION_MICMUTE "micmute"
6161
#define LED_FUNCTION_MUTE "mute"
6262

63+
/* Used for player LEDs as found on game controllers from e.g. Nintendo, Sony. */
64+
#define LED_FUNCTION_PLAYER1 "player-1"
65+
#define LED_FUNCTION_PLAYER2 "player-2"
66+
#define LED_FUNCTION_PLAYER3 "player-3"
67+
#define LED_FUNCTION_PLAYER4 "player-4"
68+
#define LED_FUNCTION_PLAYER5 "player-5"
69+
6370
/* Miscelleaus functions. Use functions above if you can. */
6471
#define LED_FUNCTION_ACTIVITY "activity"
6572
#define LED_FUNCTION_ALARM "alarm"

0 commit comments

Comments
 (0)