Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/main/config/config.rc
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,17 @@ FONT 8, "Ms Shell Dlg"
{
LTEXT "Keyboard device", IDC_STATIC, 15, 20, 54, 8, SS_LEFT
COMBOBOX IDC_KBD_DEVICE, 15, 30, 135, 12, WS_GROUP | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_HASSTRINGS
LTEXT "Card ID file", IDC_STATIC, 15, 50, 36, 8, SS_LEFT
EDITTEXT IDC_CARD_PATH, 15, 60, 135, 14, ES_AUTOHSCROLL
PUSHBUTTON "&Browse...", IDC_BROWSE, 155, 60, 50, 14
AUTOCHECKBOX "Use top keyboard row for PIN pad input", IDC_ALT_10K, 15, 47, 136, 8
LTEXT "Card ID file", IDC_CARD_TEXT, 15, 60, 36, 8, SS_LEFT
EDITTEXT IDC_CARD_PATH, 15, 70, 135, 14, ES_AUTOHSCROLL
PUSHBUTTON "&Browse...", IDC_BROWSE, 155, 70, 50, 14
LTEXT "Smartcard reader", IDC_SCARD_TEXT, 15, 60, 80, 8, SS_LEFT
LTEXT "", IDC_SCARD_READER_NAME, 15, 72, 135, 14, SS_LEFT
GROUPBOX "", IDC_GROUP, 5, 5, 210, 80
LTEXT "Keypad status", IDC_STATIC, 155, 20, 46, 8, SS_LEFT
LTEXT "", IDC_KEYPAD_STATE, 160, 30, 45, 12, SS_LEFT | SS_CENTERIMAGE
LTEXT "Card present", IDC_SCARD_CARD_TEXT, 155, 60, 46, 8, SS_LEFT
LTEXT "", IDC_SCARD_IS_PRESENT, 160, 70, 45, 12, SS_LEFT | SS_CENTERIMAGE
}


Expand Down Expand Up @@ -170,14 +175,15 @@ FONT 8, "Ms Shell Dlg"


LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_TAB_NETWORK DIALOG 0, 0, 220, 215
IDD_TAB_NETWORK DIALOG 0, 0, 220, 240
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Network"
FONT 8, "Ms Shell Dlg"
{
LTEXT "", IDC_STATIC, 0, 0, 8, 8, SS_LEFT
AUTOCHECKBOX "Generate card ID files on insertion if they do not already exist", IDC_AUTOGEN, 5, 200, 206, 8
AUTOCHECKBOX "Use top keyboard row for PIN pad input", IDC_ALT_10K, 5, 185, 141, 8
AUTOCHECKBOX "Use smartcard readers instead of card ID files", IDC_SCARD, 5, 5, 200, 8
AUTOCHECKBOX "Use NUMLOCK to deconflict overlapping keypads (ON = P2)", IDC_MUX_KEYPAD, 5, 200, 265, 8
AUTOCHECKBOX "Use NUMLOCK to share one smartcard reader (ON = P2)", IDC_MUX_SCARD, 5, 212, 265, 8
AUTOCHECKBOX "Generate card ID files on insertion if they do not already exist", IDC_AUTOGEN, 5, 224, 265, 8
}


Expand Down
176 changes: 162 additions & 14 deletions src/main/config/eam.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,25 @@ static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp);
static INT_PTR eam_ui_handle_activate(HWND hwnd);
static INT_PTR eam_ui_handle_passivate(HWND hwnd);
static INT_PTR eam_ui_handle_tick(HWND hwnd);
static INT_PTR eam_ui_handle_change_alt_10k(HWND hwnd);
static INT_PTR eam_ui_handle_change_scard(HWND hwnd);
static INT_PTR eam_ui_handle_change_mux_keypad(HWND hwnd);
static INT_PTR eam_ui_handle_change_mux_scard(HWND hwnd);
static INT_PTR eam_ui_handle_change_autogen(HWND hwnd);
static INT_PTR eam_ui_handle_fini(HWND hwnd);
static HWND eam_mux_keypad_dlg;
static HWND *eam_unit_dlgs;
static uint8_t eam_num_units;

static INT_PTR CALLBACK
eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
static INT_PTR
eam_unit_ui_handle_init(HWND hwnd, const struct eam_unit_def *def);
static void eam_unit_ui_handle_init_devs(HWND hwnd);
static void eam_unit_ui_handle_init_path(HWND hwnd);
static void eam_unit_ui_handle_init_alt_10k(HWND hwnd);
static INT_PTR eam_unit_ui_handle_browse(HWND hwnd);
static INT_PTR eam_unit_ui_handle_change_device(HWND hwnd);
static INT_PTR eam_unit_ui_handle_change_alt_10k(HWND hwnd);
static INT_PTR eam_unit_ui_handle_tick(HWND hwnd);
static INT_PTR eam_unit_ui_handle_fini(HWND hwnd);

Expand Down Expand Up @@ -110,12 +117,18 @@ eam_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
switch (HIWORD(wparam)) {
case BN_CLICKED:
switch (LOWORD(wparam)) {
case IDC_SCARD:
return eam_ui_handle_change_scard(hwnd);

case IDC_MUX_KEYPAD:
return eam_ui_handle_change_mux_keypad(hwnd);

case IDC_MUX_SCARD:
return eam_ui_handle_change_mux_scard(hwnd);

case IDC_AUTOGEN:
return eam_ui_handle_change_autogen(hwnd);

case IDC_ALT_10K:
return eam_ui_handle_change_alt_10k(hwnd);

default:
return FALSE;
}
Expand Down Expand Up @@ -163,15 +176,24 @@ static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
inst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
schema = (struct schema *) psp->lParam;

ypos = 0;
eam_unit_dlgs = xmalloc(sizeof(HWND) * schema->nunits);
eam_num_units = schema->nunits;

GetWindowRect(GetDlgItem(hwnd, IDC_SCARD), &r);
if (eam_io_config_api->get_scard()) {
SendMessage(GetDlgItem(hwnd, IDC_SCARD), BM_SETCHECK, BST_CHECKED, 0);
}

ypos = r.bottom - r.top + 8; // todo the +8 is hacky bc the bottom is hella big

for (i = 0; i < schema->nunits; i++) {
child = CreateDialogParam(
inst,
MAKEINTRESOURCE(IDD_READER),
hwnd,
eam_unit_ui_dlg_proc,
(LPARAM) &schema->units[i]);
eam_unit_dlgs[i] = child;

GetWindowRect(child, &r);
SetWindowPos(
Expand All @@ -182,14 +204,30 @@ static INT_PTR eam_ui_handle_init(HWND hwnd, const PROPSHEETPAGE *psp)
*array_append(HWND, &ui->children) = child;
}

eam_mux_keypad_dlg = GetDlgItem(hwnd, IDC_MUX_KEYPAD);
if (eam_io_config_api->get_mux_keypad()) {
SendMessage(eam_mux_keypad_dlg, BM_SETCHECK, BST_CHECKED, 0);
}

if (eam_io_config_api->get_mux_scard()) {
SendMessage(GetDlgItem(hwnd, IDC_MUX_SCARD), BM_SETCHECK, BST_CHECKED, 0);
}

if (eam_io_config_api->get_autogen()) {
SendMessage(GetDlgItem(hwnd, IDC_AUTOGEN), BM_SETCHECK, BST_CHECKED, 0);
}

if (eam_io_config_api->get_alt_10k()) {
SendMessage(GetDlgItem(hwnd, IDC_ALT_10K), BM_SETCHECK, BST_CHECKED, 0);
}
// invoke scard change handler so we can toggle card file / smartcard stuff
eam_ui_handle_change_scard(hwnd);
// invoke a keypad-related change handler so the keypad mux option updates
eam_unit_ui_handle_change_alt_10k(eam_unit_dlgs[0]);

// if only one reader is present, disablo mux options
if (schema->nunits == 1) {
EnableWindow(GetDlgItem(hwnd, IDC_MUX_KEYPAD), false);
EnableWindow(GetDlgItem(hwnd, IDC_MUX_SCARD), false);
}

return TRUE;
}

Expand Down Expand Up @@ -225,15 +263,68 @@ static INT_PTR eam_ui_handle_tick(HWND hwnd)
return TRUE;
}

static INT_PTR eam_ui_handle_change_alt_10k(HWND hwnd)
static INT_PTR eam_ui_handle_change_scard(HWND hwnd)
{
HWND btn;
bool alt_10k;
bool scard;
size_t i;

btn = GetDlgItem(hwnd, IDC_ALT_10K);
alt_10k = SendMessage(btn, BM_GETCHECK, 0, 0) == BST_CHECKED;
btn = GetDlgItem(hwnd, IDC_SCARD);
scard = SendMessage(btn, BM_GETCHECK, 0, 0) == BST_CHECKED;

eam_io_config_api->set_scard(scard);

// toggle state of card file vs scard components
EnableWindow(GetDlgItem(hwnd, IDC_AUTOGEN), !scard);
EnableWindow(GetDlgItem(hwnd, IDC_MUX_SCARD), scard);
for (i = 0; i < eam_num_units; i++) {
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_CARD_TEXT), !scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_CARD_PATH), !scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_BROWSE), !scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_TEXT), scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_READER_NAME), scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_CARD_TEXT), scard);
ShowWindow(GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_IS_PRESENT), scard);

if (scard) {
SetWindowTextA(
GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_READER_NAME),
eam_io_config_api->get_scard_reader_name(i));
}
}

eam_io_config_api->set_alt_10k(alt_10k);
return TRUE;
}

static INT_PTR eam_ui_handle_change_mux_keypad(HWND hwnd)
{
HWND btn;
bool mux_keypad;

btn = GetDlgItem(hwnd, IDC_MUX_KEYPAD);
mux_keypad = SendMessage(btn, BM_GETCHECK, 0, 0) == BST_CHECKED;

eam_io_config_api->set_mux_keypad(mux_keypad);

return TRUE;
}

static INT_PTR eam_ui_handle_change_mux_scard(HWND hwnd)
{
HWND btn;
bool mux_scard;
size_t i;

btn = GetDlgItem(hwnd, IDC_MUX_SCARD);
mux_scard = SendMessage(btn, BM_GETCHECK, 0, 0) == BST_CHECKED;

eam_io_config_api->set_mux_scard(mux_scard);

for (i = 0; i < eam_num_units; i++) {
SetWindowTextA(
GetDlgItem(eam_unit_dlgs[i], IDC_SCARD_READER_NAME),
eam_io_config_api->get_scard_reader_name(i));
}

return TRUE;
}
Expand Down Expand Up @@ -294,6 +385,15 @@ eam_unit_ui_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return FALSE;
}

case IDC_ALT_10K:
switch (HIWORD(wparam)) {
case BN_CLICKED:
return eam_unit_ui_handle_change_alt_10k(hwnd);

default:
return FALSE;
}

default:
return FALSE;
}
Expand Down Expand Up @@ -326,6 +426,7 @@ eam_unit_ui_handle_init(HWND hwnd, const struct eam_unit_def *def)

eam_unit_ui_handle_init_devs(hwnd);
eam_unit_ui_handle_init_path(hwnd);
eam_unit_ui_handle_init_alt_10k(hwnd);

return TRUE;
}
Expand Down Expand Up @@ -401,6 +502,17 @@ static void eam_unit_ui_handle_init_path(HWND hwnd)
}
}

static void eam_unit_ui_handle_init_alt_10k(HWND hwnd)
{
struct eam_unit_ui *ui;

ui = (struct eam_unit_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);

if (eam_io_config_api->get_alt_10k(ui->def->unit_no)) {
SendMessage(GetDlgItem(hwnd, IDC_ALT_10K), BM_SETCHECK, BST_CHECKED, 0);
}
}

static INT_PTR eam_unit_ui_handle_browse(HWND hwnd)
{
struct eam_unit_ui *ui;
Expand Down Expand Up @@ -451,6 +563,28 @@ static INT_PTR eam_unit_ui_handle_change_device(HWND hwnd)
eam_io_config_api->set_keypad_device(ui->def->unit_no, hid);
}

// enable the keypad mux option if the devices/keys conflict
EnableWindow(eam_mux_keypad_dlg, eam_io_config_api->do_keypads_conflict());

return TRUE;
}

static INT_PTR eam_unit_ui_handle_change_alt_10k(HWND hwnd)
{
struct eam_unit_ui *ui;
HWND btn;
bool alt_10k;

ui = (struct eam_unit_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);

btn = GetDlgItem(hwnd, IDC_ALT_10K);
alt_10k = SendMessage(btn, BM_GETCHECK, 0, 0) == BST_CHECKED;

eam_io_config_api->set_alt_10k(ui->def->unit_no, alt_10k);

// enable the keypad mux option if the devices/keys conflict
EnableWindow(eam_mux_keypad_dlg, eam_io_config_api->do_keypads_conflict());

return TRUE;
}

Expand All @@ -459,14 +593,28 @@ static INT_PTR eam_unit_ui_handle_tick(HWND hwnd)
struct eam_unit_ui *ui;
uint16_t state;
wchar_t state_str[9];
bool card_present;

// keypad state
ui = (struct eam_unit_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
state = eam_io_get_keypad_state(ui->def->unit_no);

wstr_format(state_str, lengthof(state_str), L"%04x", state);

SetWindowText(GetDlgItem(hwnd, IDC_KEYPAD_STATE), state_str);


// smartcard state
if (eam_io_config_api->get_scard()) {

eam_io_poll(ui->def->unit_no);

card_present = eam_io_get_sensor_state(ui->def->unit_no);

SetWindowText(
GetDlgItem(hwnd, IDC_SCARD_IS_PRESENT),
(card_present ? L"YES" : L"NO"));
}

return TRUE;
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/config/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define IDC_LIGHT 1001
#define IDC_SENSITIVITY 1001
#define IDC_ACTION_NAME 1002
#define IDC_ALT_10K 1002
#define IDC_KEYPAD_STATE 1002
#define IDC_GAME_TYPE 1003
#define IDC_GROUP 1003
Expand All @@ -39,6 +38,15 @@
#define IDC_BINDING_MAX 1010
#define IDC_LIMIT_MAX 1011
#define IDC_CURRENT 1013
#define IDC_SCARD 1014
#define IDC_ALT_10K 1015
#define IDC_MUX_KEYPAD 1016
#define IDC_MUX_SCARD 1017
#define IDC_CARD_TEXT 1018
#define IDC_SCARD_TEXT 1019
#define IDC_SCARD_READER_NAME 1020
#define IDC_SCARD_CARD_TEXT 1021
#define IDC_SCARD_IS_PRESENT 1022
#define IDC_BINDING_EDIT_MANY 40000
#define IDS_APPNAME 40000
#define IDS_BAD_GAME_TYPE 40001
Expand Down
2 changes: 2 additions & 0 deletions src/main/eamio/Module.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dlls += eamio
libs_eamio := geninput util
ldflags_eamio := -lwinscard
src_eamio := \
eam-api.c \
eam-impl.c \
eam-s11n.c \
eam-scard.c
Loading