Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Conflict between MSR (Magtek) and Virtual Keyboard (Read 9100 times)
MikeS
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Oct 11th, 2017
Conflict between MSR (Magtek) and Virtual Keyboard
Oct 11th, 2017 at 1:16am
Print Post  
Running a Winforms application, the textbox receives invalid / garbage from a magnetic card swipe in keyboard emulation mode when the form has a Virtual Keyboard defined. If we eliminate the Virtual Keyboard the data is sent properly. The application is running on a Windows 10 Tablet. Help....
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #1 - Oct 11th, 2017 at 7:53am
Print Post  
Add a KeyDown handler to the textbox and verify whether it receives same key codes with and without the keyboard present? If the key codes are the same but the printed characters differ, probably the card reader software expects the app to run under a specific keyboard layout (what Windows uses to map virtual key codes to actual characters), and the keyboard initialization code changes it to a different one.

If your keyboard initialization code includes assignment to InputLocale, try removing it. The keyboard itself shouldn't change the keyboard layout automatically, but just in case try moving the card reader initialization code after the keyboard's one - could help if both the reader and the keyboard activate a keyboard layout.

Also if you aren't on v4.4.2, try upgrading to it. Latest version disables a feature where current thread's UI culture was automatically set to match input locale, which might lead to changing textbox' font or character encoding. If you are already on v4.4.2, make sure you haven't set AutoUpdateCulture to true.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
MikeS
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Oct 11th, 2017
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #2 - Oct 11th, 2017 at 8:04pm
Print Post  
Hi Slavcho,
Thanks for the quick response.
Tried KeyDown event bad data is the same (key code and display).

Not setting InputLocale, however we did try changing the values without success.

We have version 4.4.2 and AutoUpdateCulture is set to false.

If it helps any, this issue is very specific to Windows 10 Tablet. It works fine on Windows 10 desktop.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #3 - Oct 12th, 2017 at 5:53am
Print Post  
Quote:
Tried KeyDown event bad data is the same (key code and display).


Do you mean the text box gets different key code values from card reader when you add keyboard to your application? Or the key codes are the same but the characters are bad?

Do the characters look like showing the shift-variant of characters, say !@#$ instead of 1234 (US keyboard layout)?

Regards,
Slavcho
  
Back to top
 
IP Logged
 
MikeS
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Oct 11th, 2017
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #4 - Oct 13th, 2017 at 7:55pm
Print Post  
To clarify, here is the data returned from a card swipe when the form has a virtual keyboard:

%L6049580600000005^MIKE+!S_112?ET^1512FLEET?;6049580600000005=1512112?

sometimes we will get something like this:
%L6049;60495806000@@@?ET^1512FLEET?;6049580600000005=1512112?;604112

Here is the proper card swipe (no virtual keyboard on the form):

%L6049580600000005^MIKES_FLEET^1512FLEET?;6049580600000005=1512112?

I hope this better illustrates what is going on.

We need to deploy the application soon so any help would be greatly appreciated.

Mike
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #5 - Oct 13th, 2017 at 9:06pm
Print Post  
While the reader is sending data, does it show VirtualKeyboard.KeyPressed event firing if you call Debug.Write from its handler?
  
Back to top
 
IP Logged
 
MikeS
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Oct 11th, 2017
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #6 - Oct 14th, 2017 at 2:18pm
Print Post  
Hi Slavcho.
A card swipe does not trigger the VirtualKeyboard.KeyPressed event.

Mike
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #7 - Oct 16th, 2017 at 5:56am
Print Post  
Hi Mike,

What key codes does it log with and without the keyboard ?

Code
Select All
textbox.KeyDown += (s, e) => Debug.WriteLine("down: " + e.KeyValue + " mod:" + e.Modifiers);
textbox.KeyUp += (s, e) => Debug.WriteLine("up: " + e.KeyValue + " mod:" + e.Modifiers);
 



Is the form created in response to some card reader event indicating it will start sending data? The keyboard initialization code sets modifier key states a few times and resets them afterwards. If the reader sends key events just then, that could change key code to character mapping. You should be able to work around it by creating the form earlier and just setting it visible when needed.

I've browsed Magtek documentation - keyboard emulation is listed as legacy compatibility mode there, and recommends using a dedicated card reader API that will read directly through USB interface. Not sure if this applies to model you are using.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
MikeS
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Oct 11th, 2017
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #8 - Oct 31st, 2017 at 2:08pm
Print Post  
Hi Slavcho,

I'll run the code and let you know, but based on my previous tests the data is correct without the keyboard and incorrect with the keyboard.

I am not creating a form, the form is already there, the card swipe is happening into a textbox.

Wierd thing is, everything works fine on multiple PC's, but when trying on multiple brands of tablets (Atom CPU's) it does not work.  Could it have something todo with the much slower Atom processors?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Conflict between MSR (Magtek) and Virtual Keyboard
Reply #9 - Oct 31st, 2017 at 6:35pm
Print Post  
Hi,

I guess there might be some difference showing from the version of the operating system or .NET framework running on Atom processors. What's the MSR device' exact model?

Here's something similar happening -
https://serverfault.com/questions/64594/magnetic-stripe-reader-over-terminal-ser
ver-has-random-uppercase-lowercase-nonse

Is your application running directly on the tablet, or it shows through remote connection too by chance? Does it make any difference whether you type on the keyboard before using the reader?

You could also check if you can't read the data directly through .NET POS APIs as in https://code.msdn.microsoft.com/windowsapps/Magnetic-stripe-reader-30aa2ca5

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint