Added support for multiple controllers (Playstation)

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2025-08-09 11:51:02 +0200
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2025-08-09 11:51:02 +0200
Commit 6c0e0437773738533587a08d53aa534216c22e4c (patch)
-rw-r--r-- README.md 24
-rw-r--r-- stdlib/button.lua 20
2 files changed, 22 insertions, 22 deletions
diff --git a/README.md b/README.md
...
82
  
82
  
83
### Controller mappings
83
### Controller mappings
84
  
84
  
85
| Button             | Keyboard | Xbox | Playstation | Nintendo |
85
| Button             | Keyboard | Xbox          | Playstation   |
86
| ------------------ | -------- | ---- | ----------- | -------- |
86
| ------------------ | -------- | ------------- | ------------- |
87
| `button.PAD_UP`    | `W`      | N/A  | N/A         | N/A      |
87
| `button.PAD_UP`    | `W`      | `D-pad Up`    | `D-PAD UP`    |
88
| `button.PAD_DOWN`  | `S`      | N/A  | N/A         | N/A      |
88
| `button.PAD_DOWN`  | `S`      | `D-pad Down`  | `D-PAD DOWN`  |
89
| `button.PAD_LEFT`  | `A`      | N/A  | N/A         | N/A      |
89
| `button.PAD_LEFT`  | `A`      | `D-pad Left`  | `D-PAD LEFT`  |
90
| `button.PAD_RIGHT` | `D`      | N/A  | N/A         | N/A      |
90
| `button.PAD_RIGHT` | `D`      | `D-pad Right` | `D-PAD RIGHT` |
91
| `button.A`         | `L`      | N/A  | N/A         | N/A      |
91
| `button.A`         | `L`      | `A`           | `Cross`       |
92
| `button.B`         | `P`      | N/A  | N/A         | N/A      |
92
| `button.B`         | `P`      | `B`           | `Circle`      |
93
| `button.X`         | `K`      | N/A  | N/A         | N/A      |
93
| `button.X`         | `K`      | `X`           | `Square`      |
94
| `button.Y`         | `O`      | N/A  | N/A         | N/A      |
94
| `button.Y`         | `O`      | `Y`           | `Triangle`    |
95
| `button.SELECT`    | `Q`      | N/A  | N/A         | N/A      |
95
| `button.SELECT`    | `Q`      | `Back`        | `Share`       |
96
| `button.START`     | `E`      | N/A  | N/A         | N/A      |
96
| `button.START`     | `E`      | `Start`       | `Options`     |
97
                                                        
97
                                                        
98
### Default colors
98
### Default colors
99
  
99
  
...
diff --git a/stdlib/button.lua b/stdlib/button.lua
1
local button = {}
1
local button = {}
2
  
2
  
3
button.PAD_UP    = { keyboard = 87, xbox = 1,  playstation = 0 }  -- Key: W
3
button.PAD_UP    = { keyboard = 87, xbox = 1,  playstation = 1  }  -- Key: W
4
button.PAD_DOWN  = { keyboard = 83, xbox = 3,  playstation = 0 }  -- Key: S
4
button.PAD_DOWN  = { keyboard = 83, xbox = 3,  playstation = 2  }  -- Key: S
5
button.PAD_LEFT  = { keyboard = 65, xbox = 4,  playstation = 0 }  -- Key: A
5
button.PAD_LEFT  = { keyboard = 65, xbox = 4,  playstation = 3  }  -- Key: A
6
button.PAD_RIGHT = { keyboard = 68, xbox = 2,  playstation = 0 }  -- Key: D
6
button.PAD_RIGHT = { keyboard = 68, xbox = 2,  playstation = 4  }  -- Key: D
7
  
7
  
8
button.A         = { keyboard = 76, xbox = 7,  playstation = 0 }  -- Key: L
8
button.A         = { keyboard = 76, xbox = 7,  playstation = 7  }  -- Key: L
9
button.B         = { keyboard = 80, xbox = 6,  playstation = 0 }  -- Key: P
9
button.B         = { keyboard = 80, xbox = 6,  playstation = 6  }  -- Key: P
10
button.X         = { keyboard = 75, xbox = 8,  playstation = 0 }  -- Key: K
10
button.X         = { keyboard = 75, xbox = 8,  playstation = 8  }  -- Key: K
11
button.Y         = { keyboard = 79, xbox = 5,  playstation = 0 }  -- Key: O
11
button.Y         = { keyboard = 79, xbox = 5,  playstation = 5  }  -- Key: O
12
  
12
  
13
button.SELECT    = { keyboard = 81, xbox = 13, playstation = 0 }  -- Key: Q
13
button.SELECT    = { keyboard = 81, xbox = 13, playstation = 13 }  -- Key: Q
14
button.START     = { keyboard = 69, xbox = 15, playstation = 0 }  -- Key: E
14
button.START     = { keyboard = 69, xbox = 15, playstation = 15 }  -- Key: E
15
  
15
  
16
return button
16
return button