4 Commits

Author SHA1 Message Date
lorenz.stechauner 7351f6826c Update PS3 button mask 2026-01-19 17:51:47 +01:00
lorenz.stechauner bb3ec4c827 Add approach from Felix and refine it 2026-01-19 17:40:57 +01:00
lorenz.stechauner 9eddc02172 Reformat code (tabs -> spaces) 2026-01-19 14:50:47 +01:00
lorenz.stechauner 2f7028f3f3 [WIP] 2 2026-01-19 00:17:47 +01:00
6 changed files with 352 additions and 702 deletions
+4 -5
View File
@@ -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
+343 -445
View File
@@ -32,9 +32,9 @@ MODULE_DESCRIPTION("Logitech G29 USB driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
enum g29_mode { enum g29_mode {
G29_MODE_MEDIA = 0, G29_MODE_MEDIA = 0,
G29_MODE_WASD = 1, G29_MODE_WASD = 1,
G29_MODE_MOUSE = 2, G29_MODE_MOUSE = 2,
}; };
static int mode = G29_MODE_MEDIA; static int mode = G29_MODE_MEDIA;
@@ -44,7 +44,7 @@ MODULE_PARM_DESC(mode, "Initial mode (0=MEDIA, 1=WASD, 2=MOUSE)");
/* Steering curve exponent (100 = linear, 200 = squared, 150 = ^1.5) /* Steering curve exponent (100 = linear, 200 = squared, 150 = ^1.5)
* Higher values reduce sensitivity at low steering angles. * Higher values reduce sensitivity at low steering angles.
*/ */
static int steer_curve = 200; static int steer_curve = 100;
module_param(steer_curve, int, 0644); module_param(steer_curve, int, 0644);
MODULE_PARM_DESC(steer_curve, "Steering sensitivity curve (100=linear, 200=squared, default=200)"); MODULE_PARM_DESC(steer_curve, "Steering sensitivity curve (100=linear, 200=squared, default=200)");
@@ -63,554 +63,452 @@ MODULE_PARM_DESC(clutch_curve, "Clutch pedal sensitivity curve (100=linear, 200=
#define NORMALIZATION_PRECISION 1000 #define NORMALIZATION_PRECISION 1000
struct g29_keymap { struct g29_keymap {
u32 mask; u32 mask;
unsigned short keycode; unsigned short keycode;
}; };
static const struct g29_keymap media_mode_keymap[] = { static const struct g29_keymap media_mode_keymap[] = {
/* Red rotary = volume */ /* Red rotary = volume */
{ G29_BTN_RED_CW, KEY_VOLUMEUP }, {G29_BTN_RED_CW, KEY_VOLUMEUP},
{ G29_BTN_RED_CCW, KEY_VOLUMEDOWN }, {G29_BTN_RED_CCW, KEY_VOLUMEDOWN},
/* Return = play/pause */ /* Return = play/pause */
{ G29_BTN_RETURN, KEY_PLAYPAUSE }, {G29_BTN_RETURN, KEY_PLAYPAUSE},
/* Plus/Minus = next/prev */ /* Plus/Minus = next/prev */
{ G29_BTN_R1, KEY_NEXTSONG }, {G29_BTN_R1, KEY_NEXTSONG},
{ G29_BTN_L1, KEY_PREVIOUSSONG }, {G29_BTN_L1, KEY_PREVIOUSSONG},
}; };
static const struct g29_keymap mouse_mode_keymap[] = { static const struct g29_keymap mouse_mode_keymap[] = {
{ G29_BTN_X, BTN_LEFT }, {G29_BTN_X, BTN_LEFT},
{ G29_BTN_CIRCLE, BTN_RIGHT }, {G29_BTN_CIRCLE, BTN_RIGHT},
{ G29_BTN_TRIANGLE, BTN_MIDDLE }, {G29_BTN_TRIANGLE, BTN_MIDDLE},
{ G29_BTN_SQUARE, BTN_SIDE }, {G29_BTN_SQUARE, BTN_SIDE},
}; };
struct g29_dev { struct g29_dev {
char name[128]; char name[128];
char phys[64]; char phys[64];
struct usb_device *udev; struct usb_device *udev;
struct input_dev *input; struct input_dev *input;
struct urb *urb; struct urb *urb;
u8 *buf; u8 *buf;
dma_addr_t buf_dma; dma_addr_t buf_dma;
int maxp; int maxp;
int interval; int interval;
int endpoint; int endpoint;
struct timer_list steer_timer; struct timer_list steer_timer;
struct timer_list mouse_timer; struct timer_list mouse_timer;
u32 steer_phase_ms; u32 steer_phase_ms;
u32 phase_accumulator; u32 phase_accumulator;
u32 gas_phase_accumulator; u32 gas_phase_accumulator;
u32 clutch_phase_accumulator; u32 clutch_phase_accumulator;
enum g29_mode current_mode; enum g29_mode current_mode;
struct g29_state last; struct g29_state last;
}; };
static void g29_switch_mode(struct g29_dev *g29, enum g29_mode new_mode) { static void g29_switch_mode(struct g29_dev *g29, enum g29_mode new_mode) {
if (g29->current_mode == new_mode) if (g29->current_mode == new_mode)
return; return;
/* Stop timers when leaving modes */ /* Stop timers when leaving modes */
if (g29->current_mode == G29_MODE_WASD) { if (g29->current_mode == G29_MODE_WASD) {
timer_delete_sync(&g29->steer_timer); timer_delete_sync(&g29->steer_timer);
} }
if (g29->current_mode == G29_MODE_MOUSE) { if (g29->current_mode == G29_MODE_MOUSE) {
timer_delete_sync(&g29->mouse_timer); timer_delete_sync(&g29->mouse_timer);
} }
g29->current_mode = new_mode; g29->current_mode = new_mode;
g29->phase_accumulator = 0; g29->phase_accumulator = 0;
g29->gas_phase_accumulator = 0; g29->gas_phase_accumulator = 0;
g29->clutch_phase_accumulator = 0; g29->clutch_phase_accumulator = 0;
/* Start timers when entering modes */ /* Start timers when entering modes */
if (new_mode == G29_MODE_WASD) { if (new_mode == G29_MODE_WASD) {
mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(2)); mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(1));
} }
if (new_mode == G29_MODE_MOUSE) { if (new_mode == G29_MODE_MOUSE) {
mod_timer(&g29->mouse_timer, jiffies + msecs_to_jiffies(10)); mod_timer(&g29->mouse_timer, jiffies + msecs_to_jiffies(10));
} }
dev_info(&g29->udev->dev, "Switched to mode: %s\n", dev_info(&g29->udev->dev, "Switched to mode: %s\n",
new_mode == G29_MODE_MEDIA ? "MEDIA" : new_mode == G29_MODE_MEDIA ? "MEDIA" :
new_mode == G29_MODE_WASD ? "WASD" : "MOUSE"); new_mode == G29_MODE_WASD ? "WASD" : "MOUSE");
}
static int calc_adjusted_steering_distance(int distance) {
/* Apply non-linear steering curve:
* adjusted = (distance / MAX)^(curve/100) * MAX
*
* For curve=200 (squared): 5% input -> 0.25% output, 50% -> 25%, 100% -> 100%
* For curve=150 (^1.5): 5% input -> ~1.1% output, 50% -> ~35%, 100% -> 100%
* For curve=100 (linear): 5% input -> 5% output (no change)
*
* Using integer math: adjusted = (distance^2 / MAX) for curve=200
*/
if (steer_curve == 100) {
return distance;
}
if (steer_curve == 200) {
return(distance * distance) / WHEEL_MAX_DIST;
}
/* Generic power curve using normalized values (0-1000 range for precision)
* normalized = (distance * 1000) / WHEEL_MAX_DIST
* Apply power approximation, then scale back
*/
int normalized = (distance * NORMALIZATION_PRECISION) / WHEEL_MAX_DIST;
int powered;
if (steer_curve == 150) {
/* Approximate ^1.5 with (x * sqrt(x)) */
int sqrt_norm = int_sqrt(normalized * NORMALIZATION_PRECISION);
powered = (normalized * sqrt_norm) / NORMALIZATION_PRECISION;
} else {
/* Fallback: squared for any other value > 100 */
powered = (normalized * normalized) / NORMALIZATION_PRECISION;
}
return (powered * WHEEL_MAX_DIST) / NORMALIZATION_PRECISION;
}
static int calc_adjusted_pedal_distance(int pedal_pressure, int curve) {
if (curve == 100) {
return pedal_pressure;
}
if (curve == 200) {
return (pedal_pressure * pedal_pressure) / G29_PEDAL_RELEASED;
}
int normalized = (pedal_pressure * NORMALIZATION_PRECISION) / G29_PEDAL_RELEASED;
int powered;
if (curve == 150) {
int sqrt_norm = int_sqrt(normalized * NORMALIZATION_PRECISION);
powered = (normalized * sqrt_norm) / NORMALIZATION_PRECISION;
} else {
powered = (normalized * normalized) / NORMALIZATION_PRECISION;
}
return (powered * G29_PEDAL_RELEASED) / NORMALIZATION_PRECISION;
} }
static void mouse_mode_timer_fn(struct timer_list *t) { static void mouse_mode_timer_fn(struct timer_list *t) {
struct g29_dev *g29 = timer_container_of(g29, t, mouse_timer); struct g29_dev *g29 = timer_container_of(g29, t, mouse_timer);
const int rot = le16_to_cpu(g29->last.rot_le); const int rot = le16_to_cpu(g29->last.rot_le);
int gas_pressure = G29_PEDAL_RELEASED - g29->last.gas; int gas_pressure = G29_PEDAL_RELEASED - g29->last.gas;
int clutch_pressure = G29_PEDAL_RELEASED - g29->last.clt; int clutch_pressure = G29_PEDAL_RELEASED - g29->last.clt;
/* Calculate speed: positive for forward (gas), negative for backward (clutch) */ /* Calculate speed: positive for forward (gas), negative for backward (clutch) */
int speed = gas_pressure - clutch_pressure; int speed = gas_pressure - clutch_pressure;
/* Apply deadzone to steering */ /* Apply deadzone to steering */
int effective_rot = rot; int effective_rot = rot;
if (abs(rot - WHEEL_CENTER) <= steer_deadzone) { if (abs(rot - WHEEL_CENTER) <= steer_deadzone) {
effective_rot = WHEEL_CENTER; effective_rot = WHEEL_CENTER;
} }
/* Calculate angle from wheel rotation /* Calculate angle from wheel rotation
* Map wheel rotation to angle: * Map wheel rotation to angle:
* - Center (32768) = 0° (straight forward) * - Center (32768) = 0° (straight forward)
* - Full left (0) = -180° (reverse) * - Full left (0) = -180° (reverse)
* - Full right (65535) = +180° (reverse) * - Full right (65535) = +180° (reverse)
* We normalize to -1000 to +1000 representing -π to +π radians * We normalize to -1000 to +1000 representing -π to +π radians
*/ */
int angle_normalized = ((effective_rot - WHEEL_CENTER) * 1000) / WHEEL_CENTER; int angle_normalized = ((effective_rot - WHEEL_CENTER) * 1000) / WHEEL_CENTER;
/* Clamp angle to prevent overflow */ /* Clamp angle to prevent overflow */
if (angle_normalized > 1000) angle_normalized = 1000; if (angle_normalized > 1000) angle_normalized = 1000;
if (angle_normalized < -1000) angle_normalized = -1000; if (angle_normalized < -1000) angle_normalized = -1000;
/* Calculate movement components using better trigonometric approximations: /* Calculate movement components using better trigonometric approximations:
* dx = sin(angle) * speed * dx = sin(angle) * speed
* dy = cos(angle) * speed * dy = cos(angle) * speed
* *
* sin(x) ≈ x - x³/6 (Taylor series) * sin(x) ≈ x - x³/6 (Taylor series)
* cos(x) ≈ 1 - x²/2 + x⁴/24 (Taylor series) * cos(x) ≈ 1 - x²/2 + x⁴/24 (Taylor series)
* *
* For angle_normalized in [-1000, 1000] representing [-π, +π]: * For angle_normalized in [-1000, 1000] representing [-π, +π]:
* This gives us full reverse when fully steered * This gives us full reverse when fully steered
*/ */
long angle_cubed = ((long)angle_normalized * angle_normalized * angle_normalized) / 1000000; long angle_cubed = ((long) angle_normalized * angle_normalized * angle_normalized) / 1000000;
int sin_approx = (angle_normalized * 1000 - angle_cubed / 6) / 1000; int sin_approx = (angle_normalized * 1000 - angle_cubed / 6) / 1000;
long angle_squared = ((long)angle_normalized * angle_normalized) / 1000; long angle_squared = ((long) angle_normalized * angle_normalized) / 1000;
long angle_fourth = (angle_squared * angle_squared) / 1000; long angle_fourth = (angle_squared * angle_squared) / 1000;
int cos_approx = 1000 - angle_squared / 2 + angle_fourth / 24; int cos_approx = 1000 - angle_squared / 2 + angle_fourth / 24;
int dx = (sin_approx * speed) / 1000; int dx = (sin_approx * speed) / 1000;
int dy = -(cos_approx * speed) / 1000; /* Negative because forward is -Y */ int dy = -(cos_approx * speed) / 1000; /* Negative because forward is -Y */
/* Scale down the movement for reasonable mouse speed */ /* Scale down the movement for reasonable mouse speed */
int scaled_dx = dx / 50; int scaled_dx = dx / 50;
int scaled_dy = dy / 50; int scaled_dy = dy / 50;
/* Report mouse movement if there's any */ /* Report mouse movement if there's any */
if (scaled_dx != 0 || scaled_dy != 0) { if (scaled_dx != 0 || scaled_dy != 0) {
input_report_rel(g29->input, REL_X, scaled_dx); input_report_rel(g29->input, REL_X, scaled_dx);
input_report_rel(g29->input, REL_Y, scaled_dy); input_report_rel(g29->input, REL_Y, scaled_dy);
input_sync(g29->input); input_sync(g29->input);
} }
/* Reschedule timer if still in mouse mode */ /* Reschedule timer if still in mouse mode */
if (g29->current_mode == G29_MODE_MOUSE) if (g29->current_mode == G29_MODE_MOUSE)
mod_timer(&g29->mouse_timer, jiffies + msecs_to_jiffies(10)); mod_timer(&g29->mouse_timer, jiffies + msecs_to_jiffies(10));
} }
static void wasd_mode_timer_fn(struct timer_list *t) { static void wasd_mode_timer_fn(struct timer_list *t) {
struct g29_dev *g29 = timer_container_of(g29, t, steer_timer); struct g29_dev *g29 = timer_container_of(g29, t, steer_timer);
const int rot = le16_to_cpu(g29->last.rot_le); const int period = 50;
const int rot = le16_to_cpu(g29->last.rot_le);
int effective_rot = rot; const int gas = 0xFF - g29->last.gas;
int distance_from_center = abs(rot - WHEEL_CENTER); const int brk = 0xFF - g29->last.brk;
if (distance_from_center <= steer_deadzone) {
effective_rot = WHEEL_CENTER;
}
int distance_to_center = abs(effective_rot - WHEEL_CENTER);
int adjusted_distance = calc_adjusted_steering_distance(distance_to_center);
/* Phase accumulator approach: const int gas_duty = gas * period / 0x40;
* Accumulate the adjusted distance on each tick. input_report_key(g29->input, KEY_W, g29->gas_phase_accumulator < gas_duty);
* When it exceeds the max distance, press the key and wrap. g29->gas_phase_accumulator++;
* This gives us a duty cycle of (adjusted_distance / WHEEL_MAX_DIST). g29->gas_phase_accumulator %= period;
*
* Examples (with curve=200):
* 5% steering -> ~0.25% press rate
* 50% steering -> 25% press rate
* 100% steering -> 100% press rate (every tick)
*/
g29->phase_accumulator += adjusted_distance;
bool press_key; input_report_key(g29->input, KEY_S, brk >= 0x80);
if (g29->phase_accumulator >= WHEEL_MAX_DIST) {
g29->phase_accumulator -= WHEEL_MAX_DIST;
press_key = true;
} else {
press_key = false;
}
input_report_key(g29->input, KEY_A, press_key && (effective_rot < WHEEL_CENTER)); if (rot >= 0x7ff8 && rot <= 0x8008){
input_report_key(g29->input, KEY_D, press_key && (effective_rot >= WHEEL_CENTER)); input_report_key(g29->input, KEY_A, 0);
input_report_key(g29->input, KEY_D, 0);
} else {
const int mag = rot < 0x8000 ? 0x8000 - rot : rot - 0x8000;
const int duty = mag * period / 0x3000;
const int k1 = rot > 0x8000 ? KEY_D : KEY_A;
const int k2 = rot > 0x8000 ? KEY_A : KEY_D;
input_report_key(g29->input, k2, 0);
input_report_key(g29->input, k1, g29->phase_accumulator < duty);
}
/* Gas pedal (0xFF=up, 0x00=down) -> W key */ g29->phase_accumulator++;
int gas_pressure = 0xFF - g29->last.gas; g29->phase_accumulator %= period;
int gas_adjusted = calc_adjusted_pedal_distance(gas_pressure, gas_curve);
g29->gas_phase_accumulator += gas_adjusted;
bool press_w = false; input_sync(g29->input);
if (g29->gas_phase_accumulator >= G29_PEDAL_RELEASED) {
g29->gas_phase_accumulator -= G29_PEDAL_RELEASED;
press_w = true;
}
/* Clutch pedal (0xFF=up, 0x00=down) -> S key */ if (g29->current_mode == G29_MODE_WASD)
int clutch_pressure = 0xFF - g29->last.clt; mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(1));
int clutch_adjusted = calc_adjusted_pedal_distance(clutch_pressure, clutch_curve);
g29->clutch_phase_accumulator += clutch_adjusted;
bool press_s = false;
if (g29->clutch_phase_accumulator >= G29_PEDAL_RELEASED) {
g29->clutch_phase_accumulator -= G29_PEDAL_RELEASED;
press_s = true;
}
input_report_key(g29->input, KEY_W, press_w);
input_report_key(g29->input, KEY_S, press_s);
input_sync(g29->input);
if (g29->current_mode == G29_MODE_WASD)
mod_timer(&g29->steer_timer, jiffies + msecs_to_jiffies(2));
} }
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 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le); const u32 buttons = le32_to_cpu(cur->buttons_le);
const u32 released = le32_to_cpu(~cur->buttons_le & prev->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]; input_report_key(g29->input, k->keycode, !!(buttons & k->mask));
if (pressed & k->mask) { }
input_report_key(g29->input, k->keycode, 1); input_sync(g29->input);
}
if (released & k->mask) {
input_report_key(g29->input, k->keycode, 0);
}
}
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)
/* No additional processing needed here */ 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_SPACE, !!(buttons & G29_BTN_R1));
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 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le); const u32 buttons = le32_to_cpu(cur->buttons_le);
const u32 released = 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);
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];
if (pressed & k->mask) { input_report_key(g29->input, k->keycode, !!(buttons & k->mask));
input_report_key(g29->input, k->keycode, 1); }
}
if (released & k->mask) {
input_report_key(g29->input, k->keycode, 0);
}
}
if (pressed & G29_BTN_RED_CW) { if (pressed & G29_BTN_RED_CW) {
input_report_rel(g29->input, REL_WHEEL, 1); input_report_rel(g29->input, REL_WHEEL, 1);
} } else if (pressed & G29_BTN_RED_CCW) {
if (pressed & G29_BTN_RED_CCW) { input_report_rel(g29->input, REL_WHEEL, -1);
input_report_rel(g29->input, REL_WHEEL, -1); } else {
} input_report_rel(g29->input, REL_WHEEL, 0);
}
input_sync(g29->input);
input_sync(g29->input);
} }
static void g29_check_mode_switch(struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) { static void g29_check_mode_switch(struct g29_dev *g29, const struct g29_state *cur, const struct g29_state *prev) {
u32 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le); const u32 pressed = le32_to_cpu(cur->buttons_le & ~prev->buttons_le);
if (pressed & G29_BTN_SHARE) {
if (pressed & G29_BTN_SHARE) { 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) {
} else if (pressed & G29_BTN_PS3_LOGO) { 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);
switch (g29->current_mode) {
g29_check_mode_switch(g29, cur, &g29->last); case G29_MODE_MEDIA: process_media_mode(g29, cur, &g29->last); break;
case G29_MODE_WASD: process_wasd_mode(g29, cur, &g29->last); break;
switch (g29->current_mode) { case G29_MODE_MOUSE: process_mouse_mode(g29, cur, &g29->last);break;
case G29_MODE_MEDIA: }
process_media_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;
} }
static void g29_urb_complete(struct urb *urb) { static void g29_urb_complete(struct urb *urb) {
struct g29_dev *g29 = urb->context; struct g29_dev *g29 = urb->context;
int ret; int ret;
switch (urb->status) { switch (urb->status) {
case 0: case 0:
break; /* success */ break; /* success */
case -ECONNRESET: case -ECONNRESET:
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
return; /* cancelled/disconnected */ return; /* cancelled/disconnected */
default: default:
goto resubmit; /* transient error */ goto resubmit; /* transient error */
} }
g29_process_report(g29, g29->buf, urb->actual_length); g29_process_report(g29, g29->buf, urb->actual_length);
resubmit: resubmit:
ret = usb_submit_urb(urb, GFP_ATOMIC); ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret) if (ret)
dev_err(&g29->udev->dev, "usb_submit_urb failed: %d\n", ret); dev_err(&g29->udev->dev, "usb_submit_urb failed: %d\n", ret);
} }
static int g29_input_open(struct input_dev *input) { static int g29_input_open(struct input_dev *input) {
struct g29_dev *g29 = input_get_drvdata(input); struct g29_dev *g29 = input_get_drvdata(input);
g29->urb->dev = g29->udev; g29->urb->dev = g29->udev;
if (usb_submit_urb(g29->urb, GFP_KERNEL)) if (usb_submit_urb(g29->urb, GFP_KERNEL))
return -EIO; return -EIO;
g29_switch_mode(g29, mode); g29_switch_mode(g29, mode);
return 0; return 0;
} }
static void g29_input_close(struct input_dev *input) { static void g29_input_close(struct input_dev *input) {
struct g29_dev *g29 = input_get_drvdata(input); struct g29_dev *g29 = input_get_drvdata(input);
if (g29->current_mode == G29_MODE_WASD) if (g29->current_mode == G29_MODE_WASD)
timer_delete_sync(&g29->steer_timer); timer_delete_sync(&g29->steer_timer);
if (g29->current_mode == G29_MODE_MOUSE) if (g29->current_mode == G29_MODE_MOUSE)
timer_delete_sync(&g29->mouse_timer); timer_delete_sync(&g29->mouse_timer);
usb_kill_urb(g29->urb); usb_kill_urb(g29->urb);
} }
static int g29_probe(struct usb_interface *intf, const struct usb_device_id *id) { static int g29_probe(struct usb_interface *intf, const struct usb_device_id *id) {
struct usb_device *udev = interface_to_usbdev(intf); struct usb_device *udev = interface_to_usbdev(intf);
int ret; int ret;
/* Find an interrupt IN endpoint capable of carrying the 12-byte report. */ /* Find an interrupt IN endpoint capable of carrying the 12-byte report. */
struct usb_endpoint_descriptor *ep = NULL; struct usb_endpoint_descriptor *ep = NULL;
const struct usb_host_interface *alts = intf->cur_altsetting; const struct usb_host_interface *alts = intf->cur_altsetting;
for (int i = 0; i < alts->desc.bNumEndpoints; i++) { for (int i = 0; i < alts->desc.bNumEndpoints; i++) {
struct usb_endpoint_descriptor *d = &alts->endpoint[i].desc; struct usb_endpoint_descriptor *d = &alts->endpoint[i].desc;
if (!usb_endpoint_is_int_in(d)) if (!usb_endpoint_is_int_in(d))
continue; continue;
if (usb_maxpacket(udev, usb_rcvintpipe(udev, d->bEndpointAddress)) >= 12) { if (usb_maxpacket(udev, usb_rcvintpipe(udev, d->bEndpointAddress)) >= 12) {
ep = d; ep = d;
break; break;
} }
} }
if (!ep) return -ENODEV; if (!ep) return -ENODEV;
struct g29_dev *g29; struct g29_dev *g29;
if ((g29 = kzalloc(sizeof(*g29), GFP_KERNEL)) == NULL) { if ((g29 = kzalloc(sizeof(*g29), GFP_KERNEL)) == NULL) {
return -ENOMEM; return -ENOMEM;
} }
struct input_dev *input; struct input_dev *input;
if ((input = input_allocate_device()) == NULL) { if ((input = input_allocate_device()) == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_g29; goto err_free_g29;
} }
g29->udev = udev; g29->udev = udev;
g29->input = input; g29->input = input;
g29->endpoint = usb_endpoint_num(ep); g29->endpoint = usb_endpoint_num(ep);
g29->maxp = usb_endpoint_maxp(ep); g29->maxp = usb_endpoint_maxp(ep);
g29->interval = ep->bInterval; g29->interval = ep->bInterval;
memset(&g29->last, 0, sizeof(g29->last)); memset(&g29->last, 0, sizeof(g29->last));
g29->current_mode = mode; /* Initialize to module parameter */ g29->current_mode = mode; /* Initialize to module parameter */
timer_setup(&g29->steer_timer, wasd_mode_timer_fn, 0); timer_setup(&g29->steer_timer, wasd_mode_timer_fn, 0);
timer_setup(&g29->mouse_timer, mouse_mode_timer_fn, 0); timer_setup(&g29->mouse_timer, mouse_mode_timer_fn, 0);
if ((g29->buf = usb_alloc_coherent(udev, g29->maxp, GFP_KERNEL, &g29->buf_dma)) == NULL) { if ((g29->buf = usb_alloc_coherent(udev, g29->maxp, GFP_KERNEL, &g29->buf_dma)) == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_input; goto err_free_input;
} }
if ((g29->urb = usb_alloc_urb(0, GFP_KERNEL)) == NULL) { if ((g29->urb = usb_alloc_urb(0, GFP_KERNEL)) == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_buf; goto err_free_buf;
} }
if (udev->manufacturer) if (udev->manufacturer)
strscpy(g29->name, udev->manufacturer, sizeof(g29->name)); strscpy(g29->name, udev->manufacturer, sizeof(g29->name));
if (udev->product) { if (udev->product) {
if (udev->manufacturer) if (udev->manufacturer)
strlcat(g29->name, " ", sizeof(g29->name)); strlcat(g29->name, " ", sizeof(g29->name));
strlcat(g29->name, udev->product, sizeof(g29->name)); strlcat(g29->name, udev->product, sizeof(g29->name));
} }
if (!strlen(g29->name)) if (!strlen(g29->name))
snprintf(g29->name, sizeof(g29->name), snprintf(g29->name, sizeof(g29->name),
"Logitech G29 USB %04x:%04x", "Logitech G29 USB %04x:%04x",
le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct)); le16_to_cpu(udev->descriptor.idProduct));
usb_make_path(udev, g29->phys, sizeof(g29->phys)); usb_make_path(udev, g29->phys, sizeof(g29->phys));
strlcat(g29->phys, "/input0", sizeof(g29->phys)); strlcat(g29->phys, "/input0", sizeof(g29->phys));
input->name = g29->name; input->name = g29->name;
input->phys = g29->phys; input->phys = g29->phys;
usb_to_input_id(udev, &input->id); usb_to_input_id(udev, &input->id);
input->dev.parent = &intf->dev; input->dev.parent = &intf->dev;
__set_bit(EV_KEY, input->evbit); __set_bit(EV_KEY, input->evbit);
__set_bit(EV_REL, input->evbit); __set_bit(EV_REL, input->evbit);
/* Media mode keys */ // Media mode keys
input_set_capability(input, EV_KEY, KEY_VOLUMEUP); input_set_capability(input, EV_KEY, KEY_VOLUMEUP);
input_set_capability(input, EV_KEY, KEY_VOLUMEDOWN); input_set_capability(input, EV_KEY, KEY_VOLUMEDOWN);
input_set_capability(input, EV_KEY, KEY_PLAYPAUSE); input_set_capability(input, EV_KEY, KEY_PLAYPAUSE);
input_set_capability(input, EV_KEY, KEY_NEXTSONG); input_set_capability(input, EV_KEY, KEY_NEXTSONG);
input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG); input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG);
/* WASD mode keys */ // WASD mode keys
input_set_capability(input, EV_KEY, KEY_W); input_set_capability(input, EV_KEY, KEY_W);
input_set_capability(input, EV_KEY, KEY_A); input_set_capability(input, EV_KEY, KEY_A);
input_set_capability(input, EV_KEY, KEY_S); input_set_capability(input, EV_KEY, KEY_S);
input_set_capability(input, EV_KEY, KEY_D); input_set_capability(input, EV_KEY, KEY_D);
input_set_capability(input, EV_KEY, KEY_C);
input_set_capability(input, EV_KEY, KEY_SPACE);
/* Mouse mode capabilities */ // Mouse mode capabilities
input_set_capability(input, EV_KEY, BTN_LEFT); input_set_capability(input, EV_KEY, BTN_LEFT);
input_set_capability(input, EV_KEY, BTN_RIGHT); input_set_capability(input, EV_KEY, BTN_RIGHT);
input_set_capability(input, EV_KEY, BTN_MIDDLE); input_set_capability(input, EV_KEY, BTN_MIDDLE);
input_set_capability(input, EV_REL, REL_X); input_set_capability(input, EV_REL, REL_X);
input_set_capability(input, EV_REL, REL_Y); input_set_capability(input, EV_REL, REL_Y);
input_set_capability(input, EV_REL, REL_WHEEL); input_set_capability(input, EV_REL, REL_WHEEL);
input_set_drvdata(input, g29); input_set_drvdata(input, g29);
input->open = g29_input_open; input->open = g29_input_open;
input->close = g29_input_close; input->close = g29_input_close;
usb_fill_int_urb(g29->urb, udev, usb_rcvintpipe(udev, ep->bEndpointAddress), usb_fill_int_urb(g29->urb, udev, usb_rcvintpipe(udev, ep->bEndpointAddress),
g29->buf, g29->maxp, g29->buf, g29->maxp,
g29_urb_complete, g29, ep->bInterval); g29_urb_complete, g29, ep->bInterval);
g29->urb->transfer_dma = g29->buf_dma; g29->urb->transfer_dma = g29->buf_dma;
g29->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; g29->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
if ((ret = input_register_device(input)) != 0) { if ((ret = input_register_device(input)) != 0) {
goto err_free_urb; goto err_free_urb;
} }
usb_set_intfdata(intf, g29); usb_set_intfdata(intf, g29);
dev_info(&intf->dev, dev_info(&intf->dev,
"G29 media driver bound (ep=%02x interval=%u)\n", "G29 media driver bound (ep=%02x interval=%u)\n",
ep->bEndpointAddress, ep->bInterval); ep->bEndpointAddress, ep->bInterval);
return 0; return 0;
err_free_urb: err_free_urb:
usb_free_urb(g29->urb); usb_free_urb(g29->urb);
err_free_buf: err_free_buf:
usb_free_coherent(udev, g29->maxp, g29->buf, g29->buf_dma); usb_free_coherent(udev, g29->maxp, g29->buf, g29->buf_dma);
err_free_input: err_free_input:
input_free_device(input); input_free_device(input);
err_free_g29: err_free_g29:
kfree(g29); kfree(g29);
return ret; return ret;
} }
static void g29_disconnect(struct usb_interface *intf) { static void g29_disconnect(struct usb_interface *intf) {
struct g29_dev *g29 = usb_get_intfdata(intf); struct g29_dev *g29 = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
if (!g29) return; if (!g29) return;
usb_kill_urb(g29->urb); usb_kill_urb(g29->urb);
input_unregister_device(g29->input); input_unregister_device(g29->input);
usb_free_urb(g29->urb); usb_free_urb(g29->urb);
usb_free_coherent(interface_to_usbdev(intf), g29->maxp, g29->buf, g29->buf_dma); usb_free_coherent(interface_to_usbdev(intf), g29->maxp, g29->buf, g29->buf_dma);
kfree(g29); kfree(g29);
dev_info(&intf->dev, "G29 driver disconnected\n"); dev_info(&intf->dev, "G29 driver disconnected\n");
} }
static const struct usb_device_id g29_id_table[] = { static const struct usb_device_id g29_id_table[] = {
{ USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29) }, {USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29)},
{ USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_ALT) }, {USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_ALT)},
{ } {}
}; };
MODULE_DEVICE_TABLE(usb, g29_id_table); MODULE_DEVICE_TABLE(usb, g29_id_table);
static struct usb_driver g29_driver = { static struct usb_driver g29_driver = {
.name = "g29_usb", .name = "g29_usb",
.id_table = g29_id_table, .id_table = g29_id_table,
.probe = g29_probe, .probe = g29_probe,
.disconnect = g29_disconnect, .disconnect = g29_disconnect,
}; };
module_usb_driver(g29_driver); module_usb_driver(g29_driver);
+3 -3
View File
@@ -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
@@ -59,8 +59,8 @@
#define G29_GEARSHIFT_Z_NEUTRAL 0x9C /* Neutral position */ #define G29_GEARSHIFT_Z_NEUTRAL 0x9C /* Neutral position */
#define G29_GEARSHIFT_Z_PRESSED 0xDC /* Pressed down */ #define G29_GEARSHIFT_Z_PRESSED 0xDC /* Pressed down */
#define WHEEL_CENTER 32768 #define WHEEL_CENTER 0x8000
#define WHEEL_MAX_DIST 32768 #define WHEEL_MAX_DIST 0x8000
struct g29_state { struct g29_state {
u32 buttons_le; /* Button bitmask (little-endian) */ u32 buttons_le; /* Button bitmask (little-endian) */
+2 -1
View File
@@ -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).
-25
View File
@@ -1,25 +0,0 @@
.PHONY: all
obj-m += wasd.o
KVER := $(shell uname -r)
KDIR ?= $(firstword $(wildcard /lib/modules/$(KVER)/build) $(wildcard /usr/lib/modules/$(KVER)/build))
PWD := $(shell pwd)
OUT := $(PWD)/out
all:
@if [ -z "$(KDIR)" ]; then \
echo "ERROR: kernel build dir not found for $(KVER). Install kernel headers (e.g. linux-headers)"; \
exit 2; \
fi
mkdir -p $(OUT)
$(MAKE) -C $(KDIR) M=$(PWD) modules
-mv -f -- *.ko *.mod.c *.o .*.o *.mod modules.order .*.cmd *.symvers $(OUT)
clean:
@if [ -z "$(KDIR)" ]; then \
echo "ERROR: kernel build dir not found for $(KVER)."; \
exit 2; \
fi
$(MAKE) -C $(KDIR) M=$(PWD) clean
rm -rf $(OUT) *.cmd *.order *.mod *.o
-223
View File
@@ -1,223 +0,0 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/usb/input.h>
#include <linux/input.h>
#include <linux/slab.h>
#define DRV_NAME "usb_steeringwheel_wasd"
struct wheel_evt {
uint32_t buttons_be;
uint16_t rot_be;
uint8_t gas;
uint8_t brk;
uint8_t clt;
uint8_t gr_x;
uint8_t gr_y;
uint8_t gr_z;
};
struct wheel {
struct usb_device *udev;
struct usb_interface *intf;
struct input_dev *input;
struct urb *irq_urb;
struct wheel_evt *irq_data;
dma_addr_t irq_dma;
int irq_len;
int irq_interval;
int irq_ep;
char phys[64];
atomic_t opened;
};
static int drv_open(struct input_dev *dev) {
struct wheel *w = input_get_drvdata(dev);
if (!w) return -ENODEV;
atomic_set(&w->opened, 1);
int ret;
if ((ret = usb_submit_urb(w->irq_urb, GFP_KERNEL))) {
atomic_set(&w->opened, 0);
return ret;
}
return 0;
}
static void drv_irq(struct urb *urb) {
// called every 2ms?
struct wheel *w = urb->context;
if (!w || !atomic_read(&w->opened))
return;
const int status = urb->status;
if (status) {
if (status == -ENOENT || status == -ECONNRESET || status == -ESHUTDOWN)
return;
dev_dbg(&w->intf->dev, "irq urb status %d\n", status);
goto resubmit;
}
const struct wheel_evt *data = w->irq_data;
const int rot = be16_to_cpu(data->buttons_be);
// TODO set keys according to ratio
input_report_key(w->input, KEY_W, data->gas <= 0x80);
input_report_key(w->input, KEY_S, data->brk <= 0x80);
input_report_key(w->input, KEY_A, rot <= 0x6000);
input_report_key(w->input, KEY_D, rot >= 0xA000);
input_sync(w->input);
resubmit:
usb_submit_urb(w->irq_urb, GFP_ATOMIC);
}
static void drv_close(struct input_dev *dev) {
struct wheel *w = input_get_drvdata(dev);
if (!w) return;
atomic_set(&w->opened, 0);
usb_kill_urb(w->irq_urb);
}
static int drv_probe(struct usb_interface *intf, const struct usb_device_id *id) {
struct usb_device *udev = interface_to_usbdev(intf);
int ret;
// Logitech G29
//if (le16_to_cpu(udev->descriptor.idVendor) != 0x046d || le16_to_cpu(udev->descriptor.idProduct) != 0xc24f)
// return -ENODEV;
struct usb_endpoint_descriptor *ep = NULL;
const struct usb_host_interface *alts = intf->cur_altsetting;
for (int i = 0; i < alts->desc.bNumEndpoints; i++) {
struct usb_endpoint_descriptor *d = &alts->endpoint[i].desc;
if (usb_endpoint_is_int_in(d)) {
ep = d;
break;
}
}
if (!ep) return -ENODEV;
struct wheel *w;
if ((w = kzalloc(sizeof(*w), GFP_KERNEL)) == NULL)
return -ENOMEM;
w->udev = usb_get_dev(udev);
w->intf = intf;
atomic_set(&w->opened, 0);
w->irq_ep = usb_endpoint_num(ep);
w->irq_len = usb_endpoint_maxp(ep);
w->irq_interval = ep->bInterval;
if ((w->irq_urb = usb_alloc_urb(0, GFP_KERNEL)) == NULL) {
ret = -ENOMEM;
goto err_free;
}
if ((w->irq_data = usb_alloc_coherent(udev, w->irq_len, GFP_KERNEL, &w->irq_dma)) == NULL) {
ret = -ENOMEM;
goto err_free_urb;
}
if ((w->input = input_allocate_device()) == NULL) {
ret = -ENOMEM;
goto err_free_buf;
}
usb_make_path(udev, w->phys, sizeof(w->phys));
strlcat(w->phys, "/input0", sizeof(w->phys));
w->input->name = "USB Boot Mouse (example driver)";
w->input->phys = w->phys;
usb_to_input_id(udev, &w->input->id);
w->input->dev.parent = &intf->dev;
w->input->open = drv_open;
w->input->close = drv_close;
input_set_drvdata(w->input, w);
usb_fill_int_urb(
w->irq_urb,
udev,
usb_rcvintpipe(udev, ep->bEndpointAddress),
w->irq_data,
w->irq_len,
drv_irq,
w,
w->irq_interval);
w->irq_urb->transfer_dma = w->irq_dma;
w->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
usb_set_intfdata(intf, w);
if ((ret = input_register_device(w->input)) != 0)
goto err_clear_intfdata;
dev_info(&intf->dev,
"bound to %04x:%04x, int-in ep 0x%02x maxp %u interval %u\n",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ep->bEndpointAddress,
w->irq_len,
w->irq_interval);
return 0;
err_clear_intfdata:
usb_set_intfdata(intf, NULL);
input_free_device(w->input);
w->input = NULL;
err_free_buf:
usb_free_coherent(udev, w->irq_len, w->irq_data, w->irq_dma);
err_free_urb:
usb_free_urb(w->irq_urb);
err_free:
usb_put_dev(w->udev);
kfree(w);
return ret;
}
static void drv_disconnect(struct usb_interface *intf) {
struct wheel *w = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
if (!w) return;
if (w->input) {
input_unregister_device(w->input);
w->input = NULL;
}
usb_kill_urb(w->irq_urb);
usb_free_coherent(w->udev, w->irq_len, w->irq_data, w->irq_dma);
usb_free_urb(w->irq_urb);
usb_put_dev(w->udev);
kfree(w);
dev_info(&intf->dev, "disconnected\n");
}
static const struct usb_device_id drv_id_table[] = {
{ USB_DEVICE_INTERFACE_NUMBER(0x046d, 0xc24f, 0) },
{ USB_INTERFACE_INFO(3, 1, 1) },
{}
};
MODULE_DEVICE_TABLE(usb, drv_id_table);
static struct usb_driver drv = {
.name = DRV_NAME,
.probe = drv_probe,
.disconnect = drv_disconnect,
.id_table = drv_id_table,
};
module_usb_driver(drv);
MODULE_AUTHOR("Lorenz Stechauner");
MODULE_DESCRIPTION("Steering wheel WASD emulator");
MODULE_LICENSE("GPL");