2023年10月23日 星期一

Use pure bluetooth in KOReader v2021.10.1

KOReader is an awesome application on Kobo device. The architecture of application is very flexible.

I follow the guides of NiLuJe to modify source code a little to let my Kobo Elipsa to use bluetooth.

The only file you modify is koreader/frontend/device/kobo/device.lua

01. Add "hasKeys = yes," in KoboEuropa object.

-- Kobo Elipsa
local KoboEuropa = Kobo:new{
    model = "Kobo_europa",
    isSunxi = yes,
    canToggleChargingLED = yes,
    hasFrontlight = yes,
    hasKeys = yes,
    hasGSensor = yes,
    canToggleGSensor = yes,
    pressure_event = C.ABS_MT_PRESSURE,
    misc_ntx_gsensor_protocol = true,
    display_dpi = 227,
    boot_rota = C.FB_ROTATE_CCW,
    battery_sysfs = "/sys/class/power_supply/battery",
    ntx_dev = "/dev/input/by-path/platform-ntx_event0-event",
    touch_dev = "/dev/input/by-path/platform-0-0010-event",
    isSMP = yes,
}

02. Modify key code for your pageturner, I use Logitech R500.

-- NOTE: For the Forma, with the buttons on the right, 193 is Top, 194 Bottom.
    self.input = require("device/input"):new{
        device = self,
        event_map = {
            [35] = "SleepCover",  -- KEY_H, Elipsa
            [59] = "SleepCover",
            [90] = "LightButton",
            [102] = "Home",
            [105] = "RPgBack",
            [106] = "RPgFwd",
            [116] = "Power",
            [331] = "Eraser",
            [332] = "Highlighter",
        },
        
03. Open your pageturner manually. My pageturner is event4.

-- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status (... but only when Nickel is running ;p)
    self.input.open("fake_events")
    self.input.open("/dev/input/event4")
    
Enjoy it.

------------------------------------------------------------------------

The issue of entering Kobo again is that we can't use bluetooth anymore. The below messages are from logread command. Maybe we can google these keywords to get the solution ?

Oct 23 20:49:02 nickel: (   144.927 @ 0x374c538) QObject::disconnect: Unexpected null parameter
Oct 23 20:49:02 nickel: (   144.927 @ 0x374c538 / ui.warning) cancelled before full sync has started
Oct 23 20:49:02 nickel: (   144.977 @ 0x374c538 / libraryLayout.warning) void AbstractLibraryController<C>::layout(bool) [with C = BluetoothDevice] view is null
Oct 23 20:49:02 nickel: (   144.999 @ 0x374c538 / libraryLayout.warning) void AbstractLibraryController<C>::layout(bool) [with C = BluetoothDevice] source has no rows
Oct 23 20:49:02 nickel: (   145.000 @ 0x374c538 / libraryLayout.warning) void AbstractLibraryController<C>::layout(bool) [with C = BluetoothDevice] source has no rows
Oct 23 20:49:53 bluetoothd[3342]: Endpoint unregistered: sender=:1.2 path=/org/bluez/hci0/A2DP/SBC/Source/1
Oct 23 20:49:53 bluetoothd[3342]: Endpoint unregistered: sender=:1.2 path=/org/bluez/hci0/A2DP/SBC/Source/2
Oct 23 20:49:57 bluetoothd[3342]: Terminating
Oct 23 20:49:57 nickel: (   200.505 @ 0x374c538 / bt.warning) void BluetoothManager::objectManagerInterfacesRemoved(const QDBusObjectPath&, const QStringList&) adapter already destroyed
Oct 23 20:49:57 bluetoothd[3342]: Stopping SDP server
Oct 23 20:49:57 bluetoothd[3342]: Exit
Oct 23 20:50:13 bluetoothd[3352]: Bluetooth daemon 5.63
Oct 23 20:50:13 bluetoothd[3352]: src/main.c:check_options() Unknown key InitVolume for group General in /etc/bluetooth/main.conf
Oct 23 20:50:13 bluetoothd[3352]: Starting SDP server
Oct 23 20:50:13 bluetoothd[3352]: Bluetooth management interface 1.14 initialized
Oct 23 20:50:13 bluetoothd[3352]: src/adapter.c:reset_adv_monitors_complete() Failed to reset Adv Monitors: Unknown Command (0x01)
Oct 23 20:50:23 bluetoothd[3352]: Failed to set mode: Failed (0x03)
Oct 23 20:50:23 bluetoothd[3352]: Player registered: sender=:1.4 path=/com/kobo/bluetooth/MediaPlayer
Oct 23 20:50:24 bluealsa: Couldn't get HCI version: Network is down
Oct 23 20:50:24 bluetoothd[3352]: Endpoint registered: sender=:1.8 path=/org/bluez/hci0/A2DP/SBC/Source/1
Oct 23 20:50:24 bluetoothd[3352]: Endpoint registered: sender=:1.8 path=/org/bluez/hci0/A2DP/SBC/Source/2
Oct 23 20:50:31 bluetoothd[3352]: Endpoint unregistered: sender=:1.8 path=/org/bluez/hci0/A2DP/SBC/Source/1
Oct 23 20:50:31 bluetoothd[3352]: Endpoint unregistered: sender=:1.8 path=/org/bluez/hci0/A2DP/SBC/Source/2

沒有留言:

張貼留言