Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Added ioctl UI_DEV_SETUP call before UI_DEV_CREATE
Browse files Browse the repository at this point in the history
The current implementation using fwrite() was causing new device
events not to be properly identified on Wayland (Sway), rendering
the udevice useless.

This change moves the code closer to the reference kernel impl
from https://kernel.org/doc/html/v6.2/input/uinput.html
  • Loading branch information
gslandtreter committed Apr 27, 2023
1 parent fa2027b commit 47348ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion uinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func createUsbDevice(deviceFile *os.File, dev uinputUserDev) (fd *os.File, err e
_ = deviceFile.Close()
return nil, fmt.Errorf("failed to write user device buffer: %v", err)
}
_, err = deviceFile.Write(buf.Bytes())
err = ioctl(deviceFile, uiDevSetup, uintptr(unsafe.Pointer(buf)))
if err != nil {
_ = deviceFile.Close()
return nil, fmt.Errorf("failed to write uidev struct to device file: %v", err)
Expand Down
1 change: 1 addition & 0 deletions uinputdefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const (
uinputMaxNameSize = 80
uiDevCreate = 0x5501
uiDevDestroy = 0x5502
uiDevSetup = 0x405c5503
// this is for 64 length buffer to store name
// for another length generate using : (len << 16) | 0x8000552C
uiGetSysname = 0x8041552c
Expand Down

1 comment on commit 47348ad

@wenfer
Copy link

@wenfer wenfer commented on 47348ad May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TouchPad does not work after use this commit

Please sign in to comment.