프로그램 사용/uinput2022. 8. 11. 23:42

uinput 에서 절대값을 받기 위해서는 마우스가 아니라 터치로 인식을 시켜야 한다.

 

가장 도움을 받았던 문서가 오히려 함정 카드(?)였는데

1.7.4.2의 내용은 상대좌표를 이용하는 일반적인 마우스의 예라서

[링크 : https://www.kernel.org/doc/html/v4.12/input/uinput.html]

 

struct uinput_setup 구조체를 이용하고 있지만

struct uinput_setup {
struct input_id id;
char name[UINPUT_MAX_NAME_SIZE];
__u32 ff_effects_max;
};

[링크 : https://github.com/torvalds/linux/blob/master/include/uapi/linux/uinput.h]

 

터치패드의 경우(혹은 터치 스크린) 아래의 구조체 중 absmax, absmin 에  시작, 끝 좌표를 넣어 주어야 한다. 

ABS_CNT(64)가 왜 상당히 크게 잡혀있는지 모르겠지만

absmax[0] = WIDTH, absmax[1] = HEIGHT를 넣고 초기화 해주면 된다.

struct uinput_user_dev {
char name[UINPUT_MAX_NAME_SIZE];
struct input_id id;
__u32 ff_effects_max;
__s32 absmax[ABS_CNT];
__s32 absmin[ABS_CNT];
__s32 absfuzz[ABS_CNT];
__s32 absflat[ABS_CNT];
};

[링크 : https://elixir.bootlin.com/linux/v4.6/source/include/uapi/linux/uinput.h#L222]

 

VID와 PID 혹은 문자열이 영향을 주는진 모르겠다.

[링크 : https://github.com/bendahl/uinput/blob/master/touchpad.go#L172]

 

UI_DEV_SETUP을 ioctl을 이용하여 setup 하는게 아니라

/dev/uinput fd에 write() 함수로 써버리는 것이 EV_REL과의 차이라고 해야하나..?

void init_uinput_touchscreen()
{
    int ret = 0;
    struct uinput_user_dev usetup;
    int keys[] = {BTN_LEFT, BTN_RIGHT, BTN_TOUCH};

    int fd_touch = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
    printf("fd[%d]\n", fd_touch);

    //Custom key events init
    ioctl(fd_touch, UI_SET_EVBIT, EV_KEY);
    for(int i = 0; i < sizeof(keys) / sizeof(int); i++){
        ioctl(fd_touch, UI_SET_KEYBIT, keys[i]);
    }

    //Mouse Pointer events init
    ret = ioctl(fd_touch, UI_SET_EVBIT, EV_ABS);
    printf("EV_ABS ret[%d]\n",ret);
    ret = ioctl(fd_touch, UI_SET_ABSBIT, ABS_X);
    printf("ABS_X ret[%d]\n",ret);
    ret = ioctl(fd_touch, UI_SET_ABSBIT, ABS_Y);
    printf("ABS_Y ret[%d]\n",ret);

    memset(&usetup, 0, sizeof(usetup));
    usetup.id.bustype = BUS_USB;
    usetup.id.vendor = 0x4711;
    usetup.id.product = 0x0817;
    strcpy(usetup.name, "TouchPad");
    usetup.absmax[0] = 1024;
    usetup.absmax[1] = 768;

    // ret = ioctl(fd_touch, UI_DEV_SETUP, &usetup);
    ret = write(fd_touch, &usetup, sizeof(struct uinput_user_dev));
    printf("UI_DEV_SETUP ret[%d]\n",ret);
    printf("sizeof %d\n",sizeof(struct uinput_user_dev));
    ret = ioctl(fd_touch, UI_DEV_CREATE);
    printf("UI_DEV_CREATE ret[%d]\n",ret);
}
Posted by 구차니
프로그램 사용/wayland2022. 8. 10. 16:41

 

sway와 wayfire 라는 녀석이 wlroot 기반의 compositor 인 듯.

 

일단~~은 sway 패키지를 설치하고

$ sudo apt install sway

[링크 : https://installati.one/ubuntu/21.04/sway/]


wayvnc 설치(ubuntu 22.04 LTS/x86)

$ sudo apt install wayvnc

 

로그아웃 후에 세션을 sway로 변경

[링크 : https://llandy3d.github.io/sway-on-ubuntu/]

[링크 : https://www.slant.co/topics/11023/versus/~sway_vs_wayfire_vs_weston]

 

"윈 + D" 누르고 terminal 친 후 방향키로 gnome-terminal 선택 + enter

혹은 "윈 + enter"

 

요건 심심해서 htop 실행. i7-3635QM 이긴 한데

sway와 wayvnc가 동일하게 1.3% 씩 먹는 상황. 이걸 낮다고 봐야하나 높다고 봐야하나..

[링크 : https://swaywm.org/]

[링크 : https://wiki.archlinux.org/title/Sway]

 

터미널에서 wayvnc 접속가능하도록 실행

$ wayvnc 0.0.0.0

 

 

+

sway 단축키

super - shift - space (타일/창 전환)
super - e (가로 / 세로 타일 배치 전환)
super - h (창 전환)
super - enter (터미널 열기)
super - d (프로그램 실행?)

 

+

로그아웃

방법을 못 찾아서, sway 프로세스 kill 하고 다시 로그인 함 -_-

'프로그램 사용 > wayland' 카테고리의 다른 글

weston screen shooter 뜯어보기  (0) 2022.08.17
wayland glreadpixels 실패  (0) 2022.08.16
wayvnc 0.5 릴리즈  (0) 2022.08.09
capture drm screen  (0) 2022.08.08
weston redraw 취소하기  (0) 2022.07.07
Posted by 구차니

22.07.10 에 릴리즈 되었는데 H.264 인코딩이 특징인 듯.

wayland도 힘을 못써서 조용히 사라질줄 알았는데, 조용히 부활하고 있었던 건가.. -_-

[링크 : https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/wayland-display-server/1333848-wayvnc-0-5-vnc-server-for-wlroots-based-wayland-compositors-released]

[링크 : https://github.com/any1/wayvnc/releases/tag/v0.5.0]

[링크 : https://github.com/any1/wayvnc]

 

 

그나저나 s390x는 먼가 해서 찾아봤더니 (s로 시작해서 스냅드래곤인가 싶었지만)

[링크 : https://packages.ubuntu.com/jammy/wayvnc]

 

1998년 단종된 IBM System/390 시리즈 인 것 같은데.. 이걸 아직도(?) 지원해주다니..

[링크 : https://en.wikipedia.org/wiki/IBM_System/390]

[링크 : https://en.wikipedia.org/wiki/Linux_on_IBM_Z#Hardware]

'프로그램 사용 > wayland' 카테고리의 다른 글

wayland glreadpixels 실패  (0) 2022.08.16
sway + wayvnc  (0) 2022.08.10
capture drm screen  (0) 2022.08.08
weston redraw 취소하기  (0) 2022.07.07
weston drm debug  (0) 2022.06.29
Posted by 구차니

openGL 컨텍스트를 이용해서 빼내거나

mmap 으로 빼내라고 하는데 어떤 주소값을 복사해야 하는지 이야기가 없네.

 

[링크 : https://stackoverflow.com/questions/47428631/get-screenshot-of-egl-drm-kms-application]

 

+

22.08.09

void glReadPixels( GLint x,
  GLint y,
  GLsizei width,
  GLsizei height,
  GLenum format,
  GLenum type,
  void * data);
 
void glReadnPixels( GLint x,
  GLint y,
  GLsizei width,
  GLsizei height,
  GLenum format,
  GLenum type,
  GLsizei bufSize,
  void * data);

[링크 : https://registry.khronos.org/OpenGL-Refpages/es3/html/glReadPixels.xhtml]

 

[링크 : https://community.nxp.com/t5/i-MX-Processors/Rendering-with-OpenGL-ES-2-x-3-x-to-a-DMA-buffer-physical-memory/m-p/1229007]
  [링크 : https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044158]

[링크 : https://stackoverflow.com/questions/3191978/how-to-use-glut-opengl-to-render-to-a-file]

'프로그램 사용 > wayland' 카테고리의 다른 글

sway + wayvnc  (0) 2022.08.10
wayvnc 0.5 릴리즈  (0) 2022.08.09
weston redraw 취소하기  (0) 2022.07.07
weston drm debug  (0) 2022.06.29
libwayland debug 메시지  (0) 2022.06.27
Posted by 구차니

왼쪽은 golang의 touchscreen uinput 기능을 이용한 것, 오른쪽은 uinput 예제에서 설정한 것인데

UI_DEV_SETUP 대신 write로 쓰는게 좀.. 특이하다. 

그리고 write로 장치 이름을 쓰고 1116 바이트가 써졌다라..

ioctl(3, UI_SET_EVBIT, 0x1)             = 0
ioctl(3, UI_SET_KEYBIT, 0x110)          = 0
ioctl(3, UI_SET_KEYBIT, 0x111)          = 0
ioctl(3, UI_SET_KEYBIT, 0x14a)          = 0

ioctl(3, UI_SET_EVBIT, 0x3)             = 0
ioctl(3, UI_SET_ABSBIT, 0)              = 0
ioctl(3, UI_SET_ABSBIT, 0x1)            = 0

write(3, "testpad\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1116) = 1116
ioctl(3, UI_DEV_CREATE, 0)              = 0
ioctl(3, UI_SET_EVBIT, 0x1)             = 0
ioctl(3, UI_SET_KEYBIT, 0x110)          = 0
ioctl(3, UI_SET_KEYBIT, 0x111)          = 0
ioctl(3, UI_SET_KEYBIT, 0x14a)          = 0

ioctl(3, UI_SET_EVBIT, 0x3)             = 0
ioctl(3, UI_SET_ABSBIT, 0)              = 0
ioctl(3, UI_SET_ABSBIT, 0x1)            = 0

ioctl(3, UI_DEV_SETUP, 0x7ffc48a87ef0)  = 0
ioctl(3, UI_DEV_CREATE, 0)              = 0

 

struct uinput_user_dev   uinp;

            // create input device in input subsystem
            retcode = write(ufile, &uinp, sizeof(uinp));
            printf("First write returned %d.\n", retcode);

First write returned 1116.

[링크 : https://hybridego.net/1823]

 

sturct uinput_setup 은 92 바이트 길이

#define UINPUT_MAX_NAME_SIZE 80
struct uinput_setup {
struct input_id id;
char name[UINPUT_MAX_NAME_SIZE];
__u32 ff_effects_max;
};

[링크 : https://elixir.bootlin.com/linux/v4.7/source/include/uapi/linux/uinput.h#L66]

 

struct uinput_user_dev도 그리 길어 보이진 않는데..

#define UINPUT_MAX_NAME_SIZE 80
struct uinput_user_dev {
char name[UINPUT_MAX_NAME_SIZE];
struct input_id id;
__u32 ff_effects_max;
__s32 absmax[ABS_CNT];
__s32 absmin[ABS_CNT];
__s32 absfuzz[ABS_CNT];
__s32 absflat[ABS_CNT];
};

[링크 : https://elixir.bootlin.com/linux/v4.0/source/include/uapi/linux/uinput.h#L148]

 

64개까지 등록 가능하도록 되어있는건가?

#define ABS_MAX 0x3f
#define ABS_CNT (ABS_MAX+1)

[링크 : https://github.com/spotify/linux/blob/master/include/linux/input.h]

 

+

uinput old interface 로 분류된 구조체인듯..

Programs supportinf older versions of uinput interface need to fill a uinput_user_dev structure and write it to the uinput file descriptor to configure the new uinput device

[링크 : https://www.kernel.org/doc/html/v4.12/input/uinput.html]

Posted by 구차니

golang의 예제로는 원하는대로 절대 좌표 이동이 되는데..

C로 하는건 영 안되네 ㅠㅠ 무슨 차이냐!!!

 

[링크 : https://pkg.go.dev/github.com/bendahl/uinput#section-readme]

[링크 : https://github.com/torvalds/linux/blob/master/include/uapi/linux/uinput.h]

[링크 : https://github.com/bendahl/uinput/blob/master/touchpad.go]

Posted by 구차니

uinput에 대한 이벤트 로그를 dmesg를 통해 볼 수 있게 해주는 디버그용 모듈

 

$ sudo modprobe evbug

[링크 : https://www.linuxquestions.org/questions/debian-26/how-to-disable-the-evbug-module-478529/]

[링크 : https://copyprogramming.com/howto/simulating-absolute-mouse-movements-in-linux-using-uinput] << 링크 깨짐

'프로그램 사용 > uinput' 카테고리의 다른 글

struct uinput_setup 와 struct uinput_user_dev  (0) 2022.08.05
uinput 터치 스크린 예제  (0) 2022.08.05
uinput 장치 확인  (0) 2022.03.04
uinput absolute mouse  (0) 2022.02.23
xmodmap  (0) 2022.02.21
Posted by 구차니
프로그램 사용/vi2022. 8. 4. 11:25

ctrl-o, ctrl-i

 

오오 만세!

[링크 : https://kldp.org/node/98528]

'프로그램 사용 > vi' 카테고리의 다른 글

vi가 늦게 켜지는 이유  (0) 2022.07.28
vim 색상 바꾸기(colorscheme)  (0) 2021.01.20
vi 에서 매칭되는 갯수 확인하기  (0) 2019.12.18
vi gg=G와 set ts  (0) 2019.07.04
vi 검색 취소하기  (0) 2019.06.04
Posted by 구차니
프로그램 사용/VLC2022. 8. 1. 10:49

보기 - 고급 컨트롤

 

하단의 컨트롤바 위의 빨간 버튼 클릭

 

별다른 설정이 없는데, 윈도우 기준 개인 홈 - 비디오에 저장된다.

[링크 : https://www.groovypost.com/howto/record-your-webcam-vlc-media-player/]

'프로그램 사용 > VLC' 카테고리의 다른 글

vlc 화면 돌리기  (0) 2025.03.21
http vlc protocol  (0) 2018.11.30
vlc for windows / ascii art ㅋㅋㅋ  (0) 2016.11.22
vlc 옵션 -vvv  (0) 2015.09.15
dash with VLC  (0) 2015.09.11
Posted by 구차니

-ss와 -t 조합으로 가능한데, -to 로는 잘안되서 쓰는법을 모르겠다.

-codec copy는 코덱변경없이 단순하게 원본을 자르는거라 속도도 빠르고 화질 저하도 없게 하는 옵션이다.

$ ./ffmpeg -ss 00:39:05 -i input.mkv -codec copy -t 00:03:03 out.mkv

[링크 : https://superuser.com/questions/742434/use-ffmpeg-to-cut-mkv-file]

[링크 : https://trac.ffmpeg.org/wiki/Seeking]

 

$ ffmpeg -ss 00:01:00 -to 00:02:00  -i input.mp4 -c copy output.mp4

-i: This specifies the input file. In that case, it is (input.mp4).
-ss: Used with -i, this seeks in the input file (input.mp4) to position.
00:01:00: This is the time your trimmed video will start with.
-to: This specifies duration from start (00:01:40) to end (00:02:12).
00:02:00: This is the time your trimmed video will end with.
-c copy: This is an option to trim via stream copy. (NB: Very fast)

[링크 : https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg]

 

[링크 : https://hi098123.tistory.com/141]

Posted by 구차니