<commit_before>#pragma once

#include "user_client.hpp"

class io_hid_post_event_wrapper final {
public:
  void start(void) {
    user_client_.open(kIOHIDSystemClass, kIOHIDParamConnectType);
  }

  void post_modifier_flags(IOOptionBits flags) {
    auto connect = user_client_.get_connect();
    if (!connect) {
      return;
    }

    NXEventData event;
    memset(&event, 0, sizeof(event));

    std::cout << std::hex << flags << std::dec << std::endl;

    IOGPoint loc = {0, 0};
    auto kr = IOHIDPostEvent(connect, NX_FLAGSCHANGED, loc, &event, kNXEventDataVersion, flags, kIOHIDSetGlobalEventFlags);

    if (KERN_SUCCESS != kr) {
      std::cerr << "IOHIDPostEvent returned 0x" << std::hex << kr << std::dec << std::endl;
    }
  }

  void post_aux_key(uint8_t key_code, bool key_down, IOOptionBits flags) {
    auto connect = user_client_.get_connect();
    if (!connect) {
      return;
    }

    NXEventData event;
    bzero(&event, sizeof(event));
    event.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
    event.compound.misc.L[0] = (key_code << 16) | ((key_down ? NX_KEYDOWN : NX_KEYUP) << 8);

    IOGPoint loc = {0, 0};
    kern_return_t kr = IOHIDPostEvent(connect, NX_SYSDEFINED, loc, &event, kNXEventDataVersion, flags, 0);
    if (KERN_SUCCESS != kr) {
      std::cerr << "IOHIDPostEvent returned 0x" << std::hex << kr << std::dec << std::endl;
    }
  }

private:
  user_client user_client_;
};
<commit_msg>suppress log message<commit_after>#pragma once

#include "user_client.hpp"

class io_hid_post_event_wrapper final {
public:
  void start(void) {
    user_client_.open(kIOHIDSystemClass, kIOHIDParamConnectType);
  }

  void post_modifier_flags(IOOptionBits flags) {
    auto connect = user_client_.get_connect();
    if (!connect) {
      return;
    }

    NXEventData event;
    memset(&event, 0, sizeof(event));

    IOGPoint loc = {0, 0};
    auto kr = IOHIDPostEvent(connect, NX_FLAGSCHANGED, loc, &event, kNXEventDataVersion, flags, kIOHIDSetGlobalEventFlags);

    if (KERN_SUCCESS != kr) {
      std::cerr << "IOHIDPostEvent returned 0x" << std::hex << kr << std::dec << std::endl;
    }
  }

  void post_aux_key(uint8_t key_code, bool key_down, IOOptionBits flags) {
    auto connect = user_client_.get_connect();
    if (!connect) {
      return;
    }

    NXEventData event;
    bzero(&event, sizeof(event));
    event.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
    event.compound.misc.L[0] = (key_code << 16) | ((key_down ? NX_KEYDOWN : NX_KEYUP) << 8);

    IOGPoint loc = {0, 0};
    kern_return_t kr = IOHIDPostEvent(connect, NX_SYSDEFINED, loc, &event, kNXEventDataVersion, flags, 0);
    if (KERN_SUCCESS != kr) {
      std::cerr << "IOHIDPostEvent returned 0x" << std::hex << kr << std::dec << std::endl;
    }
  }

private:
  user_client user_client_;
};

{'fraction_non_alphanumeric': 0.13515431003902093, 'fraction_numerical': 0.009223128769067045, 'mean_word_length': 3.8040885860306646, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5395978', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1027, 'n_words': 213}