Skip to content

Commit

Permalink
TEMP: Basic sync of KeyboardMacOS.cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Oct 2, 2024
1 parent 972eb84 commit b2e6f67
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 535 deletions.
2 changes: 1 addition & 1 deletion vncviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ elseif(APPLE)
set(OS_DEP_SOURCES
vncmacview.cxx
vncmacview.h
KeyboardMacOS.cxx
KeyboardMacOS.mm
KeyboardMacOS.h
cocoa.h
cocoa.mm
Expand Down
135 changes: 0 additions & 135 deletions vncviewer/KeyboardMacOS.cxx

This file was deleted.

57 changes: 45 additions & 12 deletions vncviewer/KeyboardMacOS.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
#ifndef X11KEYBOARDHANDLER_H
#define X11KEYBOARDHANDLER_H
/* Copyright 2011-2021 Pierre Ossman <[email protected]> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/

#ifndef __KEYBOARDMACOS_H__
#define __KEYBOARDMACOS_H__

#include "Keyboard.h"

class NSView;
class NSCursor;
#ifdef __OBJC__
@class NSEvent;
@class NSString;
#else
class NSEvent;
class NSString;
#endif

class KeyboardMacOS : public Keyboard
{
class KeyboardMacOS : public Keyboard {
public:
KeyboardMacOS(KeyboardHandler* handler);
virtual ~KeyboardMacOS();

bool handleEvent(const char* eventType, void* message) override;

static bool isKeyboardSync(QByteArray const& eventType, void* message);

unsigned getLEDState() override;
void setLEDState(unsigned state) override;
void grabKeyboard() override;
void ungrabKeyboard() override;

private:
NSView* view;
NSCursor* cursor;
// Special helper on macOS
static bool isKeyboardSync(const char* eventType, void* message);

protected:
bool isKeyboardEvent(const NSEvent* nsevent);
bool isKeyPress(const NSEvent* nsevent);
uint32_t translateSystemKeyCode(int systemKeyCode);
unsigned getSystemKeyCode(const NSEvent* nsevent);

NSString* keyTranslate(unsigned keyCode, unsigned modifierFlags);
uint32_t translateEventKeysym(const NSEvent* nsevent);

int openHID(unsigned int* ioc);
int getModifierLockState(int modifier, bool* on);
int setModifierLockState(int modifier, bool on);
};

#endif // VNCMACVIEW_H
#endif
Loading

0 comments on commit b2e6f67

Please sign in to comment.