Xentales

Talk about stuff, and if you must, about Xenimus
It is currently 27 Jun 2017 15:15

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 12 May 2016 19:53 
Offline

Joined: 05 Nov 2007 10:56
Posts: 82
Hi,

I updated to the newest version of Xenlua and I noticed that I can no longer use my keyboard's function keys while Xenimus is the active window.

I often use FN + F12 to switch songs I have playing in the background in Foobar.
With the latest Xenlua update, I can no longer do this from within Xenimus when Xenlua is loaded. I have to first Alt tab out and then do it.

Is there any way to fix this?

Thanks,

Constitution

_________________
Hey ugly mugly..
Did Adolf Zitler launch a Zitzkrieg across your face?


Top
 Profile  
 
PostPosted: 13 May 2016 13:56 
Offline

Joined: 17 Mar 2016 20:33
Posts: 28
Is XenLua open source? If so, I could take a look. If not, there's only 1 person who can help.


Top
 Profile  
 
PostPosted: 14 May 2016 16:32 
Offline

Joined: 05 Nov 2007 11:14
Posts: 107
When did it stop working? I haven't changed any code related to key input for years.


Top
 Profile  
 
PostPosted: 14 May 2016 16:34 
Offline

Joined: 05 Nov 2007 11:14
Posts: 107
To be honest I don't see how it would affect your programs, it just bypasses the Xenimus pass-through, code below:

Code:
LRESULT CALLBACK WindowProcHook(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
{
   if (UIController::getSingletonPtr() == NULL)
      return g_wndproc(wnd, message, wparam, lparam);

   bool give = true;
   switch (message)
   {
      case WM_SYSKEYDOWN:
      case WM_KEYDOWN:
      {
         //update modifiers
         if (wparam == VK_CONTROL)
            sUIController.m_modifierControl = true;
         else if (wparam == VK_SHIFT)
            sUIController.m_modifierShift = true;
         else if (wparam == VK_MENU)
            sUIController.m_modifierAlt = true;
         else
            sUIController.VKeyEvent(wparam, true);

         if (!sUIController.CanSendKeyboard())
            give = false;
      } break;
      case WM_KEYUP:
      {
         if (wparam == VK_CONTROL)
            sUIController.m_modifierControl = false;
         else if (wparam == VK_SHIFT)
            sUIController.m_modifierShift = false;
         else if (wparam == VK_MENU)
            sUIController.m_modifierAlt = false;
         else
            sUIController.VKeyEvent(wparam, false);
         if (!sUIController.CanSendKeyboard())
            give = false;
      } break;
      case WM_CHAR:
      {
         sUIController.KeyEvent(wparam);
         if (UIController::getSingletonPtr() != NULL && !sUIController.CanSendKeyboard())
            give = false;
      } break;
      case WM_LBUTTONDOWN:
      {
         if (sUIController.OnLeftMouseDown())
            give = false;
      } break;
      case WM_LBUTTONUP:
      {
         if (sUIController.OnLeftMouseUp())
            give = false;
      } break;
      case WM_RBUTTONDOWN:
      {
         if (sUIController.OnRightMouseDown())
            give = false;
      } break;
      case WM_RBUTTONUP:
      {
         if (sUIController.OnRightMouseUp())
            give = false;
      } break;
   }

   if (give)
      return g_wndproc(wnd, message, wparam, lparam);
   else
      return DefWindowProc(wnd, message, wparam, lparam);
}


Top
 Profile  
 
PostPosted: 14 May 2016 16:38 
Offline

Joined: 05 Nov 2007 11:14
Posts: 107
Code:
void UIController::VKeyEvent(uint32 key, bool down)
{
   if (!masterel->visible)
      return;
   //special, VK_SNAPSHOT is multi scan and only sends an "up", we make it a down
   if (key == VK_SNAPSHOT)
      down = true;

   SetHardwareEvent();

   char* rkey = "";
   char tmpkey[128];

   //Default = use mapped key
   auto mappedchar = MapVirtualKey(key, MAPVK_VK_TO_CHAR);
   sprintf(tmpkey, "%c", mappedchar);
   rkey = tmpkey;

   switch (key)
   {
   case VK_ESCAPE: rkey = "ESC"; break;
   case VK_RETURN: rkey = "RETURN"; break;
   case VK_PRIOR: rkey = "PGUP"; break;
   case VK_NEXT: rkey = "PGDOWN"; break;
   case VK_HOME: rkey = "HOME"; break;
   case VK_END: rkey = "END"; break;
   case VK_DELETE: rkey = "DEL"; break;
   case VK_INSERT: rkey = "INS"; break;
   case VK_TAB: rkey = "TAB"; break;
   case VK_SNAPSHOT: rkey = "PRINTSCREEN"; break;
   case VK_MENU: rkey = "ALT"; break;
   case VK_SHIFT: rkey = "SHIFT"; break;
   case VK_CAPITAL: rkey = "CAPSLOCK"; break;
   case VK_CONTROL: rkey = "CTRL"; break;
   case VK_LEFT: rkey = "LEFT"; break;
   case VK_UP: rkey = "UP"; break;
   case VK_RIGHT: rkey = "RIGHT"; break;
   case VK_DOWN: rkey = "DOWN"; g_recordFlags = RECORD_FLAG_SKIP_NEXT_FRAME | RECORD_FLAG_SCREENSHOT_TAKEN; break;
   }

   //handle f1-f18
   if (key >= VK_F1 && key <= VK_F18)
   {
      sprintf(tmpkey, "F%u", key - VK_F1 + 1);
      rkey = tmpkey;

#ifdef _DEBUG
      if (key == VK_F10)
         sPlayer.ModelChange(0, true);
      if (key == VK_F11)
         sPlayer.ModelChange(0, false);
#endif
   }

   //numpad
   if (key >= VK_NUMPAD0 && key <= VK_NUMPAD9)
   {
      sprintf(tmpkey, "NUM%u", key - VK_NUMPAD0);
      rkey = tmpkey;
   }

   char tmpmodifier[128];
   char tmpmodifier2[128];
   char tmpmodifier3[128];
   if (GetAsyncKeyState(VK_MENU) & 0x8000) { sprintf(tmpmodifier3, "ALT-%s", rkey); rkey = tmpmodifier3; }
   if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { sprintf(tmpmodifier2, "SHIFT-%s", rkey); rkey = tmpmodifier2; }
   if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { sprintf(tmpmodifier, "CTRL-%s", rkey); rkey = tmpmodifier; }

   LUAString arg(rkey);
   if (down)
      sLuaMgr.FireEvent("KEY_EVENT_DOWN", 1, &arg);
   else
      sLuaMgr.FireEvent("KEY_EVENT_UP", 1, &arg);

   //handle the camera modification, TODO: rewrite
   if (m_controlCamera && down)
   {
      switch (key)
      {
         case VK_UP:
            {
               m_cameraEye.y += 10;
            } break;
#ifndef MAPGEN
         case VK_DOWN: m_cameraEye.y -= 10; break;
#endif
         case VK_RIGHT:
            {
               m_cameraEye.x += 10;
            } break;
         case VK_LEFT:
            {
               m_cameraEye.x -= 10;
            } break;
      }

      sConfigMgr.SetCVar("CameraEyeX", m_cameraEye.x, true);
      sConfigMgr.SetCVar("CameraEyeY", m_cameraEye.y, true);
   }

   ClearHardwareEvent();
}


Top
 Profile  
 
PostPosted: 14 May 2016 16:38 
Offline

Joined: 05 Nov 2007 11:14
Posts: 107
Code:
void UIController::KeyEvent(uint32 key)
{
   if (!masterel->visible)
      return;
   SetHardwareEvent();
   switch (key)
   {
      case SK_BACKSPACE: sLuaMgr.FireEvent("KEY_EVENT_BACKSPACE", 0); break;
      case SK_CARRIAGE_RETURN: sLuaMgr.FireEvent("KEY_EVENT_RETURN", 0); break;
      case SK_ESCAPE: sLuaMgr.FireEvent("KEY_EVENT_ESCAPE", 0); break;
      default:
      {
         //pass it as a string to lua
         char test[128];
         sprintf(test, "%c", key);
         LUAString arg(test);
         sLuaMgr.FireEvent("KEY_EVENT", 1, &arg);
      } break;
   }

   if (m_editfocus != NULL)
   {
      switch (key)
      {
         case SK_BACKSPACE:
         {
            //remove the last point :(
            m_editfocus->text = m_editfocus->text.substr(0, m_editfocus->text.size() - 1);
         } break;
         case SK_ESCAPE:
         {
            //remove focus
            m_editfocus = NULL;
         } break;
         case SK_CARRIAGE_RETURN: //don't want to add these
         {

         } break;
         default:
         {
            char test[128];
            sprintf(test, "%c", key);
            m_editfocus->text.append(test);
            m_editfocus->SetDirty();
         } break;
      }
   }

   //handle the camera modification
   if (m_controlCamera)
   {
      switch (key)
      {
         case '+': m_cameraEye.z += 10; break;
         case '-': m_cameraEye.z -= 10; break;
      }

      sConfigMgr.SetCVar("CameraEyeZ", m_cameraEye.z, true);
   }

   ClearHardwareEvent();
}


Top
 Profile  
 
PostPosted: 15 May 2016 01:10 
Offline
User avatar

Joined: 30 Apr 2013 00:03
Posts: 221
Constitution wrote:
Hi,

I updated to the newest version of Xenlua and I noticed that I can no longer use my keyboard's function keys while Xenimus is the active window.

I often use FN + F12 to switch songs I have playing in the background in Foobar.
With the latest Xenlua update, I can no longer do this from within Xenimus when Xenlua is loaded. I have to first Alt tab out and then do it.

Is there any way to fix this?

Thanks,

Constitution



Try starting xenimus without lua and then see if you are able to use your keyboard function key to skip songs. If you cant, then it could be xenimus (but that doesnt make sense either). But andy is right, nothing he is doing is blocking your keys or locking them to the window. So doubt its lua.


Top
 Profile  
 
PostPosted: 15 May 2016 13:23 
Offline

Joined: 05 Nov 2007 10:56
Posts: 82
lawn gnome wrote:
Constitution wrote:
Hi,

I updated to the newest version of Xenlua and I noticed that I can no longer use my keyboard's function keys while Xenimus is the active window.

I often use FN + F12 to switch songs I have playing in the background in Foobar.
With the latest Xenlua update, I can no longer do this from within Xenimus when Xenlua is loaded. I have to first Alt tab out and then do it.

Is there any way to fix this?

Thanks,

Constitution



Try starting xenimus without lua and then see if you are able to use your keyboard function key to skip songs. If you cant, then it could be xenimus (but that doesnt make sense either). But andy is right, nothing he is doing is blocking your keys or locking them to the window. So doubt its lua.


Very weird.
Running Xenimus without LUA and my keyboard FN keys work as they should.
It's only when I run LUA that they stop working.

Also I use an old autohotkey script that someone from Xenimus made years and years ago called XenStore.exe
Basically it's just a script that when you hold down your middle mouse button it will allow you to store/sell fast. When you let go it stops.
Anyway, the point is with LUA running, this script also does not function. It does function when I run LUA without it.

Here's the script:
http://www.filedropper.com/xenstore

Edit: I just noticed that it's just my FN + F10, FN + F11, FN + F12 keys that don't work from within Xenlua anymore. Those are my previous, play/pause, and next keys.
The other FN keyboard shortcuts seem to still work.

I am starting to think the issue may be something to do with the xenlua hotkeys set in game. I will have to verify.

_________________
Hey ugly mugly..
Did Adolf Zitler launch a Zitzkrieg across your face?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group