Browse Source

tinydisplay: Try to fix SDL compile errors

Fixes #1708
rdb 4 months ago
parent
commit
ab357ea120

+ 12 - 9
panda/src/tinydisplay/tinySDLGraphicsWindow.cxx

@@ -43,7 +43,10 @@ TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
   _pitch = 0;
   _pitch = 0;
   update_pixel_factor();
   update_pixel_factor();
 
 
-  add_input_device(GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse"));
+  PT(GraphicsWindowInputDevice) device =
+    GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
+  add_input_device(device);
+  _input = device.p();
 }
 }
 
 
 /**
 /**
@@ -166,35 +169,35 @@ process_events() {
     switch(evt.type) {
     switch(evt.type) {
     case SDL_KEYDOWN:
     case SDL_KEYDOWN:
       if (evt.key.keysym.unicode) {
       if (evt.key.keysym.unicode) {
-        _input_devices[0]->keystroke(evt.key.keysym.unicode);
+        _input->keystroke(evt.key.keysym.unicode);
       }
       }
       button = get_keyboard_button(evt.key.keysym.sym);
       button = get_keyboard_button(evt.key.keysym.sym);
       if (button != ButtonHandle::none()) {
       if (button != ButtonHandle::none()) {
-        _input_devices[0]->button_down(button);
+        _input->button_down(button);
       }
       }
       break;
       break;
 
 
     case SDL_KEYUP:
     case SDL_KEYUP:
       button = get_keyboard_button(evt.key.keysym.sym);
       button = get_keyboard_button(evt.key.keysym.sym);
       if (button != ButtonHandle::none()) {
       if (button != ButtonHandle::none()) {
-        _input_devices[0]->button_up(button);
+        _input->button_up(button);
       }
       }
       break;
       break;
 
 
     case SDL_MOUSEBUTTONDOWN:
     case SDL_MOUSEBUTTONDOWN:
       button = get_mouse_button(evt.button.button);
       button = get_mouse_button(evt.button.button);
-      _input_devices[0]->set_pointer_in_window(evt.button.x, evt.button.y);
-      _input_devices[0]->button_down(button);
+      _input->set_pointer_in_window(evt.button.x, evt.button.y);
+      _input->button_down(button);
       break;
       break;
 
 
     case SDL_MOUSEBUTTONUP:
     case SDL_MOUSEBUTTONUP:
       button = get_mouse_button(evt.button.button);
       button = get_mouse_button(evt.button.button);
-      _input_devices[0]->set_pointer_in_window(evt.button.x, evt.button.y);
-      _input_devices[0]->button_up(button);
+      _input->set_pointer_in_window(evt.button.x, evt.button.y);
+      _input->button_up(button);
       break;
       break;
 
 
     case SDL_MOUSEMOTION:
     case SDL_MOUSEMOTION:
-      _input_devices[0]->set_pointer_in_window(evt.motion.x, evt.motion.y);
+      _input->set_pointer_in_window(evt.motion.x, evt.motion.y);
       break;
       break;
 
 
     case SDL_VIDEORESIZE:
     case SDL_VIDEORESIZE:

+ 2 - 0
panda/src/tinydisplay/tinySDLGraphicsWindow.h

@@ -63,6 +63,8 @@ private:
   unsigned int _flags;
   unsigned int _flags;
   unsigned int _pitch;
   unsigned int _pitch;
 
 
+  GraphicsWindowInputDevice *_input;
+
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
     return _type_handle;
     return _type_handle;