'2024/03'에 해당되는 글 42건

  1. 2024.03.16 1.58bit
  2. 2024.03.14 다이소 웹캠.. M12 렌즈.. 계륵?!
  3. 2024.03.13 gps kalman
  4. 2024.03.13 uinput touch 장치 흉내내기
  5. 2024.03.12 touchscreen 장치 프로토콜 분석
  6. 2024.03.12 javascript groupby map
  7. 2024.03.12 uinput 으로 touchscreen을 만들기
  8. 2024.03.11 weston evdev libinput
  9. 2024.03.11 untangle
  10. 2024.03.11 usb hid, hidraw

 

log2(3) = 1.58 이라고

 

그나저나 +1 -1 0 으로 곱셈을 사실상 덧셈으로 처리하게 하다니

회로 복잡도가 어마어마 하게 낮아질듯

[링크 : https://endplan.ai/양자화-quantization-1-58bit/]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

radix 4 - fp4  (0) 2024.03.21
gps kalman  (0) 2024.03.13
db 식별/비식별 관계  (0) 2024.02.15
ffb - force feedback  (0) 2023.08.25
vRAN  (0) 2023.08.23
Posted by 구차니
개소리 왈왈/컴퓨터2024. 3. 14. 10:48

음.. 대충 보니 M12 렌즈 마운트 같아서

렌즈를 찾아보는데 영 없다 -_-!

초기형 라즈베리 카메라는 M12렌즈가 포함되었는데

가격이 낮아진 후기형이 나오면서 렌즈들이 멸종

 

카메라는 5천원에 다이소에서 샀는데

렌즈가 7천원이 넘으면.. 이거 해봐야 하는거 맞....나?

[링크 : http://itempage3.auction.co.kr/DetailView.aspx?itemno=E231434797]

 

16200원, 미니 렌즈 포함

[링크 : https://www.devicemart.co.kr/goods/view?no=10824332]

 

27000원, M12 렌즈 마운트, M12 렌즈 포함

[링크 : https://www.devicemart.co.kr/goods/view?no=10824336]

'개소리 왈왈 > 컴퓨터' 카테고리의 다른 글

컴퓨터 셋팅완료  (0) 2024.03.20
cpu, ram 적출  (0) 2024.03.19
다이소 웹캠  (0) 2024.02.24
2 포트 vs 4 포트 그리고 컴퓨터  (0) 2024.01.27
G4400T 내장 그래픽이...  (0) 2024.01.10
Posted by 구차니

GPS 값은 원체 튀다보니

그걸 가공없이 쓰면 추정이 불가능한데

kalman 필터를 적용해서 선형적으로 이동하는 것으로 보정이 가능하다.

 

[링크 : https://youtu.be/ZYexI6_zUMk?si=eDcBHxIn39Tq3gXl]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

radix 4 - fp4  (0) 2024.03.21
1.58bit  (0) 2024.03.16
db 식별/비식별 관계  (0) 2024.02.15
ffb - force feedback  (0) 2023.08.25
vRAN  (0) 2023.08.23
Posted by 구차니
프로그램 사용/uinput2024. 3. 13. 14:49

실제 장치에서 터치 한번 하는걸 흉내냈는데 안되서, 프로토콜 대로 구현하니 된다.

 

linux 5.10.72 이긴 한데 그거 영향인진 모르겠지만

Protocol A 로 구현하니 커서나 클릭도 안되는 것 같고

Protocol B를 따라 구현하니 된다.

 

3.4. Protocol Example B
Here is what a minimal event sequence for a two-contact touch would look like for a type B device:

ABS_MT_SLOT 0
ABS_MT_TRACKING_ID 45
ABS_MT_POSITION_X x[0]
ABS_MT_POSITION_Y y[0]
ABS_MT_SLOT 1
ABS_MT_TRACKING_ID 46
ABS_MT_POSITION_X x[1]
ABS_MT_POSITION_Y y[1]
SYN_REPORT
Here is the sequence after moving contact 45 in the x direction:

ABS_MT_SLOT 0
ABS_MT_POSITION_X x[0]
SYN_REPORT
Here is the sequence after lifting the contact in slot 0:

ABS_MT_TRACKING_ID -1
SYN_REPORT

[링크 : https://docs.kernel.org/input/multi-touch-protocol.html]

 

 

초기화

    struct uinput_setup usetup;
    int keys[] = {BTN_TOUCH}; // BTN_LEFT, BTN_RIGHT, 

    fd_touch = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
    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);
    ret = ioctl(fd_touch, UI_SET_ABSBIT, ABS_MT_SLOT);
    ret = ioctl(fd_touch, UI_SET_ABSBIT, ABS_MT_POSITION_X);
    ret = ioctl(fd_touch, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
    ret = ioctl(fd_touch, UI_SET_EVBIT, EV_SYN);

    struct uinput_abs_setup abs_setup_x;
    struct uinput_abs_setup abs_setup_y;
    memset(&abs_setup_x, 0, sizeof(abs_setup_x));
    memset(&abs_setup_y, 0, sizeof(abs_setup_y));
    abs_setup_x.code = ABS_MT_POSITION_X;
    abs_setup_x.absinfo.minimum = 0;
    abs_setup_x.absinfo.maximum = 1024;
    abs_setup_y.code = ABS_MT_POSITION_Y;
    abs_setup_y.absinfo.minimum = 0;
    abs_setup_y.absinfo.maximum = 768;
    ret = ioctl(fd_touch, UI_ABS_SETUP, &abs_setup_x);
    ret = ioctl(fd_touch, UI_ABS_SETUP, &abs_setup_y);

    memset(&usetup, 0, sizeof(usetup));
    usetup.id.bustype = BUS_USB;
    usetup.id.vendor = 0x4711;
    usetup.id.product = 0x0817;
    strcpy(usetup.name, "virtual touch device");
    ret = ioctl(fd_touch, UI_DEV_SETUP, &usetup);
    ret = ioctl(fd_touch, UI_DEV_CREATE);

 

터치(클릭) 처리

switch(buttonMask)
{
    default:
        printf("buttonMask[%02X]\n",buttonMask);
    break;
    
    case BUTTON_RELEASE:
        switch(prev_click)
        {
            case BUTTON_L_DOWN:
                printf("BUTTON_L_DOWN BUTTON_RELEASE\n");
                prev_click = -1;
                emit(fd_touch, EV_ABS, ABS_MT_TRACKING_ID, -1);
                emit(fd_touch, EV_SYN, SYN_REPORT, 0);
                break;
        }
        break;

    case BUTTON_L_DOWN:
        if(prev_click == -1)
        {
            printf("BUTTON_L_DOWN\n");
            prev_click = buttonMask;
            emit(fd_touch, EV_ABS, ABS_MT_SLOT, 0);
            emit(fd_touch, EV_ABS, ABS_MT_TRACKING_ID, track_id++);
            emit(fd_touch, EV_ABS, ABS_MT_POSITION_X, pos_x);
            emit(fd_touch, EV_ABS, ABS_MT_POSITION_Y, pos_y);
            emit(fd_touch, EV_ABS, ABS_X, pos_x);
            emit(fd_touch, EV_ABS, ABS_Y, pos_y);
            emit(fd_touch, EV_SYN, SYN_REPORT, 0);
        }
        else
        {
            printf("BUTTON_L_DOWN MOVE\n");
            emit(fd_touch, EV_ABS, ABS_MT_SLOT, 0);
            emit(fd_touch, EV_ABS, ABS_MT_POSITION_X, pos_x);
            emit(fd_touch, EV_ABS, ABS_MT_POSITION_Y, pos_y);
            emit(fd_touch, EV_ABS, ABS_X, pos_x);
            emit(fd_touch, EV_ABS, ABS_Y, pos_y);
            emit(fd_touch, EV_SYN, SYN_REPORT, 0);
        }
        break;
}

 

Posted by 구차니
프로그램 사용/uinput2024. 3. 12. 18:17

대충 봐선(?)

protocol A에 ABS_X, ABS_Y를 추가한 변종(?) 같긴한데

 

아래는 한번 터치해서 클릭하는 내용

BTN_TOUCH로 눌렸다 떼었다 라는 걸 보내주는데

깔끔(?) 하게 원격으로 좌표 + 떼어라 만 보내도 되는지 테스트 해봐야 할 듯 (눌렀다 없이 떼었다가 될지 모르겠음)

 

그 와중에 ABS_MT_TRACKING_ID는 왜 음수 값이 나오지?

 

세번의 터치가 있었는데(터치 1회, 드래그, 줌 인)

그 때 마다 ABS_MT_TRACKING_ID가 증가하고 매번 -1 로 BTN_TOUCH 0 을 누르기 전에 트래킹이

사용되지 않는다는걸 알려주는건가..?

마지막의 Tracking_id 2,3은 두 손가락으로 줌 인 한 거라, 각각의 손가락에 대해서 처리하는 듯

 

A non-negative tracking id is interpreted as a contact, and the value -1 denotes an unused slot

[링크 : https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt]

Posted by 구차니

'Programming > javascript & HTML' 카테고리의 다른 글

javascript 숫자  (0) 2024.02.07
마우스로 테이블 열 변경하기  (0) 2024.02.02
html video 재생종료 event  (0) 2023.09.02
숫자에 콤마 찍기(자릿수 표현)  (0) 2023.07.27
canvas 없는 getcontext  (0) 2023.07.12
Posted by 구차니
프로그램 사용/uinput2024. 3. 12. 11:03

아래와 같이 설정하면 BTN_LEFT, BTN_RIGHT 때문에, udev에서 Mouse Touchscreen으로 인식된다.

    int keys[] = {BTN_LEFT, BTN_RIGHT, BTN_TOUCH};

    fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);

    //Custom key events init
    ioctl(fd, UI_SET_EVBIT, EV_KEY);
    for(int i = 0; i < sizeof(keys) / sizeof(int); i++){
        ioctl(fd, UI_SET_KEYBIT, keys[i]);
    }
[01:49:49.721] event5  - virtual touch driver: is tagged by udev as: Mouse Touchscreen
[01:49:49.722] event5  - virtual touch driver: kernel bug: device has min == max on ABS_MT_POSITION_X
[01:49:49.722] event5  - virtual touch driver: was rejected
[01:49:49.722] event5  - using input device '/dev/input/event5'

 

그래서 BTN_TOUCH만 넣으면 Mouse는 빠지고 Touchscreen만 뜨는데, 도대체 커널 버그 쪽은 어떻게 해결해야 할까?

    int keys[] = {BTN_TOUCH}; // BTN_LEFT, BTN_RIGHT

    fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);

    //Custom key events init
    ioctl(fd, UI_SET_EVBIT, EV_KEY);
    for(int i = 0; i < sizeof(keys) / sizeof(int); i++){
        ioctl(fd, UI_SET_KEYBIT, keys[i]);
    }
[01:50:22.720] event5  - virtual touch driver: is tagged by udev as: Touchscreen
[01:50:22.720] event5  - virtual touch driver: kernel bug: device has min == max on ABS_MT_POSITION_X
[01:50:22.720] event5  - virtual touch driver: was rejected
[01:50:22.720] event5  - not using input device '/dev/input/event5'

 

+

chatGPT 응답해준 것을 조합하면 아래와 같이 하면

일단 터치 장비로 인식은 되는데.. 커서도 안되고 터치 이동, 클릭을 어떻게 구현해야 하나...

void initializeTouchEvent(int fd) {
    struct uinput_setup usetup;
    int keys[] = {BTN_TOUCH}; // BTN_LEFT, BTN_RIGHT, 

    fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
    ioctl(fd, UI_SET_EVBIT, EV_KEY);

    // 사용할 키 등록(터치니까 BTN_TOUCH 만, BTN_LEFT 나 BTN_RIGHT가 등록되면 마우스로 인식됨)
    for(int i = 0; i < sizeof(keys) / sizeof(int); i++){
       ioctl(fd, UI_SET_KEYBIT, keys[i]);
    }

    ioctl(fd, UI_SET_EVBIT, EV_ABS);
    ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT);
    ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
    ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
    ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);  // 요건 없어도 되는 듯
    ioctl(fd, UI_SET_EVBIT, EV_SYN);

    struct uinput_abs_setup abs_setup_x;
    struct uinput_abs_setup abs_setup_y;
    memset(&abs_setup_x, 0, sizeof(abs_setup_x));
    memset(&abs_setup_y, 0, sizeof(abs_setup_y));
    abs_setup_x.code = ABS_MT_POSITION_X;
    abs_setup_x.absinfo.minimum = 0; // 최솟값
    abs_setup_x.absinfo.maximum = 1024; // 최댓값
    abs_setup_y.code = ABS_MT_POSITION_Y;
    abs_setup_y.absinfo.minimum = 0; // 최솟값
    abs_setup_y.absinfo.maximum = 1024; // 최댓값

    ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
    ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
    ioctl(fd, UI_ABS_SETUP, &abs_setup_x);
    ioctl(fd, UI_ABS_SETUP, &abs_setup_y);

    // 가상 디바이스를 생성
    memset(&usetup, 0, sizeof(usetup));
    usetup.id.bustype = BUS_USB;
    usetup.id.vendor = 0x1;
    usetup.id.product = 0x1;
    strcpy(usetup.name, "Virtual Touch Device");

    ioctl(fd, UI_DEV_SETUP, &usetup);
    ioctl(fd, UI_DEV_CREATE);
}
Posted by 구차니
프로그램 사용/wayland2024. 3. 11. 18:01

디바이스 마다 인식 방법이 차이가 있을줄을 알았지만.. 어우..

struct evdev_device *
evdev_device_create(struct libinput_device *libinput_device,
    struct weston_seat *seat)
{
struct evdev_device *device;

device = zalloc(sizeof *device);
if (device == NULL)
return NULL;
weston_log("%s:%d\n",__func__,__LINE__);
device->seat = seat;
wl_list_init(&device->link);
device->device = libinput_device;

if (libinput_device_has_capability(libinput_device,
   LIBINPUT_DEVICE_CAP_KEYBOARD)) {
weston_seat_init_keyboard(seat, NULL);
device->seat_caps |= EVDEV_SEAT_KEYBOARD;
weston_log("%s:%d\n",__func__,__LINE__);
}
if (libinput_device_has_capability(libinput_device,
   LIBINPUT_DEVICE_CAP_POINTER)) {
weston_seat_init_pointer(seat);
device->seat_caps |= EVDEV_SEAT_POINTER;
weston_log("%s:%d\n",__func__,__LINE__);
}
if (libinput_device_has_capability(libinput_device,
   LIBINPUT_DEVICE_CAP_TOUCH)) {
weston_seat_init_touch(seat);
device->seat_caps |= EVDEV_SEAT_TOUCH;
device->touch_device = create_touch_device(device);
weston_log("%s:%d\n",__func__,__LINE__);
}

libinput_device_set_user_data(libinput_device, device);
libinput_device_ref(libinput_device);

return device;
}

 

LIBINPUT_EXPORT int
libinput_device_has_capability(struct libinput_device *device,
       enum libinput_device_capability capability)
{
return evdev_device_has_capability((struct evdev_device *) device,
   capability);
}

[링크 : https://github.com/jadahl/libinput/blob/master/src/libinput.c#L938]

 

int
evdev_device_has_capability(struct evdev_device *device,
    enum libinput_device_capability capability)
{
switch (capability) {
case LIBINPUT_DEVICE_CAP_POINTER:
return !!(device->seat_caps & EVDEV_DEVICE_POINTER);
case LIBINPUT_DEVICE_CAP_KEYBOARD:
return !!(device->seat_caps & EVDEV_DEVICE_KEYBOARD);
case LIBINPUT_DEVICE_CAP_TOUCH:
return !!(device->seat_caps & EVDEV_DEVICE_TOUCH);
default:
return 0;
}
}

[링크 : https://github.com/jadahl/libinput/blob/master/src/evdev.c#L699]

 

장치별로 인식되는 차이 확인! 커서가 안뜨던 녀석은 touch로 인식

[08:25:22.166] event2  - eGalax Inc. eGalaxTouch P80H84 0900 v12 k4.18.200: is tagged by udev as: Touchscreen
[08:25:22.166] event2  - eGalax Inc. eGalaxTouch P80H84 0900 v12 k4.18.200: device is a touch device
[08:25:22.176] event3  - FHD WebCam: FHD WebCam: is tagged by udev as: Keyboard
[08:25:22.176] event3  - FHD WebCam: FHD WebCam: device is a keyboard
[08:25:22.181] event1  - audio-hdmi HDMI Jack: is tagged by udev as: Switch
[08:25:22.181] event1  - not using input device '/dev/input/event1'
[08:25:22.181] evdev_device_create:856
[08:25:22.208] evdev_device_create:865 // LIBINPUT_DEVICE_CAP_KEYBOARD
[08:25:22.208] libinput: configuring device "30370000.snvs:snvs-powerkey".
[08:25:22.208] evdev_device_create:856
[08:25:22.208] Touchscreen - eGalax Inc. eGalaxTouch P80H84 0900 v12 k4.18.200 - /sys/devices/platform/soc@0/32f10108.usb/38200000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.3/1-1.3.2/1-1
[08:25:22.208] evdev_device_create:878 // LIBINPUT_DEVICE_CAP_TOUCH
[08:25:22.208] libinput: configuring device "eGalax Inc. eGalaxTouch P80H84 0900 v12 k4.18.200".
[08:25:22.208] input device event2 has no enabled output associated (none named), skipping calibration for now.
[08:25:22.208] evdev_device_create:856
[08:25:22.208] evdev_device_create:865 // LIBINPUT_DEVICE_CAP_KEYBOARD
[08:25:22.208] libinput: configuring device "FHD WebCam: FHD WebCam".
[08:25:22.209] DRM: head 'LVDS-1' found, connector 39 is connected, EDID make 'unknown', model 'unknown', serial 'unknown'
[08:25:22.210] DRM: head 'HDMI-A-1' found, connector 40 is connected, EDID make 'unknown', model 'unknown', serial 'unknown'

 

얘는 특이하게도 MT protocol B를 쓰더니, 그래서 그런가 pointer와 touch 두 가지로 인식

[08:30:59.219] event5  - eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19" UNKNOWN: is tagged by udev as: Mouse
[08:30:59.220] event5  - eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19" UNKNOWN: device is a pointer
[08:30:59.221] evdev_device_create:856
[08:30:59.221] evdev_device_create:871 // LIBINPUT_DEVICE_CAP_POINTER
[08:30:59.221] libinput: configuring device "eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19" UNKNOWN".
[08:30:59.221] input device event5 has no enabled output associated (none named), skipping calibration for now.
[08:30:59.221] associating input device event5 with output LVDS-1 (none by udev)
[08:30:59.312] event4  - eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19": is tagged by udev as: Touchscreen
[08:30:59.312] event4  - eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19": device is a touch device
[08:30:59.313] evdev_device_create:856
[08:30:59.313] Touchscreen - eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19" - /sys/devices/platform/soc@0/32f10108.usb/38200000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/0003:0EEF:C000.0002/input/input5/event4
[08:30:59.313] evdev_device_create:878 // LIBINPUT_DEVICE_CAP_TOUCH
[08:30:59.313] libinput: configuring device "eGalax Inc. eGalaxTouch EXC3188-3374-08.00.00.00 19"".
[08:30:59.313] input device event4 has no enabled output associated (none named), skipping calibration for now.
[08:30:59.313] associating input device event4 with output LVDS-1 (none by udev)

 

내가 만든건.. 일단 ABS로 하긴 했지만 pointer 디바이스로 인식..

이제 어떻게 하면 touch로 하냐가 문제네

[08:40:03.449] event4  - vnc virtual keyboard driver: is tagged by udev as: Keyboard
[08:40:03.450] event4  - vnc virtual keyboard driver: device is a keyboard
[08:40:03.450] evdev_device_create:856
[08:40:03.450] evdev_device_create:865 // LIBINPUT_DEVICE_CAP_KEYBOARD
[08:40:03.450] libinput: configuring device "vnc virtual keyboard driver".
[08:40:03.450] associating input device event4 with output LVDS-1 (none by udev)
[08:40:03.453] event5  - TouchPad: is tagged by udev as: Mouse
[08:40:03.453] event5  - TouchPad: device is a pointer
[08:40:03.454] evdev_device_create:856
[08:40:03.454] evdev_device_create:871 // LIBINPUT_DEVICE_CAP_POINTER
[08:40:03.454] libinput: configuring device "TouchPad".
[08:40:03.454] input device event5 has no enabled output associated (none named), skipping calibration for now.
[08:40:03.454] associating input device event5 with output LVDS-1 (none by udev)

 

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

weston 커서 숨기기  (0) 2024.02.26
wayland hdmi - touch 연결  (0) 2023.09.08
wayland atomic commit 패치?  (0) 2022.08.22
weston screen shooter 뜯어보기  (0) 2022.08.17
wayland glreadpixels 실패  (0) 2022.08.16
Posted by 구차니
파일방2024. 3. 11. 17:32

'파일방' 카테고리의 다른 글

ventoy  (0) 2024.03.09
flipper zero  (0) 2024.02.13
LVGL (Light and Versatile Graphics Library)  (0) 2023.11.18
bytran - hitran 시뮬레이터?  (0) 2023.08.21
kchmviewer  (0) 2023.06.14
Posted by 구차니
Linux API/linux2024. 3. 11. 15:52

hi draw로 봤는데

hid + raw.. -_-

 

The hidraw driver provides a raw interface to USB and Bluetooth Human Interface Devices (HIDs). It differs from hiddev in that reports sent and received are not parsed by the HID parser, but are sent to and received from the device unmodified.

[링크 : https://docs.kernel.org/hid/hidraw.html]

 

그런데 hidraw의 경우 HID 장비에 대한 RAW 인터페이스를 제공하고 sent, received를 지원한다는데

HID 장치로 등록된 장비에 대해서 중간에 읽어보고 대신 보낼수 있지

uinput 처럼 연결도 안된애를 흉내낼수 있는건 아닌것 같은데 나중에 찾아봐야겠다.

'Linux API > linux' 카테고리의 다른 글

linux 멀티터치 프로토콜  (0) 2024.03.08
btrfs CoW  (0) 2024.02.15
statvfs() 의 f_bavail과 f_bfree 차이  (0) 2024.02.15
corrupted size vs. prev_size 에러.. part2  (0) 2023.12.15
리눅스 커널 6.6.6 릴리즈  (0) 2023.12.13
Posted by 구차니