Skip to content

Instantly share code, notes, and snippets.

@dhorlick
Last active September 5, 2025 15:33
Show Gist options
  • Select an option

  • Save dhorlick/f42133baab48ca7be8520e3c761a2bb9 to your computer and use it in GitHub Desktop.

Select an option

Save dhorlick/f42133baab48ca7be8520e3c761a2bb9 to your computer and use it in GitHub Desktop.
Mods tmk_firmware to configure the special function key mode on Omnikey keyboards
diff --git a/converter/ps2_usb/matrix.c b/converter/ps2_usb/matrix.c
index c441a89b..bb14b9cd 100644
--- a/converter/ps2_usb/matrix.c
+++ b/converter/ps2_usb/matrix.c
@@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host.h"
#include "led.h"
#include "matrix.h"
+#include "timer.h"
static void matrix_make(uint8_t code);
@@ -64,8 +65,25 @@ static uint8_t matrix[MATRIX_ROWS];
#define PRINT_SCREEN (0xFC)
#define PAUSE (0xFE)
+// Set Special Function Keys for Northgate Omnikey Keyboards
+#define SFSET (0xE9)
+
static bool is_modified = false;
+static bool sf_set_ran = false;
+static uint16_t start_time_in_millis = 0;
+
+/**
+ * Set Special Function key mode for Northgate Omnikey keyboards
+ *
+ * @param mode 0 = normal, 1 = shift, 2 = ctrl, 4 = alt
+ */
+void sf_set(uint8_t mode)
+{
+ // _delay_ms(500);
+ ps2_host_send(SFSET);
+ ps2_host_send(mode);
+}
void matrix_init(void)
{
@@ -74,7 +92,7 @@ void matrix_init(void)
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
-
+ start_time_in_millis = timer_read();
return;
}
@@ -143,7 +161,6 @@ void matrix_init(void)
*/
uint8_t matrix_scan(void)
{
-
// scan code reading states
static enum {
INIT,
@@ -203,9 +220,11 @@ uint8_t matrix_scan(void)
break;
case 0xAA: // Self-test passed
case 0xFC: // Self-test failed
+ case 0xFD: // Self-test failed
printf("BAT %s\n", (code == 0xAA) ? "OK" : "NG");
led_set(host_keyboard_leds());
state = INIT;
+ sf_set(1);
break;
default: // normal key make
if (code < 0x80) {
@@ -379,6 +398,17 @@ uint8_t matrix_scan(void)
xprintf("Resend: %02X\n", ret);
}
*/
+ // Run SFSET two seconds after matrix started being scanned
+
+ if (!sf_set_ran)
+ {
+ if (timer_read() > start_time_in_millis + 2000)
+ {
+ sf_set(1);
+ sf_set_ran = true;
+ }
+ }
+
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment