Hey Friends,
I’m trying to connect my Razer Analog Keyboard via the HID interface.
Since Keystrokes can be processed without using the HID interface ( ie View.keyDownEvent, or KeyState.kr ), I’ve never tried to receive HID input from a QWERTY keyboard before. However, My new analog keyboard is supposed to produce X and Y values akin to a joystick (I think from each key), so I’m hoping to receive those values via the HID interface.
I’m able to receive HID data from my mouse with the code below, but when I try to connect either my new keyboard or even my laptop’s built-in keyboard - it appears to make a successful connection but keystrokes don’t produce any results.
FYI: While the HID connection to my mouse is active, the mouse stops moving the cursor, however, even though the HID connection to the keyboard appears active, I’m still able to type. It seems that the keyboard packets are being intercepted by the OS before they reach supercollider, but I really don’t know how that works behind the scenes at all.
Is there a way to receive HID data from a keyboard? Any light shed on the situation would be helpful - even generic info about how OSes deal differently with mouse vs keyboard input.
I’m using a decade old macbook pro running catalina. Here’s my code, basically from the docs:
HID.findAvailable;
HID.postAvailable;
~myhid = HID.open(1452, 594);
~myhid.action = { |value, physValue, rawValue, arrayValue, usage, page, elid|
["Mouse Event:", value, physValue, rawValue, arrayValue, usage, page, elid].postln;
};
Thanks in advance,
Kevin