Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PineTab (aka Quirky Devices) #15

Closed
zhaofengli opened this issue Sep 12, 2020 · 3 comments
Closed

PineTab (aka Quirky Devices) #15

zhaofengli opened this issue Sep 12, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@zhaofengli
Copy link

zhaofengli commented Sep 12, 2020

So I recently got a PineTab, which is an ARM tablet with a detachable keyboard dock (see picture, the magnetic connector is actually USB). It has the following quirks:

The native orientation is rotated by 90 degrees

my-neck-hurts

(Yes, that's the native resolution - 800x1280)

Because we use the normal orientation to decide whether to enable the keyboard, we need to

  • a) allow the user to specify "the orientation at which the keyboard is disabled" - easy but confusing ("why is my normal not 'normal'?"), or
  • b) allow the user to specify a rotation applied to the vector before deciding the orientation - less confusing

Actually, as the keyboard can be detached, we should have a feature where we lock the rotation to the normal human orientation when an input device is present (in this case, the USB keyboard).

Edit: Wanted to set up everything again half a year later, and saw this silliness. Please, ignore my brain fart 😆 There is no need to normalize anything, or flip the axes. In fact, the current code in src/main.rs is over-complicating the thing by comparing the vectors.

zhaofengli added a commit to zhaofengli/rot8 that referenced this issue Sep 12, 2020
This commit adds a bunch of features, including:

* Use the correct accelerometer value scale

Not all devices have the accelerometer raw value between 0 and 1 (e.g. PineTab).
The current scale is accessible via sysfs.

* Revamped keyboard mode system

You can specify how your keyboard is attached so that rot8 will do the
appropriate thing. `--keyboard-mode` can be one of:

- `integral`: The keyboard is an integral part of the device. We will
  disable the keyboard when the screen is not oriented upright.
- `detachable`: The keyboard is detachable. We will keep the screen
  oriented upright when the keyboard is attached.
- `none`: We won't touch your keyboard.

The old `-k`/`--disable-keyboard` flag has been removed.

* After-rotation hook

Specify a command to be run in shell after rotation with `--rotate-hook`. Useful
for forcing a restart of Polybar, for example.

* PineTab-specific flags

There are several PineTab-specific additions. If you are using a
PineTab, the following flags should be given:

--display DSI-1 --touchscreen 'pointer:Goodix Capacitive TouchScreen' --flip-y
--rotate-90 --keyboard-mode detachable --keyboard 'HAILUCK CO.,LTD USB KEYBOARD'

If you are setting the default rotation in Xorg.conf, use `TransformationMatrix`
instead of `CalibrationMatrix` for the touchscreen, otherwise the setting will
conflict with rot8.

Issue: efernau#15
zhaofengli added a commit to zhaofengli/rot8 that referenced this issue Sep 12, 2020
This commit adds a bunch of features, including:

* Use the correct accelerometer value scale

Not all devices have the accelerometer raw values between 0 and 1 (e.g. PineTab).
The correct scale is accessible via sysfs.

* Revamped keyboard mode system

You can specify how your keyboard is attached so that rot8 will do the
appropriate thing. `--keyboard-mode` can be one of:

- `integrated`: The keyboard is an integral part of the device. We will
  disable the keyboard when the screen is not oriented upright.
- `detachable`: The keyboard is detachable. We will keep the screen
  oriented upright when the keyboard is attached.
- `none`: We won't touch your keyboard.

The old `-k`/`--disable-keyboard` flag has been removed.

* After-rotation hook

Specify a command to be run in shell after rotation with `--rotate-hook`. Useful
for forcing a restart of Polybar, for example.

* PineTab-specific flags

There are several PineTab-specific additions. If you are using a
PineTab, the following flags should be given:

--display DSI-1 --touchscreen 'pointer:Goodix Capacitive TouchScreen' --flip-y
--rotate-90 --keyboard-mode detachable --keyboard 'HAILUCK CO.,LTD USB KEYBOARD'

If you are setting the default rotation in Xorg.conf, use `TransformationMatrix`
instead of `CalibrationMatrix` for the touchscreen, otherwise the setting will
conflict with rot8.

Issue: efernau#15
@zhaofengli zhaofengli reopened this Sep 12, 2020
@zhaofengli
Copy link
Author

zhaofengli commented Sep 12, 2020

Still WIP, but I've made some changes to accommodate PineTab and similar devices:

Use the correct accelerometer value scale

Not all devices have the accelerometer raw values between 0 and 1 (e.g. PineTab). The correct scale is accessible via sysfs.

Revamped keyboard mode system

I added --keyboard-mode, which can be one of:

  • integrated: The keyboard is an integral part of the device. We will disable the keyboard when the screen is not oriented upright.
  • detachable: The keyboard is detachable. We will keep the screen oriented upright when the keyboard is attached.
  • none: We won't touch your keyboard.

After-rotation hook (#4)

You can specify a command to be run in shell after rotation with --rotate-hook. Useful for forcing a restart of Polybar, for example.

@efernau efernau added the bug Something isn't working label May 20, 2021
@thurstylark
Copy link

thurstylark commented Jun 28, 2021

I also have issues with the accelerometer value scale. For my hw (Lenovo Yoga 920), /sys/bus/iio/devices/iio\:device0/in_accel_scale contains 0.009806650

I believe all that's necessary is to replace / 1e6 with a multiplication of whatever value is read from in_accel_scale:

rot8/src/main.rs

Lines 260 to 262 in b7b42d9

// Normalize vectors
let x: f32 = (x_clean as f32) / 1e6;
let y: f32 = (y_clean as f32) / 1e6;


Edit: Actually, it should be (raw + offset) * scale

Reference: https://wiki.analog.com/resources/tools-software/linux-drivers/iio-inertial-measurement-units/adis16400#show_channel_value

@efernau
Copy link
Owner

efernau commented May 16, 2022

thanks for your commit, sadly not merged.
your problem should now be solved with --normalization-factor and --invert-y. the idea with the after-rotation hook and the keybord mode should be implemented. but the change of -k would be a braking change, see this in the planned rewrite version 0.2.0.

@efernau efernau closed this as completed May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants