Partner sites: Aminet - Amiga downloadsIntuitionBase - Amiga guidesAmigaNN - Amiga newsAmiFund - Sponsor projects

[Y]UtilityBase
Your guide to Amiga development
Sign up at our provider 
and get $50 off!
Not logged in
  HomeProjectsForumArticlesResourcesLinksChatAbout 
Search
Login
Username:
Password:
Register now!
Forgot your password?
Aminet - Development
Blitz_AVI.lha (dev/basic)
bullet.lha (dev/lib)
MCC_TheBar-26.6.lha (dev/mui)
MCC_TextEditor-15.35.lha (dev/mui)
MCC_BetterString-11.19.lha (dev/mui)
fw_c2p_p2c.lha (dev/lib)
plib_examples.lha (dev/src)
plib.lha (dev/lib)
MCC_NList-0.107.lha (dev/mui)
MCC_NList-0.106.lha (dev/mui)
More...
Newest users
prowler
apache64 (Chris)
cpeel2300 (Chris)
Branquito
chris (Chris Young)

Pending:
ZebraZeem, Mad_Dog, hhjoker, voxel, JosDuchIt, MarcB, MarBo, Sollaris, sara, species
More...
Who's Online
Online members:


12 guests are online.

You are an Anonymous user. You can register for free by clicking here.
News sites
Amiga-News.de
Amiga.org
AmigaNN
Amigans.net
Amigaweb.net
AmigaWorld.net
AROS-Exec
MorphOS-News.de
MorphZone
polarBoing
Tutorials
Change Graphics cards in AmigaOS 4.
Installing the latest OS4 SDK in Cubic IDE
Writing Installer scripts for AmiUpdate
Cross Compiling for OS4 or OS3 using MS Visual Studio 2005
Installing an AmigaOS 4 cross compiler
More...
Sources
How to open and use the exec debug interface
How to install a hardware interrupt
Install SObjs with Installer
How to make clean picture datatypes
Most of the old ClassACT examples converted to OS4
More...
Documentations
How to write portable code for Amiga (english)
Comment écrire du code portable pour Amiga (français)
Development How to with OS3.9 SDK
The PartyPack Hack
The Amiga PDA Programming Guidelines
More...
DreamHost

Support
UtilityBase

[Valid RSS]

UtilityBase needs your help!

Amiga OS 4.x - C/C++ development Forum / Amiga OS 4.x - C/C++ development /

Keyboard handling under OS4

 
Author Minuous
Forums Member
#1 · Posted: 2010-07-28 07:26
Hello, I'm getting bug reports from members of my OS4 userbase, reporting that keyboard input is being ignored. It works fine on OS3.9 and MOS. So I'm wondering if something has changed for keyboard.device under OS4? The OS4 SDK implies that it hasn't.
I searched the forums here for guidance, but this is all I found:

On a classic Amiga keyboard.device is probably the one to ask, but on an A1 you have more than one device which could hold a keyboard (PS/2, USB, Catweasel etc.)

Does this mean that keyboard input on OS4 might not always go through keyboard.device? If that's the case, what would be the recommended method to get the up/down state of all keys?
I assume that reading IntuitionBase->ActiveWindow is still the best way to get the active window?
Here's the function in question.

EXPORT void readkybd(void)
{ ULONG IBaseLock, i;
struct Window* ActiveWindowPtr;

IBaseLock = LockIBase(0);
ActiveWindowPtr = IntuitionBase->ActiveWindow;
UnlockIBase(IBaseLock);

if
( ActiveWindowPtr == MainWindowPtr
|| (ControlsWindowPtr && ActiveWindowPtr == ControlsWindowPtr)
|| ( DIPsWindowPtr && ActiveWindowPtr == DIPsWindowPtr)
|| (GameInfoWindowPtr && ActiveWindowPtr == GameInfoWindowPtr)
|| ( MonitorWindowPtr && ActiveWindowPtr == MonitorWindowPtr)
|| ( MemoryWindowPtr && ActiveWindowPtr == MemoryWindowPtr)
|| ( PaletteWindowPtr && ActiveWindowPtr == PaletteWindowPtr)
)
{ // Strangely, this only seems to work if KeyMatrix is dynamically
// allocated.
KybdIO->io_Command = KBD_READMATRIX;
KybdIO->io_Length = 16;
KybdIO->io_Data = (APTR) KeyMatrix;

DISCARD DoIO((struct IORequest *) KybdIO);
} else
{ for (i = 0; i < 16; i++)
{ KeyMatrix[i] = 0;
} } }
Author ZeroG
Forums Member
#2 · Posted: 2010-07-28 12:58
I assume that reading IntuitionBase->ActiveWindow is still the best way to get the active window?

I guess it's better to use IIntuition->GetScreenInfo() with the SA_ActiveWindow tag.
Author Trixie
Forums Member
#3 · Posted: 2010-07-28 13:49
Minuous
Minuous:
I assume that reading IntuitionBase->ActiveWindow is still the best way to get the active window?

No it's not, under OS4 at least. As of V50 there's an Intuition function, GetScreenAttr(), that you can use to obtain your value - so there's no need (and is generally discouraged) to peek a system structure directly. See Intuition autodocs for more info.
Author Minuous
Forums Member
#4 · Posted: 2010-07-28 16:17
OK, thanks, I will make this change and see if it helps.
Author Minuous
Forums Member
#5 · Posted: 2010-07-28 16:26 · Edited by: Minuous
Just got word back from my betatester, this call is OK, it seems to be the KBD_READMATRIX that is the problem.

(Regarding the ActiveWindow issue, I need a screen pointer to give the GetScreenAttr(SA_ActiveWindow) to get a meaningful result. So I imagine I would need to read that out of IntuitionBase->ActiveScreen, which defeats the purpose :-(
Anyway, according to the intuitionbase.h comments, reading the public part of the structure is still considered legal.)
Author ZeroG
Forums Member
#6 · Posted: 2010-07-28 19:12
Yes, it is legal, but it's deprecated.

You can find your Screenpointer in struct Window (WScreen).

BTW:
The best way would be to wait for IDCMP_ACTIVEWINDOW IDCMP messages.
Author Minuous
Forums Member
#7 · Posted: 2010-08-01 10:20 · Edited by: Minuous
OK, I've rewritten the keyboard handling to entirely avoid the use of keyboard.device.
But nevertheless it does seem that there is some kind of OS4 bug which prevents KBD_READMATRIX from working correctly, the code is system-legal AFAICT and works fine on OS3.9 and MorphOS.
I might add that this is not the first such workaround that I have had to implement to avoid OS4 bugs. It was my impression that the OS4 team has access to OS3.x source code so I'm not sure why they introduced these bugs, they can't be just faulty reverse engineering.
Author Minuous
Forums Member
#8 · Posted: 2010-08-08 17:03 · Edited by: Minuous
I'm surprised that there is no interest from the OS4 dev team in fixing this, it strikes me as a pretty serious bug, one of the most important .devices is basically useless...?
 
Amiga OS 4.x - C/C++ development Forum / Amiga OS 4.x - C/C++ development / Keyboard handling under OS4 Top
Your Reply Click this icon to move up to the quoted message

 

UtilityBase is a site focused on development for Amiga systems,
spanning over all different Amiga clones, that be AmigaOS 3.x, 4.x, MorphOS, AROS or AmigaDE/Anywhere.
News syndication: RSS
Contact address: mail@utilitybase com