Update PS3 button mask
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# Device Drivers
|
|
||||||
----------------------------------
|
Device Driver
|
||||||
|
=============
|
||||||
|
|
||||||
This repository contains Linux **kernel modules** (``.ko``) that implement low-level USB input drivers and expose device events through the Linux **input subsystem** (evdev).
|
This repository contains Linux **kernel modules** (``.ko``) that implement low-level USB input drivers and expose device events through the Linux **input subsystem** (evdev).
|
||||||
|
|
||||||
@@ -9,7 +10,6 @@ A helper tool (``usb_driver_manager.py``) is included to make it easier to:
|
|||||||
- unbind/bind a selected interface to a chosen driver during development
|
- unbind/bind a selected interface to a chosen driver during development
|
||||||
|
|
||||||
## Drivers
|
## Drivers
|
||||||
----------
|
|
||||||
|
|
||||||
### Mouse driver (``mouse/``)
|
### Mouse driver (``mouse/``)
|
||||||
USB HID boot-protocol mouse driver.
|
USB HID boot-protocol mouse driver.
|
||||||
@@ -37,7 +37,6 @@ make
|
|||||||
After building, the module (``*.ko``) is typically placed under ``build/`` by the provided Makefiles.
|
After building, the module (``*.ko``) is typically placed under ``build/`` by the provided Makefiles.
|
||||||
|
|
||||||
## USB Driver Manager
|
## USB Driver Manager
|
||||||
---------------------
|
|
||||||
|
|
||||||
**Usage examples:**
|
**Usage examples:**
|
||||||
```bash
|
```bash
|
||||||
@@ -55,7 +54,7 @@ sudo python3 usb_driver_manager.py ./mouse/build ./g29_media_usb/build
|
|||||||
4. Confirm; the tool unbinds the current driver, reloads the module if needed, and binds the chosen interface.
|
4. Confirm; the tool unbinds the current driver, reloads the module if needed, and binds the chosen interface.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
----------
|
|
||||||
After binding the driver, use ``evtest`` to confirm key events:
|
After binding the driver, use ``evtest`` to confirm key events:
|
||||||
```bash
|
```bash
|
||||||
sudo evtest
|
sudo evtest
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ static void wasd_mode_timer_fn(struct timer_list *t) {
|
|||||||
mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(1));
|
mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_media_mode(struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
static void process_media_mode(const struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
||||||
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
||||||
for (int i = 0; i < ARRAY_SIZE(media_mode_keymap); i++) {
|
for (int i = 0; i < ARRAY_SIZE(media_mode_keymap); i++) {
|
||||||
const struct g29_keymap *k = &media_mode_keymap[i];
|
const struct g29_keymap *k = &media_mode_keymap[i];
|
||||||
@@ -254,7 +254,7 @@ static void process_media_mode(struct g29_dev *g29, const struct g29_state *cur,
|
|||||||
input_sync(g29->input);
|
input_sync(g29->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_wasd_mode(struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
static void process_wasd_mode(const struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
||||||
// WASD mode is handled by the timer function (g29_steer_timer_fn)
|
// WASD mode is handled by the timer function (g29_steer_timer_fn)
|
||||||
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
||||||
input_report_key(g29->input, KEY_C, !!(buttons & G29_BTN_L1));
|
input_report_key(g29->input, KEY_C, !!(buttons & G29_BTN_L1));
|
||||||
@@ -262,10 +262,10 @@ static void process_wasd_mode(struct g29_dev *g29, const struct g29_state *cur,
|
|||||||
input_sync(g29->input);
|
input_sync(g29->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_mouse_mode(struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
static void process_mouse_mode(const struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
|
||||||
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
const u32 buttons = le32_to_cpu(cur->buttons_le);
|
||||||
const u32 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le);
|
const u32 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le);
|
||||||
const u32 released = le32_to_cpu(~cur->buttons_le & prev->buttons_le);
|
//const u32 released = le32_to_cpu(~cur->buttons_le & prev->buttons_le);
|
||||||
|
|
||||||
for (int i = 0; i < ARRAY_SIZE(mouse_mode_keymap); i++) {
|
for (int i = 0; i < ARRAY_SIZE(mouse_mode_keymap); i++) {
|
||||||
const struct g29_keymap *k = &mouse_mode_keymap[i];
|
const struct g29_keymap *k = &mouse_mode_keymap[i];
|
||||||
@@ -289,28 +289,20 @@ static void g29_check_mode_switch(struct g29_dev *g29, const struct g29_state *c
|
|||||||
g29_switch_mode(g29, G29_MODE_MEDIA);
|
g29_switch_mode(g29, G29_MODE_MEDIA);
|
||||||
} else if (pressed & G29_BTN_OPTION) {
|
} else if (pressed & G29_BTN_OPTION) {
|
||||||
g29_switch_mode(g29, G29_MODE_WASD);
|
g29_switch_mode(g29, G29_MODE_WASD);
|
||||||
} else if (pressed & G29_BTN_PS3_LOGO) {
|
} else if (pressed & G29_BTN_PS3) {
|
||||||
g29_switch_mode(g29, G29_MODE_MOUSE);
|
g29_switch_mode(g29, G29_MODE_MOUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void g29_process_report(struct g29_dev *g29, const u8 *data, unsigned int len) {
|
static void g29_process_report(struct g29_dev *g29, const u8 *data, const unsigned int len) {
|
||||||
if (len < 12) return;
|
if (len < 12) return;
|
||||||
|
const struct g29_state *cur = (void *) data;
|
||||||
struct g29_state *cur = (void *) data;
|
|
||||||
|
|
||||||
g29_check_mode_switch(g29, cur, &g29->last);
|
g29_check_mode_switch(g29, cur, &g29->last);
|
||||||
|
|
||||||
switch (g29->current_mode) {
|
switch (g29->current_mode) {
|
||||||
case G29_MODE_MEDIA:
|
case G29_MODE_MEDIA: process_media_mode(g29, cur, &g29->last); break;
|
||||||
process_media_mode(g29, cur, &g29->last);
|
case G29_MODE_WASD: process_wasd_mode(g29, cur, &g29->last); break;
|
||||||
break;
|
case G29_MODE_MOUSE: process_mouse_mode(g29, cur, &g29->last);break;
|
||||||
case G29_MODE_WASD:
|
|
||||||
process_wasd_mode(g29, cur, &g29->last);
|
|
||||||
break;
|
|
||||||
case G29_MODE_MOUSE:
|
|
||||||
process_mouse_mode(g29, cur, &g29->last);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g29->last = *cur;
|
g29->last = *cur;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#define G29_BTN_RED_CW 0x02000000u
|
#define G29_BTN_RED_CW 0x02000000u
|
||||||
#define G29_BTN_RED_CCW 0x04000000u
|
#define G29_BTN_RED_CCW 0x04000000u
|
||||||
#define G29_BTN_RETURN 0x08000000u
|
#define G29_BTN_RETURN 0x08000000u
|
||||||
#define G29_BTN_PS3_LOGO 0xF0000000u
|
#define G29_BTN_PS3 0x10000000u
|
||||||
|
|
||||||
#define G29_DPAD_MASK 0x0000000Eu
|
#define G29_DPAD_MASK 0x0000000Eu
|
||||||
#define G29_DPAD_UP 0x00000000u
|
#define G29_DPAD_UP 0x00000000u
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ Logitech G29 USB Protocol
|
|||||||
- `0x02000000` - Red rotation clockwise
|
- `0x02000000` - Red rotation clockwise
|
||||||
- `0x04000000` - Red rotation counterclockwise
|
- `0x04000000` - Red rotation counterclockwise
|
||||||
- `0x08000000` - Return
|
- `0x08000000` - Return
|
||||||
- `0xF0000000` - Playstation 3 Logo Button (verify)
|
- `0x10000000` - PS3 Logo
|
||||||
|
- `0xE0000000` - ?
|
||||||
- `Rot`: Wheel rotation (little-endian). `0x0000` (leftmost) - `0xFFFF` (rightmost).
|
- `Rot`: Wheel rotation (little-endian). `0x0000` (leftmost) - `0xFFFF` (rightmost).
|
||||||
- `Gas`: Gas pedal. `0xFF` (up, default) - `0x00` (down).
|
- `Gas`: Gas pedal. `0xFF` (up, default) - `0x00` (down).
|
||||||
- `Brk`: Brake pedal. `0xFF` (up, default) - `0x00` (down).
|
- `Brk`: Brake pedal. `0xFF` (up, default) - `0x00` (down).
|
||||||
|
|||||||
Reference in New Issue
Block a user