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

Unable to map keys with keyboard that suppors Razer Hypershift #1

Open
eghere opened this issue Mar 31, 2022 · 2 comments
Open

Unable to map keys with keyboard that suppors Razer Hypershift #1

eghere opened this issue Mar 31, 2022 · 2 comments

Comments

@eghere
Copy link

eghere commented Mar 31, 2022

After trying to do i3razer --map I can map most of the keys, except the two FN keys on my Razer Blade 15 (Mid 2019) Mercury White keyboard.

Here is the output from running i3razer --map:

]$ i3razer --map
The program will loop through each device and trough every key.
Please press the green lit key. If no Key is lit press 'escape'
The result can be inserted to to a copy of 'layout.py' which can replace the old file
Found 1 Razer devices
Next Keyboard: Razer Blade 15 (Mid 2019) Mercury White
(0, 0)
^[(0, 1)
^[(0, 2)
^[OP(0, 3)
^[OQ(0, 4)
^[OR(0, 5)
^[OS(0, 6)
^[[15~(0, 7)
^[[17~(0, 8)
^[[18~(0, 9)
^[[19~(0, 10)
^[[20~(0, 11)
(0, 12)
(0, 13)
^[[24~(0, 14)
^[[2~(0, 15)
^[[3~(1, 0)
^[(1, 1)
`(1, 2)
1(1, 3)
2(1, 4)
3(1, 5)
4(1, 6)
5(1, 7)
6(1, 8)
7(1, 9)
8(1, 10)
9(1, 11)
0(1, 12)
-(1, 13)
=(1, 14)
^[(1, 15)
(2, 0)
^[(2, 1)
	(2, 2)
q(2, 3)
w(2, 4)
e(2, 5)
r(2, 6)
t(2, 7)
y(2, 8)
u(2, 9)
i(2, 10)
o(2, 11)
p(2, 12)
[(2, 13)
](2, 14)
^[(2, 15)
\(3, 0)
^[(3, 1)
(3, 2)
A(3, 3)
S(3, 4)
D(3, 5)
F(3, 6)
G(3, 7)
H(3, 8)
J(3, 9)
K(3, 10)
L(3, 11)
;(3, 12)
'(3, 13)
^[(3, 14)
^[(3, 15)

(4, 0)
^[(4, 1)
(4, 2)
^[(4, 3)
Z(4, 4)
X(4, 5)
C(4, 6)
V(4, 7)
B(4, 8)
N(4, 9)
M(4, 10)
,(4, 11)
.(4, 12)
/(4, 13)
^[[A(4, 14)
^[(4, 15)
(5, 0)
(5, 1)
(5, 2)
^[(5, 3)
(5, 4)
^[(5, 5)
(5, 6)
^[(5, 7)
^[(5, 8)
^[(5, 9)
(5, 10)
^[(5, 11)
(5, 12)
^[[D(5, 13)
^[[B(5, 14)
^[[C(5, 15)
^[keyboard Razer Blade 15 (Mid 2019) Mercury White finished:
All keyboards are done
Layouts have been updated in 'layout.py'. Move the file to the correct position and consider opening a pull request on github
(6, 0)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/site-packages/i3razer/pyxhook.py", line 92, in run
    self.record_dpy.record_enable_context(self.context, self._process_events)
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/ext/record.py", line 239, in enable_context
    EnableContext(
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/ext/record.py", line 220, in __init__
    rq.ReplyRequest.__init__(self, *args, **keys)
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/protocol/rq.py", line 1369, in __init__
    self.reply()
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/protocol/rq.py", line 1381, in reply
    self._display.send_and_recv(request = self._serial)
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/protocol/display.py", line 613, in send_and_recv
    gotreq = self.parse_response(request)
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/protocol/display.py", line 705, in parse_response
    gotreq = self.parse_request_response(request) or gotreq
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/protocol/display.py", line 793, in parse_request_response
    req._parse_response(self.data_recv[:self.recv_packet_len])
  File "/home/eghere/.local/lib/python3.10/site-packages/Xlib/ext/record.py", line 224, in _parse_response
    self._callback(r)
  File "/usr/lib/python3.10/site-packages/i3razer/pyxhook.py", line 126, in _process_events
    self.KeyDown(hook_event)
  File "/usr/lib/python3.10/site-packages/i3razer/map_layout.py", line 116, in on_key_pressed
    self.next_key()
  File "/usr/lib/python3.10/site-packages/i3razer/map_layout.py", line 107, in next_key
    self.keyboard.fx.advanced.matrix[self.row, self.column] = self.green
  File "/usr/lib/python3.10/site-packages/openrazer/client/fx.py", line 1101, in __setitem__
    assert 0 <= key[0] < self._rows, "Row out of bounds"
AssertionError: Row out of bounds

Is there a way to manually map each key such as editing a config file? If so, where is this config file so I can manually edit it?

@eghere
Copy link
Author

eghere commented Mar 31, 2022

Additionally, trying to load a config file has a similar output of errors:

~]$ i3razer -c ~/Documents/Misc/config.yaml 
Traceback (most recent call last):
  File "/usr/bin/i3razer", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/i3razer/__init__.py", line 62, in main
    i3razer.start()
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 309, in start
    self._update_color_scheme()
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 68, in _update_color_scheme
    self._draw_color_scheme(scheme)
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 79, in _draw_color_scheme
    self._draw_static_scheme(color_config)
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 196, in _draw_static_scheme
    self._add_to_static_scheme(color_config)
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 236, in _add_to_static_scheme
    self._set_color(color, keys)
  File "/usr/lib/python3.10/site-packages/i3razer/i3_razer.py", line 243, in _set_color
    self._keyboard.fx.advanced.matrix[self._key_layout[key]] = color
  File "/usr/lib/python3.10/site-packages/openrazer/client/fx.py", line 1102, in __setitem__
    assert 0 <= key[1] < self._cols, "Column out of bounds"

@leofah
Copy link
Owner

leofah commented Apr 22, 2022

Thanks for pointing out the issue with map_layout. It is not a problem with your keyboard but a problem in the code. I fixed it in the new release v0.2. Actually in the old version the file layout.py was still created and then the exception was thrown. I also noticed, the original layout.py, which keeps the keymap, was missing in this repo but was available with pip. This file is now also present.

Once you created your version of the layout you need to copy it to the install directory (either ~/.local/... or /usr/ ... lib/python3.x/site-packages/i3razer) and replace the current file. Unfortunately any update or re installation of the package will overwrite your file, but I have no current plan to load the layout in another way. Maybe you have an idea how to solve this problem.

I think your second issue with the config fails resolves, if you use your updated layout. I did not consider the usage of smaller keyboards than mine. Maybe I should add a check such that invalid keys would not break the program.

As far as I checked the fn key can't be mapped automatically, because it implemented in the hardware and does not send any information to the computer. But its color can be set. So it is needed to manually add the the fn key to the layout.

I hope this solves your problem and you can use my tool for your keyboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants