Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2005 with .NET 3.0 Programmer's Reference ISBN: 978-0-470-13705-5
This is the forum to discuss the Wrox book Visual Basic 2005 with .NET 3.0 Programmer's Reference by Rod Stephens; ISBN: 9780470137055
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 with .NET 3.0 Programmer's Reference ISBN: 978-0-470-13705-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 31st, 2008, 01:54 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default USB keypad

I thought I'd ask you before I search the net!

How can I determine which USB keypad has caused a key event in my VB app.

My app records scores in a competition and each judge has a keypad. I need to know the key value (OK, I get that as a keyValue argument) but I also need to know whether a particular judge has given his score yet.

Alternatively, can I take control of the keypads somehow?

Thanks Rod

Phil

Reply With Quote
  #2 (permalink)  
Old January 31st, 2008, 02:10 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 Posts
Default

Sorry but I have no clue on that one. If you can't make the devices identify themselves in some way, it may be tough.

Rod

Rod Stephens, Visual Basic MVP
RodStephens@vb-helper.com

*** New Book ***
"Visual Basic 2008 Programmer's Reference"

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
Reply With Quote
  #3 (permalink)  
Old February 11th, 2008, 05:36 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I've found I need to use Raw Input which is in the User32 dll.
Unfortunately, all the samples are in C or C++. It uses structures like

        [StructLayout(LayoutKind.Sequential)]
        internal struct RAWINPUTDEVICE
        {
            [MarshalAs(UnmanagedType.U2)]
            public ushort usUsagePage;
            [MarshalAs(UnmanagedType.U2)]
            public ushort usUsage;
            [MarshalAs(UnmanagedType.U4)]
            public int dwFlags;
            public IntPtr hwndTarget;
        }

and API calls like


        [DllImport("User32.dll")]
        extern static bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice, uint uiNumDevices, uint cbSize);



In VB6 I'd have got a reference via
Declare function RegisterRawInputDevices lib "USER32" (pRawInpoutDevice as ptr, numDevices as Integer, size as Integer) as boolean

but is there a better way in VB.net and how do I best create the structure and its pointer?

Reply With Quote
  #4 (permalink)  
Old March 17th, 2008, 06:59 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've got RawInput working nicely, but it returns a RawInput code that only tells me which key was pressed. I doesn't tell me the ASCII code for the key. I can manage the shift, alt and ctl keys OK, but the ASCII meaning of a key is dependent on the keyboard in use. For example, if I shift-press the 4th key on the top row of my English keyboard I get the UK currency symbol £. If you press the same key on a US keyboard it generates the same code but means # (or possibly cent - I forget which)

Somewhere in Windows there is a table that converts RawInput codes to ASCII - any idea where?

(PS I'm going to cross-post this on a Windows site)

Cheers

Phil

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Port kanoorani Beginning VB 6 8 August 12th, 2009 04:28 PM
backing up through USB Shira VB Databases Basics 1 October 9th, 2008 06:57 AM
USB security samantha Beginning VB 6 1 November 2nd, 2006 05:30 PM
USB Communication BrianWren VB.NET 0 July 21st, 2006 01:34 PM
Acceptin dtmf number of any length using keypad vikrant.roy XML 0 April 28th, 2005 06:59 AM



All times are GMT -4. The time now is 12:47 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.