Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3451858
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:28+00:00 2026-05-18T09:11:28+00:00

I have a module written using XNA which polls the GamePad and the Keyboard

  • 0

I have a module written using XNA which polls the GamePad and the Keyboard on a background thread, and calls some callbacks. No Game class whatsoever.
I want to use this module from a WPF application, calling Dispatcher.BeginInvoke on the callback, and makeing some changes on the display (which contains no TextBox, etc), based on the callbacks parameters.
It works perfectly with the GamePad, but the Keyboard.GetState().GetPressedKeys() array is always empty!
I think it has something to do with WPF message loop catching the keyboard events before I can poll them in XNA, or there is nothing for xna to set the keyboard focus to.
Do you have any tips? How to pass keyboard state to XNA, so I don’t have to rewrite the keyboard handling using WPF classes?
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:11:28+00:00Added an answer on May 18, 2026 at 9:11 am

    Never mind, I worked it out! The problem wasn’t with focus, it was with threading! I exposed a callback on polling class, and when I wanted to call Keyboard.GetState(), I called the callback, which (in WPF) was a Dispatcher.Invoke(()=>poll.GetKeyboardState()) call, so this time the GetState() was on the same thread as the WPF control, so it worked!!! Hoorah!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I have a module which declares a number of instance methods module UsefulThings
I have a c++ application which logs to some file using log4cxx (RollingFile appender).
I have written a module that has some generic, reusable code that I would
I am having some strange problem. I have written a small module in VC++
I have one module written on Java - web service module which accepts request
I have written a simple module to store and manipulate an ontology which is
I have written a XS based Perl module which provides access to functions in
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have a ASP.NET application that we've written our own logging module for. My
So I have a module in flex in which I add a custom component.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.