<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Detecting SHIFT in Virtual Pascal Win32?' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Detecting SHIFT in Virtual Pascal Win32?' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 18:41:11 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 18:41:11 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340784/detecting-shift-in-virtual-pascal-win32/</link>
      <description>I'm currently porting a DOS textmode game to Win32 using Virtual Pascal. I've used the below code to detect whether or not SHIFT is pressed, but it doesn't work when I try to compile in Virtual Pascal. I get "Error 3: Unknown identifier 'registers'".&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
function SHIFTDOWN : boolean;
var regs : registers;
begin
   FillChar (regs, SizeOf(regs), 0);
   regs.ah := $02;
   Intr ($16, regs);
   shiftdown := (regs.al and $02) = $02;
end;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Any advice on how to detect SHIFT in Virtual Pascal Win32?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340784/detecting-shift-in-virtual-pascal-win32/</guid>
      <pubDate>Sat, 08 Jul 2006 09:44:40 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340788/re-detecting-shift-in-virtual-pascal-win32/#340788</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Alcatiz at  2006-7-8 13:58:6&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: I'm currently porting a DOS textmode game to Win32 using Virtual Pascal. I've used the below code to detect whether or not SHIFT is pressed, but it doesn't work when I try to compile in Virtual Pascal. I get "Error 3: Unknown identifier 'registers'".&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: function SHIFTDOWN : boolean;
: var regs : registers;
: begin
:    FillChar (regs, SizeOf(regs), 0);
:    regs.ah := $02;
:    Intr ($16, regs);
:    shiftdown := (regs.al and $02) = $02;
: end;
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: Any advice on how to detect SHIFT in Virtual Pascal Win32?&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Hi !&lt;br /&gt;
&lt;br /&gt;
First of all you can include some assembler in a Virtual Pascal source code using the &lt;strong&gt;asm&lt;/strong&gt; directive.&lt;br /&gt;
&lt;br /&gt;
If you have a look at the DOS unit in the &lt;strong&gt;\source\rtl&lt;/strong&gt; folder you'll see that some Turbo pascal types (like &lt;strong&gt;Registers&lt;/strong&gt;), procedures and functions (like &lt;strong&gt;Intr&lt;/strong&gt;) are not implemented. The reason is that interrupt and direct port handling don't work in protected mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340788/re-detecting-shift-in-virtual-pascal-win32/#340788</guid>
      <pubDate>Sat, 08 Jul 2006 13:57:44 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340807/re-detecting-shift-in-virtual-pascal-win32/#340807</link>
      <description>: &lt;br /&gt;
: Hi !&lt;br /&gt;
: &lt;br /&gt;
: First of all you can include some assembler in a Virtual Pascal source code using the &lt;strong&gt;asm&lt;/strong&gt; directive.&lt;br /&gt;
: &lt;br /&gt;
: If you have a look at the DOS unit in the &lt;strong&gt;\source\rtl&lt;/strong&gt; folder you'll see that some Turbo pascal types (like &lt;strong&gt;Registers&lt;/strong&gt;), procedures and functions (like &lt;strong&gt;Intr&lt;/strong&gt;) are not implemented. The reason is that interrupt and direct port handling don't work in protected mode.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
So, I can't modify the code to make it work in protected mode? Bummer. Do you know of any other way to detect whether or not SHIFT is down in protected mode?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340807/re-detecting-shift-in-virtual-pascal-win32/#340807</guid>
      <pubDate>Sun, 09 Jul 2006 01:34:00 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340822/re-detecting-shift-in-virtual-pascal-win32/#340822</link>
      <description>: : &lt;br /&gt;
: : Hi !&lt;br /&gt;
: : &lt;br /&gt;
: : First of all you can include some assembler in a Virtual Pascal source code using the &lt;strong&gt;asm&lt;/strong&gt; directive.&lt;br /&gt;
: : &lt;br /&gt;
: : If you have a look at the DOS unit in the &lt;strong&gt;\source\rtl&lt;/strong&gt; folder you'll see that some Turbo pascal types (like &lt;strong&gt;Registers&lt;/strong&gt;), procedures and functions (like &lt;strong&gt;Intr&lt;/strong&gt;) are not implemented. The reason is that interrupt and direct port handling don't work in protected mode.&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: So, I can't modify the code to make it work in protected mode? Bummer. Do you know of any other way to detect whether or not SHIFT is down in protected mode?&lt;br /&gt;
: &lt;br /&gt;
To detect if the SHIFT key is pressed you can use the &lt;strong&gt;GetKeyboardState&lt;/strong&gt; function of then &lt;strong&gt;VPUtils&lt;/strong&gt; unit as follows :&lt;br /&gt;
&lt;pre class="sourcecode"&gt;if GetKeyboardState( kbd_Shift ) then 
   ...&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340822/re-detecting-shift-in-virtual-pascal-win32/#340822</guid>
      <pubDate>Sun, 09 Jul 2006 06:32:40 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340831/re-detecting-shift-in-virtual-pascal-win32/#340831</link>
      <description>: To detect if the SHIFT key is pressed you can use the &lt;strong&gt;GetKeyboardState&lt;/strong&gt; function of then &lt;strong&gt;VPUtils&lt;/strong&gt; unit as follows :&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;if GetKeyboardState( kbd_Shift ) then 
:    ...&lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
I tried to test this in the below code, but it doesn't seem to work. It always writes "SHIFT NOT PRESSED!".&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
PROGRAM TEST;

USES Crt, VPUTILS;

VAR PressedKey : Word;

BEGIN
   PressedKey := 0;
   ClrScr;
   REPEAT
      REPEAT UNTIL KeyPressed;
      PressedKey := Ord(ReadKey);
      GotoXY(1,1);
      IF GetKeyboardState(kbd_Shift) THEN Write('SHIFT PRESSED!    ')
      ELSE Write('SHIFT NOT PRESSED!');
   UNTIL PressedKey = 27;
END.
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340831/re-detecting-shift-in-virtual-pascal-win32/#340831</guid>
      <pubDate>Sun, 09 Jul 2006 09:44:32 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340844/re-detecting-shift-in-virtual-pascal-win32/#340844</link>
      <description>: : To detect if the SHIFT key is pressed you can use the &lt;strong&gt;GetKeyboardState&lt;/strong&gt; function of then &lt;strong&gt;VPUtils&lt;/strong&gt; unit as follows :&lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;if GetKeyboardState( kbd_Shift ) then 
: :    ...&lt;/pre&gt;&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: I tried to test this in the below code, but it doesn't seem to work. It always writes "SHIFT NOT PRESSED!".&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: PROGRAM TEST;
: 
: USES Crt, VPUTILS;
: 
: VAR PressedKey : Word;
: 
: BEGIN
:    PressedKey := 0;
:    ClrScr;
:    REPEAT
:       REPEAT UNTIL KeyPressed;
:       PressedKey := Ord(ReadKey);
:       GotoXY(1,1);
:       IF GetKeyboardState(kbd_Shift) THEN Write('SHIFT PRESSED!    ')
:       ELSE Write('SHIFT NOT PRESSED!');
:    UNTIL PressedKey = 27;
: END.
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
Well your code works fine in my Windows 2000 console - but I had to add this compiler directive :&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
{$PMTYPE VIO}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340844/re-detecting-shift-in-virtual-pascal-win32/#340844</guid>
      <pubDate>Sun, 09 Jul 2006 14:32:05 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340864/re-detecting-shift-in-virtual-pascal-win32/#340864</link>
      <description>: Well your code works fine in my Windows 2000 console - but I had to add this compiler directive :&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: {$PMTYPE VIO}
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I tried adding this, but that didn't do anything. I'm running Windows 98 if that something interferes with what I'm trying to do. Also, in the "Linker" options the "Application" is already set to "Compatible with GUI". Isn't that what the {$PMTYPE VIO} does?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340864/re-detecting-shift-in-virtual-pascal-win32/#340864</guid>
      <pubDate>Mon, 10 Jul 2006 00:09:11 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340904/re-detecting-shift-in-virtual-pascal-win32/#340904</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Alcatiz at  2006-7-10 12:22:6&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : Well your code works fine in my Windows 2000 console - but I had to add this compiler directive :&lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;
: : {$PMTYPE VIO}
: : &lt;/pre&gt;&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: I tried adding this, but that didn't do anything. I'm running Windows 98 if that something interferes with what I'm trying to do. Also, in the "Linker" options the "Application" is already set to "Compatible with GUI". Isn't that what the {$PMTYPE VIO} does?&lt;br /&gt;
: &lt;br /&gt;
Yes it's right.&lt;br /&gt;
&lt;br /&gt;
I also tried the code on Windows 98 and it doesn't detect the shift key. It seems to work only on Windows NT/2000/XP.&lt;br /&gt;
I think that Windows 98 allows you to read ports directly so maybe you can try to read port 60h in your loop ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340904/re-detecting-shift-in-virtual-pascal-win32/#340904</guid>
      <pubDate>Mon, 10 Jul 2006 12:21:38 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Detecting SHIFT in Virtual Pascal Win32?</title>
      <link>http://www.programmersheaven.com/mb/pasprog/340784/340933/re-detecting-shift-in-virtual-pascal-win32/#340933</link>
      <description>: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Alcatiz at  2006-7-10 12:22:6&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : : Well your code works fine in my Windows 2000 console - but I had to add this compiler directive :&lt;br /&gt;
: : : &lt;pre class="sourcecode"&gt;
: : : {$PMTYPE VIO}
: : : &lt;/pre&gt;&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : I tried adding this, but that didn't do anything. I'm running Windows 98 if that something interferes with what I'm trying to do. Also, in the "Linker" options the "Application" is already set to "Compatible with GUI". Isn't that what the {$PMTYPE VIO} does?&lt;br /&gt;
: : &lt;br /&gt;
: Yes it's right.&lt;br /&gt;
: &lt;br /&gt;
: I also tried the code on Windows 98 and it doesn't detect the shift key. It seems to work only on Windows NT/2000/XP.&lt;br /&gt;
: I think that Windows 98 allows you to read ports directly so maybe you can try to read port 60h in your loop ?&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Ok, I'll try that. Thanks for your help! :o)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/340784/340933/re-detecting-shift-in-virtual-pascal-win32/#340933</guid>
      <pubDate>Tue, 11 Jul 2006 05:20:44 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>